Commit Graph

582 Commits

Author SHA1 Message Date
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
florian
b2b26f84cf * partially merged the mips-embedded branch of Michael Ring:
- startup code/controller units are not merged yet
  - assembler call does not pass the needed CPU type yet

git-svn-id: trunk@27188 -
2014-03-19 21:25:38 +00:00
Jonas Maebe
009c96a0bd * fixed setting up the global switch for main programs without a "program"
header on platforms not in systems_unit_program_exports

git-svn-id: trunk@26975 -
2014-03-06 18:41:03 +00:00
florian
68f1a51164 * set PIC defines earlier, resolve #25788
git-svn-id: trunk@26924 -
2014-03-02 15:35:08 +00:00
florian
fe7238bdf1 * avoid compiler warning about uninitialized variable
git-svn-id: trunk@26441 -
2014-01-12 21:21:56 +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
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
paul
2fa739f729 compiler: remove unneeded push/pop to symtablestack
git-svn-id: trunk@25518 -
2013-09-18 05:24:19 +00:00
paul
5aa919c2a8 compiler: have unit interface symtable in stack while parsing implementation uses list (fixes issue #10477)
git-svn-id: trunk@25505 -
2013-09-17 08:53:37 +00:00
paul
0d8ad2a932 compiler: don't treat TRUE and FALSE as keywords. They are predefined constants from this moment. This change is compatible with other pascal compilers. Fixes issue #0025030
git-svn-id: trunk@25497 -
2013-09-16 09:11:17 +00:00
paul
60c0de6c09 compiler: formatting
git-svn-id: trunk@25476 -
2013-09-13 02:24:47 +00:00
sergei
d11ec8ac47 - Reverted r25269 and commented out r25261. The former one is wrong because it changes unit initialization order. The latter one causes RTL build failures on some targets, needs testing and likely RTL/makefiles patching.
git-svn-id: trunk@25271 -
2013-08-16 15:17:25 +00:00
sergei
e1ddd914ac * Do not implicitly load Variants unit when compiling units. Doing so is mostly waste of time, and introduces unwanted build dependencies. It is enough to set uf_uses_variants flag for units, and examine these flags when compiling program/library. Resolves #24880.
git-svn-id: trunk@25269 -
2013-08-16 12:42:47 +00:00
florian
5e0585c0d0 + introduce tf_no_objectfiles_when_smartlinking so object file generation on i8086-msdos can be turned off
* object file generation on i8086-msdos can be turned off if smartlinking is enabled

git-svn-id: trunk@24396 -
2013-04-30 19:11:55 +00:00
sergei
d54d38b4ab * Moved all code responsible for writing VMTs and interface wrappers (nobj.TVMTWriter, ncgutil.gen_intf_wrappers, ptype.write_persistent_type_info) into a new unit ncgvmt.pas.
This improves compiling speed a bit (two iterations over symtables replaced by one, code generator is created once per unit rather than once per class).
In perspective it makes possible to reduce amount of generated smartlink sections and global labels.

git-svn-id: trunk@24269 -
2013-04-19 13:31:27 +00:00
florian
784641ec46 * delay parsing of the closing SEMICOLON of a uses clause till the
unit map is updated to avoid symbols not being found, resolves #8611

git-svn-id: trunk@23886 -
2013-03-17 11:06:04 +00:00
paul
5d74e0578a compiler: remove unused variables and unneeded assignments
git-svn-id: trunk@23467 -
2013-01-21 01:24:36 +00:00
Jeppe Johansen
8b17a358e4 Remove all traces of the interrupt vector table generation mechanism
Clean up cpuinfo tables
Fixed ARMv7M bug(BLX <label> doesn't exist on that version)

git-svn-id: branches/laksen/arm-embedded@22579 -
2012-10-08 00:10:52 +00:00
pierre
2f24527ea0 Enable gotvarsym for sparc cpu
git-svn-id: trunk@22486 -
2012-09-27 15:55:07 +00:00
svenbarth
e04fae2c67 Remove commented variables which strangely weren't detected by a "make cycle"...
git-svn-id: trunk@22456 -
2012-09-25 11:52:10 +00:00
svenbarth
88af293155 Fix for Mantis #22160
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 -
2012-09-25 09:45:25 +00:00
Jonas Maebe
14cfe770a4 * replaced most (if not all) remaining fields/parameters in the compiler
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 -
2012-04-29 17:36:23 +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
adbad5ab96 + fcl-res support for xcoff/aix
+ compiler support for Delphi-style resources on aix

git-svn-id: trunk@20841 -
2012-04-11 18:06:33 +00:00
Jonas Maebe
d545a72f1a + lnfogdb unit that can use gdb to symbolicate backtraces on unix targets
(used for stabx/aix)

git-svn-id: trunk@20833 -
2012-04-11 18:05:56 +00:00
Jonas Maebe
481b3d99a9 * just like Darwin and Classic Mac OS, AIX uses the system crt* files and
hence contains a dummy "main" that refers to the system unit
    FPC_SYSTEMMAIN, which in turn jumps to the main program's PASCALMAIN
  * we call FPC_SYSTEMMAIN instead of jumping to it like on Darwin, so that
    the TOC gets set correctly

git-svn-id: trunk@20792 -
2012-04-11 18:00:43 +00:00
florian
4cf4c65502 * write the file location (if available), if a unit is not found, resolves #21514
git-svn-id: trunk@20583 -
2012-03-22 21:04:16 +00:00
florian
fbc519faeb * don't allow multiple deprecated messages, resolves #21466
git-svn-id: trunk@20515 -
2012-03-12 21:39:43 +00:00
paul
a71d588105 compiler: write INIT and RTTI info also for defs of nested records and classes + test (issue #0020909)
git-svn-id: trunk@20162 -
2012-01-24 06:57:04 +00:00
sergei
c8e65c501a * Don't optimize away implicit initialization/finalization procedures if corresponding clause is present in the source but is empty. Resolves #19701.
git-svn-id: trunk@19692 -
2011-11-26 05:01:30 +00:00
Jonas Maebe
b584c71e42 * use {$IFNDEF cpu64bitaddr} instead of {$IFDEF cpu32bit} so that it's
also correct for 16 bit cpus (if they use 32 bit addresses anyway)

git-svn-id: trunk@19691 -
2011-11-25 21:12:59 +00:00
Jonas Maebe
de3a7f0cfd * the size of the FPC_RESSYMBOL pointer must depend on the target
cpu, not the host cpu

git-svn-id: trunk@19687 -
2011-11-25 16:56:50 +00:00
florian
d7f7a9bb76 * patch by Alexander Shishkin to clean up $ifopt usage by $push/$pop, resolves #20346
git-svn-id: trunk@19256 -
2011-09-27 20:22:40 +00:00
Jonas Maebe
125c0cf225 + support for generics on the JVM target:
o don't try to create .class files for generic types
   o still generate all JVM-specific wrappers for generic types even though they
     won't be written out, because when specializing all the defid's have to
     match exactly
   o add synthetic routine implementations after generating the specializations,
     so that the synthetic routines for those specializations are also generated
     (we don't specialize generic versions of the synthetic generic routines
      because it's not easy or even always possible to create valid generic
      versions of synthetic routines)
   o Note: these are Pascal-style generics, not Java-style generics. The generic
     types nor their specializations are usable from Java code (specializations
     may become usable in the future)

git-svn-id: branches/jvmbackend@19047 -
2011-09-11 11:54:37 +00:00
sergei
689d4b3ecc + Mantis #19651: Generate table of typed string constants which are initialized with resourcestrings, so they are updated when SetResourceStrings or SetUnitResourceStrings is called.
git-svn-id: trunk@18968 -
2011-09-04 16:01:26 +00:00
paul
3c5d642685 fix indenting (after the merge of namespaces branch)
git-svn-id: trunk@18920 -
2011-08-31 08:10:31 +00:00
paul
adceaf438c reintegrate paul/namespaces branch into trunk:
r18890 | paul | 2011-08-29 16:45:23 +0800 (Пн, 29 авг 2011) | 1 line

compiler: also parse dots in package name and in units which package contains (although package support is not implemented yet in FPC it can parse packages)
------------------------------------------------------------------------
r18886 | paul | 2011-08-29 10:46:13 +0800 (Пн, 29 авг 2011) | 1 line

compiler: replace "string" with ansistring where we concatenate substrings to prevent 255 chars limit overflow
------------------------------------------------------------------------
r18859 | paul | 2011-08-27 11:52:07 +0800 (Сб, 27 авг 2011) | 1 line

compiler: implement delphi like namespaces

git-svn-id: trunk@18911 -
2011-08-30 01:10:24 +00:00
paul
fbbbc1117d compiler: also parse dots in package name and in units which package contains (although package support is not implemented yet in FPC it can parse packages)
git-svn-id: branches/paul/namespaces@18890 -
2011-08-29 08:45:23 +00:00
paul
61f2335de9 compiler: replace "string" with ansistring where we concatenate substrings to prevent 255 chars limit overflow
git-svn-id: branches/paul/namespaces@18886 -
2011-08-29 02:46:13 +00:00
paul
de21de2024 compiler: implement delphi like namespaces
git-svn-id: branches/paul/namespaces@18859 -
2011-08-27 03:52:07 +00:00
florian
a08dfdf803 o slightly modified patch by John Clymer:
* converts the embedded information into controller specific records (arm and avr)
  * new cpu-specific units for several Stellaris (Fury and Tempest class) targets, 
  + STM32F103RB
  - old Stellaris unit has been removed

git-svn-id: trunk@18848 -
2011-08-25 21:46:26 +00:00
Jonas Maebe
28c20cfc5e * the default string type for the JVM target is no longer automatically
unicodestring = java.lang.String. The reason this was the default in
    the past is that this was the first string type that was implemented,
    and without it being the default most code involving string operations
    would fail. Now the default strings types are the same as for other
    targets
  + new {$modeswitch unicodestrings} directive, that when activated
    *together* with {$h+},
   1) changes char into an alias for widechar
   2) changes string into an alias for unicodestring
   3) changes the preferred string evaluation type (in case of uncertainty)
      to unicodestring
    {$modeswitch unicodestrings} with {$h-} does not change anything at all
    regarding the string type (it still changes the char type)
  + new uuchar unit that redefines char as widechar, and which is automatically
    included by the compiler if {$modeswitch unicodestrings} is enabled

git-svn-id: branches/jvmbackend@18781 -
2011-08-20 08:35:47 +00:00
Jonas Maebe
979f55e1db + support for procedural variables for the JVM target
o every porocedural variable type is represented by a class with one
     public "invoke" method whose signature matches the signature of the
     procvar
   o internally, dispatching happens via java.lang.reflect.Method.invoke().
     WARNING: while this allows calling private/protected or other methods
     that are normally not accessible from another context, a security
     manger can override this. If such a security manager is installed,
     most procvars will cause security exceptions
   o such dispatching also requires that all arguments are wrapped, but
     that's done in the compiler-generated body of the invoke method,
     so that procvars can also be called conveniently from Java code
   o typecasting between a procedure of object and tmethod is supported,
     as well as Delphi-style replacing of only the method pointer via
     @procvar1=@procvar2.
   o nested procvars are not yet supported, but most of the basic
     infrastructure for them is already present
  * all units/programs now get an internal __FPC_JVM_Module_Class_Alias$
    type when compiled for the JVM target, which is an "external" class
    that maps to the unit name. This is required to look up the
    JLRMethod instances for regular functions/procedures
  + new tabstractprocdef.copyas() method that allows to create a procvar
    from a procdef and vice versa

git-svn-id: branches/jvmbackend@18690 -
2011-08-20 08:24:58 +00:00
Jonas Maebe
2376003cd0 * wrap the init/finalization code even when it is implicitly generated
* only wrap the init/finalization code after the main program has been
    completely processed (pass1, codegen), because this may influence
    the required wrapping in case of the JVM target
  * replace periods with slashes in the package name when constructing
    the classes corresponding to the units (to execute their initialization
    code) -- didn't notice this was wrong previously because due to the
    incomplete wrapping, they were never being initialized until now

git-svn-id: branches/jvmbackend@18645 -
2011-08-20 08:20:56 +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
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
019ca93a04 * symcreat functionality to use the parser from inside the compiler for
artificially generated stuff rather than directly working with defs/syms
   problems
    o scanner state saving/restoring, and avoiding problems in case of
      errors in the injected strings
    o in case of the actual application (adding overriding constructors):
      the parameters may be of types not visible in the current unit to
      newly written code -> can't just use the scanner...

git-svn-id: branches/jvmbackend@18427 -
2011-08-20 07:58:44 +00:00
Jonas Maebe
28740dce2d - removed extra "fordefinition" parameter again from tprocdef.mangledname(),
since the definition-specific adorning of JVM mangled names is Jasmin-
    specific, and such code has no place in symdef
  * moved code to adorn JVM mangled names for Jasmin definitions to agjasmin

git-svn-id: branches/jvmbackend@18346 -
2011-08-20 07:49:31 +00:00
Jonas Maebe
0ee702b3a2 * tprocdef.mangledname now gets an extra boolean parameter indicating
whether the mangled name is for defining a symbol, or for referencing
    it later (e.g. for a call or load of its address). The reason is that
    on the JVM both cases are different.
  + jvmdef unit to encode types according to the JVM rules
  + tprocdef.jvmmangledname() to encode a procdef's JVM mangled name
    (the common part of defining/referencing it; tprocdef.mangledname
     afterwards adorns it as required)

git-svn-id: branches/jvmbackend@18288 -
2011-08-20 07:22:00 +00:00
sergei
fec5dde5b6 * Fix handling of Windows WideString typed constants, resolves #15842 and completes the related #14308:
* Do not initialize unused symbols, because finalization code is not generated for them either.
  * Always initialize/finalize such constants, even if they are declared in {$J-} state and cannot be modified by user code.

git-svn-id: trunk@18121 -
2011-08-06 18:11:39 +00:00