Commit Graph

102 Commits

Author SHA1 Message Date
Michael VAN CANNEYT
f364bb6b11 * Forbid use of string alias in system unit 2023-07-22 08:26:22 +00:00
Sven/Sarah Barth
7974f39522 * implement assignment of procedure and method variables and routines (global, instance and nested) to function references 2022-05-26 21:44:24 +02:00
florian
637976e83f * patch by Marģers to unify internal error numbers, resolves #37888
git-svn-id: trunk@47103 -
2020-10-13 19:59:01 +00:00
svenbarth
24c4b90343 * instead of declaring another type with a 'attribute' suffix, *search* for another type with a 'ATTRIBUTE' suffix (Delphi allows declaring both a TFoo and TFooAttribute in the same unit)
+ added test

git-svn-id: trunk@42362 -
2019-07-12 22:05:18 +00:00
svenbarth
ed5f19e7e3 * change boolean parameters for try_consume_unitsym to a set
git-svn-id: trunk@42360 -
2019-07-12 22:05:05 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
svenbarth
8bc0b604db * a symbol might be specified using a partial namespace path as long as the missing part is a namespace symbol,
so handle that correctly in try_consume_unitsym()

git-svn-id: trunk@38918 -
2018-05-05 17:18:45 +00:00
svenbarth
e7f29e9e28 * also pass the pattern with which the potential unit/namespace symbol had been found to try_consume_unitsym*()
git-svn-id: trunk@38913 -
2018-05-05 17:18:31 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +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
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
paul
1c578de28c compiler:
* don't allow to apply the same hint directive twice
  * change parser_e_proc_dir_not_allowed to more generic variant parser_e_dir_not_allowed - they are similar and 'procedure' prefix does not give more information about the error.
  * maybe_parse_hint_directives() uses procdef settings for initial values
  + add tests

git-svn-id: trunk@25720 -
2013-10-08 04:56:42 +00:00
florian
f25f44605e - get rid of m_all, use a set instead for tokens, this allows to disable/enable tokens depending on the language mode
git-svn-id: trunk@22506 -
2012-09-30 21:03:35 +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
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
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
paul
8309809a0d compiler: use try_consume_unitsym for except variable parse. this is needed to reduce maintenance cost for later unit identifier search changes
git-svn-id: trunk@18826 -
2011-08-24 10:54:17 +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
7200245337 + cs_unicodestrings global switch to indicate that the default string type
is unicodestring (does *not* change the type of "char" to "unicodechar"
    (yet)). Not yet (un)selectable via a directive.
  + systems_default_unicodestring set containing systems on which the
    default string type is unicodestring

git-svn-id: branches/jvmbackend@18415 -
2011-08-20 07:57:45 +00:00
paul
668cd1f3c0 compiler: change check for current in try_consume_unitsym - don't use current_unit in check because specialize code does not replace this variable (fixes bug #0015591)
git-svn-id: trunk@16489 -
2010-12-01 08:18:51 +00:00
florian
c6ffbe9eda * support string constants > 255 chars
* don't cut off anymore string constants silently at 255 chars

git-svn-id: trunk@14789 -
2010-01-24 09:28:46 +00:00
paul
e784ec1079 merge revisions 13898-13899:
- compiler: allow message after the *deprecated* keyword
 - compiler: raise an internal error if deprecated message is trying to set to a non clear string pointer

git-svn-id: trunk@13997 -
2009-11-01 14:06:30 +00:00
florian
d8d96f14e6 + experimental directive, resolves #10833
git-svn-id: trunk@10331 -
2008-02-15 19:29:34 +00:00
florian
2d91fef4f1 + accept system.string, resolves #10489
git-svn-id: trunk@9727 -
2008-01-12 22:25:33 +00:00
peter
1e123d66ba * improved generics
git-svn-id: trunk@8838 -
2007-10-18 00:24:05 +00:00
florian
7229dcfdcb * setup a proper symtable stack before parsing the generic declaration itself, resolves #9419
git-svn-id: trunk@8820 -
2007-10-15 19:43:01 +00:00
daniel
9adb202a92 * Rework the constexprint to allow operations from low(int64) to high(qword).
+ Some initial work on a formaldef which also carries the typinfo of a parameter.

git-svn-id: trunk@7639 -
2007-06-13 07:41:18 +00:00
florian
11aa2b483e * kicked ignore_equal, usage was wrong anyways
git-svn-id: trunk@5763 -
2006-12-31 00:48:52 +00:00
peter
658c46b903 * remove tdictionary and tindexarray
* symtables based on TFPHashObjectList and TFPObjectList
  * rename torddef.typ to torddef.ordtype
  * rename tfloatdef.typ to tfloatdef.floattype
  * rename tdef.deftype to tdef.typ
  * remove obsolete browser code, browcol is kept so the ide
    can still be compiled

git-svn-id: trunk@5192 -
2006-11-03 00:30:30 +00:00
florian
be2b715d3c + parsing of disp variant invokes
git-svn-id: trunk@5162 -
2006-11-01 21:23:04 +00:00
florian
bce905b106 * give correct error locations for errors when specializing templates
* removed more germanisms
* better dumping of tokenbuf in ppudump

git-svn-id: trunk@5101 -
2006-10-30 23:28:06 +00:00
florian
85d63d9fa9 * settings refactored
git-svn-id: trunk@5094 -
2006-10-30 18:02:58 +00:00
florian
3824604e8a * export of qualified unit symbols, fixes #6848
git-svn-id: trunk@3570 -
2006-05-18 20:43:52 +00:00
peter
232555904e * symtablestack cleanup and rewrite
git-svn-id: trunk@2448 -
2006-02-05 22:24:18 +00:00
peter
4c19728d9b * fix crash with ident not found
git-svn-id: trunk@2444 -
2006-02-05 20:05:45 +00:00
Jonas Maebe
9fd4e98dad * fixed displaying of hints such for procedures and functions
(and moved check_hints from pbase to htypechk)

git-svn-id: trunk@2417 -
2006-02-03 18:14:13 +00:00
peter
95879fe8a7 * basic support for generic classes
git-svn-id: trunk@2020 -
2005-12-21 10:11:15 +00:00
fpc
790a4fe2d3 * log and id tags removed
git-svn-id: trunk@42 -
2005-05-21 09:42:41 +00:00
fpc
50778076c3 initial import
git-svn-id: trunk@1 -
2005-05-16 18:37:41 +00:00
peter
e417e34496 * truncate log 2005-02-14 17:13:06 +00:00
peter
8d251e8506 * unit mapping rewrite
* new derefmap added
2005-01-19 22:19:41 +00:00
florian
fe54af8f82 * finally is an "endtoken" as well 2004-08-08 12:06:38 +00:00
florian
8a9758c5e2 * logs truncated 2004-06-20 08:55:28 +00:00
daniel
ce11762359 - Comment out unused tokenstring function 2004-02-21 20:10:27 +00:00
peter
607b41f22e * except is also an end of block token
* after a label don't try to parse a statement when the next token
    is an end token
2004-01-22 17:24:49 +00:00
peter
8af51ea6d3 * locals and paras are allocated in the code generation
* tvarsym.localloc contains the location of para/local when
    generating code for the current procedure
2003-09-23 17:56:05 +00:00
peter
92ee1804b6 * removed selfpointer_offset, vmtpointer_offset
* tvarsym.adjusted_address
  * address in localsymtable is now in the real direction
  * removed some obsolete globals
2003-05-15 18:58:53 +00:00
peter
fe6518a49c * allow more tokens instead of only semicolon after inherited 2003-03-17 18:55:30 +00:00
carl
6227991d96 - remove lower in hint 2002-12-05 19:27:40 +00:00