Commit Graph

35071 Commits

Author SHA1 Message Date
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
144ba2a2ad * enabled (generic) fpc_pchar_length() and fpc_pwidechar_length()
git-svn-id: branches/jvmbackend@18771 -
2011-08-20 08:34:31 +00:00
Jonas Maebe
1a23a7cd27 * removed all remaining nounsupported ifdefs (except for the one about
variants)

git-svn-id: branches/jvmbackend@18770 -
2011-08-20 08:34:26 +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
27f2edea57 + pchar -> short/ansi/unicodestring support
git-svn-id: branches/jvmbackend@18767 -
2011-08-20 08:34:11 +00:00
Jonas Maebe
1ff004312b * null-terminate ansistrings like on native platforms (so support
can be added to typecast them to pchars)
  * fixed array-of-char to ansistring conversion in case of zero-based
    array and an embedded #0 (didn't stop at the embedded #0)

git-svn-id: branches/jvmbackend@18766 -
2011-08-20 08:34:05 +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
549e51fdfa * uncommented a bunch of pointer types
git-svn-id: branches/jvmbackend@18764 -
2011-08-20 08:33:54 +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
6d0dd347ba * declare procvar constructors as "overload" so that the implicitly added
parameterless constructor can also be found from Delphi mode

git-svn-id: branches/jvmbackend@18758 -
2011-08-20 08:33:24 +00:00
Jonas Maebe
c648cade1a * prevent internal errors when calling location_force_mem() for
dynamic or open arrays on the JVM target

git-svn-id: branches/jvmbackend@18757 -
2011-08-20 08:33:20 +00:00
Jonas Maebe
eb8ba875db * set the node complexity of stringconstn and setconstn to 1 rather than
respectively to 0 and 255 (both generally require one memory load);
    the setconstn complexity of 255 also caused the node cse to replace
    them with temprefn in some cases, which wreaked havoc with the JVM
    practice of determining whether in-expressions can be handled by
    the generic code generator or not

git-svn-id: branches/jvmbackend@18756 -
2011-08-20 08:33:10 +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
48710a5a3f * print the owning class/record of internally generated methods when
parsing their implementation if -vd is specified

git-svn-id: branches/jvmbackend@18754 -
2011-08-20 08:32:57 +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
0b7b6361fe * ignore methods that are added for the purpose of the JVM (inherited
constructors, inherited virtual class methods) when deciding which
    overloaded version of a routine to call. Otherwise they can change
    which variant is called compared to code on platforms where such
    implicit methods are not added

git-svn-id: branches/jvmbackend@18752 -
2011-08-20 08:32:47 +00:00
Jonas Maebe
a73d5b6da7 * only set the assignmentside flag for typeconversion nodes in
valid_for_assign() if that routine returns true (in some cases,
    it's used to simply check whether we could possibly put it on
    the assignment side)

git-svn-id: branches/jvmbackend@18751 -
2011-08-20 08:32:41 +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
851cb65021 * activate code to remove unnecessary widenings to 64 bit in case
cpu64bitaddr is not defined rather than if cpu64bitalu is not
    defined, because whether or not operations should be 64 bit by
    default depends on cpu64bitaddr, and even if a cpu can perform
    64 bit alu operations, 32 bit ones are likely faster

git-svn-id: branches/jvmbackend@18748 -
2011-08-20 08:32:26 +00:00
Jonas Maebe
d48fa1d7e2 * for all managed VM targets, reject ord->ptr typecasts (except for 0),
typeof(), typeinfo(), seg(), ofs(), settextbuf(), slice(), resourcestring,
    new(), dispose()

git-svn-id: branches/jvmbackend@18747 -
2011-08-20 08:32:21 +00:00
Jonas Maebe
8a95a04e16 * extracted dynarray helpers from system unit into jdynarr.inc (were
in the system unit for easier debugging)
  * disabled a bunch more feature flags by default for the JVM target
  * incorporate modified version of inc/systemh.inc (split into two parts:
    jsystemh_types.inc and jsystemh.inc, because some of the types are
    required for the declaration of the shortstring/ansistring/set/...
    classes, which in turn are required for the routine declarations) and
    inc/system.inc (as jsystem.inc)
   o moved some routines around from old to new locations based on where
     they appear in the common files
   o added a number of defines that allow skipping more common implementations
     in case a platform-specific one is already available
  * all base classes (AnsistringClass etc) are now descendants of
    JLObject rather than TObject, because their declaration is now parsed
    before TObject is known (and there's no need for them to inherit from
    TObject)
  * incorporate modified version of inc/system.inc
  * use the common version of generic.inc, currh.inc, gencurr.inc and
    genmath.inc (with small modification to those files)
  + addition of quite a bit of system unit functionality (halt, runerror,
    random, round, str() for integer types, abs, odd, endian swapping helpers,
    bit scanning, trigonometric functions, ln, exp, ...)
   o round()/trunc() for comp-types has been renamed trunc_comp() on the
     JVM target because their JVM signature conflicts with trunc(currency)
   o the unsigned versions of swapendian() and other endian helpers are not
     available on the JVM target because of JVM signature conflicts

git-svn-id: branches/jvmbackend@18746 -
2011-08-20 08:32:13 +00:00
Jonas Maebe
1418faf854 * converted tcginlinenode.second_abs_long() to hlcgobj
git-svn-id: branches/jvmbackend@18745 -
2011-08-20 08:32:05 +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
27c004807f * typecast the indices generated for array constants in the node-based
typed constant parser to the rangedef of the array (can be an enum,
    char, etc)

git-svn-id: branches/jvmbackend@18743 -
2011-08-20 08:31:41 +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
48d63f2c75 * when taking the address of an expression for a with-statement, make
it a typed address to prevent unnecessary checkcast instructions
    on the JVM target

git-svn-id: branches/jvmbackend@18740 -
2011-08-20 08:30:57 +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
084c76119b * use unsigned type for unsigned comparison
git-svn-id: branches/jvmbackend@18738 -
2011-08-20 08:30:26 +00:00
Jonas Maebe
a216707cf2 * also generate wrappers for inherited virtual class methods, because their
visibility can change. However, simply call the inherited version in
    those rather than re-adding the complete dispatching code again

git-svn-id: branches/jvmbackend@18737 -
2011-08-20 08:30:15 +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
6fe124507e * fixed calling procvars with copyout parameters
git-svn-id: branches/jvmbackend@18733 -
2011-08-20 08:29:24 +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
c7f6ee94e6 * always get the real class definition before writing out a mangled name
git-svn-id: branches/jvmbackend@18731 -
2011-08-20 08:28:57 +00:00
Jonas Maebe
441787672d * migrated java.lang.NoSuchMethodException to java_sys.inc
* catch java.lang.NoSuchMethodException exceptions when resolving a procvar,
    because java.lang.Class.getDeclaredMethod() only searches that particular
    class itself and not its parents -> in case we get the address of a method
    that's not overridden in the current class, also search the parent classes

git-svn-id: branches/jvmbackend@18730 -
2011-08-20 08:28:45 +00:00
Jonas Maebe
2338463a4b * don't mark non-virtual class methods automatically as "final"
git-svn-id: branches/jvmbackend@18729 -
2011-08-20 08:28:30 +00:00
Jonas Maebe
13d68da2be * translated Pascal 'protected' also in JVM 'protected', because 'protected'
in the JVM means "accessible to subclasses *and* to classes in the same
    package" (and all classes in the same unit are by definition also in the
    same package) -- before, such fields were declared as "package" which means
    that they could not be accessed by subclasses in other packages

git-svn-id: branches/jvmbackend@18728 -
2011-08-20 08:28:17 +00:00
Jonas Maebe
3791f0de1c * fixed mangled name of JVM class vars with an external name in case their
type is a forward-defined class whose full definition hasn't been parsed
    yet and if the full definition changes the external name of the class

git-svn-id: branches/jvmbackend@18727 -
2011-08-20 08:28:09 +00:00
Jonas Maebe
9bdcb1d7e5 * also write the stativarsym section information when symansistr is defined
git-svn-id: branches/jvmbackend@18726 -
2011-08-20 08:28:04 +00:00
Jonas Maebe
b59df3f2fd * reparsed with new version of javapp that doesn't mark final static
methods as "virtual" anymore (since they're not virtual, and the
    compiler now handles virtual class methods differently)

git-svn-id: branches/jvmbackend@18725 -
2011-08-20 08:27:59 +00:00
Jonas Maebe
df5fc421ce + support for increasing the visibility of fields using properties
on the JVM target (at the Pascal level), by automatically generating
    getters/setters of the same visibility as the property that are used
    instead of directly accessing the fields when translating the property

git-svn-id: branches/jvmbackend@18724 -
2011-08-20 08:27:53 +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