Commit Graph

281 Commits

Author SHA1 Message Date
Jonas Maebe
e5c097a6e2 * mark nodes that have been created by transforming a read-accessor of
of a property with nf_no_lvalue flag, and check that such nodes are
    never used in direct assignments (fixes mantis #21087 and a couple of
    other cases of invalid assignments to properties)

git-svn-id: trunk@20140 -
2012-01-21 19:09:30 +00:00
svenbarth
4419dc3d34 Rebase to revision 19673
pexpr.pas: Changes in postfixoperators and the base of handle_factor_typenode not yet incorporated (the code from trunk was simply commented for now)

git-svn-id: branches/svenbarth/generics@19676 -
2011-11-24 16:48:47 +00:00
svenbarth
461d231daa Rebase to revision 19078 (directly before the merge of cpstrnew)
The changes regarding pretty names for generics and token buffer endianess were integrated into my changes. Not every call to generate_specialization is fixed though, so compilation will fail.

git-svn-id: branches/svenbarth/generics@19674 -
2011-11-24 10:19:57 +00:00
svenbarth
594f84dc2c Merge branch 'unique-syms'
Conflicts:
	compiler/pdecl.pas
	compiler/pexpr.pas
	compiler/pgenutil.pas
	compiler/ptype.pas

The original log messages as git was a bit forgetting here :( (newest at the top):

commit 7ef252de8023494ee6d39910e289f9e31658d47b
Author: Sven Barth <pascaldragon@minerva>
Date:   Mon Nov 21 17:13:36 2011 +0100

    Fix the compilation of inline specializations of which the generic is derived from another generic.
    
    pgenutil.pas, generate_specialization:
    * Set the "block_type" to "bt_type" when parsing the type parameters, so that the nodes are returned as "ttypenode" instead of e.g. "tloadvmtaddrnode" in case of classes outside of type sections.
    * Set the "block_type" to "bt_type" before calling "read_name_type", so that no unexpected sideeffects happen, because types like classes normally only are declared inside type sections (e.g. for the case a generic class is derived from another generic class a classrefdef for the specialized parent class will be created inside the derived specialized class if the block type is not a type one).

commit 1041a8f7a3a41f4fdf2975ce40055c698281ce71
Author: Sven Barth <pascaldragon@minerva>
Date:   Fri Nov 18 19:03:50 2011 +0100

    Improve inline specializations a bit, so now expressions like "TSomeGeneric<TSomeType>.SomeClassProc OP SomeNonGeneric" is possible. Using another class function of a generic as the right side is not yet working (that still needs some thinking).
    
    To achive this the generalization code must basically continue directly after the "factor" call, so that the operator and the right side are correctly parsed when walking up the call stack. This is done by jumping from the end of the specialization code in the "<"-case to the start of "sub_expr". The freshly generated node (in the above example a callnode) will be passed down the callstack through a new parameter "factornode". If that is set (currently only in the case of a specialization on the left side) "factor" won't be called and the right side will be parsed with the "factornode" as the left side. If it is not set (which is the case for all other calls to "sub_expr" in the unit) then the usual call to "factor" will be done and the result will be used as the left side.

commit a01ccd265f8d6cc5a2f3e88e23afbcd3d5960afb
Author: Sven Barth <pascaldragon@minerva>
Date:   Fri Nov 18 18:37:04 2011 +0100

    Fix compilation of ppudump.
    
    symconst.pas:
    * Remove sto_has_generic, which was the last remainer of my "overloaded type symbols" approach.
    * Remove df_methods_specialized, as it isn't needed anymore with the recent "temporary symtable" solution.
    
    psub.pas, specialize_objectdefs, process_abstractrecorddef:
    Remove the checks for/inclusion of df_methods_specialized.
    
    utils/ppudump.pp:
    Add "sp_generic_dummy" to the symbol options.

commit d16deac060e65d4b53e8fe9c27fe7e1f6d00a416
Author: Sven Barth <pascaldragon@minerva>
Date:   Wed Nov 16 16:34:51 2011 +0100

    Fix compilation of "gset.pp" from fcl-stl.
    
    nld.pas:
    Extend ttypenode by a reference to the type symbol. Normally this is simply the typesym of the given def, but for specializations in type sections of generics this is not the case, because generate_specialization will return a reference to the generic definition and not the new one (thus the symbol will be wrong).
    
    ppu.pas:
    Increase PPU version because of the extension of ttypenode.
    
    pexpr.pas:
    * handle_factor_typenode: Extend the function by a "sym" parameter which will normally be "nil". In that case it is set to the def's typesym. The "typesym" field of the created type node is then set to this sym.
    * For now pass nearly always "nil" for the above mentioned sym except inside factor_read_id when we've encountered a typesym.
    
    ptype.pas, read_named_type, expr_type:
    Exchange the "is_owned_by" check with a "sym_is_owned_by" check so that we can correctly detect that we are using a specialized type declaration inside a generic (once nested generic are allowed this condition needs to be checked).

commit 23668d2fc9070afc26b4288ed0db9a8eaf6f40e6
Author: Sven Barth <pascaldragon@minerva>
Date:   Wed Nov 16 07:51:12 2011 +0100

    psub.pas:
    * tcgprocinfo.parse_body: Methods of generic classes need to set "parse_generic" as well, so that variables for "stacked generics" (generic array => generic record) inside the method body are handled correctly.
    * specialize_objectdefs: Don't try to generate method bodies for abstract methods.
    
    pdecvar.pas, read_property_dec:
    Allow specializations for the return types of properties (should they be allowed for index types as well?).
    
    symtable.pas:
    Add a new class "tspecializesymtable" which is basically a globalsymtable but is always assuming to be the current unit. This symtable is used in "generate_specializations" (see below) and is needed to allow visibilty checks for "private", etc. to succeed.
    
    pgenutil.pas, generate_specializations:
    Instead of hackily pushing a symtable that may contain conflicting symbols onto the symtable stack for the specialization, a temporary global symtable using the above mentioned "tspecializesymtable" is created and pushed. After the specialization is done all symbols and defs that were added to the temporary symtable are moved to their final symtable (either the global- or localsymtable of the unit, depending on the current position of compilation). This way symbols are correctly added to a top level symtable, but without potential side effects like resolving the wrong symbol.

git-svn-id: branches/svenbarth/generics@19671 -
2011-11-23 17:25:09 +00:00
paul
a1e0b833b2 compiler: fix ppu read/write of property parameters symtable (bug #0020454)
- add new property option ppo_overrides for property which overrides parent class properties
  - write overriddenpropsymderef only in case if property has ppo_overrides flag
  - save/load parameters symtable only in case if property has ppo_parameters flag and has not ppo_overrides flag
  - in case if property is overrides and has parameters copy original symtable

git-svn-id: trunk@19615 -
2011-11-09 03:35:55 +00:00
pierre
019ecd53fe Use out parameter type for tppufile.getXXX methods
git-svn-id: trunk@19586 -
2011-11-03 11:09:34 +00:00
paul
62b4ef3d1a compiler: don't create a parasymtable for property if property has no parameters
git-svn-id: trunk@19550 -
2011-10-28 01:38:55 +00:00
paul
ceb141523d compiler: store property parameters in a parasymtables together with property. restore those parameters for descendant properties (fixes mantis #0020421 but maybe not very optimal)
git-svn-id: trunk@19400 -
2011-10-07 05:58:58 +00:00
paul
7a74d2c2f8 compiler: reduce amount of hints and notes
git-svn-id: trunk@19293 -
2011-09-30 08:56:05 +00:00
pierre
a17390126a Fix an error in reading real variable for change_endian
git-svn-id: trunk@19023 -
2011-09-07 23:19:48 +00:00
pierre
b526bb4dfa * Fix failures introduced by rev 18975
git-svn-id: trunk@18976 -
2011-09-05 07:51:22 +00:00
pierre
68d27263e7 Try to improve RecordTokenBuf with respect to PPU reading
git-svn-id: trunk@18975 -
2011-09-04 22:43:41 +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
pierre
4c633c46ed Change mangling to avoid overlap and increase PPU version
git-svn-id: trunk@18946 -
2011-09-02 14:20:14 +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
275c6092e5 * avoid range check errors for empty ansistrings written/read from ppus
git-svn-id: trunk@18253 -
2011-08-17 19:01:03 +00:00
florian
79a96ab287 + ttypesym.prettyname
* write names of specialization type syms more pretty

git-svn-id: trunk@18241 -
2011-08-17 11:10: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
Jonas Maebe
0398ff6bf5 * also save/restore the size of the padding of record/objectsymtables
* when creating a child class, ignore the padding added to the parent
    in case of objcclasses (gcc/clang also do that; maybe the same
    has to be done for cppclass as well)
  -> objcclass layouts seem to finally completely match the gcc ones

git-svn-id: trunk@18119 -
2011-08-06 18:01:39 +00:00
Jonas Maebe
1c11f6c8b7 + tppufile.putasizeint()
* save/restore tabstractrecordsymtable.datasize as asizeint instead of
    aint (not ppu version change because they are the same on all
    production targets)
  * add shortint() typecasts when reading/writing fieldalignment/
    recordalignment fields

git-svn-id: trunk@18118 -
2011-08-06 17:18:21 +00:00
Jonas Maebe
86b088f398 * store the current field alignment of tobjectdefs that use C_alignment,
because it influences the offset at which the next field in child classes
    should be placed in case it also uses C_alignment
  * also pad objectdefs based on the packrecords setting (Delphi-compatible)
  -> field offset calculation in objcclasses is now correct if they are
     compiled with {$packrecords c}

git-svn-id: trunk@18114 -
2011-08-06 13:11:23 +00:00
pierre
322e3f8a16 * More fixes for ppudump use
git-svn-id: trunk@17956 -
2011-07-08 15:38:14 +00:00
pierre
dd96bfb3dd * fix ppu dumping with ppudump utility for cross CPU
git-svn-id: trunk@17952 -
2011-07-08 08:57:24 +00:00
pierre
239944f8d0 + Use DLL name in assembler labels used to import DLL functions/variables
in Windows, Emx and OS2 targets.
    This fixes test failures: test/library/tlib1b.pp and lib2b.pp

    link unit TLinker.AddImportSymbol: Added symmangledname parameter.
    ogbase unit TImportSymbol.Create: Add AMangledName parameter.
    fmodule unit TModule.AddExternalImport: Add symmangledname parameter.
    fppu unit: Also put mangled name string for imported symbol.
    ppu unit: Increase PPUVersion
    utils/ppudump.pp: Adapt to PPU change above.
    systems/T_OS units: Use ImportSymbol.MangledName property to create
    import libraries or .idata sections.

git-svn-id: trunk@17804 -
2011-06-23 11:38:57 +00:00
pierre
09e9d922c7 * Reset F to NIL after freeing in tempclose
git-svn-id: trunk@17683 -
2011-06-07 16:10:25 +00:00
pierre
82ffdb48c9 * Fix tppufile.tempopen method needed for go32v2 cycle
git-svn-id: trunk@17674 -
2011-06-06 16:11:19 +00:00
florian
d19d8de8fe * packed column writing/reading for token recorder, reduces size of fgl.ppu by approx. 10%
git-svn-id: trunk@17512 -
2011-05-20 17:43:11 +00:00
florian
41c18adaf4 * patch by Sven Barth, handle idtoken correctly in the token recorder, resolves #19277
git-svn-id: trunk@17506 -
2011-05-19 19:31:08 +00:00
paul
d21bbc4548 compiler: reduce amount of hints and warnings
git-svn-id: trunk@17350 -
2011-04-20 02:58:52 +00:00
svenbarth
35b47e491c Rebase to revision 17306
git-svn-id: branches/svenbarth/classhelpers@17314 -
2011-04-13 10:04:14 +00:00
florian
c97869bd89 * merge user sections support branch
git-svn-id: trunk@17285 -
2011-04-10 18:08:59 +00:00
florian
0c62133d38 * patch by Mattias Gaertner to allow to override how the compiler reads source/ppu files, resolves #18740
git-svn-id: trunk@17255 -
2011-04-05 20:10:09 +00:00
florian
e4656050a7 + get/putansistring
git-svn-id: branches/usersections@17153 -
2011-03-20 15:39:33 +00:00
svenbarth
80e6498921 Rebase to revision 17096
git-svn-id: branches/svenbarth/classhelpers@17099 -
2011-03-09 16:29:47 +00:00
florian
26fbfaf5a7 + introduce the usage of asizeint/asizeuint for cpus with sizeof("alu")<>sizeof(pointer)
git-svn-id: trunk@17011 -
2011-02-26 20:10:03 +00:00
svenbarth
e19bcfae38 Added a flag set to TSymtable that tells whether it contains a class helper symbol, which is currently only used for static- and globalsymtables.
symconst.pas: added new enum tsymtableoption with set tsymtableoptions; currently it contains only sto_has_classhelper, but refactoring tstoredsymtable.b_needs_init_final is on the todo list
ppu.pas: added a new entry type that will hold the symtable options (91)
symbase.pas: added a new field "tableoptions" to TSymtable which will hold the flags of the symtable (only saved by tstoredsymtable)
symdef.pas: when a tobjectdef is created as a odt_classhelper or odt_objccategory the flag sto_has_classhelper is added to its owning global- or staticsymtable
symtable.pas: 
* load and write the symtable's options as a small set to an entry before the definition entries
* tabstractlocalsymtable needed to annoy me by not calling "inherited writeppu" which does the same as tabstractsymtable did before
* search_last_objectpascal_classhelper: check whether the static- or globalsymtable contains a class helper at all; if not then just continue with the next
utils/ppudump.pas:
* added reading of symtableoptions entry (as readsymtableoptions) based on the reading of tsym options
* added the reading of symtableoptions before every read of the contents of a TSymtable (definitions, symbols)

git-svn-id: branches/svenbarth/classhelpers@16845 -
2011-01-30 09:19:59 +00:00
svenbarth
a7d99a5561 Increased PPU version again so it differs from that in trunk
git-svn-id: branches/svenbarth/classhelpers@16834 -
2011-01-29 10:23:43 +00:00
sergei
58f37dc952 Improvements to dispinterface property handling:
* Create implicit access methods, which hold type information for property parameters and allow parsing/typechecking occur the same way as for regular (non-dispinterface) properties.
+ Introduce separate proctypeoptions for property access methods. They are translated into correct dispatch call types and used to distinguish property access from regular method calls.
* Bump PPU version because new information has been introduced.
- Code specific to dispinterface properties in expression parser is no longer necessary, removed.
* Allow access to default property with [] for dispinterfaces.
+ Extended the test with basic correctness checks for property dispatching.

git-svn-id: trunk@16810 -
2011-01-24 20:30:48 +00:00
svenbarth
d4be11cb42 Implement advanced class helper syntax which allows "inheritance" of class helpers. This is not the same as normal class inheritance as its only used to extend the scope to other class helpers (that pseudo heritage line) when searching for a symbol. The real parent is always the extended class.
- compiler/symdef.pas: add "helperparent" which contains the class helper the current class helper "inherits" from (its real parent is the extended class); it's saved to ppu as well
- compiler/ppu.pas: increase ppu version
- compiler/pdecobj.pas: 
* parse the "parent" of a class helper before parsing the extended class (the real parent)
* also disallow to inherit from class helpers for normal class (and to extend class helpers for class helpers)
* disallow the declarations of fields
* disallow the use of destructors
* don't parse abstract/sealed for class helpers
- compiler/ptyp.pas: _FOR is now parsed inside pdecobj.pas
- compiler/msg*: 
* extended some messages for class helpers
* added some class helper related messages (perhaps the one or other will vanish again...)

git-svn-id: branches/svenbarth/classhelpers@16792 -
2011-01-19 19:39:47 +00:00
paul
55a0fefb1f compiler: implement generic array type:
- add tarraysymtable to store generic type symbols
  - process generic and specialize declarations similar to generic records and classes
  - fix insert_generic_parameter_types to use def passed in argument instead of current_structdef because generic array type can't be assigned to the current_structdef variable
  - increase ppu version because of arraydef changes
  - tests

git-svn-id: trunk@16681 -
2011-01-02 13:16:17 +00:00
paul
86d3e41442 compiler: replace MODESWTICH POINTERARITHMETICS with $POINTERMATH directive, disable pointer arithmetic in delphi mode by default (compatible with delphi), enable pointer arithmetic in fpc/objfpc modes as they had it enabled by default before, add has_pointer_math field to tpointerdef to allow pointer arithmetic with such pointer even if pointer math mode is off (delphi compatible) + tests
git-svn-id: trunk@16651 -
2010-12-29 03:24:28 +00:00
paul
ee6fe6c4f5 compiler: add unary plus node, search for unary plus operator if a type cannot be handled by compiler, increase ppu version because of node types change
git-svn-id: trunk@16640 -
2010-12-26 12:19:28 +00:00
paul
4f274b157c compiler: move objectoptions to tabstractrecorddef because it will be needed for records too
git-svn-id: branches/paul/extended_records@16541 -
2010-12-11 06:48:08 +00:00
paul
26cef34005 compiler:
- move objname, objrealname fields from tobjectdef to tabstractrecorddef, 
  - load and save them from/to ppu file, 
  - use tabstarctrecorddef in some more places where previously code worked for tobjectdef
  - change push_nested_hierarchy, pop_nested_hierarchy to handle records too

git-svn-id: branches/paul/extended_records@16519 -
2010-12-08 06:58:48 +00:00
Jonas Maebe
92997a0249 * store/load tloopnode.loopflags to/from ppu files so that for/repeat/while
loops are correctly inlined (mantis #17493)

git-svn-id: trunk@16106 -
2010-10-08 13:01:25 +00:00
Jonas Maebe
57bd6d2685 + merged nestedprocvars branch
+ support for nested procedural variables:
    o activate using {$modeswitch nestedprocvars} (compatible with all
      regular syntax modes, enabled by default for MacPas mode)
    o activating this mode switch changes the way the frame pointer is
      passed to nested routines into the same way that Delphi uses (always
      passed via the stack, and if necessary removed from the stack by
      the caller) -- Todo: possibly also allow using this parameter
      passing convention without enabling nested procvars, maybe even
      by default in Delphi mode, see mantis #9432
    o both global and nested routines can be passed to/assigned to a
      nested procvar (and called via them). Note that converting global
      *procvars* to nested procvars is intentionally not supported, so
      that this functionality can also be implemented via compile-time
      generated trampolines if necessary (e.g. for LLVM or CIL backends
      as long as they don't support the aforementioned parameter passing
      convention)
    o a nested procvar can both be declared using a Mac/ISO Pascal style
      "inline" type declaration as a parameter type, or as a stand-alone
      type (in the latter case, add "is nested" at the end in analogy to
      "of object" for method pointers -- note that using variables of
      such a type is dangerous, because if you call them once the enclosing
      stack frame no longer exists on the stack, the results are
      undefined; this is however allowed for Metaware Pascal compatibility)

git-svn-id: trunk@15694 -
2010-08-02 22:20:36 +00:00
Jonas Maebe
25561d0f71 - removed unnecessary string copy form tppufile.getstring
git-svn-id: trunk@15459 -
2010-06-20 12:31:27 +00:00
Jonas Maebe
15e9c54b44 * fixed ABI compliance for parameter passing and function returning on all
x86-64 platforms (except for win64, which uses another ABI and which
    already complied to it) + test
  * fixed returning records containing 1 single or double field on darwin/i386,
    these have to be returned via ST0 instead of as a regular record
  * added support for LOC_FPUREGISTER and LOC_MMREGISTER in several places
    where they can now occur due to the previous two changes
  * made a few internalerrors unique

git-svn-id: trunk@15368 -
2010-06-03 20:08:50 +00:00
Jonas Maebe
72bec41317 * increased ppu version after r15350, because the explicit paralocations
are now stored in a different way

git-svn-id: trunk@15354 -
2010-05-31 16:13:34 +00:00
paul
ceccce93f5 compiler: add class constructors, class destructors to the initfinal table as regular initialization/finalization sections (class constructors is still not striped away with the class)
git-svn-id: trunk@15143 -
2010-04-15 07:37:41 +00:00