Commit Graph

34961 Commits

Author SHA1 Message Date
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
9ebf623895 + tcallnode.createinternmethod() constructor to easily call methods
(both instance and class/static methods)

git-svn-id: branches/jvmbackend@18661 -
2011-08-20 08:22:15 +00:00
Jonas Maebe
c387bc0c27 * allow overriding first_IncludeExclude
git-svn-id: branches/jvmbackend@18660 -
2011-08-20 08:22:10 +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
51095fdd28 * make it possible to override parts of the typed constant code generation
by platform-specific units

git-svn-id: branches/jvmbackend@18658 -
2011-08-20 08:21:59 +00:00
Jonas Maebe
402390a25d * same extension as other files
git-svn-id: branches/jvmbackend@18657 -
2011-08-20 08:21:54 +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
4af73c0c51 + also support sp_internal for constsyms (mark them as "synthetic")
git-svn-id: branches/jvmbackend@18652 -
2011-08-20 08:21:29 +00:00
Jonas Maebe
5ea497857d + FpcEnumValueObtainable interface that's implemented by all FPC
enums (for use in set factory helpers)

git-svn-id: branches/jvmbackend@18651 -
2011-08-20 08:21:24 +00:00
Jonas Maebe
386136ba7c * declare enumclass "values" method as "static" (necessary so that the JVM
recognises the class as a proper enum class)

git-svn-id: branches/jvmbackend@18650 -
2011-08-20 08:21:19 +00:00
Jonas Maebe
112d17af84 + support for local enum types (defined in procedures), by stuffing their
corresponding classes into the global symtable ("local classes" don't
    exist/work)

git-svn-id: branches/jvmbackend@18649 -
2011-08-20 08:21:15 +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
b65422cd59 * make sure that the real name of enums is not replaced by the alias
typesyms we create

git-svn-id: branches/jvmbackend@18647 -
2011-08-20 08:21:05 +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
466f6751c8 + getpointerdef() function that returns a pointerdef for the passed def.
Multiple calls to getpointerdef() for the same def in a single module
    return the same pointerdef

git-svn-id: branches/jvmbackend@18644 -
2011-08-20 08:20:51 +00:00
Jonas Maebe
9d4162d840 * ifdefed jvmdef usage
git-svn-id: branches/jvmbackend@18643 -
2011-08-20 08:20:43 +00:00
Jonas Maebe
ae554ba1d3 * ifdefed pjvm usage
git-svn-id: branches/jvmbackend@18642 -
2011-08-20 08:20:38 +00:00
Jonas Maebe
ec33f745a2 * ifdefed jvmdef usage
git-svn-id: branches/jvmbackend@18641 -
2011-08-20 08:20:33 +00:00
Jonas Maebe
bd9e0b1a45 * ifdefed pjvm usage
git-svn-id: branches/jvmbackend@18640 -
2011-08-20 08:20:28 +00:00
Jonas Maebe
93ddf11143 * ifdefed pjvm usage
git-svn-id: branches/jvmbackend@18639 -
2011-08-20 08:20:23 +00:00
Jonas Maebe
75e259e426 * ifdef'ed jvmdef/pjvm usage for jvm target
git-svn-id: branches/jvmbackend@18638 -
2011-08-20 08:20:18 +00:00
Jonas Maebe
e534a17c01 - removed unused scanner.tscannerstate, inserttext_begin and inserttext_end
(leftovers from the initial symcreat implementations that didn't work)

git-svn-id: branches/jvmbackend@18637 -
2011-08-20 08:20:13 +00:00
Jonas Maebe
90d82ad826 * fixed unit reloading after the addition of the def field to tcgpara
as used in the function return location (and loading in case of
    an explicit para location)

git-svn-id: branches/jvmbackend@18636 -
2011-08-20 08:17:17 +00:00
Jonas Maebe
6154f1b0d9 * keep track of the number of abstract methods per class via a counter
* use this counter to mark classes containing abstract methods as
    "abstract" in the bytecode per the JVM spec
  * also use the counter to short-circuit printing of all abstract
    methods in a class when creating a new instance (we build the list
    of abstract methods every time a new instance is created, which is
    a waste of time if there are none in the first place)

git-svn-id: branches/jvmbackend@18635 -
2011-08-20 08:17:12 +00:00
Jonas Maebe
92fbbcff88 * also write definitions for abstract methods
* write "abstract" modifier for abstract classes

git-svn-id: branches/jvmbackend@18634 -
2011-08-20 08:17:07 +00:00
Jonas Maebe
390bf35b52 * skip the funcretsym in tprocdef.getcopy in case it's in the localst,
because in that case it will be inserted while parsing the body
    (instead of giving an internalerror)

git-svn-id: branches/jvmbackend@18633 -
2011-08-20 08:17:01 +00:00
Jonas Maebe
1ad834f5f9 * in case a property uses a getter/setter with lower visibility than the
property, generate a wrapper with the same visibility as the property
    that calls through to the original getter/setter (JVM target only:
    ensures that the JVM verifier doesn't complain about calling methods
    that are not visible to the current class when using such properties
    from other units/classes)

git-svn-id: branches/jvmbackend@18632 -
2011-08-20 08:16: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
a3bd8cb0ba * correctly add an extra [ to the type of call-by-reference parameters that
are translated into arrays by the compiler (for the debug information)

git-svn-id: branches/jvmbackend@18630 -
2011-08-20 08:16:47 +00:00
Jonas Maebe
b50bd9534d * name nestedfpstruct types so they can no longer be confused with names of
nested classes by e.G. the bcel bytecode verification library

git-svn-id: branches/jvmbackend@18629 -
2011-08-20 08:16:42 +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
815ab863b6 * fixed external name for inner classes (must not contain the name for
the outer class)
  * migrated some types that will be required for set support from jdk15
    to java_sys

git-svn-id: branches/jvmbackend@18627 -
2011-08-20 08:16:30 +00:00
Jonas Maebe
f59a2b38bf + string conversion for oo_is_enum_class
git-svn-id: branches/jvmbackend@18626 -
2011-08-20 08:16:24 +00:00
Jonas Maebe
94a4e1e069 + string version of vis_none
git-svn-id: branches/jvmbackend@18625 -
2011-08-20 08:16:19 +00:00
Jonas Maebe
622ac7184c * fixed string length for varspez strings
git-svn-id: branches/jvmbackend@18624 -
2011-08-20 08:16:14 +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
297f3d087d * don't write field definitions for varsyms marked as external
git-svn-id: branches/jvmbackend@18618 -
2011-08-20 08:15:43 +00:00
Jonas Maebe
1c3f0c7a2f * also wrap the initcode of main programs, so that typed constants get
initialized there as well for systems_typed_constants_node_init

git-svn-id: branches/jvmbackend@18617 -
2011-08-20 08:15:39 +00:00
Jonas Maebe
13b0ac91d9 + generate java.lang.Enum descendant classes for Pascal enum types
o these classes get an "enum" flag in the class files
   o these classes get a class field (whose type is that same enum
     class) per enum in the type, which also gets the "enum" flag
   o those class fields are initialised in the class constructor
     with the name of the enum and their order in the declaration
   o if the enum has jumps in FPC (lowest value is not 0, or not
     all values are contiguous), then we add an extra field
     to hold the FPC ordinal value of the enum
   o these classes get a class field valled $VALUES that contains
     a reference to the aforementioned class fields in order of
     declaration (= ordinal->instance mapping, JDK-mandated)
   o apart from the JDK-mandated instance methods (values, valueOf),
     also add FPCOrdinal (returns FPC ordinal value; same as order
     of declaration in case of no jumps) instance method and FPCValueOf
     (returns enum corresponding to FPC ordinal value) static class
     method
   o the mapping between FPC ordinals and enum instances in case of
     jumps is stored in a hashmap whose size is the next prime number
     greater or equal than the number of enum elements
   o moved several extra JDK types to the system unit for the enum
     support, and for future boxing and Java set support
   o several new synthetic method identifiers to generate the enum class
     methods/constructor/class constructor
   o enums with jumps are ordered by FPC ordinal value in the JVM
     $VALUES array so that the java.lang.Enum.doCompare() method
     will properly compare them

git-svn-id: branches/jvmbackend@18616 -
2011-08-20 08:15:28 +00:00
Jonas Maebe
d0b1bfa52d * mark sp_internal fields as "synthetic"
* don't mark class var fields as sp_internal (since they're user-visible)

git-svn-id: branches/jvmbackend@18615 -
2011-08-20 08:15:20 +00:00
Jonas Maebe
30478a14b6 + new vis_none visibility specifier that can be used as "neutral"
* make it possible to force the visibility of added constructors
    in add_missing_parent_constructors_intf() to a particular
    setting (use vis_none to keep the visibility of the inherited
    constructor)

git-svn-id: branches/jvmbackend@18614 -
2011-08-20 08:15:15 +00:00
Jonas Maebe
1302017b21 + support class variables in propaccesslist_to_node() (use regular loadn,
no subscriptn)

git-svn-id: branches/jvmbackend@18613 -
2011-08-20 08:15:10 +00:00