Commit Graph

145 Commits

Author SHA1 Message Date
pierre
34c0898d97 Fix m68k-amiga linking failure for native compiler, due conflict between odd length string and .balignw directive
git-svn-id: trunk@38351 -
2018-02-26 13:06:37 +00:00
Jonas Maebe
c0b0fa9c0b * change the type of the -gt uninitialised result of ansistring functions to
rawbytestring so the compiler does not try to convert it to the declared
    string type of the function result, as this may not be available
    (mantis #32510)

git-svn-id: trunk@37889 -
2018-01-01 18:04:13 +00:00
svenbarth
a301bf75ea * ngenutil.tnodeutils.sym_maybe_initialize: don't use "is" operator, but corresponding is_* functions
git-svn-id: trunk@36617 -
2017-06-29 18:51:35 +00:00
Károly Balogh
dd01b7ca8b fix a typo to hopefully fix the build
git-svn-id: trunk@36312 -
2017-05-23 21:13:00 +00:00
svenbarth
7c9aeda656 * rework InsertInitFinalTable a bit more so that the list of init/fini entries does not need to be generated twice for AVR
git-svn-id: trunk@36310 -
2017-05-23 19:58:39 +00:00
svenbarth
d311881b34 * extract calculation of unit init/fini entries into separate method get_init_final_list() so that it can be used by the AVR code as well
git-svn-id: trunk@36257 -
2017-05-19 16:12:22 +00:00
nickysn
efc5e339d0 * use an enum instead of integer constants to represent inline numbers
* compinnr.inc include file converted to a unit
* inline number field size stored in ppu increased from byte to longint
* inlines in the parse tree (when written with the -vp option) now printed with
  their enum name, instead of number

git-svn-id: trunk@36174 -
2017-05-10 14:41:43 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
Jonas Maebe
cadf177a93 * fixed bugs in r33737: that revision was supposed to only move
code from one unit to another, but in splitting some methods
    I made a couple of mistakes :/ (causing global variables to be
    initialised three times)

git-svn-id: trunk@35461 -
2017-02-20 22:15:34 +00:00
maciej-izak
9441fb3968 * ngenutil.pas, tnodeutils.sym_maybe_initialize: Ensure that management operator (Initialize) is used also for local variables.
git-svn-id: trunk@35443 -
2017-02-18 19:19:46 +00:00
svenbarth
1a6a8b7c9f + introduce a new potype for the main stub of a package library (which on Windows is simply a DLLMain returning True)
git-svn-id: trunk@35371 -
2017-01-29 22:37:40 +00:00
florian
29a2c433f7 * -Sr option for iso mode: in case no command line parameter is passed, the file name for program parameters is derived from their variable name
git-svn-id: trunk@35257 -
2017-01-07 14:50:58 +00:00
Jonas Maebe
472b5228fe * changed ncgutil.has_alias_name(pd,s) to a method of tprocdef
git-svn-id: trunk@35085 -
2016-12-09 13:39:28 +00:00
nickysn
d28963f434 * emit the heap and stack sizes via Tai_const.Create_int_dataptr, instead of
using create_pint

git-svn-id: trunk@34646 -
2016-10-07 20:58:50 +00:00
nickysn
bacea005fc * emit a sizeint, not a ptruint for TableCount in tnodeutils.InsertRuntimeInitsTablesTable as well
git-svn-id: trunk@34643 -
2016-10-07 17:21:52 +00:00
nickysn
16dfb839d8 * emit a sizeint, not a ptruint for TableCount in tnodeutils.InsertResourceTablesTable
git-svn-id: trunk@34638 -
2016-10-07 13:49:48 +00:00
nickysn
f6356e03e4 * use aluuinttype, instead of sinttype, when emitting TableCount and InitCount
for the InitFinalTable, because they are declared as ALUUInt in the RTL and
  sinttype doesn't always correspond to the ALU size (it differs on platforms
  with the combination of a 64-bit ALU and 32-bit address space)

git-svn-id: trunk@34629 -
2016-10-04 22:57:06 +00:00
Jonas Maebe
473cec9d85 * converted tnodeutils.InsertRuntimeInits() to the high level typed const
builder

git-svn-id: trunk@34443 -
2016-09-07 16:09:06 +00:00
yury
e3d9dbbeef * Removed unused vars.
git-svn-id: trunk@34404 -
2016-09-01 19:55:45 +00:00
Jonas Maebe
18d728eb72 * ensure that local variables and parameters moved to a parentfpstruct aren't
initialised and finalised twice (once at their original location, and once
    when the parentfpstruct is initialised/finalised)

git-svn-id: trunk@34374 -
2016-08-24 16:41:07 +00:00
Jonas Maebe
a31ca58593 * factored out the loading the function result from the parentfpstruct into
its original location so it can be reused elsewhere too

git-svn-id: trunk@34304 -
2016-08-13 14:47:47 +00:00
svenbarth
6b7f55cc77 * import the class con-/destructor symbol into the *current* unit not into the unit the symbol comes from
git-svn-id: trunk@34251 -
2016-08-05 13:48:27 +00:00
svenbarth
ccb4b23949 * register the start and end symbols of resource strings in the extern assembler list of the program/library
* export the start and end symbols of resource strings from the package

git-svn-id: trunk@34186 -
2016-07-22 16:03:16 +00:00
svenbarth
947c876ba3 * use the indirect start and end symbols for the resource string table (affects both the compiler and the RTL)
git-svn-id: trunk@34185 -
2016-07-22 16:01:39 +00:00
svenbarth
4df4449933 Extend the ttypedconstbuilder's dead_stripe_section handling (get_vectorized_dead_strip_section_symbol() and finalize_vectorized_dead_strip_asmlist()) with the ability to
- register a symbol in the unit's public or extern asm symbol list
 - add an indirect symbol when defining the symbol
 - use an indirect symbol instead of the direct one
This will be needed to correctly handle resourcestrings for packages

git-svn-id: trunk@34182 -
2016-07-22 15:55:14 +00:00
svenbarth
f69b365b77 * declare various symbols as external assembler symbols: RTTI references, parent VMT, FPC_EMPTYMETHOD (all three only if it's used from a different unit), threadvar lists and symbols declared as "external"
git-svn-id: trunk@34176 -
2016-07-22 13:34:38 +00:00
svenbarth
bb72c1c4df * declare various assembler symbols (VMT, RTTI, threadvars) as public assembler symbols
* declare public function alias as public assembler symbols

git-svn-id: trunk@34175 -
2016-07-22 13:11:24 +00:00
Jonas Maebe
a0efde8167 * automatically generate necessary indirect symbols when a new assembler
symbol is defined
   o removed all places where AB_INDIRECT symbols were explicitly generated
   o only generate AB_INDIRECT symbols for AT_DATA on systems_indirect_var_imports
   o for some symbols an indirect symbol is always required (because they are
     dereferenced by code in RTL units) -> use new AT_DATA_FORCEINDIRECT type

git-svn-id: trunk@34165 -
2016-07-20 20:53:03 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
svenbarth
72be688a8c A unit's threadvar list needs to be indirectly referenced by the THREADVARLIST as well.
compiler/ngenutil.pas, tnodeutils:
  * InsertThreadvarTablesTable: reference a unit's (and the program's) threadvar table using a indirect symbol
  * InsertThreadvars: generate an indirect symbol for the threadvar table
rtl/inc/threadvr.inc:
  * TltvInitTablesTable: add an additional indirection for the tables field

git-svn-id: trunk@34043 -
2016-07-01 14:18:28 +00:00
svenbarth
ca07a4f86f Merged revision(s) 32491-32492 from branches/svenbarth/packages:
Adjust non-Windows resources to work with indirect main information as well.

rtl/inc/systemh.inc, TEntryInformation:
  + new cross platform field ResLocation which stores the pointer to the resources
rtl/inc/intres.inc:
  * change the type of ResHeader from PResHdr to PPResHdr (and adjust code that uses it accordingly; Note: the first dereferencing is assumed to be always valid!)
  * adjust declaration of ResHeader depending on whether indirect main information is used or not
rtl/darwin/sysinit.pas & rtl/linux/si_impl.inc:
  * pass the location of the resources through SysInitEntryInformation
rtl/bsd/system.pp & rtl/linux/system.pp:
  + new public variable FPCResLocation which is setup by SysEntry
rtl/win32/sysinit.inc:
  * initialize ResLocation of SysInitEntryInformation as Nil
rtl/win32/system.pp:
  * initialize ResLocation of EntryInformation as Nil
........
For systems that support both internal and external resources (in this case only Darwin ones) we need to generate the FPC_RESLOCATION symbol always, because the SysInit unit is resource type agnostic.

ngenutil.pas, tnodeutils:
  * InsertResourceInfo: generate FPC_RESLOCATION symbol pointing to 0 in case the program is compiled on Darwin with resources set to external ones (-We)

git-svn-id: trunk@33952 -
2016-06-12 09:08:17 +00:00
nickysn
c78f406d99 + implemented proper stack checking for the i8086
git-svn-id: trunk@33787 -
2016-05-24 23:57:47 +00:00
pierre
4ff01e1f41 Modify tnodeutils.insertbsssym method to generate indirect symbol only if flags contains tf_supports_packages
git-svn-id: trunk@33762 -
2016-05-23 15:31:18 +00:00
Jonas Maebe
fe5cf94e10 * moved generation of initialisation/finalisation nodes from the code
generator to psub and ngenutil
   o removed dependence of hlcgobj on pass_1

git-svn-id: trunk@33737 -
2016-05-21 14:48:34 +00:00
svenbarth
86478fa781 Fix the handling of imports of the init and finalize functions now that the symbols are correctly registered
ngenutil.pas, tnodeutils:
  * InsertInitFinalTable: the init and finalize functions are in the *local* symboltable not the global one
  * InsertInitFinalTable.add_initfinal_import: reenable the internal error

git-svn-id: trunk@33508 -
2016-04-14 21:32:53 +00:00
svenbarth
e2b1f70ac6 Local symbols and defs that are needed for packages need to be registered as well => register the symbols and defs for the init and finalize functions.
pmodules.pas:
  * create_main_proc: register the proc's symbol
ngenutil.pas, tnodeutils:
  * create_main_procdef: register the proc's def

git-svn-id: trunk@33507 -
2016-04-14 21:30:36 +00:00
svenbarth
bd82059f0e Fix cycling.
ngenutil.pas, tnodeutils.InsertInitFinalTable:
  * add_initfinal_import: disable the internal error until I've found out why the INIT$ function isn't there

git-svn-id: trunk@33504 -
2016-04-14 20:51:06 +00:00
svenbarth
35809b58f8 Merged revision(s) 28856 from branches/svenbarth/packages:
Also add the initialization/finalization sections and the class constructors/destructors to the imported symbols of the current program/library.

ngenutil.pas, tnodeutils.InsertInitFinalTable:
  + new function add_initfinal_import to find the procsym for the initialization/finalization code and to add it to the imported unit symbols
  * write_struct_inits: import the found class constructor/destructor symbols if they are not in the program/library unit
  * use add_initfinal_import for the initialization and finalization sections of all used units beside the program/library unit
........

git-svn-id: trunk@33501 -
2016-04-14 19:47:19 +00:00
svenbarth
6722c611cf Generate indirect symbols for global variables and (typed) constants.
Note: It needs to be checked what adjustments will need to be done for JVM and LLVM

Note 2: The indirect symbols will always be generated even if the target won't use them so that assembler code can be consistent among the targets (e.g. i386-win32 needs them while i386-linux does not)

ptconst.pas, read_typed_const:
  * generate the indirect symbol in a read only data section
ngenutil.pas, tnodeutils:
  * insertbsssym: generate the indirect symbol in a read only data section

git-svn-id: trunk@33279 -
2016-03-18 21:40:11 +00:00
Jonas Maebe
0e97811b50 + initialise managed string function results with an error string when
compiling with -gt (mantis #28948)

git-svn-id: trunk@33198 -
2016-03-06 17:22:11 +00:00
Jonas Maebe
5f14029e74 * if a function result has been migrated to the parentfpstruct because it is
accessed by a nested routine, assign it back to the original funcretsym
    at the end because the code generator is hardcoded to use funcretsym.
    We can't replace funcretsym with an absolutevarsym that redirects to
    the parentfpstruct field, because the code generator can only handle
    simple variables

git-svn-id: trunk@32687 -
2015-12-20 20:56:08 +00:00
yury
17358aa3ed * Removed unused local vars.
git-svn-id: trunk@32537 -
2015-11-26 17:15:04 +00:00
Jonas Maebe
eefcbaff69 * converted tnodeutils.InsertResourceInfo to the high level typed constant
builder and enabled it for llvm

git-svn-id: trunk@32532 -
2015-11-25 22:25:48 +00:00
Jonas Maebe
416894f206 * converted tnodeutils.InsertResourceTablesTable() to the high level typed
const builder
   o also put the resourcestring tables table in rodata instead of in data,
     since it doesn't change at run time (unlike the individual resourcestring
     tables)

git-svn-id: trunk@32397 -
2015-11-21 12:36:16 +00:00
Jonas Maebe
96b529072a * factored out generating the start and end of a vectorized dead strippable
section to the high level typed const builder, and use this functionality
    for the resource strings (generating items: todo)
  * fixed dead stripping unused resource strings (all string data was put in the
    same section since r30342)

git-svn-id: trunk@32394 -
2015-11-21 12:36:06 +00:00
Jonas Maebe
964f8c9f9b * factored out the creation of start/end symbols of vectorized dead strippable
sections such as the resourcestring data

git-svn-id: trunk@32391 -
2015-11-21 12:35:56 +00:00
florian
70b8789262 o basic extended pascal support:
+ automatically loaded helper unit
  * Makefiles adapted
  * mode switch
  * mode switches reorganized
+ TimeStamp support

git-svn-id: trunk@32330 -
2015-11-15 15:13:36 +00:00
svenbarth
529677cc79 ncal.pas:
* extend tcallnode with the ability to pass a tspecializationcontext so that tcallcandidates can do a final specialization
  * the final procdef is registered at the end of tcallnode.pass_typecheck

git-svn-id: trunk@31763 -
2015-09-18 14:48:54 +00:00
Jonas Maebe
f8d9e70ec2 * converted tnodeutils.InsertMemorySizes() to the high level typed constant
builder and activated it for llvm

git-svn-id: trunk@31678 -
2015-09-14 16:10:54 +00:00
Jonas Maebe
381270bf30 * changed the threadvars table count back from
tai_const.create_32bit_unaligned() into tai_const.create_32bit() after
    r31649 (Lazarus autocompletion...) (fixes webtbs/tw3540.pp regression)

git-svn-id: trunk@31661 -
2015-09-13 07:56:12 +00:00
Jonas Maebe
faf4a9cb38 * moved the generation of the "main" stub for libc-based platforms from
hlcgobj to pmodules/symcreat/ngenutil, so that it also works for llvm

git-svn-id: trunk@31658 -
2015-09-12 23:34:01 +00:00
Jonas Maebe
4b92083006 * converted tnodeutils.InsertRuntimeInitsTablesTable to the high level typed
const builder
   o enabled the routines that use this one for LLVM

git-svn-id: trunk@31652 -
2015-09-12 23:33:38 +00:00
Jonas Maebe
a4ee982269 * converted tnodeutils.InsertInitFinalTable to the high level typed const
builder and enabled it for LLVM

git-svn-id: trunk@31651 -
2015-09-12 23:33:35 +00:00
Jonas Maebe
a1c676cc51 * converted tnodeutils.InsertThreadvarTablesTable to the high level typed
constant builder

git-svn-id: trunk@31649 -
2015-09-12 23:33:28 +00:00
Jonas Maebe
f49d6e5f26 * converted tnodeutils.InsertThreadvars to the high level typed constant
builder

git-svn-id: trunk@31647 -
2015-09-12 23:33:21 +00:00
svenbarth
65c37df999 + extend tprocdef with the possiblity to create it as unregistered
* for now all procdefs are created as registered
Note: an additional parameter instead of an overload is used for tprocdef.create as otherwise both constructors would need to be overridden in potential descendant CPU-specific classes...

git-svn-id: trunk@31593 -
2015-09-11 13:36:00 +00:00
Jonas Maebe
1941e64488 + added a hook to insert object-global information into the asmlists (will
be used to insert type definitions for llvm)

git-svn-id: trunk@30674 -
2015-04-19 21:37:43 +00:00
Jonas Maebe
640efba580 * fixed warnings after r30449/r30450
git-svn-id: trunk@30466 -
2015-04-06 14:24:09 +00:00
florian
9ab9e03650 * limit number of possible units with initialization/finalization for a certain architecture to high(aint)
+ give an error if the number of possible units is exceeded

git-svn-id: trunk@30450 -
2015-04-05 21:06:58 +00:00
Jonas Maebe
bd203a5b57 * synchronised with trunk till r30240
git-svn-id: branches/hlcgllvm@30241 -
2015-03-15 19:44:58 +00:00
Jeppe Johansen
155998fe89 Support .set and .weak in internal assembler.
Fix problem with fpc_initialHeap getting put in .data instead of .bss.

git-svn-id: trunk@30233 -
2015-03-15 12:10:54 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
florian
8de49997ea * align compiler generated constants according to constant aligment settings
git-svn-id: trunk@29652 -
2015-02-08 11:23:01 +00:00
florian
632f43c490 * fix assembling with masm according to #25858
git-svn-id: trunk@29635 -
2015-02-05 21:22:39 +00:00
sergei
a67478e033 * Simplified, removed redundant asmlist and duplicate call to maybe_new_object_file.
git-svn-id: trunk@29509 -
2015-01-20 07:52:11 +00:00
svenbarth
b38fb606cc Fix for Mantis #27185.
ngenutil.pas:
  * AddToStructInits: also process the class constructors/destructors of nested types

+ added test

git-svn-id: trunk@29308 -
2014-12-21 14:01:32 +00:00
Jonas Maebe
37009c917b * pass alignment to tnodeutils.insertbsssym()
git-svn-id: branches/hlcgllvm@28751 -
2014-10-06 20:53:14 +00:00
Jonas Maebe
7949bebb8d * synchronised with r28168 of trunk
git-svn-id: branches/hlcgllvm@28169 -
2014-07-05 21:30:28 +00:00
svenbarth
4a0d27ebfe Fix for Mantis #26271: Don't trash local variables that are used for the Default() intrinsic.
* ngenutil.pas, tnodeutils.trashable_sym:
    check for vo_is_default_var flag and don't consider such as trashable

+ added test

git-svn-id: trunk@27872 -
2014-06-06 13:59:52 +00:00
Jonas Maebe
bacd303208 * synchronized with trunk up to r27758
git-svn-id: branches/hlcgllvm@27779 -
2014-05-12 16:12:34 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
Jonas Maebe
e9268a0a14 * synchronised with trunk up till r26975
git-svn-id: branches/hlcgllvm@26976 -
2014-03-06 21:36:58 +00:00
nickysn
5242ed7864 * changed TResStrInitTable.Count and TWStrInitTablesTable.Count to nativeint
git-svn-id: trunk@26921 -
2014-03-02 13:27:59 +00:00
nickysn
73e6ffe675 * the TableCount and InitCount fields in the INITFINAL table changed to
nativeint (generates smaller and more efficient code on i8086)

git-svn-id: trunk@26913 -
2014-03-01 14:33:10 +00:00
florian
15df4a4f80 + support iso pascal like program parameters in iso mode
git-svn-id: trunk@26437 -
2014-01-12 20:17:51 +00:00
Jonas Maebe
aa5823a454 * factored out inserting a single bss symbol in ngenutil so it can be
overridden by the llvm target
  * override a bunch of other ngenutil methods with empty stubs for things
    that are not yet supported when targeting llvm

git-svn-id: branches/hlcgllvm@26051 -
2013-11-11 11:16:13 +00:00
Jonas Maebe
a14ceba791 + -CTinitlocals switch for the JVM that initialises all local variables
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 -
2013-08-29 22:21:23 +00:00
nickysn
e4f84b0f5d * i8086 medium model fixes in tnodeutils.InsertResourceTablesTable
git-svn-id: trunk@25290 -
2013-08-18 20:37:18 +00:00
nickysn
10db067372 * specify Tasmsymtype=AT_FUNCTION and use Create_nil_codeptr when generating the code pointers in the InitFinal table
git-svn-id: trunk@25286 -
2013-08-18 18:27:48 +00:00
svenbarth
ff3bb9322a Fix for Mantis #24848.
ngenutil.pas, AddToStructsInit:
  * don't add class constructors/destructors to the init table if they belong to a generic type

+ test

git-svn-id: trunk@25234 -
2013-08-11 11:20:12 +00:00
florian
380bc56e32 + create a default heap on embedded targets and register this default heap
* sysutils for the embedded target depends on a working heap manager

git-svn-id: trunk@23853 -
2013-03-16 10:37:18 +00:00
paul
5d74e0578a compiler: remove unused variables and unneeded assignments
git-svn-id: trunk@23467 -
2013-01-21 01:24:36 +00:00
sergei
1116bc3542 * Fixed incorrect condition (a linked list always has at least one dummy element) which was causing every unit to have a threadvar table, regardless of actual presence of threadvars. For units without code, this was causing creation of .o files which aren't necessary otherwise.
git-svn-id: trunk@23201 -
2012-12-21 14:13:30 +00:00
Jonas Maebe
289486346b * factored out code to decide when an asmsym for a staticvarsym has to be
global, and no longer make it global for all symbols when smartlinking
    is enabled on systems that use section-based smartlinking

git-svn-id: trunk@22241 -
2012-08-25 15:12:39 +00:00
Jonas Maebe
baa8fa39a8 * converted code to trash variables (-gt) to operate at the node tree level,
and also use this code to trash local variables in inlined routines
   o fixes mantis #22088
   o makes it possible to also implement it for the jvm target in the future

git-svn-id: trunk@21393 -
2012-05-26 11:32:39 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
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 -
2012-04-15 15:54:10 +00:00
Jonas Maebe
40cf2cefa0 * when the user calls initialize(), force initialization to happen on the
JVM platform (normally it's not necessary because all types are
    automatically initialized)

git-svn-id: branches/jvmbackend@18672 -
2011-08-20 08:23:16 +00:00
Jonas Maebe
13b0ac91d9 + generate java.lang.Enum descendant classes for Pascal enum types
o these classes get an "enum" flag in the class files
   o these classes get a class field (whose type is that same enum
     class) per enum in the type, which also gets the "enum" flag
   o those class fields are initialised in the class constructor
     with the name of the enum and their order in the declaration
   o if the enum has jumps in FPC (lowest value is not 0, or not
     all values are contiguous), then we add an extra field
     to hold the FPC ordinal value of the enum
   o these classes get a class field valled $VALUES that contains
     a reference to the aforementioned class fields in order of
     declaration (= ordinal->instance mapping, JDK-mandated)
   o apart from the JDK-mandated instance methods (values, valueOf),
     also add FPCOrdinal (returns FPC ordinal value; same as order
     of declaration in case of no jumps) instance method and FPCValueOf
     (returns enum corresponding to FPC ordinal value) static class
     method
   o the mapping between FPC ordinals and enum instances in case of
     jumps is stored in a hashmap whose size is the next prime number
     greater or equal than the number of enum elements
   o moved several extra JDK types to the system unit for the enum
     support, and for future boxing and Java set support
   o several new synthetic method identifiers to generate the enum class
     methods/constructor/class constructor
   o enums with jumps are ordered by FPC ordinal value in the JVM
     $VALUES array so that the java.lang.Enum.doCompare() method
     will properly compare them

git-svn-id: branches/jvmbackend@18616 -
2011-08-20 08:15:28 +00:00
Jonas Maebe
e9e72e6de0 * fixed copyright date
git-svn-id: branches/jvmbackend@18581 -
2011-08-20 08:12:24 +00:00
Jonas Maebe
739c654e3a + support for main programs for the JVM target
o moved several routines from pmodules to ngenutil and overrode them
     in njvmutil (for unit initialisation tables, resource strings, ...)
   o force the evaluation stack size to at least 1 for the main program,
     because the unit initialisation triggers are inserted there afterwards
     and they require one stack slot

git-svn-id: branches/jvmbackend@18507 -
2011-08-20 08:05:38 +00:00
Jonas Maebe
41624e8102 * pd.owner.defowner -> pd.struct
git-svn-id: branches/jvmbackend@18484 -
2011-08-20 08:03:42 +00:00
Jonas Maebe
43c5ed20c2 + support for initialising typed constants via compiler-generated
assignment-nodes. For global typed constants and typed constants/
    local variable initialisers in regular functions/procedurs, the
    assignments are performed in the unit initialisation code. For
    those in object/record definitions and their methods, it's done
    in the class constructor. Since we may not yet have parsed all
    method implementations when the class constructor is parsed, part
    of these may be initialised in a helper routine called from the
    class constructor. The ones known when the class constructor is
    parsed are inited there, because the ones marked as "final" and
    declared as static class fields must be initialised in the class
    constructor for Java
   o new set systems_typed_constants_node_init in systems unit that
     indicates that a target uses node trees to initialise typed consts
     instead of an initialised data section
   o mark typed constants in {$j-} mode as "final" for JVM
   o mangle the name of staticvarsyms inside localtables a bit to avoid
     name clashes (only with procedure names for now, no parameters yet
     so can still cause problems with overloaded routines)
   o after a routine has been parsed, it is now processed by
     cnodeutils.wrap_proc_body(), which can add extra nodes before code
     generation (used for injected the typed constant node trees)

git-svn-id: branches/jvmbackend@18475 -
2011-08-20 08:02:58 +00:00
Jonas Maebe
c264c24fb0 + support for unit initialisation sections for the JVM target,
and initialise global variables that are wrapped (records, arrays)
    in those sections
   o check whether pd.localst is assigned in dbgjasm, because it's
     not for the unit initialisation routine
   o moved insertbssdata() from ncgutil to ngenutil and override it
     njvmutil (it does nothing in the latter, since global variables
     are added as fields to the class representing the unit; the
     initialisation is done in gen_initialize_code() in thlcgjvm)
   o added force_init() and force_final() methods to ngenutil, so
     that targets can force init/final routines separate from the
     regular managed types infrastructure (used by JVM for forcing
     an init section in case of records/arrays)

git-svn-id: branches/jvmbackend@18460 -
2011-08-20 08:01:39 +00:00
Jonas Maebe
ab5b1fb686 * turned call_fail_node, initialize_data_node, and finalize_data_node from
nutils.pas into virtual class methods of a new tnodeutils class defined
    in ngenutil (global factory: cnodeutils), so they can be overridden by
    architecture-specific implementations (required by the JVM backend)

git-svn-id: branches/jvmbackend@18364 -
2011-08-20 07:52:11 +00:00