Commit Graph

26 Commits

Author SHA1 Message Date
marco
d24f4b0926 --- Merging r42998 into '.':
U    compiler/blockutl.pas
U    compiler/jvm/njvmutil.pas
U    compiler/jvm/pjvm.pas
U    compiler/ncal.pas
U    compiler/ninl.pas
U    compiler/pdecl.pas
U    compiler/pdecsub.pas
U    compiler/pdecvar.pas
U    compiler/pexpr.pas
U    compiler/pgenutil.pas
U    compiler/pmodules.pas
U    compiler/pparautl.pas
U    compiler/pstatmnt.pas
U    compiler/psub.pas
U    compiler/psystem.pas
U    compiler/ptype.pas
U    compiler/symcreat.pas
U    compiler/symdef.pas
U    compiler/symsym.pas
U    compiler/symutil.pas
--- Recording mergeinfo for merge of r42998 into '.':
 U   .
--- Merging r43116 into '.':
G    compiler/symsym.pas
A    tests/webtbf/tw36114.pp
--- Recording mergeinfo for merge of r43116 into '.':
 G   .

# revisions: 42998,43116

git-svn-id: branches/fixes_3_2@43442 -
2019-11-10 16:12:48 +00:00
Jonas Maebe
3ac703506c * rest of the previous accidental partial commit
git-svn-id: branches/fixes_3_2@41250 -
2019-02-07 19:56:21 +00:00
nickysn
f3391f81a5 + introduce a new method tparamanager.asm_result_var(), which determines whether
a pure assembler routine should be allocated a 'result' variable

git-svn-id: trunk@38245 -
2018-02-15 17:41:07 +00:00
nickysn
657685a8b6 * use sizesinttype instead of ptrsinttype for the index and high parameter of
open arrays/dynarrays/string-like char arrays, etc.

git-svn-id: trunk@34665 -
2016-10-08 13:56:24 +00:00
florian
e1d4d167b4 * hidden high parameter must be of type ptrsinttype, resolves issue #29204
git-svn-id: trunk@32745 -
2015-12-26 20:48:50 +00:00
Jonas Maebe
d16d2e6e3c * don't crash when inserting the parentfp parameter for "is nested" procvar
declarations on systems_fpnestedstruct platforms

git-svn-id: trunk@32593 -
2015-12-05 18:03:42 +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
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
Jonas Maebe
dd3d0ae5bc * set the type of the hidden $vmt parameter to the correct classrefdef and
adjust the parameter comparison code to ignore types of $vmt parameters
    when comparing (previously they were all voidpointer and hence also
    equal)

git-svn-id: trunk@30955 -
2015-05-31 16:51:02 +00:00
Jonas Maebe
fa9ba26cb4 * fixed the type of self in Objective-C category methods
git-svn-id: trunk@30948 -
2015-05-31 16:50:42 +00:00
Jonas Maebe
edb3124ae8 * copy arrays passed by value to cdecl routines on the callee side even on
platforms that normally must copy value parameters on the caller side,
    because
   o if we copy them on the caller side, then the behaviour will be different
     compared to other platforms if the called routine is implemented in C
     (since they are passed by reference, changes to the array contents will
      be visible on other platforms, while they wouldn't be visible if the
      copy is made on the caller side)
   o if we don't copy them on the caller nor on the callee side, then behaviour
     will be different compared to other platforms if the called routine is
     implemented in Pascal and modifies the array (since then changes won't be
     visible on the caller side, except on platforms that normally perform
     the copy on the caller side)

git-svn-id: trunk@29873 -
2015-02-23 22:50:29 +00:00
Jonas Maebe
6e12ad817f * don't make copies of arrays passed as value parameters to cdecl routines
(since C compilers don't copy such arrays either, as they're implciitly
     pointers)

git-svn-id: trunk@29871 -
2015-02-23 22:50:23 +00:00
Jonas Maebe
c6ba0bb6fb + support for targets that require by-reference value parameters to be
be copied on the caller instead of callee side
   o mark Darwin/Aarch64 as such a target (any AArch64 target will be like
     that normally, as its ABI specifies this behaviour)
   o don't mark by-reference value parameters on such targets as
     vo_has_local_copy, since a) they don't have one (the copy is on the
     caller side), and b) this ensures that all code handling such
     parameters automatically knows that they are still by reference
     after the init code has run
   o when making the copies on the caller side, don't increase the
     reference count for managed types except for variants, just like
     is done when making the copies on the callee side. This is because
     the reference count increasing code on the callee side only runs
     for non-assembler functions, and we cannot know 100% certain on the
     caller side whether the called function is assembler or not (e.g. in
     case of externally declared functions)
   o maybe over time we can reuse the Pascal code in
     tcallparanode.copy_value_by_ref_para to replace the equivalent code
     in hlcgobj and ncgutil also on the caller side for other targets

git-svn-id: trunk@29870 -
2015-02-23 22:50:20 +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
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
nickysn
2908fa9123 + added type parentfpvoidpointertype, which is a void pointer with the same size
as the hidden parentfp parameter, passed to nested procs. On i8086 it is
  always a near pointer, unlike voidpointer (which changes according to the
  memory model). This fixes nested procs in i8086 far data memory models.

git-svn-id: trunk@26934 -
2014-03-02 22:55:52 +00:00
nickysn
8744fbefbb * add $parentfp as a first parameter on i8086, instead of last. This makes
regular non-nested procedures compatible with nested var procvars and fixes
  the tmaclocalprocparam*.pp tests on i8086

git-svn-id: trunk@25825 -
2013-10-18 21:37:06 +00:00
paul
cdd5d029f0 compiler: don't add operator name as a function result into operator symtable. For FPC mode only operator result identifier should be added and for Delphi mode only 'Result' identifier. Fixes mantis #0025081
git-svn-id: trunk@25562 -
2013-09-25 05:22:28 +00:00
svenbarth
344571cb4e Added support for type helpers. In non Delphi modes they use "type helper" and in mode Delphi they use "record helper". They can also be used on constants.
symconst.pas:
  + extend "thelpertype" by "ht_type" which tells the code in "pdecobj.parse_extended_type" that a type helper declaration has been parsed
node.pas:
  + add a constant which identifies all constant node types
ptype.pas:
  + read_named_type: add a parameter "hadtypetoken" to tell the code whether a "type" token had been parsed before
  + read_named_type: if an identifier "helper" is parsed we need to check whether "hadtypetoken" is true and the modeswitch "m_class" is set, but the "m_delphi" one is not; in that case we have a "type helper" declaration
pgenutil.pas, generate_specialization:
  * adjust call to read_named_type
pdecl.pas, types_dec:
  * adjust call to read_named_type

pdecobj.pas:
  * parse_extended_type: extend for correct handling of primitive types (includes Delphi compatible handling as well) and reject types that are explicitly not allowed
  * method_dec: require "static" for class methods in type helpers
  * method_doc: allow constructors for type helpers as well
paramgr.pas, tparamanager:
  * set_common_funcretloc_info: handle type helper constructors like record constructors
  * handle_common_ret_in_param: the "self" value of a type helper constructor is also returned in a parameter
pexpr.pas:
  + add a function to postfixoperators which tries to find and apply a type helper for a given type
  * postfixoperators: try to apply type helpers for ordinal constants
  * postfixoperators: use the correct string type for string constants
  * postfixoperators: try to apply type helpers for enum constants
  * postfixoperators: try to apply type helpers for arrays
  * postfixoperators: try to apply type helpers for Variant
  * postfixoperators: try to apply type helpers for pointer types
  * postfixoperators: try to apply type helpers for other types
  * factor: check postfixoperators after _REALNUMBER, _CCHAR, _CWCHAR, _TRUE and _FALSE
  * factor: also check postfixoperators if a _POINT follows a _NIL

symdef.pas, tdefawaresymtablestack.addhelpers:
  * use "generate_objectpascal_helper_key" to generate the key
symtable.pas:
  + add function to generate the key value for the map of extended types using the extended def
  * adjust "search_last_objectpascal_helper" and "search_objectpascal_helper" to handle primitive types as well
  * use the new "generate_objectpascal_helper_key" function to generate the key

pparautl.pas:
  * insert_self_and_vmt_para: don't insert the $vmt symbol for record or type helpers (ToDo: check whether class helpers really need the symbol as well)
  * insert_self_and_vmt_para: pass "self" as var parameter for type helpers as well
psub.pas, generate_bodyentry_block: 
  * also allow type helpers for constructor methods
ncal.pas, tcallnode.gen_self_tree:
  * also use a temp variable for type helper constructors
ncgcal.pas, tcgcallnode.secondcallparan:
  * allow Pointers to be passed as address param if it is the Self value of a type helper extending a pointer type
  * correctly handle the location in case of type helper constructors

+ add tests

git-svn-id: trunk@23580 -
2013-02-06 09:49:35 +00:00
paul
51825b6f2e compiler: change ret_in_param to accept tabstractprocdef instead of tproccalloption to allow check more options (required for record constructor implementation)
git-svn-id: trunk@23394 -
2013-01-16 01:14:23 +00:00
Jonas Maebe
dfe3ca5328 * prevent invalid typecast on targets using nestedfpstruct functionality
in case of type errors in the source (the compiler will already have
    printed an error at this point)

git-svn-id: trunk@23044 -
2012-11-22 12:22:00 +00:00
pierre
42586baa34 Use SUPPORT_SAFECALL conditional
git-svn-id: trunk@22488 -
2012-09-27 15:57:40 +00:00
svenbarth
d87b203a0a Do not call ret_in_param of the current parameter manager when parsing a generic method/function. This fixes Mantis #21921.
* pparautl.pas, insert_funcret_para:
    assume that the result in a generic function/method can not be passed in a param
* pparautl.pas, insert_funcret_local: 
    don't call ret_in_param, but create the symbol as we need a valid funcretsym
* pstatmnt.pas, assembler_block:
    don't modify the framepointer for a generic method/function
* rautils.pas, TOperand.SetupResult:
    don't assume that we can't use the result for a generic function/method

git-svn-id: trunk@21608 -
2012-06-14 12:11:11 +00:00
sergei
19053de279 * Added {$i fpcdefs.inc}, was missing in the newly added unit, causing incorrect parameter positions on some platforms (e.g. broken tsafecall2, tsafecall3).
git-svn-id: trunk@21318 -
2012-05-17 17:34:12 +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
Jonas Maebe
69abbba6bb * split several parameter insertion helpers out from pdecsub for
easier reuse elsewhere

git-svn-id: branches/jvmbackend@18687 -
2011-08-20 08:24:40 +00:00