Commit Graph

408 Commits

Author SHA1 Message Date
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
paul
974aeb5573 compiler: support MOD, DIV, SHR, SHL in preprocessor expressions
git-svn-id: trunk@25469 -
2013-09-12 11:22:59 +00:00
paul
cc37b19bb2 compiler: allow 1 and 0 to be used as Booleans in preprocessor expressions
git-svn-id: trunk@25467 -
2013-09-12 09:30:48 +00:00
paul
06e7808f64 compiler: return short evaluation of preprocessor expressions with AND or OR. This fixes univint package compilation.
git-svn-id: trunk@25466 -
2013-09-12 09:06:13 +00:00
paul
038b7746fb compiler: implement preprocessor expressions (fixes mantis #0010671)
- move operator_levels to topens.pas - it is used from 2 units now
  - implement pexpr like sub_expr for preprocessor expressions
  - implement +,-,*,/ expressions for the moment
  * move OR, AND, IN implemenetation to the new logic

git-svn-id: trunk@25465 -
2013-09-12 08:35:24 +00:00
paul
6eba4226b6 compiler: move OR and AND preprocessor evaluation to texprvalue.evaluate
git-svn-id: trunk@25464 -
2013-09-12 06:59:12 +00:00
paul
7ecaaf0ef8 compiler: further improve preprocessor evaluator:
* support TRUE,FALSE for all modes
  * refactor texprvalue.evaluate to support arithmetic expressions and implement them here
  * simplify read_expr and read_factor code

git-svn-id: trunk@25463 -
2013-09-12 06:01:49 +00:00
paul
cac09f9df1 compiler: better handling of '$','%','&' in macros
git-svn-id: trunk@25462 -
2013-09-12 02:33:02 +00:00
paul
0eb4244a67 compiler: implement compile-time expression with float numbers (issue #0010670), better handling of integer expressions too
git-svn-id: trunk@25461 -
2013-09-12 01:59:26 +00:00
paul
eff0403fc1 compiler: reimplement handling of compile time variables - they are stored like tconstsym now instead of string. Expressions are evaluated more accurate now.
git-svn-id: trunk@25460 -
2013-09-12 00:38:17 +00:00
paul
8d526e9b07 compiler: add a check for srsym <> nil since try_consume_unitsym may change srsym to nil, better error message
git-svn-id: trunk@25423 -
2013-09-05 08:39:10 +00:00
paul
3f2e62874b compiler: handle unit, namespace and class/record/object prefixes before identifiers while parsing {$IF ...} expressions (fixes mantis #0020996)
git-svn-id: trunk@25422 -
2013-09-05 07:05:19 +00:00
florian
0e41df598e * merge i8086 branch by Nikolay Nikolov
git-svn-id: trunk@24324 -
2013-04-25 20:23:51 +00:00
florian
7ac7d8a4b6 + define UNICODE as well as FPC_UNICODESTRINGS
git-svn-id: trunk@24214 -
2013-04-09 13:05:29 +00:00
Jonas Maebe
8b7071c8e8 * fixed recording generics token line info on big endian systems
git-svn-id: trunk@23926 -
2013-03-18 13:29:15 +00:00
florian
d4613fe961 * update init_settings.setalloc in SetCompileMode if changeinit is set
git-svn-id: trunk@23898 -
2013-03-17 16:42:34 +00:00
florian
20a534e63f * fixed code which causes range check errors when compiled with -Cr
git-svn-id: trunk@23889 -
2013-03-17 14:24:50 +00:00
nickysn
7d212a7e79 * default to intel assembler for delphi/tp7 modes also on i8086
git-svn-id: branches/i8086@23838 -
2013-03-14 22:19:10 +00:00
paul
3682fddc49 compiler: minor optimization of tscannerfile.recordtoken
git-svn-id: trunk@23798 -
2013-03-12 01:32:07 +00:00
paul
2a3618fb6c compiler: set apptype using new SetAppType routine, add 'CONSOLE' define for console apptype.
git-svn-id: trunk@23603 -
2013-02-13 03:21:03 +00:00
paul
8db6118965 compiler: define FPC_UNICODESTRINGS when UnicodeString is a default string type (for issue #0023861)
git-svn-id: trunk@23601 -
2013-02-13 01:02:40 +00:00
svenbarth
d49b4043ab Implement DECLARED() for generic symbols. This fixes Mantis #21829 . The syntax is SomeGenericType<> for a generic with only one type parameter and SomeGeneric<,[,]*> for a generic with more than one type parameter. Spaces between the commas or brackets are allowed.
scanner.pas, parse_compiler_expr.read_factor:
  + allow "<>" after "declared" (handle "<>" operator specially)
  + count "," to get correct amount of type parameters
  + check together with the count string for symbols 
  + correctly handle dummy symbols

+ added tests

git-svn-id: trunk@23544 -
2013-01-30 16:10:15 +00:00
svenbarth
632db2229f Fix for Mantis #23700 .
scanner.pas, parse_compiler_expr.read_factor:
  * initialize result value

git-svn-id: trunk@23454 -
2013-01-20 11:21:20 +00:00
svenbarth
b5827ce363 Move the handling of "misstyled" floating point constants like "2." or "2.e10" from the scanner to the parser. This way type helpers calls for integer constants can be parsed correctly in the future.
Note: the error messages for incorrect "misstyled" floating point numbers (e.g. "2e10foo") have changed because of this.

scanner.pas, tscannerfile.readtoken:
  instead of tokenizing "2.", "2.e10", "2.e+10" and "2.e-10" as "_REALNUMBER" tokenize them as "_INTCONST _POINT", "_INTCONST _POINT _ID", "_INTCONST _POINT _ID _PLUS _INTCONST" "_INTCONST _POINT _ID _PLUS _INTCONST"; tokenizing of normal floating constants is not changed

pexpr.pas:
  factor: 
    * extract the code for creating a new constant floating point from "factor" into a new function "real_const_node_from_pattern"
    + allow the parsing of postfixoperators for integer constants if a "." is encountered
  + postfixoperators: check for a "misstyled" floating point number if an ordinal const (not an enum and not a boolean) is encountered (the code is already partially prepared for type helper support)
  
+ Added tests

git-svn-id: trunk@23356 -
2013-01-10 16:23:00 +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
paul
57da93dd11 compiler: don't reject utf-8 codepage as default althought it is not present in mapping tables
git-svn-id: trunk@22409 -
2012-09-17 02:24:56 +00:00
Jonas Maebe
07ebc51b6c * always store generics token streams in little endian, so we don't have to
keep a separate field for each tstoreddef that records whether the
    endianness needs to be swapped

git-svn-id: trunk@21914 -
2012-07-15 16:09:14 +00:00
svenbarth
f90e686be2 Always try to present file/line information for generics even if no source is available or the unit was compiled as release unit. This allows IDE like Lazarus to correctly navigate to an error or warning even if the unit containing the generic was compiled as a release unit.
* pscanner.pas, tscannerfile.replaytoken: remove the checks for "sources_avail" and always update the read file/line information 
* fppu.pas, tppumodule.readsourcefiles: always load at least the filenames which were used when compiling the unit from the ppu file, so that file/line information will be correctly shown, but don't touch the "sources_avail" flag of the tppumodule

git-svn-id: trunk@21657 -
2012-06-20 09:01:28 +00:00