Commit Graph

186 Commits

Author SHA1 Message Date
J. Gareth "Curious Kit" Moreton
7488f1e3f8 * New node pruning methods 2023-02-21 20:44:02 +00:00
J. Gareth "Curious Kit" Moreton
1b43913408 * New 'do not execute' flag for notes and respective internal error triggering 2023-02-21 20:44:02 +00:00
florian
2c51abf40d + print optinfo pointer if set 2022-10-21 21:13:28 +02:00
Yuriy Sydorov
d96600a02d * Removed unused and confusing tnode.parent and tnode.concattolist(). 2021-11-02 16:55:59 +02:00
pierre
a0e96fd551 Fix pos field closing in XML node output after commit 47720
git-svn-id: trunk@47737 -
2020-12-09 12:36:46 +00:00
pierre
348be7657d Fix bug introduced in commit #47709, by only calling node_complexity if first pass was already done (bug report 38183)
git-svn-id: trunk@47720 -
2020-12-08 11:28:50 +00:00
pierre
af17e9460b Apply patch proposed by J. Gareth Moreton in:
bug report #0036882: [Feature] Class and record definition XML dump extension

  These patches extend the node dump feature (enabled with DEBUG_NODE_XML)
  so it also dumps class and record definitions to the XML file. They are contained within <definition> tags.
  Currently only fields and constants are dumped to the XML file. Methods, constant and variable definitions may be added later.

git-svn-id: trunk@47658 -
2020-12-01 11:45:14 +00:00
florian
792cf056eb * a nil node is also a constant pointer node
+ convert (v1=const1) and (v2=const2) into ((v1 xor const1) or (v2 xor const2))=0 if the expressions have no side effects

git-svn-id: trunk@45555 -
2020-06-01 20:50:38 +00:00
svenbarth
60345366f2 * fix for Mantis #35140: apply patch by Ryan Joseph together with some further changes by me to add support for constant parameters in generics
+ added tests

git-svn-id: trunk@45080 -
2020-04-25 22:12:35 +00:00
florian
fd0012deff * when copying goto nodes take care if the label node is part of the copied tree
or not, resolves #35820

git-svn-id: trunk@43793 -
2019-12-25 17:10:14 +00:00
florian
86d8e79e86 * fix some currency issues, resolves #33963 and #36179
git-svn-id: trunk@43620 -
2019-12-01 20:24:00 +00:00
Jonas Maebe
ac1e0f96bd * replaced tentryfile.get/putsmall/normalset() with a common tget/putset
that expects an open array of byte, and use it for all sets
   o since all sets need to be typecasted to an array type of the appropriate
     size, we'll get a compilation error in case this needs to be done and
     that also tells us at the same time that the ppu version will need to
     be increased
  * enabled {$packset 1} for the compiler, as this is now safe with the above
    changes

git-svn-id: trunk@43407 -
2019-11-06 21:50:19 +00:00
pierre
67cf63049d Commit patch submitted in bug report #35787 by Gareth Moreton
git-svn-id: trunk@42318 -
2019-07-01 19:42:48 +00:00
pierre
243c967967 Commit of new debug feature implemented by J. Gareth Moreton
Allows compilation of compiler using -dDEBUG_NODE_XML
  which will generate a NAME-node-dump.xml file for each 
  unit, program or library compiled,
  containing a XML description of the nodes handled during
  compilation of the unit, program or library.

git-svn-id: trunk@42271 -
2019-06-22 14:08:47 +00:00
Jonas Maebe
170ec00348 - removed withnode (was no longer used since a very long time)
git-svn-id: trunk@40777 -
2019-01-05 22:28:37 +00:00
Jonas Maebe
3b9f5a5e96 * moved finalization of code generator temps to a node, so it can be getcopy'd
(needed for LLVM, where we need two copies of the finally code: one in case
     an exception occurs, and one in case none is raised)
   o also first finalize parameters and only then code generator temps, since
     in theory the former could create more of the latter

git-svn-id: trunk@40345 -
2018-11-17 22:38:36 +00:00
florian
eea088c5f5 * allow nil to be assigned to generic types, resolves #34037
* niln is also a constant node

git-svn-id: trunk@39934 -
2018-10-14 07:38:13 +00:00
nickysn
3318703ece * moved nf_typedaddr to addrnodeflags (anf_typedaddr)
git-svn-id: trunk@38671 -
2018-04-03 16:41:01 +00:00
Jonas Maebe
7911cc8437 - removed some dataconstn remenants
git-svn-id: trunk@35314 -
2017-01-16 21:27:20 +00:00
florian
8fe986ba11 + write also node complexity when dumping a node tree
git-svn-id: trunk@33133 -
2016-02-28 18:44:43 +00:00
svenbarth
02e56f410d Merged revision(s) 28689 from branches/svenbarth/packages:
Extract functionality that is shared between the metadata files for units (PPU) and for packages (PCP) into a parent class called tentryfile

+ add new unit entfile which contains the new tentryfile class and related types and constants
* ppu.pas:
    - remove methods, fields, types and constants which were moved to entfile.pas
    * replace the parts of tppuheader shared with tentryheader by a field of type tentryheader
fppu.pas, pmodules.pas, utils/ppumove.pp, utils/ppuutils/ppudump.pp:
    + add entfile to uses
    * adjust access to common header fields
node.pas, symdef.pas, symsym.pas, symtable.pas, wpoinfo.pas, utils/ppufiles.pp:
    + add entfile to uses
........

git-svn-id: trunk@32976 -
2016-01-22 15:26:30 +00:00
Jonas Maebe
9ace5ad038 * let is_conststringnode() and is_constwidestringnode() also recognise string
constants that have a stringdef as resultdef

git-svn-id: trunk@32969 -
2016-01-20 21:11:22 +00:00
svenbarth
4f5fc66298 + new parser-only node class to handle Delphi-mode inline specializations
git-svn-id: trunk@31588 -
2015-09-11 12:58:25 +00:00
florian
1366498255 + nf_addr_taken: it marks nodes which address is taken
+ check if tnodeflags is 4 bytes or less
* do not do cse on expressions which address is taken

git-svn-id: trunk@26713 -
2014-02-07 20:40:42 +00:00
florian
880201e56c + pointerconstn is also a constant node
git-svn-id: trunk@26305 -
2013-12-28 20:20:00 +00:00
florian
3cb747f4a7 * mark the node which is the entry of the user code with a flag
* check for uninitialized variables at the node which is marked as the start of the user code

git-svn-id: trunk@26014 -
2013-11-10 20:20:27 +00:00
sergei
dac8cbcefc * Handle assigned(x) expressions entirely in first pass by converting them to "x<>nil", indicate that procedure variables should not be called by setting nf_load_procvar flag (which is already used with typeconvnode for exactly the same purpose). This allows to generate better code when assigned(x) is used on right side of assigments. Mantis #24572.
git-svn-id: trunk@25499 -
2013-09-16 14:38:38 +00:00
florian
be2ab84474 * make actualtargetnode a normal procedure using pointers to node so it can be used also when replacing nodes
+ replacenode to replace nodes inline

git-svn-id: trunk@25013 -
2013-06-29 22:20:30 +00:00
florian
3016d48521 * clear optinfo after allocating it
git-svn-id: trunk@24898 -
2013-06-14 20:52:38 +00:00
florian
2fdd3e2d0a + introduce tvariantrecbranch to be able to store
all needed information for iso compatible variant records
* new for variant records as required by iso pascal
+ tests

git-svn-id: trunk@24241 -
2013-04-14 15:50:42 +00:00
svenbarth
344571cb4e Added support for type helpers. In non Delphi modes they use "type helper" and in mode Delphi they use "record helper". They can also be used on constants.
symconst.pas:
  + extend "thelpertype" by "ht_type" which tells the code in "pdecobj.parse_extended_type" that a type helper declaration has been parsed
node.pas:
  + add a constant which identifies all constant node types
ptype.pas:
  + read_named_type: add a parameter "hadtypetoken" to tell the code whether a "type" token had been parsed before
  + read_named_type: if an identifier "helper" is parsed we need to check whether "hadtypetoken" is true and the modeswitch "m_class" is set, but the "m_delphi" one is not; in that case we have a "type helper" declaration
pgenutil.pas, generate_specialization:
  * adjust call to read_named_type
pdecl.pas, types_dec:
  * adjust call to read_named_type

pdecobj.pas:
  * parse_extended_type: extend for correct handling of primitive types (includes Delphi compatible handling as well) and reject types that are explicitly not allowed
  * method_dec: require "static" for class methods in type helpers
  * method_doc: allow constructors for type helpers as well
paramgr.pas, tparamanager:
  * set_common_funcretloc_info: handle type helper constructors like record constructors
  * handle_common_ret_in_param: the "self" value of a type helper constructor is also returned in a parameter
pexpr.pas:
  + add a function to postfixoperators which tries to find and apply a type helper for a given type
  * postfixoperators: try to apply type helpers for ordinal constants
  * postfixoperators: use the correct string type for string constants
  * postfixoperators: try to apply type helpers for enum constants
  * postfixoperators: try to apply type helpers for arrays
  * postfixoperators: try to apply type helpers for Variant
  * postfixoperators: try to apply type helpers for pointer types
  * postfixoperators: try to apply type helpers for other types
  * factor: check postfixoperators after _REALNUMBER, _CCHAR, _CWCHAR, _TRUE and _FALSE
  * factor: also check postfixoperators if a _POINT follows a _NIL

symdef.pas, tdefawaresymtablestack.addhelpers:
  * use "generate_objectpascal_helper_key" to generate the key
symtable.pas:
  + add function to generate the key value for the map of extended types using the extended def
  * adjust "search_last_objectpascal_helper" and "search_objectpascal_helper" to handle primitive types as well
  * use the new "generate_objectpascal_helper_key" function to generate the key

pparautl.pas:
  * insert_self_and_vmt_para: don't insert the $vmt symbol for record or type helpers (ToDo: check whether class helpers really need the symbol as well)
  * insert_self_and_vmt_para: pass "self" as var parameter for type helpers as well
psub.pas, generate_bodyentry_block: 
  * also allow type helpers for constructor methods
ncal.pas, tcallnode.gen_self_tree:
  * also use a temp variable for type helper constructors
ncgcal.pas, tcgcallnode.secondcallparan:
  * allow Pointers to be passed as address param if it is the Self value of a type helper extending a pointer type
  * correctly handle the location in case of type helper constructors

+ add tests

git-svn-id: trunk@23580 -
2013-02-06 09:49:35 +00:00
svenbarth
c7a9e17bc5 Patch by Vasiliy Kevroletin. Fixes Mantis #23655.
compiler/node.pas, tnode.printnodeinfo:
  * write flags to file "t" instead of stdout

git-svn-id: trunk@23384 -
2013-01-15 06:04:10 +00:00
Jonas Maebe
6e9a8c9187 * write node flags to log file instead of to stdout
git-svn-id: trunk@23150 -
2012-12-15 22:47:07 +00:00
florian
ca5fabda6d * cleanup some unused units from uses clauses
git-svn-id: trunk@22433 -
2012-09-21 18:53:46 +00:00
florian
dd18d0bd4d * write flags in tnode.printnodeinfo
git-svn-id: trunk@22072 -
2012-08-13 14:50:37 +00:00
Jonas Maebe
eedb5c89de * part of r20140, forgot to commit
git-svn-id: trunk@20145 -
2012-01-21 21:16:47 +00:00
florian
6ec0f2549a * factored load node flags out of node flags to gain space
+ implemented iso mode mod, resolves #17685

git-svn-id: trunk@19558 -
2011-10-30 15:14:21 +00:00
florian
111d05c68f o patch by Alexander Shishkin, resolves #20409
* eliminate warnings in compiler (i386 & i368->x86_64) and minor refactorings
    - comment out unused vars and types
    - comment out unneeded comparisons (Longword <=> 0)
    - suppress some "comparison always true|false" warnings
    - tweak visiblity sections

git-svn-id: trunk@19385 -
2011-10-05 20:11:09 +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
Jonas Maebe
94d976bc87 * when simplifying ordinal expressions during inlining, keep the resultdef
that was set during the typecheck pass because typeconversion nodes
    may have been optimised away previously and sometimes the resultdef is
    important (e.g. for the value of callparanodes) (mantis #17458)

git-svn-id: trunk@16101 -
2010-10-07 15:08:52 +00:00
Jonas Maebe
1f4d7d6057 * add type symbol names to -vp output (patch by Adriaan van Os, mantis
#15737)

git-svn-id: trunk@14903 -
2010-02-13 16:47:37 +00:00
Jonas Maebe
3660bf7f98 * integrated the transformation of an Objective-C method call into a call
to objc_msgSend* into the callnode. This allows reusing the current
    call node rather than having to create a new one, and is in particular
    necessary because even though the objc_msgSend* functions are declared
    as varargs, you're supposed to typecast them to the function type
    describing the method before calling them (so they should *not* use
    varargs calling conventions!)
  * for the above, a field called fobjcforcedprocname has been added to the
    callnode, which can be set to a string that will be used as the (mangled)
    name of the function to call instead of the mangled name of the procsym
  -> fixes calling obj-c methods with floating point arguments on ppc

git-svn-id: branches/objc@13783 -
2009-10-01 12:05:11 +00:00
Jonas Maebe
ed9656d1e6 Merged revisions 13627-13631,13637-13638,13640,13642-13648,13650-13653,13656-13658,13660,13664-13667,13672-13675,13680,13682,13687 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13697 -
2009-09-12 12:42:38 +00:00
florian
cf215d5097 o patch by Michael V. Denisenko to handle case <string> of (see also #13700)
+ compiler implementation
  + tests

git-svn-id: trunk@13642 -
2009-09-03 20:21:30 +00:00
Jonas Maebe
2799cfd83f + parser-side of objcprotocol() expression to obtain the metaclass
associated with an Objective-C protocol. Code generator part will
    always generate an internalerror currently, because it cannot yet
    be implemented (needs support for generating RTTI for Objective-C
    classes)

git-svn-id: branches/objc@13461 -
2009-07-26 16:03:37 +00:00
Jonas Maebe
92de010fe1 Merged revisions 13218-13347 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13350 -
2009-06-28 16:09:53 +00:00
Jonas Maebe
66c14c8a88 * don't mark classes used in "is"- or "as"-expressions as potentially
instantiated (for wpo)
  * also replace vmt-entries for classes for which we don't have any
    information at all with FPC_ABSTRACTERROR (since that means they
    certainly are not instantiated), except for their published and
    virtual class methods
  * fixed check for published methods in wpo

git-svn-id: trunk@13219 -
2009-05-31 13:52:40 +00:00
Jonas Maebe
b1b9894ae3 * initial Objective-C 1.0 support:
o support for declaring external Objective-C classes (see
      rtl/inc/objcbase.pas), including derived classes
    o support for converting methods of objcclasses into selectors
      (see tests/test/tobjc1.pp)
    o support for loading from/storing to fields of objcclasses
    o support for calling Objective-C methods using regular
      Object Pascal syntax (see tests/test/tobjc1.pp)
    o some things that are known to be not yet working:
      o automatic conversion from ID to objcclasses and back
      o declaring and implementing new objcclasses/methods in Pascal code
      o debug information (objcclasses are currently plain pointers
        as far as the debugger knows)

git-svn-id: branches/objc@13162 -
2009-05-17 13:42:50 +00:00
Jonas Maebe
6165536b5e + added {$modeswitch objectivec1}/-Mobjectivec1 mode switch to enable
the use of Objective-C 1.0 constructs. Because it is a mode switch, it
    can be used cumulatively with every syntax mode. Note that a {$mode xxx}
    statement resets all mode switches as well, so you cannot use the
    -Mobjectivec1 variant if you have such a statement in a unit. This
    modeswitch is currently only enabled for Darwin/PowerPC and Darwin/i386,
    as the backend support is not yet implemented for other platforms.
  + implemented selector() statement that can be used to create an Objective-C
    selector for the message with the specified *constant* name (in the future,
    it will also work for Objective-C method identifiers)
  + added SEL type to the system unit (the selector() statement returns it)
  + added all Objective-C segments to the assembler writers
  + (currently mostly dummy) objc1 unit that is automatically included if the
    {$modeswitch objectivec1} statement is used
  + some tests for the selector() statement

git-svn-id: trunk@12870 -
2009-03-08 18:40:32 +00:00
Jonas Maebe
e5920bc2b8 * delay verbosity changes just like localswitches changes
* store a node's verbosity in the node so that e.g. disabling warnings
    also disables warnings for this node in pass_1
   (the above together fix mantis #12076)
  * save/restore verbosity with {$push}/{$pop} (mantis #12075)
  * if warnings/notes/hints are turned off, also do not count encountered
    ones for the totals (otherwise -Sew cannot be used properly in
    combination with {$warnings off}, because disabled warnings will still
    trigger a compiler error) -- this required adding -vw/-vn/-vh to all
    tests using -Sew/-Sen/-Seh
  - removed some superfluous state saving/restoring from firstpass()

git-svn-id: trunk@12025 -
2008-11-03 21:18:27 +00:00