only tdef descendants are added to the deflist and casting deflist entries to
tdef directly appears to be safe and is done in other parts of the compiler
git-svn-id: trunk@49428 -
introduced in r49417. Now it no longer depends on current_module, so it
handles the case when current_module changes between the time the tdef was
registered and the time it was freed. It also supports freeing the tmodule
before the defs, so the freeing order of the object is once again flexible.
git-svn-id: trunk@49426 -
o they are implemented as a new metadata register class, whereby the
subregister indicates the metadata type (currently always a string)
and the superregister is an index in the metadata array (which
contains the strings). LLVM metadata can only be passed as parameters
to intrinsics in bitcode, so moves of metadata into other registers
triggers internal errors and when moving them into parameters, we
replace the parameter's register with the metadata register (and look
up the corresponding string when writing out the bitcode)
git-svn-id: trunk@43816 -
Implemented attributes for class types and properties (based on work by Joost van der Sluis). Added TCustomAttribute - a base class for attributes. Added TUnitInfo record to RTTI. It contains the unit name and unit options (for now only a flag which specifies if the unit contains attributes). Added several tests for attributes.
git-svn-id: trunk@42356 -
pass them to the linker so it does not reorder them
o fixes resource strings on Darwin when using LTO (this used to reorder the
resource string symbols, so they no longer all appeared between the START
and END symbols for their compilation module)
git-svn-id: trunk@41907 -
add such symbols to the pseudo-arrays llvm.compiler.used or llvm.used
depending on their nature (fixes compiling Objective-C programs with
optimization, and keeps the FPC ident in the linked binary)
git-svn-id: trunk@35041 -
This basically revives the globalasmsym entry of the PPU though it feeds to different lists, one for the public (exported) symbols and one for the external (imported) symbols. Also the list of symbols is much smaller as it would be if all symbols would be dumped in there.
git-svn-id: trunk@34174 -
is reset (mantis #28814)
o if they are freed in end_of_parsing, they need to be recreated in case the
unit needs to be recompiled anyway during the current run
o in other cases they need to be reset since they will be repopulated during
the recompilation
git-svn-id: trunk@34069 -
fmodule.pas, tmodule:
+ new list pendingspecializations which keeps track of all pending specializations of the current module
psub.pas:
* move generate_specialization_procs and related routines to pgenutil
+ new procedure read_proc_body to read a routine's body, cause generate_specialization_procs needs it (unlike the already existing overload in the implementation section, this one can only handle bodies of non-nested routines)
pgenutil.pas:
* generate_specialization_phase2: add the newly specialized generic to the current module's pending specializations
* generate_specialization_procs: reworked so that it uses the new pendingspecializations field instead of walking the global and local symboltable of the current unit
pmodules.pas:
+ add pgenutil to uses due to the moved generate_specialization_procs
+ added test
git-svn-id: trunk@33826 -
fmodule.pas, tmodule:
* end_of_parsing: free neither extendeddefs nor genericdummysyms as both might be used by the def-aware symtablestack even after parsing the unit is done
git-svn-id: trunk@33780 -
Don't try to export generic symbols.
pkgutil.pas:
* exportabstractrecordsymproc: do not export generic type symbols or their nested symbols
........
Ensure that the correct name is used for the PCP file.
proc_package:
* use current_module.modulename instead of module_name for the base filename of the PCP file
........
Add a possibility to track if a unit was loaded from a package.
fmodule.pas, tmodule:
+ new field "package" which is Nil if the unit is not (yet) part of a package or a reference to the package this unit was loaded from
fppu.pas, tppumodule:
* loadfrompackage: set the "package" field of the module to the package it's loaded from.
........
Ensure that units loaded from a package are not recompiled if the source files should happen to be available.
fppu.pas, tppumodule:
loadppu: set the state to ms_compiled instead of ms_load if the unit was loaded from a package (additionally close the PPU file as it's no longer needed)
........
Add support for reading/writing required packages from/to the PCP file
fpcp.pas, tpcppackage:
+ new methods writerequiredpackages and readrequiredpackages
* loadpcp: use readrequiredpackages
* savepcp: use writerequiredpackages
pcp.pas:
* increase PCP version
........
When compiling a package, handle only those units that are not yet part of a package.
pmodules.pas, proc_package:
* only export units that are part of the package
* only add units to the package if they are really part of the package
* don't rewrite the PPU if the unit is not part of the package
* don't link the unit's files if it is not part of the package
........
Add support for parsing required packages.
pkgutil.pas:
+ new function add_package to add a package to the list of available packages with the possibility to check for duplicates
* load_packages: also load all required packages
pmodules.pas, proc_package:
* create the tpcppackage instance earlier (and use the module name as read from the source file as package name)
* clear the list of packages in case the user passed any using -FPxxx
* parse the "requires" section like a list of units and add each full identifier as a package to load
* before parsing the "contains" section load all packages, so that all units can be correctly resolved
........
Correctly create import libraries for packages as well.
pkgutil.pas, createimportlibfromexternals:
* instead of processing units without the uf_in_library flag, only process those that don't have a package reference set (thus becoming part of the program/library or the package)
- remove unneeded "pkg" parameter
pmodules.pas:
+ proc_package: create the import library if the package requires other packages
* proc_program: adjust call to createimportlibfromexternals
........
Ensure that the reference to the System unit is correctly set up for packages. Among other things this is needed to compile a package with the -gl option (though debug information doesn't work yet).
pmodules.pas:
* convert AddUnit to a function and let it return the newly loaded module
* proc_package: when parsing the contained units ensure that we correctly set up the System unit reference if we are to contain the System unit
* proc_package: also set up the System unit reference once all units are loaded and this hasn't happened yet (because all contained units are already compiled)
........
git-svn-id: trunk@33502 -
To correctly generate the import library for a package we need to resolve the dangling external symbols of all units. For this each unit now stores which symbols it exported from another unit and it also stores all global and external assembler symbols it has (maybe this can be streamlined later on, but for now this works).
entfile.pas:
+ new entry for the imported unit symbols
fmodule.pas, tmodule:
+ new field unitimportsyms which holds all symbols imported by a unit from another unit
+ new method to add an imported symbol
* create, destroy & reset: correctly instantiate/free the two new lists
fppu.pas, tppumodule:
+ new field unitimportsymsderefs to hold the derefs during loading from/storing to PPU
+ new method buildderefunitimportsyms to generate the derefs for each imported symbol
+ new method derefunitimportsyms to resolve each imported symbol deref
+ new method readunitimportsyms to read the imported symbols from the PPU
+ new method writeunitimportsyms to write all imported symbols to the PPU
* load_implementation: read the imported symbols if their entry is encountered
* writeppu: generate the derefs for the imported symbols and write them to the PPU
* load_usedunits: resolve the imported symbols once all derefs are known
symtable.pas:
* addsymref: if the symbol is not from the current unit than mark it as imported
ppu.pas:
* increase PPU version
-- Diese und die folgenden Zeilen werden ignoriert --
M entfile.pas
M fmodule.pas
M fppu.pas
M ppu.pas
M symtable.pas
git-svn-id: trunk@33492 -
o handle parameters and function results divided over multiple paralocs,
including generating fake recorddefs that represent
o fixed zero/sign extension handling
o properly handle difference between procdefs as printed for the
implementation, an alias declaration or a procvar definition
git-svn-id: branches/hlcgllvm@27009 -
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 -
The cause of the internal error was the following:
We have a generic in an unit ("A") which uses another unit ("B") in the implementation section and this other unit uses unit A in the interface section. Now the generic is specialized in the interface section of B. This leads to the problem that in unit A when it tries to load the globalsymtable of unit B that globalsymtable will be Nil, because parsing of the interface section is not yet finished. Thus the change in pgenutil.pas, specialization_init: if the unit is still "in_interface" the localsymtable needs to be used instead of the globalsymtable.
This doesn't necessarily lead to a compiling test though, as there is the following possibility:
Unit A contains a generic class/record (with methods) and uses unit B in the implementation section. This unit B also contains a generic class/record (with methods) and uses unit A in the implementation section. Both units contain a specialization of the other unit's generic outside of it's own generics (such that generate_specialization is fully triggered). Let's assume compilation starts with unit A and we reach the uses of unit B. Now compilation switches to unit B and completes as unit A is already registered and in compilation. The problem now is that the generic in unit A still contains unresolved forward declarations as the implementation section of A was not yet parsed which will lead to "forward declaration not solved" errors (Note: Delphi compiles this).
The solution to this is the following: if a generic is specialized from another unit which is not in state ms_compiled then the unit of the specialization needs to wait for the unit of the generic. So the specialization's unit adds itself into a list of waiting units of the generic's unit. Now inside "proc_unit" we need to check whether this module is waiting for other modules and if so avoid "finishing" the unit (which means generating the methods of the specialization, generating assembler code and ultimately freeing the scanner and PPU). Now when the generic's unit finishes we need to check whether other modules are waiting for it and finish them (of course it's a bit more complicated in reality, but that pretty much sums it up).
+ globstat.pas: Added an unit which handles the saving and restoring of the global state which was originally inside "parser.pas, compile" so that Don't Repeat Yourself (DRY) is respected.
* fmodule.pas, tmodule:
+ add fields to keep track of the units the module is waiting for and which modules are waiting for the module
+ add field for the saved global state (raw pointer to avoid circles)
+ add field for the state which is needed to finish the unit (raw pointer to avoid circles)
+ move the code which was used in "parser.pas, compile" after a module was successfully compiled to the new virtual method "end_of_parsing"
+ fppu.pas, tppumodule.end_of_parsing:
free the ppufile here
* pgenutil.pas:
+ add new procedure "maybe_add_waiting_unit" which adds the specialization's unit to the waiting list of the generic if that unit is not yet compiled
* generate_specialization: call the new function when we add a new (true) specialization
* specialization_init: instead of not adding implementation units at all check whether the unit is still parsing the interface section and add the localsymtable in that case
* pmodules.pas:
* change "proc_unit" to a function which returns "true" if the unit was already finished (no need to wait for other units)
+ move the code from "proc_unit" from "generate_specialization_procs" on to a new procedure "finish_unit" which
* this procedure is either called immediately in "proc_unit" if the unit does not need to wait for other units or from "finish_unit" itself if a unit that is waiting for the given unit does no longer wait for another module (special care is taken in proc_unit to avoid circles)
* parser.pas, compile:
* correctly handle the case if an unit is not finished
* use the new global state functionality from globstat.pas
* pay special attention when calling "set_current_module" (see comment at that call)
+ add tests from 22160
+ add test for above mentioned "diamond" case
git-svn-id: trunk@22452 -
that deal with paths/filenames with TPathStr (= ansistring) to prevent
cutting off long paths (no change in speed when compiling the compiler,
1% extra memory usage)
git-svn-id: trunk@21120 -
be generated for a single object file on AIX, automatically switch to
an indirection scheme that uses much less TOC entries, but is slower to
access global variables
* manually merged infrastructure for target-specific code generation
switches from JVM branch (-CTxxx switches)
* -CTsmalltoc switch for AIX that forces the indirection scheme for TOC
entries from the start in case the automatic one does not conserve
a sufficient amount (or in case you bump up against the global TOC
entries limit during linking)
git-svn-id: trunk@20963 -
o support for the new codepage-aware ansistrings in the jvm branch
o empty ansistrings are now always represented by a nil pointer rather than
by an empty string, because an empty string also has a code page which
can confuse code (although this will make ansistrings harder to use
in Java code)
o more string helpers code shared between the general and jvm rtl
o support for indexbyte/word in the jvm rtl (warning: first parameter
is an open array rather than an untyped parameter there, so
indexchar(pcharvar^,10,0) will be equivalent to
indexchar[pcharvar^],10,0) there, which is different from what is
intended; changing it to an untyped parameter wouldn't help though)
o default() support is not yet complete
o calling fpcres is currently broken due to limitations in
sysutils.executeprocess() regarding handling unix quoting and
the compiler using the same command lines for scripts and directly
calling external programs
o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
to the make command line
git-svn-id: branches/jvmbackend@20887 -
- add helper function getansistringcodepage which returns explicitly set codepage or 0 in other case
- add helper function getansistringdef which return a def with explicitly set codepage or cansistringtype in other case
- change tstoreddef.createnai constructor to allow set codepage in constructor
- don't convert string constants to rawbytestring. if string constant already has a codepage - preserve it or convert to ansistring codepage (delphi compatible)
- don't perform string conversion from ansistring to strings with explicitly set codepage (by directive or by compiler switch) and vice versa (delphi compatible)
+ test which covers most of the cases
git-svn-id: trunk@19510 -