Commit Graph

411 Commits

Author SHA1 Message Date
Jonas Maebe
7a0ae38700 + also specify the parameter def when allocating a parameter via
getintparaloc + adapted all call sites of getintparaloc. This
    led to a number of additional, related changes:
   o corrected the type information for some getintparaloc parameters
   o don't allocate some intparalocs in cases they aren't used
   o changed "const tvardata" parameter into "constref tvardata" for
     fpc_variant_copy_overwrite to make pass-by-reference semantics
     explicit
   o moved a number of routines that now have to call find_system_type()
     from cgobj to hlcgobj so that cgobj doesn't have to start depending
     on the symtable unit
   o added versions of the cpureg alloc/dealloc methods to hlcgobj that
     call through to their cgobj counter parts, so we can call save/restore
     the cpu registers before/after calling system helpers from hlcgobj
     (not implemented in hlcgobj itself, because all basic register
      allocator functionality is still part of cgobj/cgcpu)

git-svn-id: trunk@21696 -
2012-06-24 15:02:12 +00:00
Jonas Maebe
708a2532fc * consistently define empty saved_mm_registers arrays as containing a single
RS_INVALID superregister (instead of sometimes RS_NO and sometimes
    RS_INVALID)
  * check for RS_INVALID in tcg.g_save_registers() and ignore such entries

git-svn-id: trunk@21622 -
2012-06-15 18:24:25 +00:00
Jonas Maebe
8234a842e6 * fixed conversion of empty ansistring/widestring constants to pchar on
the jvm target + test

git-svn-id: trunk@21391 -
2012-05-26 11:32:20 +00:00
Jonas Maebe
85a3fd3357 + ossinttype/osuinttype defs that correspond to OS_SINT/OS_INT for use in
the high level code generator

git-svn-id: trunk@21279 -
2012-05-12 16:03:15 +00:00
Jonas Maebe
8a7123eed8 * override a_call_reg() with an internalerror rather than a_call_ref(),
since it's the former that is abstract in the base class

git-svn-id: trunk@21126 -
2012-04-29 22:26:51 +00:00
Jonas Maebe
1345b7d107 * changed ref parameter of thlcgobj.a_call_ref() into a const parameter
git-svn-id: trunk@21115 -
2012-04-29 13:13:42 +00:00
Jonas Maebe
4fced5d142 + generic implementation of thlcgobj.a_call_ref()
* override thlcg.a_call_reg() in JVM hlcgcpu with dummy that calls
    internalerror

git-svn-id: trunk@21099 -
2012-04-28 14:27:45 +00:00
Jonas Maebe
e20639732f + cghlcpu unit with thlbasecgcpu class that overrides all abstract tcg
methods that don't have to be implemented by targets using the high
    level code generator, with dummy implementations that raise an internal
    error (to remove warnings about instantiating classes with abstract
    methods)
  * let the JVM tcg descendent derive from this new thlbasecgcpu class

git-svn-id: trunk@21098 -
2012-04-28 14:27:31 +00:00
pierre
857abd87ee + Implement create_varargs_paraloc_info, to allow compilation without warnings
git-svn-id: trunk@21073 -
2012-04-27 08:25:19 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
Jonas Maebe
0659058e44 * fixed ansistring -> pchar type conversion on JVM target now that empty
ansistrings are represented by nil
  * fixed type conversion of constant empty ansistring/unicodestring to
    pchar/pwidechar on the JVM target

git-svn-id: branches/jvmbackend@21055 -
2012-04-25 22:29:20 +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
622eb4b782 * call getbasedef before getting the classdef of an enum (only the basedef
has an associated class)

git-svn-id: branches/jvmbackend@20870 -
2012-04-14 17:38:02 +00:00
Jonas Maebe
21722802fa * also allow taking the address of a derefence expression on the JVM target
(required for taking the address of threadvars, used by the current RTL)

git-svn-id: branches/jvmbackend@20869 -
2012-04-14 17:37:56 +00:00
Jonas Maebe
94bdf8a086 * adjust integer type information before stores part of a_op_const_ref for
Dalvik type checker

git-svn-id: branches/jvmbackend@20628 -
2012-03-25 14:46:37 +00:00
Jonas Maebe
94b058fe19 * fixed version of r20547: can't check the number of abstract methods of a
class before its VMT has been built, because that's the process that looks
    for inherited abstract methods that are overridden -> instead use a new
    synthetic method kind (tsk_callthrough_nonabstract) that will call
    through to another method (in this case a constructor) if the owning
    class does not contain any abstract methods, and generates an
    empty routine otherwise

git-svn-id: branches/jvmbackend@20589 -
2012-03-23 11:26:30 +00:00
Jonas Maebe
94bffa65e9 * don't create an instance of abstract classes inside their virtual
constructors (simply do nothing), because creating an abstract class
    is not possible in the JVM (and while the JVM only triggers an
    exception when you actually execute code that tries to create an
    abstract class, the Android platform checks this using the bytecode
    verifier at class verification time and therefore stumbled over the
    old code)

git-svn-id: branches/jvmbackend@20547 -
2012-03-20 21:59:57 +00:00
Jonas Maebe
fc6be612fd * also insert an explicit conversion from byte/char/bytebool/... to smallint
on Dalvik, because those values are obtained via an "and 255" operation
    which again turns them into longint values as var as the Dalvik type
    system is concerned

git-svn-id: branches/jvmbackend@20527 -
2012-03-16 20:57:22 +00:00
Jonas Maebe
83235a483b * always return a LOC_JUMP from tjvmnotnode.second_boolean: required both
to correctly handle non-pasbool types (can't just "not" their value),
    and for Dalvik (a "not pasbool" became "xori 1", which turned the value
    from a boolean into an integer as far as the Dalvik type checker was
    concerned)

git-svn-id: branches/jvmbackend@20525 -
2012-03-16 17:23:55 +00:00
Jonas Maebe
0248258670 * always size the value on top of the stack back down to its original size
after an 8/16 bit operation on Dalvik (even if the value cannot have
    become too big), because otherwise its type checker complains

git-svn-id: branches/jvmbackend@20520 -
2012-03-15 17:05:50 +00:00
Jonas Maebe
85ef5e109c + assert() support for the JVM target (currently ignores the Java classloader
assertionStatus setting)

git-svn-id: branches/jvmbackend@20388 -
2012-02-20 11:28:59 +00:00
Jonas Maebe
3916a32f9e * created generic version of thlcgobj.g_reference_loc() and only override
JVM-specific case (needed for future trunk marge to prevent abstract
    method warning)

git-svn-id: branches/jvmbackend@20387 -
2012-02-20 11:28:50 +00:00
Jonas Maebe
0dfdae3132 * always get the basedef for an enum before using its classdef (since only
the basedef has an associated classdef)

git-svn-id: branches/jvmbackend@20142 -
2012-01-21 19:35:58 +00:00
Jonas Maebe
af9934cb6c * make sure that integers converted to widechar are always processed by an
i2c instruction for Dalvik verification purposes

git-svn-id: branches/jvmbackend@19826 -
2011-12-11 17:26:14 +00:00
Jonas Maebe
764502fbe4 * don't "and" loaded unsigned values of 1/2 bytes with 255/65535 in case
their upper bound is lower than 127/32767: not necessary, and in case
    of booleans not even allowed for Dalvik (because the "and" operation
    turns the boolean into an integer as far as Dalvik is concerned)

git-svn-id: branches/jvmbackend@19825 -
2011-12-11 17:25:58 +00:00
Jonas Maebe
c61e9a2f04 * fixed (harmless) invalid typecasts that caused run time errors with -CR
git-svn-id: branches/jvmbackend@19824 -
2011-12-11 17:25:50 +00:00
Jonas Maebe
f4f70f99b2 * call all operators with invokestatic, since they are always
class methods

git-svn-id: branches/jvmbackend@19823 -
2011-12-11 17:25:42 +00:00
Jonas Maebe
21e6401921 * no longer encode all pointers to other pointer types (such as
classes, interfaces, dynamic arrays, ...) as "array of JLObject",
    but instead as an array of the actual pointed-to type. The reason
    for the previous behaviour was mainly that the JVM threadvar
    implementation internally stores all threadvars that are
    such double pointer types into an "array of JLObject". Type casting
    this array to e.g. an "array of array of byte" causes an exception
    even if it only contains "array of byte" instances (since the outer
    array type is different). This is now solved by first taking the
    element of the array and then typecasting it to the destination
    type (so dynarrbyte(arr[0]) instead of pdynarrbyte(arr)^[0]).

    The reason for the new (more accurate) behaviour is because the
    old one caused type errors in case a double pointer field was
    internally created for the nestedfpstruct support (see added
    test)

git-svn-id: branches/jvmbackend@19821 -
2011-12-11 17:25:09 +00:00
Jonas Maebe
bd990d1173 * generate JVM bytecode that passes the stringent requirements of the Dalvik
verifier when -Cpjvmdalvik is used (including debug information). Using
    -Cpjvmdalvik changes the semantics at the language-level in one case:
    boolean(bytevar) will no longer return a boolean that contains the same
    value as bytevar did, but will map the value to 0/1 (that also means that
    such expressions cannot be passed to var-parameters in case of
    -Cpjvmdalvik). Code compiled with -Cpjvmdalvik will also work fine on
    the regular JVM, but it may be somewhat slower (it won't necessarily
    be slower on Dalvik, because the .class -> .dex transformation
    applies many optimizations itself)

git-svn-id: branches/jvmbackend@19743 -
2011-12-04 14:48:54 +00:00
Jonas Maebe
faaa86238c * enable support for creating loadvmtaddr nodes for Java interfaces, because
those are also supported by the Java language (intftype.class) and required
    in equivalent Pascal expressions (such as JLClass(intftype))

git-svn-id: branches/jvmbackend@19742 -
2011-12-04 14:48:48 +00:00
Jonas Maebe
08565ce5be * save/restore the current_except_loc instead of invalidating it after each
use (since try/except statements can be nested)

git-svn-id: branches/jvmbackend@19666 -
2011-11-21 18:48:19 +00:00
Jonas Maebe
4dee36b64b * copy the implicit pointer rather than the contents of var/out/constref
implicit pointer types into the nestedfpstruct, so that the original
    parameter is properly changed when updated from inside nested routines

git-svn-id: branches/jvmbackend@19645 -
2011-11-18 21:09:38 +00:00
Jonas Maebe
74510f9069 + generic infrastructure for target-specific switches
+ -CTcompactintarrayinit command line option to change the code generation
    for typed array of some kind of integer-type initialization so that it
    takes up less space in the bytecode (because the bytecode for all
    routines, including the class initialization code that contains the
    typed constant init code, is limited 64kb, large array or multiple
    array constants could fairly easily bump into that limit)

git-svn-id: branches/jvmbackend@19638 -
2011-11-14 22:57:41 +00:00
Jonas Maebe
1401c4e573 * fixed popping the unused function results of methods returning implicit
function pointer type results (records, shorstrings, ...): always pop a
    single stack slot in that case

git-svn-id: branches/jvmbackend@19598 -
2011-11-06 14:01:12 +00:00
Jonas Maebe
cfca607b9b * in case of an enum without a type name (e.g., "type xx = set of (ea,eb)"),
set the external name of the underlying class type to the internal name
    instead of to an (invalid) empty string

git-svn-id: branches/jvmbackend@19555 -
2011-10-28 21:19:12 +00:00
Jonas Maebe
cf47b8d422 * fixed all known memory leaks in the code added for the JVM port
git-svn-id: branches/jvmbackend@19248 -
2011-09-26 19:31:34 +00:00
Jonas Maebe
26b19274a3 + create an nested interface type called "Callback" inside the classes that
are used to implement procvar types, and add a constructor to the procvar
    types that accept an instance implementing this interface -> much easier
    and more natural to use procvar types from Java code

git-svn-id: branches/jvmbackend@19216 -
2011-09-24 20:32:01 +00:00
Jonas Maebe
5332263d46 * fixed r18981 (conversion of LOC_JUMP to something else must happen before
before the old jump labels are restored)

git-svn-id: branches/jvmbackend@19155 -
2011-09-19 21:22:35 +00:00
Jonas Maebe
583c9a3360 * replace assigned(dynarray) and dynarray=/<>nil with length(dynarray)=/<>0
on the JVM target because empty dynarrays are not always nil there

git-svn-id: branches/jvmbackend@19154 -
2011-09-19 19:59:32 +00:00
Jonas Maebe
f96f5f9e94 + {$VARPARACOPYOUTCHECK+/-} / -Cv switch to enable checking
var-parameters on the JVM target for changes to the value passed
    as var-parameter during the function call (because they are handled
    via copy-in/copy-out, this may indicate unexpected bahviour later on).

    out-parameters are checked in the same way, except if the out-parameter
    is a local variable because then reading it before the call may result
    in a bytecode verification error (since the variable may not yet be
    initialized)

git-svn-id: branches/jvmbackend@19153 -
2011-09-19 19:59:26 +00:00
Jonas Maebe
633de3fe30 * give an error when calling a virtual constructor from another constructor
on the JVM target, because the generated code was invalid and I can't think
    of a generic way to solve it (see added comments in njvmcal.pas)

git-svn-id: branches/jvmbackend@19055 -
2011-09-12 18:08:46 +00:00
Jonas Maebe
125c0cf225 + support for generics on the JVM target:
o don't try to create .class files for generic types
   o still generate all JVM-specific wrappers for generic types even though they
     won't be written out, because when specializing all the defid's have to
     match exactly
   o add synthetic routine implementations after generating the specializations,
     so that the synthetic routines for those specializations are also generated
     (we don't specialize generic versions of the synthetic generic routines
      because it's not easy or even always possible to create valid generic
      versions of synthetic routines)
   o Note: these are Pascal-style generics, not Java-style generics. The generic
     types nor their specializations are usable from Java code (specializations
     may become usable in the future)

git-svn-id: branches/jvmbackend@19047 -
2011-09-11 11:54:37 +00:00
Jonas Maebe
c9ebd433db * fixed array indexing via LOC_JUMP on the JVM target
git-svn-id: branches/jvmbackend@18981 -
2011-09-05 17:41:40 +00:00
Jonas Maebe
1a7c024ad3 * sign extend all byte/ansichar/word parameters before passing them
to and returning them from sub routines, in order to follow the JVM
    specs to the letter (not checked by the JVM bytecode verifiers, but
    checked by the Android DEX verifier)
  * -> also zero-extend them again at the caller side after returning
    from such a function

git-svn-id: branches/jvmbackend@18919 -
2011-08-30 23:34:12 +00:00
Jonas Maebe
f21b34c954 * also resize the value on the stack in a_load_reg_ref() when
required based on the source/destination sizes (like in
    a_load_reg_reg(), a_load_ref_reg() and a_load_ref_ref())

git-svn-id: branches/jvmbackend@18918 -
2011-08-30 23:34:07 +00:00
Jonas Maebe
0e80844e33 * also zero-extend incoming byte/word const-parameters (instead of only
value parameters)
  * fixed upper bound check to determine whether zero-extending is required

git-svn-id: branches/jvmbackend@18917 -
2011-08-30 23:34:02 +00:00
Jonas Maebe
a4cf406189 * use generic string concatentation and comparison infrastructure for the
JVM target (and also the generic routines in case of shortstrings)

git-svn-id: branches/jvmbackend@18910 -
2011-08-29 22:59:25 +00:00
Jonas Maebe
6a7ff1cf75 * use temp-reference nodes rather than addrnodes to create references to
complex parameters passed to inlined routines on the JVM target, because
    it is not possible to take the address of any kind of node on the JVM
    target (temp-reference nodes work for any kind of LOC_(C)REFERENCE, but
    are currently only implemented for the JVM platform)

git-svn-id: branches/jvmbackend@18905 -
2011-08-29 22:58:55 +00:00
Jonas Maebe
7117264f96 * fixed assigning ansi/unicodestrings to shortstrings on the JVM target
(and cleaned up implementing support for special x_to_shortstring
     assignments in the process)

git-svn-id: branches/jvmbackend@18877 -
2011-08-28 19:21:46 +00:00
Jonas Maebe
3bf71d8d04 * fixed unsigned comparisons after r18734 (comparison operator is now
used to determine the signedness of the comparison, not the types
    of the arguments)

git-svn-id: branches/jvmbackend@18833 -
2011-08-24 22:11:22 +00:00
Jonas Maebe
eb268fb2c4 + tcallnode.createinternmethodres() that allows specifying a forced
resultdef for internally generated method calls
  * force the resulttype of methods used to build non-unicode string
    constants on the JVM platform to the stringconstn's resultdef

git-svn-id: branches/jvmbackend@18832 -
2011-08-24 22:11:16 +00:00
Jonas Maebe
bb593346a9 * fixed typecasts between widechars and non-widechars in case an array
element is involved

git-svn-id: branches/jvmbackend@18831 -
2011-08-24 22:11:05 +00:00
Jonas Maebe
f40c893084 * when determining whether taking the address of an array element is
valid, check for the array's actual lower bound instead of always for
    zero

git-svn-id: branches/jvmbackend@18822 -
2011-08-23 20:39:17 +00:00
Jonas Maebe
a2a0436347 + support for threadvars in the JVM based on JLThreadLocal; see
rtl/java/jtvarh.inc for the details

git-svn-id: branches/jvmbackend@18820 -
2011-08-23 17:45:01 +00:00
Jonas Maebe
992cc352c6 * generalized handling of pointers to non-implicit pointer types:
as far as Java is concerned, they're now all arrays of JLObject.
    When loading a value from them, we typecast the loaded value
    to the appropriate type. This allows typecasting one pointer
    type to another without getting verification errors (since an
    "array of JLObject" is not compatible with "array of JLString")
  - no longer allow dereferencing untyped pointers on the JVM
    target, since that always results in invalid bytecode

git-svn-id: branches/jvmbackend@18819 -
2011-08-23 17:44:55 +00:00
Jonas Maebe
0364b7acf9 * also allow taking the address of the first element of an array in
case of non-implicit pointer types

git-svn-id: branches/jvmbackend@18818 -
2011-08-23 17:44:49 +00:00
Jonas Maebe
d063ae10cb * use correct location.size after dereferencing pointers to non-implicit
pointer types instead of hardcoded OS_ADDR

git-svn-id: branches/jvmbackend@18817 -
2011-08-23 16:07:19 +00:00
Jonas Maebe
7010116096 * if a mangledbasename is set for staticvarsyms, also use if when emitting
definitions

git-svn-id: branches/jvmbackend@18814 -
2011-08-23 15:26:06 +00:00
Jonas Maebe
54f9947406 * no need to zero-extend after a load of a widechar
git-svn-id: branches/jvmbackend@18813 -
2011-08-23 15:26:01 +00:00
Jonas Maebe
3a5b3a0cce * don't crash after invalid JVM class definitions while trying to add
a default constructor

git-svn-id: branches/jvmbackend@18807 -
2011-08-23 15:25:11 +00:00
Jonas Maebe
5c832ecbd1 * moved jvm-specific compiler units to the jvm subdirectory
git-svn-id: branches/jvmbackend@18782 -
2011-08-20 08:35:58 +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
c4ffef0a40 * fixed initializing arrays of ansi/unicodestring and of open arrays
removing the array initialization from tgcpu

git-svn-id: branches/jvmbackend@18780 -
2011-08-20 08:35:30 +00:00
Jonas Maebe
67c2c7c166 * renamed cchartype to cansichartype
git-svn-id: branches/jvmbackend@18779 -
2011-08-20 08:35:24 +00:00
Jonas Maebe
26ee54b1a2 * fixed compilation with 2.4.4
git-svn-id: branches/jvmbackend@18778 -
2011-08-20 08:35:19 +00:00
Jonas Maebe
2428ea65c1 * replaced the old hack for non-formal var/out/constref support with
a generalized version of the formal var/out/constref support (this
    also fixes passing string[xyz] expressions to non-formal var/out/constref
    parameters)

git-svn-id: branches/jvmbackend@18774 -
2011-08-20 08:34:46 +00:00
Jonas Maebe
ee77d5a6f2 * some changes to handleformalcopyoutpara() so that in the future it can
also handle non-formal parameters
  * do not copy in the original value in handleformalcopyoutpara() if it's
    an out parameter

git-svn-id: branches/jvmbackend@18772 -
2011-08-20 08:34:36 +00:00
Jonas Maebe
d7cff1cd31 * give an error when trying to typecast a unicodestring into a pwidechar
on the JVM target (we can't access the characters of a JLString as an
    array)

git-svn-id: branches/jvmbackend@18769 -
2011-08-20 08:34:21 +00:00
Jonas Maebe
224aae8993 + support for typecasting ansistrings into pchars on the JVM platform
+ support for indexing pointers as arrays on the JVM platform (with
    JVM-provided range checking, obviously)

git-svn-id: branches/jvmbackend@18768 -
2011-08-20 08:34:16 +00:00
Jonas Maebe
27731e342c + support for array-of-const on the JVM target. Even though the
implementation is a bit different from that on native targets, the
    result is quite compatible

git-svn-id: branches/jvmbackend@18765 -
2011-08-20 08:34:00 +00:00
Jonas Maebe
d0e8cd1637 + support for dereferencing any kind of pointer type
git-svn-id: branches/jvmbackend@18763 -
2011-08-20 08:33:49 +00:00
Jonas Maebe
1a0913c462 * fixed proc_to_procvar() type conversion in case the target procvar
type was generated on-the-fly rather than specified to the
    type conversion node

git-svn-id: branches/jvmbackend@18762 -
2011-08-20 08:33:45 +00:00
Jonas Maebe
687e9fb6dc * fixed fully qualified class names passed to JLClass.forName()
(components must be separated by '.', not '/')

git-svn-id: branches/jvmbackend@18761 -
2011-08-20 08:33:40 +00:00
Jonas Maebe
dd32efa9ff + cstring_to_pchar type conversion support
* fixed AnsiCharArrayClass.CreateFromLiteralStringBytes() declaration
    (no maxlength parameter)

git-svn-id: branches/jvmbackend@18760 -
2011-08-20 08:33:35 +00:00
Jonas Maebe
4647aa3f15 * don't copy back constref parameter values after the call
git-svn-id: branches/jvmbackend@18759 -
2011-08-20 08:33:30 +00:00
Jonas Maebe
76de70e683 * since enums are represented by classes in the JVM, initialize global
variables, class/record fields and arrays with enumtype(0) on
    creation, so that using them without explicitly initializing them
    doesn't cause a null-pointer exception. If enumtype(0) is not a
    valid enum, they are not initialized (and since they wouldn't have
    a valid value on native targets either in that case, an exception
    on use is acceptable)

git-svn-id: branches/jvmbackend@18755 -
2011-08-20 08:33:02 +00:00
Jonas Maebe
d33f71460f * don't initialize static arrays of records twice (g_newarray already
initializes them)

git-svn-id: branches/jvmbackend@18753 -
2011-08-20 08:32:52 +00:00
Jonas Maebe
da5bd3b0bd * use invokespecial for "strict private" (= Java "private") rather than for
plain "private" (~ Java "package") methods

git-svn-id: branches/jvmbackend@18750 -
2011-08-20 08:32:37 +00:00
Jonas Maebe
7f22a2f223 + support for range checking calculations with hlcgobj
* added runerror number to JVM FpcRunTimeError exceptions
  * enabled calling errorproc when a run time error occurs on the
    JVM target

git-svn-id: branches/jvmbackend@18749 -
2011-08-20 08:32:31 +00:00
Jonas Maebe
f4690f90ad * keep maximum used evaluation stack size up-to-date when putting a
default return value on the stack for fpu routines

git-svn-id: branches/jvmbackend@18744 -
2011-08-20 08:31:53 +00:00
Jonas Maebe
fe82e2481b + import java.lang.Math in the system unit
+ include mathh.inc in the system unit, implement most routines based
    on java.lang.Math, and use (an unmodified!) genmath for the rest
  - removed now obsolete jmathh.inc (was partial copy of mathh.inc)
  - removed commented out overrides for several math routines in
    njvminl (doesn't make sense to handle them inline in the compiler)

git-svn-id: branches/jvmbackend@18742 -
2011-08-20 08:31:24 +00:00
Jonas Maebe
af489b99de * fixed handling of currency in int_to_int conversions
git-svn-id: branches/jvmbackend@18741 -
2011-08-20 08:31:12 +00:00
Jonas Maebe
72c81d9eb1 * always create a new call node when replacing virtual class method calls
with wrapper calls, because the parameter nodes are already bound to the
    paravarsyms of the current procdef so simply replacing the procsym and
    procdef is not enough

git-svn-id: branches/jvmbackend@18739 -
2011-08-20 08:30:38 +00:00
Jonas Maebe
c2f2a8c900 * make sure that the expression representing the ansi/unicodestring argument
to length is never evaluated more than once

git-svn-id: branches/jvmbackend@18736 -
2011-08-20 08:30:02 +00:00
Jonas Maebe
707b41b159 + allocate space of local typed consts that are implicit pointer types
in the enclosing class/unit init code

git-svn-id: branches/jvmbackend@18735 -
2011-08-20 08:29:47 +00:00
Jonas Maebe
9253d990d9 * use the signedness of the comparison operation rather than of the
types involved to determine whether or not the comparison is
    unsigned (they don't always match due to bugs in the compiler,
    and the sign of the comparison operation is what's used in
    other code generators too)

git-svn-id: branches/jvmbackend@18734 -
2011-08-20 08:29:36 +00:00
Jonas Maebe
8fcc8f92ca * allow taking the address of var-parameters in normal Pascal code (not just
via internal njvmaddrnodes), because we need it for procvar dispatching

git-svn-id: branches/jvmbackend@18732 -
2011-08-20 08:29:11 +00:00
Jonas Maebe
b3072b3dab * extracted the code to deal with static fields into a routine
(make_field_static() ) and replaced semi-duplicates of that
    code with calls to this routine
  * made the handling of static fields for the JVM target more
    similar to that on the other targets, so that class properties
    now also work there (-> updated JVM-specific code in several
    places to deal with this new handling)

git-svn-id: branches/jvmbackend@18723 -
2011-08-20 08:27:48 +00:00
Jonas Maebe
7419c97e0a * do not call the virtual class method/constructor dispatching lookup
when calling the inherited version, since that one is also known at
    compile time

git-svn-id: branches/jvmbackend@18712 -
2011-08-20 08:26:52 +00:00
Jonas Maebe
1d0388d40a + support for virtual constructors for the JVM platform. We simply
create a virtual class (factory) method that calls the constructor,
    and then let the existing support for virtual class methods handle
    everything

git-svn-id: branches/jvmbackend@18710 -
2011-08-20 08:26:40 +00:00
Jonas Maebe
2a9043f4bc * keep the node flags when replacing a call to a virtual class method with
a call to its wrapper

git-svn-id: branches/jvmbackend@18708 -
2011-08-20 08:26:30 +00:00
Jonas Maebe
7d8cbe80f5 + support for virtual class methods on the JVM platform. The JVM does not
support those natively, so they are emulated via the procvar infrastructure
    (and hence not very fast). Could probably be optimized somewhat by adding
    a cache (hashmap of procvars) to the class hierarchies, maybe in the
    future.

git-svn-id: branches/jvmbackend@18704 -
2011-08-20 08:26:11 +00:00
Jonas Maebe
cd6b8b9dd1 * correctly create procvars for procdefs that have an import_name set
git-svn-id: branches/jvmbackend@18703 -
2011-08-20 08:26:05 +00:00
Jonas Maebe
249b56d742 * fixed calling non-static class methods via procvars: since we can't known
on the caller side whether it's a normal or class method that we are
    calling, add the self-class parameter inside the invoke method if
    necessary (by simply counting the number of parameters and inserting
    it if we're one short)

git-svn-id: branches/jvmbackend@18699 -
2011-08-20 08:25:44 +00:00
Jonas Maebe
d8977b0342 - disabled the set constant caching via static variables for now because
their initialization can cause races between the unit they are declared
    in and the class constructor they are initialized in (even if both
    would be moved to the unit initialization code, a class constructor
    using the set constant could run before the unit initialization code has
    run)

git-svn-id: branches/jvmbackend@18698 -
2011-08-20 08:25:39 +00:00
Jonas Maebe
c8c75d7e1d * convert non-constant enums in in-expressions to longint if we use the
generic jumps code

git-svn-id: branches/jvmbackend@18697 -
2011-08-20 08:25:33 +00:00
Jonas Maebe
4557938e62 - removed no longer needed/used {$ifndef nounsupported} code
git-svn-id: branches/jvmbackend@18692 -
2011-08-20 08:25:08 +00:00
Jonas Maebe
979f55e1db + support for procedural variables for the JVM target
o every porocedural variable type is represented by a class with one
     public "invoke" method whose signature matches the signature of the
     procvar
   o internally, dispatching happens via java.lang.reflect.Method.invoke().
     WARNING: while this allows calling private/protected or other methods
     that are normally not accessible from another context, a security
     manger can override this. If such a security manager is installed,
     most procvars will cause security exceptions
   o such dispatching also requires that all arguments are wrapped, but
     that's done in the compiler-generated body of the invoke method,
     so that procvars can also be called conveniently from Java code
   o typecasting between a procedure of object and tmethod is supported,
     as well as Delphi-style replacing of only the method pointer via
     @procvar1=@procvar2.
   o nested procvars are not yet supported, but most of the basic
     infrastructure for them is already present
  * all units/programs now get an internal __FPC_JVM_Module_Class_Alias$
    type when compiled for the JVM target, which is an "external" class
    that maps to the unit name. This is required to look up the
    JLRMethod instances for regular functions/procedures
  + new tabstractprocdef.copyas() method that allows to create a procvar
    from a procdef and vice versa

git-svn-id: branches/jvmbackend@18690 -
2011-08-20 08:24:58 +00:00
Jonas Maebe
834f8da885 + added extra parameter to jvmgetboxtype() to indicate whether all integer
types should be mapped onto jllong or rather onto the closes matching type

git-svn-id: branches/jvmbackend@18685 -
2011-08-20 08:24:29 +00:00
Jonas Maebe
61fd6ca4ee * zero-extend small unsigned integer parameters on function *entry*, because
the functions may be called from Java code or indirectly and in that case
    there's no way to guarantee that they'll be zero-extended on the caller
    side

git-svn-id: branches/jvmbackend@18684 -
2011-08-20 08:24:24 +00:00
Jonas Maebe
cef61300ff + ttgobj.gethltemptyped() routine for allocating managed types with high level
code generator support
  * refactored some internal temp generator code

git-svn-id: branches/jvmbackend@18681 -
2011-08-20 08:24:07 +00:00
Jonas Maebe
085d0efead * some fixes for fake procvar support
git-svn-id: branches/jvmbackend@18680 -
2011-08-20 08:24:02 +00:00
Jonas Maebe
d6966e545b + support for formal var/out parameters on the JVM target:
o primitive types are first boxed
   o the parameter is passed inside an array of one class instance
   o changing the parameter inside the routine (by assigning a value to it
     like in Delphi.NET and different from regular Pascal code) will replace
     this class instance (again boxing the value if required)
   o on return, the class instance is extracted, unboxed if required, and
     assigned back to the original location
   o formal const parameters are handled without the extra array indirection,
     since they cannot be changed

  TODO: while writing tjvmcallparanode.handleformalcopyoutpara() I forgot that
    calling getcopy on ttemprefnodes whose ttempcreatenode hasn't been copied
    yet works fine, so that code is more complex than needed. Still have to
    fix.

git-svn-id: branches/jvmbackend@18675 -
2011-08-20 08:23:33 +00:00
Jonas Maebe
5bf16214cd * changed initialization of records from constructing a new instance and
copying that over the old one into calling a dedicated fpcInitializeRec()
    method that initializes the required fields. The reason is that this
    initialization is performed for out-parameters, and the fpcDeepCopy()
    method (used to copy one instance over another) has an out-parameter
    -> infinite loop

git-svn-id: branches/jvmbackend@18674 -
2011-08-20 08:23:27 +00:00
Jonas Maebe
40cf2cefa0 * when the user calls initialize(), force initialization to happen on the
JVM platform (normally it's not necessary because all types are
    automatically initialized)

git-svn-id: branches/jvmbackend@18672 -
2011-08-20 08:23:16 +00:00
Jonas Maebe
d0663411a5 * fixed order of operands on the jvm stack in case of a setlength(x,0) call
for a static field

git-svn-id: branches/jvmbackend@18671 -
2011-08-20 08:23:10 +00:00
Jonas Maebe
7286e3b645 * when determining the type to use for checkcast, first always dereference
pointers to implicit pointer types so that afterwards we can set the
    appropriate corresponding class type

git-svn-id: branches/jvmbackend@18668 -
2011-08-20 08:22:52 +00:00
Jonas Maebe
6cced31157 * treat conversions involving arrays of sets also as pointer conversions
git-svn-id: branches/jvmbackend@18667 -
2011-08-20 08:22:47 +00:00
Jonas Maebe
94be1980b4 * fixed type conversions between signed and unsigned ordinals of the same
size when stored in memory

git-svn-id: branches/jvmbackend@18666 -
2011-08-20 08:22:42 +00:00
Jonas Maebe
37aa2d8443 + full support for sets on the JVM target
o sets of enums are handled as JUEnumSet instances, others as JUBitSet
     derivatives (both smallsets and varsets, to make interoperability with
     Java easier)
   o special handling of set constants: these have to be constructed at run
     time. In case of constants in the code, create an internal constsym to
     represent them. These and regular constsyms are then aliased by an
     another internal staticvarsym that is used to initialise them in the
     unit initialisation code.
   o until they are constructed at run time, set constants are encoded as
     constant Java strings (with the characters containing the set bits)
   o hlcgobj conversion of tcginnode.pass_generate_code() for the genjumps
     part (that's the only part of the generic code that's used by the JVM
     target)
   o as far as explicit typecasting support is concerned, currently the
     following ones are supported (both from/to setdefs): ordinal types,
     enums, any other set types (whose size is the same on native targets)
   o enum setdefs also emit signatures
   o overloading routines for different ordinal set types, or for different
     enum set types, is not supported on the JVM target

git-svn-id: branches/jvmbackend@18662 -
2011-08-20 08:22:22 +00:00
Jonas Maebe
67a142c56e * fixed dereferencing pointers to JVM implicit pointer types in case the
pointer was in a register (has to be put into memory, because otherwise
    the compiler thinks that the entire type is stored in a register instead
    of only its address)

git-svn-id: branches/jvmbackend@18659 -
2011-08-20 08:22:05 +00:00
Jonas Maebe
956d63da9e * only treat Java interfaces and classes as equivalent to classdefs rather
than any objectdef

git-svn-id: branches/jvmbackend@18656 -
2011-08-20 08:21:49 +00:00
Jonas Maebe
625f52b7e4 * make sure that int->int conversions are handled by the generic code
* handle class->interface conversions by JVM-specific code

git-svn-id: branches/jvmbackend@18655 -
2011-08-20 08:21:44 +00:00
Jonas Maebe
67ce687683 * don't keep the original location in case of 2->4 byte ordinal type
conversions because the sign may not be correct in case the value comes
    from Java code

git-svn-id: branches/jvmbackend@18654 -
2011-08-20 08:21:39 +00:00
Jonas Maebe
40fdc62e74 + support for automatically converting char/widechar to java.lang.String
git-svn-id: branches/jvmbackend@18653 -
2011-08-20 08:21:34 +00:00
Jonas Maebe
5ad5a6f326 * small optimization for g_getarraylen
git-svn-id: branches/jvmbackend@18648 -
2011-08-20 08:21:10 +00:00
Jonas Maebe
cfe125198c * always return true from tjvmnodeutils.force_init(), because when this
routine is called we don't know yet whether it has to be forced or not
    for the JVM target (staticvarsyms that need initialization may still be
    created during pass1 of the main program/unit code)

git-svn-id: branches/jvmbackend@18646 -
2011-08-20 08:21:01 +00:00
Jonas Maebe
2376003cd0 * wrap the init/finalization code even when it is implicitly generated
* only wrap the init/finalization code after the main program has been
    completely processed (pass1, codegen), because this may influence
    the required wrapping in case of the JVM target
  * replace periods with slashes in the package name when constructing
    the classes corresponding to the units (to execute their initialization
    code) -- didn't notice this was wrong previously because due to the
    incomplete wrapping, they were never being initialized until now

git-svn-id: branches/jvmbackend@18645 -
2011-08-20 08:20:56 +00:00
Jonas Maebe
bc21708967 * again use areturn instead of ireturn for returning enums since they're
classes now

git-svn-id: branches/jvmbackend@18631 -
2011-08-20 08:16:52 +00:00
Jonas Maebe
460c7a519b * also handle tc_int_2_int,tc_int_2_bool,tc_bool_2_int in
target_specific_general_typeconv() for enum type conversions

git-svn-id: branches/jvmbackend@18628 -
2011-08-20 08:16:37 +00:00
Jonas Maebe
6f2b7ca830 * never use the target_specific_explicit_typeconv() code for non-tc_equal
type conversions (those are/can be intercepted in the specific handlers)

git-svn-id: branches/jvmbackend@18623 -
2011-08-20 08:16:09 +00:00
Jonas Maebe
325b5cae6b * fixed int_to_int conversion for larger->smaller types in mem locations
(cannot reuse the memory location on the JVM)
  * optimized int_to_int conversions for certain smaller->larger types
    in mem locations (can reuse the memory location on the JVM, because
    stack locations are always at least 4 bytes)

git-svn-id: branches/jvmbackend@18622 -
2011-08-20 08:16:04 +00:00
Jonas Maebe
bf2854dae5 * when internally taking the address of shortstrings to typecast
them to shortstringclass, make sure the address operator is
    "typed" so that we don't insert useless checkcast instructions

git-svn-id: branches/jvmbackend@18621 -
2011-08-20 08:15:59 +00:00
Jonas Maebe
569228447d * converted all enum handling for the JVM target so that it uses the
JDK class-style enums rather than plain ordinals like in Pascal
   o for Pascal code, nothing changes, except that for the JVM target
     you can always typecast any enum into a class instance (to interface
     with the JDK)
   o to Java programs, FPC enums look exactly like Java enum types

git-svn-id: branches/jvmbackend@18620 -
2011-08-20 08:15:54 +00:00
Jonas Maebe
d64f5d14d6 * fixed compilation with -dnounsupported
git-svn-id: branches/jvmbackend@18619 -
2011-08-20 08:15:48 +00:00
Jonas Maebe
b0d777e16b * keep dynamic array -> open array type conversion nodes for the JVM target,
so that the result type of random dynamic array expressions doesn't suddenly
    get changed into open array (causes internalerror if the size is requested),
    and instead simply change the conversion type to tc_equal

git-svn-id: branches/jvmbackend@18605 -
2011-08-20 08:14:30 +00:00
Jonas Maebe
887248af2d * support var/out managed types on the callee side in location_get_data_ref()
git-svn-id: branches/jvmbackend@18604 -
2011-08-20 08:14:26 +00:00
Jonas Maebe
7e6261ff55 * fixed return opcode for enums and smallsets
git-svn-id: branches/jvmbackend@18603 -
2011-08-20 08:14:21 +00:00
Jonas Maebe
f3f378496f * fixed memory leaks
git-svn-id: branches/jvmbackend@18598 -
2011-08-20 08:13:55 +00:00
Jonas Maebe
ce88df680b + symansistr conditional define that, when activated, makes the symbol/
mangled name handling ansistring rather than pshortstring based (required
    for JVM target; little effect on speed, some extra memory usage)

git-svn-id: branches/jvmbackend@18597 -
2011-08-20 08:13:50 +00:00
Jonas Maebe
d0a3b49e6c * fixed memory leak
git-svn-id: branches/jvmbackend@18595 -
2011-08-20 08:13:36 +00:00
Jonas Maebe
7cf06b9aa6 * fixed accessing var-parameters from nested routines
o support for JVM arrays in JVM addrnodes and derefnodes (so we
     can take the address of var parameters to store them in the
     parentfpstruct and later dereference them)
   o process loadnode.left also in tjvmloadnode.pass_generate_code() when
     handling var-parameters

git-svn-id: branches/jvmbackend@18593 -
2011-08-20 08:13:27 +00:00
Jonas Maebe
23e4405c78 * copyout parameters also have to return "true" for is_addr_param_load()
git-svn-id: branches/jvmbackend@18592 -
2011-08-20 08:13:21 +00:00
Jonas Maebe
4be0ba267a * moved creating block/statement for reference temps into
maybereplacewithtempref() helper

git-svn-id: branches/jvmbackend@18591 -
2011-08-20 08:13:16 +00:00
Jonas Maebe
8fa42c206f + support for nested procedures for the JVM target
o since the JVM target has no stack/framepointer that can be passed
     on to nested routines, all local variables and parameters accessed
     from nested routines are grouped into a local record whose address
     is passed to nested routines. The same technique is also required
     for LLVM in the future

git-svn-id: branches/jvmbackend@18588 -
2011-08-20 08:12:59 +00:00
Jonas Maebe
0fad10179c * fixed some voidpointerdef handling
git-svn-id: branches/jvmbackend@18584 -
2011-08-20 08:12:39 +00:00
Jonas Maebe
528882dc68 * allow typeconversions of formaldef to anything else (make sure to
transform into an as-node when converting into a class/array type)

git-svn-id: branches/jvmbackend@18580 -
2011-08-20 08:12:20 +00:00
Jonas Maebe
c995e56370 * internalerror if constructor not found in record
git-svn-id: branches/jvmbackend@18579 -
2011-08-20 08:12:15 +00:00
Jonas Maebe
8ec21eb426 * fixed flow control handling in case of empty try-blocks and in case of
no default exception catching block

git-svn-id: branches/jvmbackend@18576 -
2011-08-20 08:11:59 +00:00
Jonas Maebe
0706cb5eb6 + support for pointers to types that are implicit pointer types in the JVM
(non-dynamic arrays, records, shortstrings)
  - removed the ability to typecast such types directly into related class
    types, you have to use the @-operator first now to get a pointer to
    the type
   o updated the RTL and internal compiler code to properly use this
     new convention
   o allowed removing several special cases from
     tjvmtypeconvnode.target_specific_general_typeconv(), and that
     method can probably be removed completely over time
  * no longer give compile time errors for pointer-related typecasts that
    will fail at run time, because the checking was too complex and could
    be worked around via actual pointer typecasts anyway
  * removed some unnecessary checkcast operations (for shortstring/
    shortstringclass)

git-svn-id: branches/jvmbackend@18574 -
2011-08-20 08:11:49 +00:00
Jonas Maebe
207a4a32d3 * internalerror in case a stringdef manages to get through to
tjvmvecnode.pass_generate_code() (should be handled earlier)

git-svn-id: branches/jvmbackend@18573 -
2011-08-20 08:11:43 +00:00
Jonas Maebe
6857dde33e + shortstring support for the JVM target (including accessing character 0 as
the "length byte")

git-svn-id: branches/jvmbackend@18570 -
2011-08-20 08:11:28 +00:00
Jonas Maebe
eb40756d35 * zero-extend byte/word field loads (get/putstatic sign-extends)
* move the incstack() from a load before the potential "and" to
    zero-extend, so that the maximum stack height get calculated
    properly

git-svn-id: branches/jvmbackend@18565 -
2011-08-20 08:11:03 +00:00
Jonas Maebe
6374b473ff * convert string constants passed to JLString to unicode
git-svn-id: branches/jvmbackend@18563 -
2011-08-20 08:10:46 +00:00
Jonas Maebe
446d91eaab + ansistring support. Items of note:
o support for ansistring constants. It's done via a detour because the
      JVM only supports UTF-16 string constants (no array of byte or anything
      like that): store every ansicharacter in the lower 8 bits of an
      UTF-16 constant string, and at run time copy the characters to an
      ansistring. The alternative is to generate code that stores every
      character separately to an array.
    o the base ansistring support is implemented in a class called
      AnsistringClass, and an ansistring is simply an instance of this
      class under the hood
    o the compiler currently does generate nil pointers as empty
      ansistrings unlike for unicodestrings, where we always
      explicitly generate an empty string. The reason is that
      unicodestrings are the same as JLString and hence common
      for Java interoperation, while ansistrings are unlikely to
      be used in interaction with external Java code

  * fixed indentation

git-svn-id: branches/jvmbackend@18562 -
2011-08-20 08:10:39 +00:00
Jonas Maebe
aa1f299a17 + added hook for "individual value to open array of one element"-conversion,
so it can be intercepted by the JVM backend (it has to create an actual
    array)
  + JVM support for the elem_2_open_array hook

git-svn-id: branches/jvmbackend@18561 -
2011-08-20 08:10:31 +00:00
Jonas Maebe
b370314194 * fixed typecasting to/from classrefdef
git-svn-id: branches/jvmbackend@18558 -
2011-08-20 08:10:16 +00:00
Jonas Maebe
84640fe7f0 + support for non-static class methods on the JVM target
git-svn-id: branches/jvmbackend@18557 -
2011-08-20 08:10:11 +00:00
Jonas Maebe
9de14768bb * free temp location allocated for function result if not used
* don't free function result space on stack twice if the result
    is not used but a the same time has already been stored in a
    temporary funcretnode location

git-svn-id: branches/jvmbackend@18556 -
2011-08-20 08:10:05 +00:00
Jonas Maebe
704753d3e8 * change the resultdef of nf_load_procvar typeconversion nodes from
voidpointerdef to java_jlobject (they're generated by generic code
    in nmem; avoids an ifdef for the jvm target there)

git-svn-id: branches/jvmbackend@18554 -
2011-08-20 08:09:55 +00:00
Jonas Maebe
58d7a86252 + stubbed formal const/var/out support
git-svn-id: branches/jvmbackend@18552 -
2011-08-20 08:09:45 +00:00
Jonas Maebe
2ed430de8c * refactored and fixed procvar typeconversion checking
git-svn-id: branches/jvmbackend@18550 -
2011-08-20 08:09:35 +00:00
Jonas Maebe
d74aef86b4 - removed a useless condition in the check to determine whether or not
we have to generate an as-node for a type conversion

git-svn-id: branches/jvmbackend@18549 -
2011-08-20 08:09:31 +00:00
Jonas Maebe
f187128428 * allow addrnodes for procdef (and procvardef in TP/Delphi mode), and
for JVM implicit pointer types (-> JLObject)

git-svn-id: branches/jvmbackend@18547 -
2011-08-20 08:09:21 +00:00
Jonas Maebe
17db9ed895 * allow some more valid type conversions
git-svn-id: branches/jvmbackend@18546 -
2011-08-20 08:09:16 +00:00
Jonas Maebe
54bb881a1b * print an error for invalid type conversions
git-svn-id: branches/jvmbackend@18544 -
2011-08-20 08:09:05 +00:00
Jonas Maebe
63962043a5 * fixed fake nested procedures support
git-svn-id: branches/jvmbackend@18543 -
2011-08-20 08:09:00 +00:00
Jonas Maebe
000c502c9c + fake shortstring temp support
git-svn-id: branches/jvmbackend@18542 -
2011-08-20 08:08:54 +00:00
Jonas Maebe
1c1fe26ebd * refactored isstringconv/isrecordconv
* fixed checking of array element compatibility (also have to check
    for both strings/records)

git-svn-id: branches/jvmbackend@18541 -
2011-08-20 08:08:49 +00:00
Jonas Maebe
4dfdcfd139 * fixed uninitialised var-parameters in isstringconv
git-svn-id: branches/jvmbackend@18539 -
2011-08-20 08:08:39 +00:00
Jonas Maebe
bdb6cf5561 * fixed uninitialised var-parameters in isrecordconv
git-svn-id: branches/jvmbackend@18538 -
2011-08-20 08:08:34 +00:00
Jonas Maebe
1795eff237 + support for emiting "signature" attributes for fields and methods; these
are JVM annotations used by Java's generics support. They cannot be used
    for FPC's generics support, but they are useful in other cases
  * emit classrefdefs as java.lang.Class, with a signature annotation that
    indicates which class they actually refer to

git-svn-id: branches/jvmbackend@18534 -
2011-08-20 08:08:00 +00:00
Jonas Maebe
4298992619 * fixed checkcast operations for unicodestrings: replace the definition
with java_jlstring in that case, because we have to insert the type
    without L prefix and ; suffix for that opcode (which is not done for
    objectdefs/recorddefs)

git-svn-id: branches/jvmbackend@18530 -
2011-08-20 08:07:40 +00:00
Jonas Maebe
b8f6c42ec7 * don't insert checkcast operations for types that are considered to be
te_equal

git-svn-id: branches/jvmbackend@18529 -
2011-08-20 08:07:35 +00:00
Jonas Maebe
e8ec2c45af * fixed invokeinterface usage: must also specify the number of stack
slots used by the call

git-svn-id: branches/jvmbackend@18528 -
2011-08-20 08:07:30 +00:00
Jonas Maebe
c9537e3347 + support for non-array/record var parameter on the JVM target using
copy-in/out

git-svn-id: branches/jvmbackend@18527 -
2011-08-20 08:07:24 +00:00
Jonas Maebe
e7eb34e3a6 * make current_except_loc also valid while processing the default exception
block, since it can contain an anonymous "raise" statement to reraise
    the exception

git-svn-id: branches/jvmbackend@18526 -
2011-08-20 08:07:17 +00:00
Jonas Maebe
845f50448c + support for qword div/mod via helper (the JVM only supports signed
64 bit division natively)

git-svn-id: branches/jvmbackend@18523 -
2011-08-20 08:07:02 +00:00
Jonas Maebe
be1ff9ff92 * fixed handling of OP_SHL,OP_SHR,OP_SAR in op_ref_stack (second operand
is always a 32 bit int)

git-svn-id: branches/jvmbackend@18522 -
2011-08-20 08:06:57 +00:00
Jonas Maebe
2bb13723ae * don't use raw bitcasts for tc_int_2_real type conversions
git-svn-id: branches/jvmbackend@18521 -
2011-08-20 08:06:49 +00:00
Jonas Maebe
3e5b70d80d * cpu64bitaddr -> cpu64bitalu check to determine whether we need special
handling for 64 add-nodes
  * call the generic ordinal handler for 64 add nodes on the JVM

git-svn-id: branches/jvmbackend@18518 -
2011-08-20 08:06:35 +00:00
Jonas Maebe
6e0b73ad88 * handle string/jlstring/jlobject typecasts properly again after the reworked
typeconversion handling
  + support for class reference types in the JVM (although without class virtual
    methods, they're not that useful)

git-svn-id: branches/jvmbackend@18516 -
2011-08-20 08:06:25 +00:00
Jonas Maebe
10a7532968 * differentiate between typecasts on the assignment side or not, because we
cannot insert typecasting checks on the assignment side, only on the
    values that are being assigned
   o since valid_for_assignment() is called in tassignmentnode.typecheckpass()
     after typecheckpassing left and right, moved the conversion of the
     typecheck nodes into JVM-specific constructs from typecheckpass to
     pass_1, so that they can use the information whether they are on
     the assignment side or not
  * forbid casting a child type to a parent type on the assignment side on
    managed platforms, because that circumvents the type checking

git-svn-id: branches/jvmbackend@18515 -
2011-08-20 08:06:20 +00:00
Jonas Maebe
77707a447e * fixed fake ansistring length() support
git-svn-id: branches/jvmbackend@18514 -
2011-08-20 08:06:14 +00:00
Jonas Maebe
80a63197e3 + support for unaryminus for the JVM target (integer via generic code, float
JVM-specific code)

git-svn-id: branches/jvmbackend@18512 -
2011-08-20 08:06:05 +00:00
Jonas Maebe
f764a72d85 * fixed evaluation stack height count for OP_NEG and non-64 bit opertions
git-svn-id: branches/jvmbackend@18511 -
2011-08-20 08:06:00 +00:00
Jonas Maebe
694ccf3df3 + dummy support for untyped var/const/out parameters on the JVM target
o includes basic "auto-boxing" infrastructure to support Delphi.NET-
     compatible untyped parameters as described at
     http://hallvards.blogspot.com/2007/10/dn4dp24-net-vs-win32-untyped-parameters.html

git-svn-id: branches/jvmbackend@18510 -
2011-08-20 08:05:54 +00:00
Jonas Maebe
3259eae110 * fixed typecasting checks from/to arrays of records
git-svn-id: branches/jvmbackend@18508 -
2011-08-20 08:05:43 +00:00
Jonas Maebe
739c654e3a + support for main programs for the JVM target
o moved several routines from pmodules to ngenutil and overrode them
     in njvmutil (for unit initialisation tables, resource strings, ...)
   o force the evaluation stack size to at least 1 for the main program,
     because the unit initialisation triggers are inserted there afterwards
     and they require one stack slot

git-svn-id: branches/jvmbackend@18507 -
2011-08-20 08:05:38 +00:00
Jonas Maebe
e775e2d9ae * moved gen_entry_code/gen_exit_code from ncgutil to hlcgobj,
and overrode both with empty stubs for the JVM

git-svn-id: branches/jvmbackend@18506 -
2011-08-20 08:05:33 +00:00
Jonas Maebe
f20e347c7e * dummy support for copying arrays of variant/set
git-svn-id: branches/jvmbackend@18505 -
2011-08-20 08:05:28 +00:00
Jonas Maebe
7a5d334951 + support for copy(dynarray)
git-svn-id: branches/jvmbackend@18504 -
2011-08-20 08:05:23 +00:00
Jonas Maebe
ecba07c6a8 * greatly simplified dynamic array handling by making use of the
java.lang.reflect functionality

git-svn-id: branches/jvmbackend@18503 -
2011-08-20 08:05:17 +00:00
Jonas Maebe
c75246706d + stubbed ansistring support (using ansistrings compiles, but does not
generate working code)

git-svn-id: branches/jvmbackend@18499 -
2011-08-20 08:04:57 +00:00
Jonas Maebe
d1a1d30e04 * unless compiled with -dnounsupported, the compiler will now accept not
only JVM constructs that are already implemented, but also ones that
    will be supported in the future but that aren't implemented yet (to
    make it easier to already adapt code to the future changes)

git-svn-id: branches/jvmbackend@18498 -
2011-08-20 08:04:51 +00:00
Jonas Maebe
4491dafd48 * exit once we've found a target-specific handler for a type
conversion node so later checks won't try to further convert it

git-svn-id: branches/jvmbackend@18497 -
2011-08-20 08:04:45 +00:00
Jonas Maebe
a729201e37 * map normal sets to R_ADDRESSREGISTER
git-svn-id: branches/jvmbackend@18496 -
2011-08-20 08:04:40 +00:00
Jonas Maebe
99177a75fb * tprocdef -> tabstractprocdef typecasts so the code will also work
when calling procvars is supported

git-svn-id: branches/jvmbackend@18495 -
2011-08-20 08:04:35 +00:00
Jonas Maebe
8649788b7f * typecast the argument and result type of the setlength() helper to
the types as declared in the system unit, since they can also be
    used with equivalent but different types (e.g., byte vs shortint)

git-svn-id: branches/jvmbackend@18487 -
2011-08-20 08:03:56 +00:00
Jonas Maebe
5b915178fa + support for deep copy of array of strings
git-svn-id: branches/jvmbackend@18477 -
2011-08-20 08:03:09 +00:00
Jonas Maebe
43c5ed20c2 + support for initialising typed constants via compiler-generated
assignment-nodes. For global typed constants and typed constants/
    local variable initialisers in regular functions/procedurs, the
    assignments are performed in the unit initialisation code. For
    those in object/record definitions and their methods, it's done
    in the class constructor. Since we may not yet have parsed all
    method implementations when the class constructor is parsed, part
    of these may be initialised in a helper routine called from the
    class constructor. The ones known when the class constructor is
    parsed are inited there, because the ones marked as "final" and
    declared as static class fields must be initialised in the class
    constructor for Java
   o new set systems_typed_constants_node_init in systems unit that
     indicates that a target uses node trees to initialise typed consts
     instead of an initialised data section
   o mark typed constants in {$j-} mode as "final" for JVM
   o mangle the name of staticvarsyms inside localtables a bit to avoid
     name clashes (only with procedure names for now, no parameters yet
     so can still cause problems with overloaded routines)
   o after a routine has been parsed, it is now processed by
     cnodeutils.wrap_proc_body(), which can add extra nodes before code
     generation (used for injected the typed constant node trees)

git-svn-id: branches/jvmbackend@18475 -
2011-08-20 08:02:58 +00:00
Jonas Maebe
91855becfe + unicodestring support for the JVM target (except for multiple adds
in a single statement, to be added later)
   o the unicodestrings are internally simply java.lang.String instances
   o at the language level, the unicodestrings are assignment-compatible
     with java.lang.String
   o constant strings can be implicitly converted to java.lang.String
   o since java.lang.String is immutable, in particular changing a
     single character in a string is extremely inefficient. This could
     be solved by letting unicodestring map to java.lang.StringBuilder,
     but that would make integration with plain Java code harder

git-svn-id: branches/jvmbackend@18470 -
2011-08-20 08:02:33 +00:00
Jonas Maebe
bf21cd7a15 + support for (non-variant) arrayconstructornodes for the JVM target
o when allocating array temps for the JVM target, use the specified
     "forcesize" for the first dimension, since the arraydef size may
     be invalid (e.g., in case it's an array constructor)

git-svn-id: branches/jvmbackend@18468 -
2011-08-20 08:02:22 +00:00
Jonas Maebe
d13769204e * check for a tclassrefdef as the target conversion type in
asis_target_specific_typecheck, and if so get the real
    definition of its pointedtype rather than of the classrefdef
    itself (the latter would never be different from the original
    one, since there are no formal external classrefdef definitions)

git-svn-id: branches/jvmbackend@18467 -
2011-08-20 08:02:17 +00:00
Jonas Maebe
e663f0f31f + support for class constructors for the JVM target
o initialise class vars that need initialisations (records, arrays) in
     class constructors
   o treat class constructors as having a "void" resultdef rather than the
     class type for JVM (maybe has to be done in general?)
   o make it possible to specify pno_noleadingdollar to
     tprocdef.customprocname() so it can be used for class constructors
     (their name is lower cased because it mustn't conflict with other
      identifiers, since their name doesn't matter anyway)
   o added tsk_empty synthetic procdef kind which, as the name implies,
     generates an empty body (for class generated constructors)
  + auto-generate class constructors in case a class has class vars that
    need initialisation

git-svn-id: branches/jvmbackend@18462 -
2011-08-20 08:01:51 +00:00
Jonas Maebe
c264c24fb0 + support for unit initialisation sections for the JVM target,
and initialise global variables that are wrapped (records, arrays)
    in those sections
   o check whether pd.localst is assigned in dbgjasm, because it's
     not for the unit initialisation routine
   o moved insertbssdata() from ncgutil to ngenutil and override it
     njvmutil (it does nothing in the latter, since global variables
     are added as fields to the class representing the unit; the
     initialisation is done in gen_initialize_code() in thlcgjvm)
   o added force_init() and force_final() methods to ngenutil, so
     that targets can force init/final routines separate from the
     regular managed types infrastructure (used by JVM for forcing
     an init section in case of records/arrays)

git-svn-id: branches/jvmbackend@18460 -
2011-08-20 08:01:39 +00:00
Jonas Maebe
d79160a6af * correctly handle explicit typecasts between records and jlobject/
fpcbaserecordtype for the JVM target (intercept in ncnv via new
    target_specific_general_typeconv helper, handle in as/is code)
  * not only check for related types in htypechk in case they are
    objdefs, but always do so (records are related to jlobject/fpcbaserecord
    on the JVM target)

git-svn-id: branches/jvmbackend@18458 -
2011-08-20 08:01:29 +00:00
Jonas Maebe
cc6a303ee2 * allocate/initialize implicit pointer type fields (arrays, records) in
JVM classes after calling the inherited constructor (before doing
    so, self is not yet valid)

git-svn-id: branches/jvmbackend@18456 -
2011-08-20 08:01:24 +00:00
Jonas Maebe
a5af71a8d8 * don't remove regalloc/regdealloc pair if it's immediately followed by a
use of the register (can happen if the register is unused afterwards;
    remove the alloc/dealloc results in no temp being allocated for the
    register, so that instruction becomes invalid)

git-svn-id: branches/jvmbackend@18455 -
2011-08-20 08:01:19 +00:00
Jonas Maebe
da064b0ad6 * changed trgcpu.do_spill_replace_all() from a function (that doesn't set
its function result) into a procedure

git-svn-id: branches/jvmbackend@18454 -
2011-08-20 08:01:15 +00:00