pdecobj.pas, object_dec:
* Always check for genericdef and genericlist and not genericdef and ifnot then genericlist.
+ added test
git-svn-id: trunk@27877 -
ninl.pas, tinlinenode.pass_typecheck:
* if the first parameter of an Assert is a undefineddef node then accept it as well if the node is part of a generic function/method
+ added test
git-svn-id: trunk@27875 -
ptype.pas, read_named_type:
* array_dec & procvar_dec: set df_generic of the array/procvar if parse_generic was originally set
+ added test
git-svn-id: trunk@27874 -
ptype.pas:
* read_named_type: change hadtypetoken from a value to a var parameter and set it to false if a type helper is parsed so that calling code does not handle it as unique
* read_anon_type: handle that hadtypetoken is now a var parameter
pgenutil.pas, generate_specialization:
* handle that hadtypetoken of read_named_type is now a var parameter
+ added test
git-svn-id: trunk@27870 -
For partial specialization only the declaration is reparsed, but not method bodies.
The way generic parameters are passed around inside the compiler is changed: instead of creating new type symbols we keep a (name,def) pair so that the code in insert_generic_parameter_types can decide whether it needs to add a type symbol (for new undefined defs) or not (for real types and undefined defs that were passed on from the parent generic). This required the tfpobjectlist type of the genericlist variables/parameters to be changed to tfphashobjectlist.
For correctly parsing Delphi specializations as parameters in functions of records (or objects) the relationship between the def and its typesym must already be established during the parsing. For this the checks for forcing a "type is not completely defined" message needed to be adjusted to correctly handle nested types as well. This should as a sideeffect also allow the usage of nested constants, etc like was fixed for classes some months ago.
ToDo:
- if a generic is specialized with only fully defined types then we could generate the in the unit where it's used. This is not yet done.
- currently we don't specialize generics that are currently parsed; maybe this could be improved in the future for better type compatibility checks
- check whether the pausing of token recording for partial specializations works correct in context of hint modifiers
pgenutil.pas:
* parse_generic_parameters: return a tfphashobjectlist instead of a tfpobjectlist (requires a few type adjustments in various other declarations)
* maybe_insert_generic_rename_symbol, insert_generic_parameter_types: change genericlist from tfpobjectlist to tfphashobjectlist
* parse_generic_specialization_types_internal: use is_generic instead of checking for df_generic
* generate_specialization:
+ add a nested function to disable the requirement to check for method bodies
* use the "simple" parameter parsing only for error recovery
* instead of already creating a new type symbol for a parameter we use the found symbol's name and its def and maybe create it later on (therefor the type of tfpobjectlist was changed to tfphashobjectlist)
* a partial specialization is specialized into the symtable of the def it is specialized in instead of one of the two global symtables
* for now we handle partial specializations of generics we are currently parsing like before
* don't continue recording generic tokens while we do a partial specialization
* use the new unset_forwarddef function on the newly created defs
* insert_generic_parameter_types: only create a new type symbol if the found type symbol does not yet have an owner (thus was freshly created for this generic declaration)
pdecobj.pas, object_dec:
* change type of genericlist from tfpobjectlist to tfphashobjectlist
* set the type sym for all object types that can be generic or inside a generic (needed for correctly parsing Delphi style generic declarations)
pdecsub.pas, parse_proc_head:
* consume_generic_interface: always generate the specialization name as now all generics are "specialized" inside a generic
* the assumption that the def index numbers are the same is no longer true as the genericdef might contain the defs of partial specializations which are not generated for full specializations
pdecvar.pas, read_record_fields:
* we also need to check nested types whether they contain a not yet completely parsed record or object
ptype.pas:
* read_named_type:
* change genericlist from tfpobjectlist to tfphashobjectlist
* pass the typesymbol along to record_dec
* resolve_forward_types: use is_generic instead of checking for df_generic
* single_type:
* use is_generic instead of checking for df_generic
* no need to check generic parameters
* parse_record_members:
+ add parameter for the record's type symbol
* setup the typesym <=> def relationship
+ record_dec: add parameter for the type symbol and pass it to parse_record_members
* read_named_type, expr_type: use is_generic instead of checking for df_generic
* array_dec & procvar_dec: change genericlist from tfpobjectlist to tfphashobjectlist
symdef.pas, tstoreddef:
* improve the checks used in is_generic and is_specialization to really only work on true generics and true (and partial) specializations respectively
* don't search the type parameters in the symtable, but store them in the PPU and load them from there
- remove fillgenericparas method (including the calls in the descendants tarraydef, tprocvardef, tobjectdef and trecorddef)
defcmp.pas, compare_defs_ext:
* handle partial specializations: specializations with only undefineddefs are compatible to generic defs
pdecl.pas, types_dec:
* switch generictypelist from tfpobjectlist to tfphashobjectlist
ppu.pas:
* increase PPU version
+ added tests that ensure that "not completely defined" checks for records (and objects) still work correctly
git-svn-id: trunk@27861 -
more, hopefully more robust that waiting an arbitrary amount of
time in between
* replaced calls to tthread.resume with calls tthread.start
git-svn-id: trunk@27624 -
Currently it is implemented only for x86-CPUs supporting the FMA extension. While it would
be possible to implement it in software or simulate fma(<single>,<single>,<single>) using
double operations, it makes no sense in my opinion to do so.
git-svn-id: trunk@27564 -
nmat.pas:
* correctly disable type checks if one of the arguments for MOD, DIV, SHR, SHL, NOT, -X and +X is a generic type parameter
+ added tests
git-svn-id: trunk@27535 -
symtable.pas, search_objectpascal_helper:
* handle more symbol types than just properties and methods; afterall helpers can have types, static variables and constants as well
+ added test
git-svn-id: trunk@27534 -
ninl.pas, tinlinenode.pass_typecheck:
* don't generate a type error if Length() is used inside generics with a generic argument
+ added test
git-svn-id: trunk@27533 -
ptype.pas, read_named_type.array_dec:
* generate a valid range definition if we are inside a generic and the array bounds are not ordinals (Note: the check for "parse_generic" should be improved to really detect erratic indexes that are not related to generics in any way)
+ added test
git-svn-id: trunk@27532 -
+ Test.
+ Check duplicate labels in assembler blocks. This was impossible due to above bug and duplicate labels were detected only at assembling stage where no location information could be provided.
git-svn-id: trunk@27472 -
symsym.pas, tfieldvarsym:
+ add new field fieldvarsym which holds a reference to a tfieldvarsym if the static sym was created based on such a symbol
+ add necessary methods and code to correctly load from and store to PPU
+ add new constructor create_from_fieldvar
symcreat.pas, make_field_static:
* use new create_from_fieldvar constructor instead of the default one
hlcgobj.pas, finalize_static_data:
* check whether the static var is based on a generic's class var
ppu.pas:
* increase PPU version
+ added test
git-svn-id: trunk@27466 -
* pdecsub.pas, parse_proc_direc:
when a hint directive is parsed we need to check whether the new token can still be a directive
+ added test (though that won't help much as we don't check the compiler output yet... :/ )
git-svn-id: trunk@27463 -
* ninl.pas, tinlinenode.handle_default.getdefaultvarsym:
prefix the default variable's name with a "$zero" instead of a "zero" and use only the string from the second character on for comparisons so that findwithhash() and checkduplicates() generate consistent results
+ added test
git-svn-id: trunk@27320 -
functions whose implementation is declared "external". This results in less
efficient code (all calls will go through a stub), but it prevents interface
crc changes (-> no recompilations in case of circular dependencies) and it
also keeps the interface stable (if the external implementation is changed
afterwards to another external routine or to a local implementation, the
mangled name of the routine does not change) (mantis #24121)
git-svn-id: trunk@27213 -
nset.pas, tcasenode.simplify: don't assume a specific order of the case labels
+ added test based on ppu.pas, tppu.getaint where no matching case label was found because of the ordering
git-svn-id: trunk@26825 -
+ nset.pas, tcasenode: add simplify method; for ordinal constant case expressions either return a copy of the correct block or return a nothing node if the constant did not match anything
+ added test to check that nothing is broken
git-svn-id: trunk@26824 -
+ globtype.pas: add new modeswitch to modeswitch enum and name array
* ptype.pas & pdecobj.pas: check for new modeswitch instead of modeswitch class
* ppu.pas: increase ppu version as we've added a new modeswitch which requires correctly compiled units
* adjusted tests to enabled the modeswitch when necessary
+ added three new tests that check for correct functionality of modeswitch typehelpers
git-svn-id: trunk@26796 -
when assigning a string constant to a rawbytestring (system code page with
{$modeswitch systemcodepage}, CP_ACP without) (mantis #25332)
git-svn-id: trunk@26397 -
o set the code page of the temporary "text" file to utf-8 for writestr with
unicodestring/widestring as destination, so that no data loss can occur
(+ properly deal with cases whereby part of an utf-8 character is
written to the textbuf in this case)
o explicitly pass the code page of the destination ansistring for writestr
with ansistring as destination and set it for the temporary "text" file
o set the code page of the text file for readstr
git-svn-id: trunk@26317 -
* soHost -> coHost to be consistent with other TConfigOpt values.
* ConfigOpts rewritten to have corresponding coXXX constants in comments
+ Add support for long options
* Go past first >>>> line in longlog file to avoid warning
git-svn-id: trunk@26217 -
explicitly typecasting a qword to single/currency/tdatetime is no different
from assigning it directly, since integer types are assignment-compatible
with floating point types (mantis #25170)
git-svn-id: trunk@26146 -
Max Nazhalov) and use that code by default on the JVM target
* adapted JVM tests for the new str<->float code similar to how the
generic tests were adapted
git-svn-id: trunk@25954 -
based on the Grisu1 algorithm. This corrects several precision issues
with the previous code used to perform such conversions (patch by
Max Nazhalov, mantis #25241)
o adaptation of several tests to deal with the better precision of these
routines compared to the previous version
Please don't remove the real2str.inc file yet, it's still used by the
JVM target for now
git-svn-id: trunk@25888 -
defcmp.pas, objectdef_is_related:
* use "equal_defs" instead of "=", as the former also handles equivalence of specializations
+ added test
git-svn-id: trunk@25848 -
-CTlowercaseprocstart
o convert all consecutive uppercase characters at the start to lowercase
instead of only the first one. Exception: if there is more than one
such character and the last one is followed by a lowercase character,
assume the last uppercase character belongs to the second word (like
in FPCIsGreat) and don't lowercase that one
+ test
git-svn-id: trunk@25845 -
compiler/scanner.pas, tscannerfile.readtoken:
* after trying to read a _INTCONST check whether a valid first character for an identifier follows and give a syntax error if that is not the case
+ added test
git-svn-id: trunk@25835 -
compiler/pdecobj.pas, object_dec:
* since revision 25518 the global symtable of the current module is no longer popped and pushed again so that the defaware symtablestack can add the helper; thus we need to do this not only for static symtables, but for global ones as well
* adjusted comment to reflect current situation
git-svn-id: trunk@25834 -
* don't allow to apply the same hint directive twice
* change parser_e_proc_dir_not_allowed to more generic variant parser_e_dir_not_allowed - they are similar and 'procedure' prefix does not give more information about the error.
* maybe_parse_hint_directives() uses procdef settings for initial values
+ add tests
git-svn-id: trunk@25720 -
symdef.pas:
* tobjectdef.find_implemented_interface: use equal_defs to ensure that equal specializations of interfaces are found as well
* getparaencoding: use globals.CP_NONE instead of just CP_NONE, because defcmp contains a cp_none enum as well.
+ added test
git-svn-id: trunk@25609 -
m68k/cgcpu.pas, tcg68k.g_flags2reg:
* don't sign extend the flag value which was stored to the register, but instead do a "AND 1" on it to reduce it to 1 bit; afterall Booleans in Pascal are either 0 or 1 and not 0 or $FF
+ added test
git-svn-id: trunk@25598 -
pgenutil.pas:
+ add new function could_be_generic which checks whether a given symbol name could be a generic (which is determined using the genericdummysyms list for the current module)
pexpr.pas:
* factor: only do a typecheck pass (postfixoperators does one as well) if the found node can not be a generic type
* sub_expr: do a typecheck pass if it isn't a specialization
+ added test
git-svn-id: trunk@25579 -
pgenutil.pas, generate_specialization:
* use "is_generic" instead of "df_generic in defoptions" as nested non generic types will have that flag set as well and thus would be acceptable for the "<...>" notation although no generic version of it exists
ptype.pas, single_type:
* check for nested types after doing a specialization
+ added tests (one for now working case and one for now forbidden case)
git-svn-id: trunk@25578 -
cclasses.pas:
+ TFPHashList & TFPHashObjectList: add WhileEachCall methods that walk the list like ForEachCall does, but uses a while-loop instead of a for-loop
psub.pas, generate_specialization_procs:
* use WhileEachCall instead of ForEachCall as new defs can be added during the specialization that need to be specialized as well
+ added test
git-svn-id: trunk@25577 -
symtable.pas:
+ add new tsymbol_search_flag type which can be passed to various searchsym* routines
+ add support to not call "addsymref"
+ add new searchsym_with_flags function that calls searchsym_maybe_with_symoption
* adjust searchsym_maybe_with_symoption, searchsym_in_class & searchsym_in_helper to use new flag type instead of Boolean arguments
* adjust searchsym & searchsym_with_symoption which call the modified functions
nutils.pas, handle_staticfield_access:
* adjust searchsym_in_class call
pexpr.pas, handle_factor_typenode, postfixoperators, factor:
* adjust searchsym_in_helper and searchsym_in_class calls
pinline.pas, new_function:
* adjust searchsym_in_class call
scanner.pas, try_consume_nestedsym:
* adjust searchsym_in_class call
fmodule.pas, tmodule:
+ add genericdummysyms field which is a TFPHashObjectList that contains TFPObjectList instances per generic dummy that in turn contains tgenericdummysyms instances
pgenutil.pas:
+ add function split_generic_name to split a generic name into non-generic name and count value of type parameters
+ add function resolve_generic_dummysym which tries to use the new genericdummysyms field to find the real symbol of a dummy sym
* generate_specialization: adjust searchsym_in_class call
* specialization_init/specialization_done: save/restore genericdummysyms of module
symdef.pas, tdefawaresymtablestack:
+ add new intermediate method pushcommon which is used by both push and pushafter
+ add new intermediate method remove_helpers_and_generics (which calls remove_generics and remove_helpers if necessary)
* rename removehelpers to remove_helpers
* rename addhelpers to add_helpers_and_generics and extend it to correctly fill current_module.genericdummysyms
* call remove_helpers_and_generics from pop instead of remove_helpers
ptype.pas, single_type, read_named_type.expr_type, read_named_type:
* try to resolve symbols with sp_generic_dummy with resolve_generic_dummysym
+ added test
git-svn-id: trunk@25519 -
1. It allows to use comparative operators in some unusual cases (issue #25004).
2. Regular type checking does not allow to use other than Boolean types in IF expressions anyway.
3. Delphi compatibility (although Delphi documentation states otherwise).
git-svn-id: trunk@25494 -
rtl/objpas/classes/classesh.inc, TStringList:
* rename the private ExchangeItems to ExchangeItemsInt and allow inlining
+ add a protected virtual ExchangeItems
rtl/objpas/classes/stringl.inc, TStringList:
* Exchange: call ExchangeItemsInt
+ let default implementation of ExchangeItems simply call ExchangeItemsInt
* QuickSort: call ExchangeItemsInt directly if there is no override otherwise call ExchangeItems
+ added test
git-svn-id: trunk@25480 -
- move operator_levels to topens.pas - it is used from 2 units now
- implement pexpr like sub_expr for preprocessor expressions
- implement +,-,*,/ expressions for the moment
* move OR, AND, IN implemenetation to the new logic
git-svn-id: trunk@25465 -
support for arbitrarily encoded ansistrings to many routines related to
file system access (and some others).
WARNING: while the parameters of many routines have been changed from
"ansistring" to "rawbytestring" to avoid data loss due to conversions,
this is not a panacea. If you pass a string concatenation to such a
parameter and not all strings in this concatenation have the same
code page, all strings and the result will be converted to
DefaultSystemCodePage (= ansi code page by default). In particular,
concatenating e.g. an Utf8String with a constant string and passing
the result to a RawByteString parameter will convert the result into
the DefaultSystemCodePage (unless the source code is compiler with
{$modeswitch systemcodepage} or {$mode delphiunicode} *and* the ansi
code page on the system you are compiling *on* happens to be UTF-8)
You can define and use alternative routines that explicitly accept
Utf8String parameters to avoid this pitfall. Internally, all of these
routines ensure that they never trigger this condition and ensure that
not unnecessary/unwanted code page conversions occur.
+ DefaultFileSystemCodePage variable that holds the code page used for
communicating with the OS single byte file system APIs, and for the
strings returned by those same APIs. Initialized with
o the result of GetACP in the system unit of Windows platforms, except for
WinCE which uses UTF-8 since its file system OS API calls already use
the UTF-16 versions
o CP_UTF8 on Unix platforms with FPCRTL_FILESYSTEM_UTF8 defined, and with
DefaultSystemCodePage on other Unix platforms
o DefaultSystemCodePage on Java/Android JVM targets
+ DefaultRTLFileSystemCodePage variable that holds the code page used to
encode strings returned by RTL routines that return filenames obtained
from OS API calls. By default the same as DefaultFileSystemCodePage on
all platforms. Separate from DefaultFileSystemCodePage for clarity on
platforms that may use either utf-16 or single byte OS API calls to
send/receive file names (such as most Windows platforms)
+ new scpFileSystemSingleByte enum that can be passed to
GetStandardCodePage() to get the default code page for OS single byte file
system APIs, with implementations for Unix and Windows
+ SetMultiByteFileSystemCodePage() procedure to override the value of
DefaultFileSystemCodePage
+ ToSingleByteFileSystemEncodedFileName() function to convert a string to to
DefaultFileSystemCodePage (does *not* take care of OS-specific quirks like
Darwin always returning file names in decomposed UTF-8)
+ support for CP_OEMCP
* textrec/filerec now store the filename by default using widechar. It is
possible to switch back to ansichars using the FPC_ANSI_TEXTFILEREC define.
In that case, from now on the filename will always be stored in
DefaultFileSystemEncoding
* fixed potential buffer overflows and non-null-terminated file names in
textrec/filerec
* when concatenating ansistrings, do not map CP_NONE (rawbytestring) to
CP_ACP (defaultsystemcodepage), because if all input strings have the
same code page then the result should also have that code page if it's
assigned to a rawbytestring rather than getting defaultsystemcodepage
* do not consider empty strings to determine the code page of the result
in fpc_AnsiStr_Concat_multi(), because that will cause a different
result than when using a sequence of fpc_AnsiStr_Concat() calls (it
ignores empty strings to determine the result code page) and it's also
slower
* do not consider the run time code page of the destination string in
fpc_AnsiStr_Concat(_multi)() because Delphi does not do so either. This
was introduced in r19118, probably to hide another bug + test
* never change the code page of a non-empty string when calling setlength on
it
* handle the fact that GetEnvironmentStringsA returns the environment in the
OEM instead of in the Ansi code page (mantis #22524, #15233)
* don't truncate environment variable strings in GetEnvironmentString(),
its result is now ansistring/unicodestring depending on whether the
RTL was compiled with FPC_RTL_UNICODE
* unix:
o made the ansistring parameters of the fp*() file system routine overloads
constant, changed them to rawbytestring and added
DefaultFileSystemCodePage conversions
o unicodestring support for POpen(), and DefaultFileSystemCodePage support
for POpen(RawByteString)
+ DefaultFileSystemCodePage support for dynlibs unit
+ rawbytestring/unicodestring overloads for:
o system: fexpand, lowercase, uppercase, getdir, mkdir, chdir, rmdir,
assign, erase, rename
o objpas: AssignFile,
o sysutils: FileCreate, FileOpen, FileExists, DirectoryExists, FileSetDate,
FileGetAttr, FileSetAttr, DeleteFile, RenameFile, FileSearch, ExeSearch,
FindFirst, FindNext, FindClose, FileIsReadOnly, GetCurrentDir,
SetCurrentDir, ChangeFileExt, ExtractFilePath, ExtractFileDrive,
ExtractFileName, ExtractFileExt, ExtractFileDir, ExtractShortPathName,
ExpandFileName, ExpandFileNameCase, ExpandUNCFileName,
ExtractRelativepath, IncludeTrailingPathDelimiter,
IncludeTrailingBackslash, ExcludeTrailingBackslash,
ExcludeTrailingPathDelimiter, IncludeLeadingPathDelimiter,
ExcludeLeadingPathDelimiter, IsPathDelimiter, DoDirSeparators,
SetDirSeparators, GetDirs, ConcatPaths, GetEnvironmentVariable
-- the default string type used by FindFirst/Next depends on whether the
RTL was compiled with FPC_RTL_UNICODE. To force the RawByteString
version pass a TRawByteSearchRec, for the UnicodeString version pass
a TUnicodeSearchRec.
+ paramstr(longint):unicodestring available for {$modeswitch unicodestrings}
+ pwidechar versions in sysutils of strecopy, strend, strcat, strcomp,
strlcomp, stricomp, strlcat, strrscan,strlower, strupper, strlicomp,
strpos, WideStrAlloc, StrBufSize, StrDispose + tests
git-svn-id: trunk@25432 -
determine whether (wide)char->pchar will be preferred over (wide)char ->
p(wide)char or not (always convert to pchar if mode switch is not active,
otherwise always to pwidechar). Delphi-compatible + consistent with the
behaviour added for constant strings in that revision + tests
git-svn-id: branches/cpstrrtl@25430 -
the other fpc_(u)char_to_*str() routines (exception dates back to the
time calls to these routines were still inserted "manually" in the
compiler). Fixes the compilation of "shortstr:=widecharconstant" after
r23613 and simplifies other code calling this helper + test
git-svn-id: branches/cpstrrtl@25428 -
- use specially implemented type search routine in case of declaration with colon (on E: Exception do)
- parse nested types in case of declaration without colon (on Exception do)
+ test
fixes issue #0022225
git-svn-id: trunk@25412 -
pgenutil.pas, parse_generic_parameters:
* set the typesym of the newly created def so that inline specializations in pexpr.pas, sub_expr can check it correctly
git-svn-id: trunk@25410 -
when building the mangled name, because the latter can also be performed
when compiler another unit (and therefore if that other unit's setting
is different from that of the original unit, a wrong mangled name was
generated) + test for this case
git-svn-id: trunk@25388 -
that may trigger JVM bytecode verification errors if they are used
before they are initialised (this includes passing them as a "var"
parameter) + test
* sorted -CT parameters alphabetically and alligned them
git-svn-id: trunk@25387 -
so that code written according to Delphi coding standards can be compiled
into JVM bytecode with routine names conforming to JVM coding standards
git-svn-id: trunk@25385 -
The previous code deleted the newly inserted instruction instead of the
existing one, which obviously broke code.
Assembly:
mov r0, r0, lsr #23
mov r0, r0, lsr #23
transformed into:
mov r0, r0, lsr #23
expected was:
mov r0, #0
The problem only shows up in the very unlikely case of two LSR/ASR or
two LSL following on each other and having a total shift of more than 31
bits.
This fixes test/opt/tarmshift.pp
I've also removed the {%norun} directive from tarmshift.pp as this test
does only make sense when it also runs.
git-svn-id: trunk@25374 -
o these routines are now generic wrappers in filutil.inc, and call
the platform-dependent internalfindfirst/next/close routines
o on unix, the fnmatch routine got proper support for UTF-8 matching
(e.g., it won't match a partial UTF-8 code point to a "?" wildcard)
o for NativeNT, a similar (untested) UTF-16 version has been added
+ test for the above
* rawbytestring/unicodestring versions of fileage
git-svn-id: branches/cpstrrtl@25302 -
other than DefaultFileSystemCodePage, so that it can work with strings
holding any encoding
+ test for fexpand(ansistring) with UTF-8 strings while DefaultSystemCodePage
is set to CP_ASCII
git-svn-id: branches/cpstrrtl@25300 -