Commit Graph

35039 Commits

Author SHA1 Message Date
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
Jonas Maebe
1c74072748 * moved handle_staticfield_access() from pexpr to nutils so it can
be reused elsewhere
  * moved check_hints() from htypechk to symsym (so it can be called
    from nutils, and it's also more about symbols than about types)

git-svn-id: branches/jvmbackend@18722 -
2011-08-20 08:27:42 +00:00
Jonas Maebe
dbe55d1f6f * only override "clone" for records that contain fields that require a
deep copy, and for those records no longer call the inherited clone.
    Instead, declare a local variable of the record type, assign its
    address to the function and then copy all field contents to this local
    variable. Since it's dynamically allocated at the JVM level, it will
    survive the function exit.

    The problem with calling the inherited clone function is that it will
    copy the pointers of the implicit pointer fields (records, sets, …)
    from the old to the new instance, and that we (currently) have no way
    at the Pascal level to change those and make them point to new
    instances.

git-svn-id: branches/jvmbackend@18721 -
2011-08-20 08:27:37 +00:00
Jonas Maebe
e7528bbc05 * allow non-virtual class methods to be declared as "final" in Java classes,
since virtual class methods are handled differently from regular ones and
    the JDK contains several (non-virtual, since Java does not support virtual
    class methods) final class methods

git-svn-id: branches/jvmbackend@18720 -
2011-08-20 08:27:32 +00:00
Jonas Maebe
7092f2957a * use deep copies rather than cloning when copying array contents
(since the elements in the destination array are guaranteed to
     exist already)

git-svn-id: branches/jvmbackend@18719 -
2011-08-20 08:27:27 +00:00
Jonas Maebe
3ac950eed7 * changed the parameter of fpcDeepCopy() from an out-parameter of the
actual recordtype into FpcBaseRecordType so we can also use
    the deep copy routine in the RTL
  + added abstract fpcDeepCopy() declaration to FpcBaseRecordType class

git-svn-id: branches/jvmbackend@18718 -
2011-08-20 08:27:22 +00:00
Jonas Maebe
469bda2710 * fixed ShortStringClass.toString() (skipped last char) and also use it
in ShortStringClass.toUnicodeString()

git-svn-id: branches/jvmbackend@18717 -
2011-08-20 08:27:16 +00:00
Jonas Maebe
d583243fbb * only generate the dispatch wrapper for virtual class methods and virtual
constructors in the base class that defines them, rather than also in
    every class that overrides them (since the dispatch routine is the same
    everywhere)

git-svn-id: branches/jvmbackend@18716 -
2011-08-20 08:27:11 +00:00
Jonas Maebe
ad871b6acd * automatically generate versions of inherited virtual class methods that
call through to the parent method in case they are not overridden in
    the child class, because otherwise the dynamic dispatch fails (looking
    up a class method only checks that particular class, since they are
    never virtual in Java and hence not inherited either)

git-svn-id: branches/jvmbackend@18715 -
2011-08-20 08:27:07 +00:00
Jonas Maebe
57c7e21d8f * support propagating a function result (if any) from functions called
via tsk_anon_inherited synthetic functions

git-svn-id: branches/jvmbackend@18714 -
2011-08-20 08:27:02 +00:00
Jonas Maebe
18310034d7 * never allow hiding an inherited virtual class method or virtual constructor
by a non-virtual classmethod/constructor on the JVM target, because they
    would also be picked up by the dynamic dispatch

git-svn-id: branches/jvmbackend@18713 -
2011-08-20 08:26:57 +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
ddf6591f7f + support "reintroduce" for Java classes. Although in most cases this won't
work because you cannot start new inheritance trees, it can work under some
    circumstances if the parameters are not exact. In case there is a problem,
    this will be detected later by TVMTBuilder.is_new_vmt_entry().

git-svn-id: branches/jvmbackend@18711 -
2011-08-20 08:26:46 +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
e38cfc307b * renamed pc_procvar2bareproc to pc_bareproc, and allow it also to
be used to create bare procdef->procdef copy

git-svn-id: branches/jvmbackend@18709 -
2011-08-20 08:26:35 +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
e9d27c3efe * mark copied virtual parent constructors as "override"
git-svn-id: branches/jvmbackend@18707 -
2011-08-20 08:26:26 +00:00
Jonas Maebe
f20e206849 * make compatible_childmethod_resultdef() also work for Java classes
(so that you can override a method in a child class with one that
     returns a descendent of the original return type -- since the JVM
     will always select the version with the most specific return type,
     that even corresponds perfectly to standard JVM behaviour)

git-svn-id: branches/jvmbackend@18706 -
2011-08-20 08:26:21 +00:00
Jonas Maebe
3eb588cca7 * some improvements to replace_scanner():
o also save/restore orgpattern (and restore pattern) when saving/restoring
     the scanner state, since it's used by e.g. the _INTCONST token
   o also bail out on _CWCHAR and _CWSTRING tokens, since that requires saving
     the scanner widestring state

git-svn-id: branches/jvmbackend@18705 -
2011-08-20 08:26:16 +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
1ac7146182 * synchronised code of fpc_ansistr_to_chararray() with
fpc_shortstr_to_chararray()
  * same for fpc_unicodestr_to_chararray() + fixes

git-svn-id: branches/jvmbackend@18702 -
2011-08-20 08:26:00 +00:00
Jonas Maebe
02f443ce68 * support source/destinationshortstrings of different length in
ShortStringClass.FpcDeepCopy (can happen when copying value
    parameters like string[4] into local storage in case a string
    longer than 4 characters was passed)
  * create chararray of the correct maximum length when constructing
    a chararray from a constant string
  * don't pass invalid ranges to JLArrays.fill() when padding a
    chararray after filling it using the contents of shortstring

git-svn-id: branches/jvmbackend@18701 -
2011-08-20 08:25:54 +00:00
Jonas Maebe
5a1bca3b75 * small optimization
git-svn-id: branches/jvmbackend@18700 -
2011-08-20 08:25:49 +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
478a0376e3 * make sure that wrapped methods for property accesses are added to the
symtable of the current structdef

git-svn-id: branches/jvmbackend@18696 -
2011-08-20 08:25:29 +00:00
Jonas Maebe
ee75bfaaf4 * change non-virtual instance methods to "virtual; final;" methods on the
JVM target, because that's the only way to guarantee their semantics on
    that platform (see comments in pdecobj)
  * allow starting new inheritance trees (which is the same as adding a new
    non-virtual method as of this revision) on the JVM target in case the
    parameters of the new routine match the old one, but the complete mangled
    name does not (because then the JVM won't consider them to be the same
    either -> Pascal semantics are matched)

git-svn-id: branches/jvmbackend@18695 -
2011-08-20 08:25:24 +00:00
Jonas Maebe
4074bf412b - removed po_java procoption, since it wasn't really used for anything
git-svn-id: branches/jvmbackend@18694 -
2011-08-20 08:25:19 +00:00
Jonas Maebe
7e7bdc3c55 * make the real name of methods implementing interface methods the same as
as the real name of the declaration in the interface, so that the JVM
    case-sensitive mapping works out
  * process the interface mappings for the compiler-constructed classes for
    enums and procvars

git-svn-id: branches/jvmbackend@18693 -
2011-08-20 08:25:14 +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
4363a0633e * use procdef.defid instead of procdef.procsym.symid to make local typed
constant names unique, since the symid is the same for overloads

git-svn-id: branches/jvmbackend@18691 -
2011-08-20 08:25:03 +00:00