Commit Graph

708 Commits

Author SHA1 Message Date
Jonas Maebe
a0296d7311 * fixed indentation
git-svn-id: trunk@33192 -
2016-03-06 14:44:17 +00:00
svenbarth
94c0938edd Reverted accidentally committed inline if-then-else expression (committed in r33048 when I reverted the IfThen()... -.- )
git-svn-id: trunk@33111 -
2016-02-19 21:51:56 +00:00
svenbarth
25744dd3f1 Fix for Mantis #29609.
pexpr.pas, factor.factor_read_id:
  * don't use a cloadvmtaddrnode for accessing class properties in records

+ added test

git-svn-id: trunk@33110 -
2016-02-19 21:37:02 +00:00
svenbarth
8287773b16 Reverted revision 33036. This feature is too controverse to be left in.
git-svn-id: trunk@33048 -
2016-02-04 19:26:51 +00:00
svenbarth
ed94ca4b24 Add support for IfThen() instrinsic that works like the if-statement in that it evaluates only the expression that is indeed executed.
The result type of the intrinsic is determined by the Then-expression to provide a bit of control. There might however be some situations in which this fails, for this exceptions need to be added (e.g. a constant string needs to be converted to a normal string).

compinnr.inc:
  + add new constant in_ifthen_x_y_z for the IfThen() intrinsic
psystem.pas: 
  + create_intern_symbols: add symbol for IfThen() intrinsic
pexpr.pas:
  * statement_syssym: parse parameters of IfThen() intrinsic and return corresponding inline node
ninl.pas, tinlinenode:
  + new method handle_ifthen() which converts the inline node to an if-node which assigns the expressions to a temp node that is returned
  * pass_typecheck: handle in_ifthen_x_y_z using handle_ifthen()
  * pass_1: in_ifthen_x_y_z does not need a first pass as it's already converted after the typecheck pass

+ added tests

git-svn-id: trunk@33036 -
2016-01-31 14:29:12 +00:00
svenbarth
61b12af82b Fix for Mantis #29321.
pexpr.pas, postfixoperators:
  * also handle type helpers for static arrays

+ added test

git-svn-id: trunk@32845 -
2016-01-04 22:02:24 +00:00
Jonas Maebe
9ea38f4577 * support static fields in nested types in records, by always including
support for nested types when generating an access to a static fied;
    we also always do that when generating the mangled name of a static
    field declaration in symcreat.make_field_static() (mantis #29030)

git-svn-id: trunk@32517 -
2015-11-24 16:04:19 +00:00
svenbarth
b2988ad8c0 pexpr.pas, sub_expr:
* generate_inline_specialization: fix Delphi-style inline specializations of generic methods

git-svn-id: trunk@32438 -
2015-11-21 15:59:11 +00:00
florian
1142fdeccd * initialize variables to avoid warnings
git-svn-id: trunk@32428 -
2015-11-21 14:14:30 +00:00
svenbarth
89d37c1e69 pgentype.pas:
+ new constant inline_specialization_block_types to easily keep track of block types in which inline specialization is allowed
pexpr.pas:
  * use new inline_specializatio_block_types instead of a inline constant set

git-svn-id: trunk@32388 -
2015-11-21 11:05:58 +00:00
svenbarth
0471db5bb6 pexpr.pas, factor.factor_read_id:
* handle specializations after a type symbol

git-svn-id: trunk@32387 -
2015-11-21 10:52:19 +00:00
svenbarth
ae8316b1b4 Implement two phase specialization to support inline specialization of generic functions in non-Delphi modes.
pexpr.pas, factor.factor_read_id:
  * instead of using generate_specialization() use generate_specialization_phase1() and (for non-procdefs) generate_specialization_phase2
  * pass generated specialization context for procdef on to the generated call nodes which do the second part of the specialization then

git-svn-id: trunk@32384 -
2015-11-20 18:37:32 +00:00
svenbarth
74c79803f7 Extend tlocalvarsym with the ability to not register it if needed.
git-svn-id: trunk@32375 -
2015-11-20 11:29:21 +00:00
svenbarth
fe39de1573 pexpr.pas:
* sub_expr: don't extract the def from the node using gettypedef, but use the already retrieved symbol instead

git-svn-id: trunk@32371 -
2015-11-20 10:22:08 +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
0ff87336aa Convert the Boolean parameters accept_equal, typeonly and hadspecialize of comp_expr(), sub_expr() and factor() to a set parameter and adjust all calls.
pexpr.pas:
  + new enum texprflag and corresponding set texprflags
  * comp_expr: replace accept_equal and typeonly with texprflags parameter
  * factor: replace typeonly and hadspecialize with texprflags parameter
  * sub_expr: replace accept_equal and typeonly with texprflags parameter
  * adjust calls to comp_expr(), factor() and sub_expr()
other units:
  * adjust calls to comp_expr(), factor() and sub_expr() 

git-svn-id: trunk@32269 -
2015-11-07 21:45:03 +00:00
nickysn
75dc2ad7e1 + implemented Seg(procedure) on i8086
git-svn-id: trunk@32222 -
2015-11-02 16:37:19 +00:00
nickysn
072139cdb7 * fixed ofs(procedure) as well
git-svn-id: trunk@32205 -
2015-10-30 19:30:33 +00:00
nickysn
c25585daee * fixed addr(procedure), mantis #28775
git-svn-id: trunk@32204 -
2015-10-30 15:17:48 +00:00
Jonas Maebe
2cea723a0d * only write the parts of the unit localsymtables that are actually needed:
the defs and syms (recursively) referred by inline routines and by the WPO
    info
   o defs and syms are no longer added immediately to the module's deflist/
     symlist, even if they are created as "registered". Instead,
     "doregister=true" simply means "add it to the symbol table at the
     top of the symtable stack"
   o normally only when a sym/def is deref'ed, it gets added to the module
     symlist/deflist and defid/symid gets a (unique) value
   o in cases where we use(d) the defid to construct unique names within the
     current module, you now have to call call the tdef.new unique_id_str()
     method. If the def was not yet registered, we will reserve room for it
     in the deflist (to get a unique id), but the defid gets set to a
     negative value computed from its position in the deflist. Should it
     have to be written to the ppu file later on, the defid will be
     modified to the actual position in the deflist. For both values,
     new unique_id_str() will return the same result so that references
     to this def before and after actual registrations are the same (needed
     for the JVM backend, but also a good principle in general)

   Overall: don't directly use symid/defid anymore to get unique identifiers,
     but use tdef.new unique_id_str() instead (if necessary, a similar routine
     for tsym can be added)

   The result is the ppu file size gets reduced significantly after its big
   increase as a result of the high level typed constant builder (which creates
   a lot of defs). The result is even more efficient than before, as other
   unneeded defs/syms from the localsymtables don't get saved/restored anymore
   either.

git-svn-id: trunk@32153 -
2015-10-25 19:22:00 +00:00
Jonas Maebe
e921d7847a * add "doregister" parameter to tstringdef.create*, and don't register
temporary defs created in the scanner for evaluating compile time
    expressions

git-svn-id: trunk@32047 -
2015-10-13 15:59:09 +00:00
svenbarth
114dfe41a3 Fix for Mantis #28741.
pexpr.pas:
  * initialize srsym in the classrefdef case; it should not have let to problems, because it's only used if erroroutp1 is false which is only the case if the symbol is assigned, but better save then sorry...

git-svn-id: trunk@31887 -
2015-09-29 12:56:01 +00:00
Jonas Maebe
2b01a7e2c6 * initialize errorp1 for classrefdef after r31856 (mantis #28741, but this
doesn't fix it as there are more problems)

git-svn-id: trunk@31884 -
2015-09-29 07:59:59 +00:00
svenbarth
e2be6f400f Fix for Mantis #28738.
pexpr.pas:
  * the gettypedef() overload should not have been commented... Note to self: don't test things during commits

git-svn-id: trunk@31875 -
2015-09-28 09:25:07 +00:00
svenbarth
bb873c93af pexpr.pas:
* postfixoperators: generate specialize nodes in mode Delphi
  * factor: don't call postfixoperators() if returned node is a specialize node
  * sub_expr: handle specialize nodes
  * sub_expr: extract common code handling specializations in < and as/is into a nested function

git-svn-id: trunk@31859 -
2015-09-27 20:12:03 +00:00
svenbarth
9dcfec8c63 pexpr.pas:
* extend handle_specialize_inline_specialization() with the ability to handle generic functions
  * have handle_factor_typenode() and postfixoperators() make use of this extension

git-svn-id: trunk@31856 -
2015-09-27 18:53:16 +00:00
Jonas Maebe
8e50695f78 * make the meaning of "string" in {$h+} mode the same as that of ansistring:
"type ansistring(CP_ACP)", rather than "type ansistring(sourcefilecodepage)"

git-svn-id: trunk@31847 -
2015-09-27 14:46:41 +00:00
svenbarth
17a0ac7fc0 pdecsub.pas:
* extend parse_proc_head() with support for /parsing/ generic functions (at least in mode Delphi, mode ObjFPC depends on the new isgeneric parameter to be set)
  * adjust parsing of interface mappings with a generic interface (note: in mode ObjFPC this now requires a "specialize" directly before the generic interface's name, which is more in line with other uses of "specialize")
pexpr.pas, factor:
  * don't call postfixoperators() if hadspecialize is set

tests/test/tgeneric79.pp:
  * adjust test to changed syntax

git-svn-id: trunk@31769 -
2015-09-18 16:24:07 +00:00
svenbarth
35d8a51730 pexpr.pas:
* extend factor() with the ability to deal with an already parsed "specialize"

git-svn-id: trunk@31768 -
2015-09-18 15:38:09 +00:00
svenbarth
295a8af4bb pexpr.pas:
* extend do_member_read() with the possibility to pass a specialization context on to do_proc_call() if the symbol is a procsym

git-svn-id: trunk@31767 -
2015-09-18 15:30:50 +00:00
svenbarth
0539ab29d0 pexpr.pas:
* do_proc_call can take a tspecializationcontext and pass it on to ccallnode.create()

Note: pointers to generic functions/methods are not yet supported, so there's a temporary, non-translated error message for these constructs

git-svn-id: trunk@31766 -
2015-09-18 15:24:15 +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
svenbarth
040786e5bb + extend tundefineddef with the possiblity to create it as unregistered
* for now all undefineddefs are created as registered
Note: an additional parameter instead of an overload is used for tundefineddef.create as otherwise both constructors would need to be overridden in potential descendant CPU-specific classes...

git-svn-id: trunk@31757 -
2015-09-18 13:08:58 +00:00
yury
aa150093d2 * Hack-fixed a compiler note.
git-svn-id: trunk@31742 -
2015-09-17 15:11:45 +00:00
Jonas Maebe
9ab80874cc - removed FPC_REAL2REAL_FIXED-related checks, FPC 2.6.4 has it
git-svn-id: trunk@31693 -
2015-09-15 11:51:51 +00:00
Jonas Maebe
2afd8eb802 - removed FPC_HAS_STR_CURRENCY-related code, FPC 2.6.4 has it
git-svn-id: trunk@31692 -
2015-09-15 11:51:48 +00:00
nickysn
026d2be316 + support Mem[Seg:Ofs] for the win16 target as well
git-svn-id: trunk@31566 -
2015-09-07 00:48:09 +00:00
Jonas Maebe
f402b0d7df * changed getpointerdef() into a tpointerdef.getreusable() class method
o allows removing the ugly x86 hacks

git-svn-id: trunk@31144 -
2015-06-22 08:17:49 +00:00
florian
5f4dc5e54f * parentheses after an @-operator can contain a full expression, resolves #27517
git-svn-id: trunk@30272 -
2015-03-22 13:00:43 +00:00
Jonas Maebe
5b3c511467 * don't crash when "return exitvalue" is used in a procedure
git-svn-id: trunk@30177 -
2015-03-13 08:35:26 +00:00
florian
ba3f0281b0 * fix compilation errors with -O2 due to dfa based warnings
git-svn-id: trunk@29771 -
2015-02-21 10:09:37 +00:00
svenbarth
5a344ee263 Rework the way how "specialize" is handled. Instead of initializing the specialization of a full type declaration (including unit name and parent types) it is now considered part of the specialized type itself. This means that for example the following code:
type
  TTestLongInt = specialize SomeOtherUnit.TTest<LongInt>;

will now have to read as

type
  TTestLongInt = SomeOtherUnit.specialize TTest<LongInt>;

While this is not backwards compatible this situation should arise seldomly enough and the benefits especially in context with generic functions/procedures/methods outway the drawbacks.

pbase.pas:
  * try_consume_unitsym: add a allow_specialize parameter that allows to parse "specialize" in front of a non-unit symbol; whether it was a specialization or not is reported using a new is_specialize parameter
  + add a new overload try_consume_unitsym_no_specialize that calls try_consume_unit sym with allow_specialize=false and a dummy is_specialize parameter
  * switch calls to try_consume_unitsym to try_consume_unitsym_no_specialize
pstatmnt.pas, try_statement:
  * switch call to try_consume_unitsym to try_consume_unitsym_no_specialize
  * adjust call to parse_nested_types
ptype.pas:
  + extend id_type with the possibility to disallow unit symbols (needed if a specialize was already parsed) and to report whether a specialize was parsed
  + extend parse_nested_types with the possibility to tell it whether specializations are allowed
  * have parse_nested_types specialize generic defs if one is encountered and local type defs are allowed
  * id_type: only allow "unitsym.specialize sym" or "specialize sym", but not "specialize unitsym.sym"
  * single_type: correctly handle specializations with "specialize" keyword
  * read_named_type.expr_type: there is no longer a need to check for "specialize" keyword
pexpr.pas:
  + new function handle_specialize_inline_specialization which tries to specialize a type symbol
  * handle_factor_typenode: handle specializations after a point that follows a record or object (why isn't this part of postfixoperators anyway? O.o)
  * postfixoperators: handle "specialize" after records and objectdefs
  * factor_read_id: handle "specialize" in front of an identifier (and after unit symbols)

+ added tests
* adjusted test webtbs/tw16090.pp

git-svn-id: trunk@29768 -
2015-02-20 16:23:40 +00:00
svenbarth
9611c3df52 Fix for Mantis #25606.
pexpr.pas, postfixoperators:
  * try_type_helper: also allow type helpers for block type bt_const

+ added test

git-svn-id: trunk@29176 -
2014-11-28 22:06:10 +00:00
Jonas Maebe
ff583bde6c * made setstring() a compiler intrinsic so it can set the compile-time
code page of ansistrings (mantis #26735)

git-svn-id: trunk@28813 -
2014-10-12 20:27:06 +00:00
svenbarth
a7a9440692 Add a new warning message that is generated if an instance of an abstract class is created. This message is disabled by default, but can be switched on by using {$warn 4122 on} or {$warn 4122 error}.
Please note that this warning won't be triggered if an instance of that class is created using a class variable of that class type as the compiler can not know the type contained in the variable at compile time (see also the added test).

+ msg/errore.msg: added disabled message which informs about the instantiation of an abstract class
* pexpr.pas, do_member_read: generate the message if we have a constructor call for an abstract class using a loadvmtaddrnode (thus the type name is used and not a class variable)

* msg{idx,txt}.inc: updated

+ added test

git-svn-id: trunk@28127 -
2014-07-01 20:41:05 +00:00
Károly Balogh
195dbc15fa + second try on warning fix
git-svn-id: trunk@28015 -
2014-06-20 13:36:57 +00:00
Károly Balogh
00b55e100c + try to fix the warnings introduced in r27947, so the compiler builds with -Sew
git-svn-id: trunk@28014 -
2014-06-20 13:10:07 +00:00
Jonas Maebe
9450407ed5 * when taking the address of a method1 that is specified by subscripting
the result of a objtype.method2 call, ensure that we call method2 with
    objtype as methdpointer rather than the self node of the current routine
    (mantis #24844)

git-svn-id: trunk@27977 -
2014-06-15 17:26:12 +00:00
svenbarth
c6496f8ec5 Fix for Mantis #26278.
pbase.pas:
  + add an overload for identifier_not_found for which the file position can be supplied
pexpr.pas, factor_read_id:
  * store the file position before reading the identiifer token
  * use the new identiifer_not_found overload to explicitely set the file position
  * set the file position of the created node

git-svn-id: trunk@27947 -
2014-06-13 21:36:55 +00:00
svenbarth
b9a59c33f4 Fix for Mantis #25915.
* ptype.pas, id_type:
    generate the "identifier not found" message only if the identifier was really not found and not when the identifier is a non-type
* pexpr.pas, statement_syssym: 
    don't generate the "type id expected" error message for Default() anymore; this is already handled by single_type

+ added test (though this again will not help much as output is not parsed...)

git-svn-id: trunk@27464 -
2014-04-04 15:48:06 +00:00