mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 04:49:26 +02:00
The sources of the Free Pascal compiler, RTL, packages and utilities.
See https://www.freepascal.org/ for more info.
![]() Reasons for the "unique symbol" approach: - no special search operations for cross unit search needed (which is supported by Delphi) => less performance impact - no special care needed to really find the correct generic => less increase of parser complexity Currently all generic tests except tgeneric29.pp compile and inline specializations work as well. The changes in detail: * pdecl.pas/types_dec: - The variables used to hold the final name of the symbol are now prefixed with "gen". In case of non-generics the prefixed ones are equal to the non-prefixed ones (e.g. orgtypename=genorgtypename). In case of a generic symbol the "gen"-variants contain the type parameter count suffix (e.g. '$1' in case of 'TTest<T>') as well. - The unmodified pattern is used to insert and detect a dummy symbol with that name, so that type declarations and - more important - inline specializations can find that symbol. - In non-Delphi modes this symbol is also used to detect whether we have a type redefinition which is not allowed currently; its typedef points to the generic def. - In mode Delphi the def of that dummy symbol (which contains an undefineddef) is modified when a corresponding non-generic type is parsed, so that it contains the def of the real type. * pdecsub.pas/parse_proc_head - consume_generic_type_parameter now only parses the type parameters and picks the generic with the correct amount of parameters. The verification of the order and names of the parameters needs to be added again. - it also does not use "def" anymore, but it sets "srsym" - in parse_proc_head the symbol (srsym) is only searched if the symbol isn't assigned already; in case of a generic in mode FPC it will find the dummy symbol that points to the generic def * pexpr.pas - in factor_read_id there are three cases to handle: + the symbol is not assigned => error + a possible generic symbol (either an undefined def or the non-generic variant) => no error and no hints + a non-generic symbol => hints Point 1 is handled correctly, point 2 and 3 aren't currently and also they might be needed to be moved somewhere else - sub_expr: + a node can be a tloadvmtaddrnode as well if the non-generic variant of a generic symbol is a class + we can only check afterwards whether the specialization was successful * pgenutil.pas/generate_specialization using the count of the parsed types the correct symbol can be found easily git-svn-id: branches/svenbarth/generics@19424 - |
||
---|---|---|
compiler | ||
ide | ||
installer | ||
packages | ||
rtl | ||
tests | ||
utils | ||
.gitattributes | ||
.gitignore | ||
Makefile | ||
Makefile.fpc |