Commit Graph

435 Commits

Author SHA1 Message Date
maciej-izak
751bde9792 Revert revision 36436 from trunk. Final fix for issue #31675.
git-svn-id: trunk@36446 -
2017-06-07 21:06:54 +00:00
maciej-izak
d3d29fa84c Revert revisions 36133, 36128 from trunk.
git-svn-id: trunk@36436 -
2017-06-06 07:12:26 +00:00
maciej-izak
631d4a2d53 * Move global variable in_preproc_comp_expr into tscannerfile class.
git-svn-id: trunk@36133 -
2017-05-06 12:12:50 +00:00
maciej-izak
6d1ad52dc5 * for symbols used in preprocessor expressions, we don't want to increase references count (for smaller final binaries). Partial fix for problem presented in mantis 31675. Preprocessor functions like declared() in uses section will work only for symbols declared in implicytly included modules (for example like for heaptrc by option -gh, see example/test tw31675.pp)
+ added tests

git-svn-id: trunk@36128 -
2017-05-05 22:27:07 +00:00
svenbarth
c552b2957a * implement support for 4 Byte UTF-8 codepoints that result in a surrogate pair for UTF-16
git-svn-id: trunk@36116 -
2017-05-05 14:03:57 +00:00
pierre
e87cc28b64 Replaced owner field by fileindex field in tpreprocstack class, in order to display correct include file for scan_e_endif_expected error
git-svn-id: trunk@35557 -
2017-03-09 22:43:23 +00:00
yury
2387ea1ee0 * Removed unneeded var assignment.
git-svn-id: trunk@35536 -
2017-03-07 09:08:45 +00:00
florian
3d6d5145bf * fix handling of const string symbols in preprocessor expressions
+ accept string constants in preprocessor expressions, resolves #31246

git-svn-id: trunk@35432 -
2017-02-12 17:29:45 +00:00
florian
8c701eaa7b * reset c in dir_include if it will be re-read
git-svn-id: trunk@34786 -
2016-11-05 23:05:39 +00:00
nickysn
c2305809dc + added an i8086-embedded target support to the compiler (RTL and makefile
support are not done yet)

git-svn-id: trunk@33999 -
2016-06-17 19:15:24 +00:00
svenbarth
f8def6dbc9 Store and use procedure directives of generic routines.
scanner.pas, tscannerfile:
  + new method is_recording_tokens to check whether token recording is already active
pdecsub.pas, parse_proc_directives:
  * record tokens into the declaration token buffer of a generic routine if necessary
pgenutil.pas, generate_specialization_phase2:
  * process the procedure directives that had been recorded with the generic routine

git-svn-id: trunk@33824 -
2016-05-26 18:35:08 +00:00
florian
e566fe1938 * tscannerfile.readoptionalstate can handle also switches enclosed in (* ... *) comments
git-svn-id: trunk@33522 -
2016-04-15 19:08:44 +00:00
svenbarth
d24065c529 Fix compilation of the JEDI package. Old Delphi versions have {$WEAKPACKAGEUNIT} while newer ones also seem to allow {$WEAKPACKAGENUNIT ON}... :/ (analogous for DENYPACKAGEUNIT...)
scanner.pas, tscannerfile:
  + new method readoptionalstate which reads a state like readstate, but if it encounters the closing } then it returns the provided fallback state
scandir.pas:
  + do_moduleflagswitch: new parameter optional that triggers the use of readoptionalstate instead of readstate
  * dir_weakpackageunit & dir_denypackageunit: the ON/OFF is optional

git-svn-id: trunk@33515 -
2016-04-15 14:18:39 +00:00
sergei
f69f6336e9 * Replaced hacks with resetting 'c' to zero and decreasing inputpointer by boolean parameter to skipcomment and skipoldtpcomment. This parameter specifies whether first character of comment should be read.
- in_asm_string also rendered useless by r32828, removed.

git-svn-id: trunk@32836 -
2016-01-03 17:07:15 +00:00
sergei
bbfbab7e0c * Moved handling of comments and line breaks in assembler blocks from scanner to tokenizer level. Handling them at character level was causing compiler to accept comments in the middle of any assembler token, which should never happen. It was also causing Mantis #27459: a newline immediately after closing 'end' token was first handled in asmgetchar and then by normal parser, causing all subsequent line numbering to be off by one.
git-svn-id: trunk@32828 -
2016-01-02 06:17:14 +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
Jonas Maebe
cebcf0afa8 * add "doregister" parameter to tfloatdef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions

git-svn-id: trunk@32049 -
2015-10-13 15:59:15 +00:00
Jonas Maebe
b22e2ef400 * add "doregister" parameter to tsetdef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions

git-svn-id: trunk@32048 -
2015-10-13 15:59:12 +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
Jonas Maebe
2778bf55c7 * add "doregister" parameter to torddef.create, and don't register temporary
defs created in the scanner for evaluating compile time expressions, or in
    the code generator for range checking

git-svn-id: trunk@32046 -
2015-10-13 15:59:06 +00:00
Jonas Maebe
a1ed7cc162 * addending to r31831: disable cs_systemcodepage if the source file code page
is set via an UTF-8 BOM

git-svn-id: trunk@31880 -
2015-09-28 22:14:53 +00:00
Jonas Maebe
2cf8e50771 * fixed unwanted disabling of a codepage set via -FcXXX/{$codepage XXX}
when {$modeswitch systemcodepage} gets disabled without having been
    enabled first (such as when initially setting the syntax mode)
    (mantis #28718)

git-svn-id: trunk@31831 -
2015-09-25 18:31:58 +00:00
yury
432248cbf1 * Removed lot of unused vars.
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
svenbarth
267adf4e46 scanner.pas, tscanner:
+ new method to check how many token replays are currently active. This is needed for example to determine the end of a generic method which may contain modifiers and such.

git-svn-id: trunk@31506 -
2015-09-04 13:27:28 +00:00
svenbarth
5b216cca08 scanner.pas, tscanner:
* extend the state of the scanner that is saved/restored when starting/stopping a token recording so that the token recorder can be started on every kind of token.

git-svn-id: trunk@31504 -
2015-09-04 13:24:45 +00:00
florian
b61fd60b9d + support for {$I %CURRENTROUTINE%}
* if chain changed into case statements

git-svn-id: trunk@30873 -
2015-05-16 22:22:26 +00:00
florian
afa5546ff8 * aktcommentstyle => current_commentstyle
git-svn-id: trunk@30872 -
2015-05-16 21:57:01 +00:00
Jonas Maebe
146e3bcb9e * synchronised with trunk till r29513
git-svn-id: branches/blocks@29516 -
2015-01-21 23:28:34 +00:00
Jonas Maebe
e97f31541e - reverted partial commit of merge
git-svn-id: branches/blocks@29515 -
2015-01-21 23:24:37 +00:00
Jonas Maebe
a76bbf363d * synchronised with trunk r29513
git-svn-id: branches/blocks@29514 -
2015-01-21 23:18:29 +00:00
pierre
32cdcb8930 Remove wrong error message, Pascal Didier
git-svn-id: trunk@29472 -
2015-01-14 15:46:29 +00:00
florian
b7a1418065 * skip <type>(<expr>) in the cond. expression parser if eval is false
git-svn-id: trunk@29116 -
2014-11-22 22:45:02 +00:00
Tomas Hajny
3ee3542744 * boolean constant instead of IFDEFs for detection of microcontroller support
git-svn-id: trunk@29052 -
2014-11-10 12:34:59 +00:00
Jonas Maebe
bd09b88a5b + support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension)
o blocks are implemented as a variation of procedure variables
   o declaration of a block variable: "test: procedure(c: char) is block;"
     (C equivalent: (void)(^test)(char c) )
   o the compiler automatically converts procedures/functions whose address
     is passed to a block parameter or assigned to a block variable into
     a "block". This consists of
    1) generating a block descriptor (containing the size of the "block
       literal" (see below) and the signature of the invocation function
       encoded as an Objective-C selector)
    2) generating a wrapper function around the original funcion (with C
       calling convention), that has an extra first hidden parameter
       (marked as vo_is_parentfp in the compiler) whose type is a pointer
       to the describing "block literal"
    3) generating the "block literal", which contains a pointer to an
       external variable indicating whether this block captures context or
       not, some flags (see compiler/blockutl.get_block_literal_flags for
       info), a pointer to the wrapper function and a pointer to the
       descriptor. In the future, it will also contain captured variables.
   o right now, only global procedures/functions can be converted to blocks
     (because they don't require state capturing). The next steps are (Object
     Pascal) methods (not Objective-C methods, because Objective-C method
     procvars don't exist) and finally nested functions
   o on Mac OS X, the functionality will only work on Mac OS X 10.7 and later,
     because we have to use the so-called "ABI.2010.3.16" to ensure that
     our blocks aren't called as variadic functions by the runtime (which
     came out after the Mac OS X 10.6 release)
   o while the currently implemented functionality does not require any
     library support at all, there's no use enabling it on other platforms
     because unless it has been confirmed to work with a blocks runtime,
     there's no point in using blocks (they're just somewhat bulky procvars
     right now). Enabling it on other platforms (in combination with the
     GNUStep Objective-C run time), should simply be a matter of adding
     the right {$linklib xxx} statement to rtl/inc/blockrtl.pp file, adding
     that file to Makefile.fpc for that platform and adding that platform
     to the compiler/systems.systems_blocks_supported set

git-svn-id: branches/blocks@28232 -
2014-07-18 09:15:22 +00:00
nickysn
dc17b55505 * switch to asmmode_i8086_intel instead of asmmode_i386_intel on i8086 when tp
or delphi mode is selected. This fixes the error "Selected assembler reader
  not supported" in programs that specify $mode tp/delphi, but do not explicitly
  set $asmmode intel.

git-svn-id: trunk@28068 -
2014-06-25 22:02:03 +00:00
florian
24a9dd43b9 * do not crash with an ie on illegal boolean expressions in conditional compilation directives, resolves #25951
git-svn-id: trunk@27676 -
2014-04-27 15:50:37 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
florian
b2b26f84cf * partially merged the mips-embedded branch of Michael Ring:
- startup code/controller units are not merged yet
  - assembler call does not pass the needed CPU type yet

git-svn-id: trunk@27188 -
2014-03-19 21:25:38 +00:00
Jonas Maebe
b611882337 * some minor formatting fixes
git-svn-id: trunk@26616 -
2014-01-29 19:26:17 +00:00
Jonas Maebe
a6d28b5630 * pass on the "eval" state (whether or not subexpressions should be evaluated)
when encountering a "(" in a preprocessor expression (broken after r25465,
    mantis #25296)

git-svn-id: trunk@26615 -
2014-01-29 19:26:12 +00:00
Jonas Maebe
2f741121e9 * don't give an internal error when freeing an error token in the preprocessor
(mantis #25573)

git-svn-id: trunk@26614 -
2014-01-29 19:26:03 +00:00
Jonas Maebe
2274150698 * fixed compilation with -Oodfa on big endian systems
git-svn-id: trunk@26169 -
2013-12-02 13:42:48 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
Jonas Maebe
98a230d20f * don't call swapendian for shortint (it's 1 byte -> upcast to word and then
swapped, which is wrong)

git-svn-id: trunk@25949 -
2013-11-06 09:44:29 +00:00
svenbarth
d908dbeec1 Fix for Mantis #25215.
compiler/scanner.pas, tscannerfile.readtoken:
  * after trying to read a _INTCONST check whether a valid first character for an identifier follows and give a syntax error if that is not the case

+ added test

git-svn-id: trunk@25835 -
2013-10-20 12:15:49 +00:00
paul
d801548604 compiler: support also XOR expressions in macro expressions
git-svn-id: trunk@25583 -
2013-09-27 00:28:15 +00:00
nickysn
52a5ffc386 * use apptype to indicate that the target is a DOS .COM file, instead of introducing a new field in tsettings (as suggested by Sven)
git-svn-id: trunk@25544 -
2013-09-24 12:13:47 +00:00
svenbarth
9d48bc0baf Implement cross unit type overloading of generics. This fixes the regression introduced with revision 25498.
symtable.pas:
  + add new tsymbol_search_flag type which can be passed to various searchsym* routines
  + add support to not call "addsymref"
  + add new searchsym_with_flags function that calls searchsym_maybe_with_symoption
  * adjust searchsym_maybe_with_symoption, searchsym_in_class & searchsym_in_helper to use new flag type instead of Boolean arguments
  * adjust searchsym & searchsym_with_symoption which call the modified functions
nutils.pas, handle_staticfield_access:
  * adjust searchsym_in_class call
pexpr.pas, handle_factor_typenode, postfixoperators, factor:
  * adjust searchsym_in_helper and searchsym_in_class calls
pinline.pas, new_function:
  * adjust searchsym_in_class call
scanner.pas, try_consume_nestedsym:
  * adjust searchsym_in_class call
fmodule.pas, tmodule:
  + add genericdummysyms field which is a TFPHashObjectList that contains TFPObjectList instances per generic dummy that in turn contains tgenericdummysyms instances
pgenutil.pas:
  + add function split_generic_name to split a generic name into non-generic name and count value of type parameters
  + add function resolve_generic_dummysym which tries to use the new genericdummysyms field to find the real symbol of a dummy sym
  * generate_specialization: adjust searchsym_in_class call
  * specialization_init/specialization_done: save/restore genericdummysyms of module
symdef.pas, tdefawaresymtablestack:
  + add new intermediate method pushcommon which is used by both push and pushafter
  + add new intermediate method remove_helpers_and_generics (which calls remove_generics and remove_helpers if necessary)
  * rename removehelpers to remove_helpers
  * rename addhelpers to add_helpers_and_generics and extend it to correctly fill current_module.genericdummysyms
  * call remove_helpers_and_generics from pop instead of remove_helpers
ptype.pas, single_type, read_named_type.expr_type, read_named_type:
  * try to resolve symbols with sp_generic_dummy with resolve_generic_dummysym

+ added test

git-svn-id: trunk@25519 -
2013-09-18 14:28:46 +00:00
paul
73dab82a7f compiler: refactor preproc_substitutedtoken - pass the searchstr into it
git-svn-id: trunk@25475 -
2013-09-13 01:19:19 +00:00
paul
e42e9bb677 compiler: support ORD() intrinsic in preprocessor expressions
git-svn-id: trunk@25471 -
2013-09-12 12:52:07 +00:00