Commit Graph

65 Commits

Author SHA1 Message Date
pierre
441b9feffc pass new asm extra opt using -ao option
git-svn-id: trunk@26540 -
2014-01-21 00:16:53 +00:00
Jonas Maebe
7cf8bcd7eb * initialise dollarsign field of jasmin tasminfo
git-svn-id: trunk@22805 -
2012-10-21 17:56:16 +00:00
Jonas Maebe
9feee08eba * mark Java inner interfaces as "static abstract" like javac, solves the
"Illegal class modifiers in class SomeClass 0x209" when implementing
    such interfaces in code compiled by Eclipse's internal compiler

git-svn-id: trunk@22272 -
2012-08-30 22:30:32 +00:00
Jonas Maebe
b6db767ac4 * fixed uninitialized TJasminAssembler.ConstAssignmentValue() function result
git-svn-id: trunk@22126 -
2012-08-19 13:54:28 +00:00
Jonas Maebe
9c0ec8ee8c * part of r21120, forgot to commit
git-svn-id: trunk@21128 -
2012-04-29 22:27:05 +00:00
Jonas Maebe
14cfe770a4 * replaced most (if not all) remaining fields/parameters in the compiler
that deal with paths/filenames with TPathStr (= ansistring) to prevent
    cutting off long paths (no change in speed when compiling the compiler,
    1% extra memory usage)

git-svn-id: trunk@21120 -
2012-04-29 17:36:23 +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
c9f19d710b * fixed writing ".implements" directives for implemented nested interfaces
git-svn-id: branches/jvmbackend@19866 -
2011-12-17 16:49:50 +00:00
Jonas Maebe
0d5b2b84a8 + Android/JVM target, including a translation of the Android r14 SDK
(= Android 4.0) java headers: java.*, javax.*, org.*, junit.*, android.*).
    The RTL can also be used to target earlier versions of the Android
    platform, but you manually have to take care of not using APIs that
    weren't available yet. Adding separate units for separate platform
    versions would only partly solve the problem, because some of the
    classes used inside the system unit have also changed across
    versions.

    Use -Tandroid while compiling to select the Android OS as target
    platform.

git-svn-id: branches/jvmbackend@19830 -
2011-12-12 02:34:34 +00:00
Jonas Maebe
0418766417 * properly delete all generated .j files in case -a is not used
(previously, only the .j file for the unit itself was deleted,
     and the ones for classes/interfaces remained behind)

git-svn-id: branches/jvmbackend@19750 -
2011-12-04 15:43:41 +00:00
Jonas Maebe
8bca3e9b0b * don't mark nested interfaces as "static", only do so for classes
(static interfaces don't exist)

git-svn-id: branches/jvmbackend@19556 -
2011-10-28 21:19:16 +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
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
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
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
b8286c729a * always write constant values as signed values, since the JVM does not support
unsigned values (and Jasmin therefore extends them to the next larger size
    if they become too big)

git-svn-id: branches/jvmbackend@18686 -
2011-08-20 08:24:34 +00:00
Jonas Maebe
1b1face692 * fixed signature in enum class header (missed L-prefix)
git-svn-id: branches/jvmbackend@18663 -
2011-08-20 08:22:28 +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
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
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
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
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
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
9a6ab55c97 * correctly handle "class fields" in record definitions
git-svn-id: branches/jvmbackend@18610 -
2011-08-20 08:14:55 +00:00
Jonas Maebe
52b62732e2 * mark classes representing records as final
* mark sealed classes as final
  * mark "final" fields as final

git-svn-id: branches/jvmbackend@18609 -
2011-08-20 08:14:50 +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
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
8248e6762f * support opcode+operands > 255 characters (e.g. when loading string constants)
git-svn-id: branches/jvmbackend@18560 -
2011-08-20 08:10:26 +00:00
Jonas Maebe
0fa1c9bbdd * escape #127 under all circumstances (it's not printable)
git-svn-id: branches/jvmbackend@18559 -
2011-08-20 08:10:21 +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
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
f75a5895d8 * fixed crash for global constants after previous change
git-svn-id: branches/jvmbackend@18525 -
2011-08-20 08:07:12 +00:00
Jonas Maebe
a6e196bfd6 * don't write local constants of procedures, because their names may clash
(the JVM doesn't have a concept of local constants, so they were made
     global)

git-svn-id: branches/jvmbackend@18524 -
2011-08-20 08:07:07 +00:00
Jonas Maebe
bd69e52451 * fixed writing string constants > 255 characters
git-svn-id: branches/jvmbackend@18517 -
2011-08-20 08:06:30 +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
1c54d3a758 * fixed handling of static varsyms used for typed constants
* also print staticvarsyms inside localsymtables of procdefs
    (used for typed constants and variable initialisers)

git-svn-id: branches/jvmbackend@18473 -
2011-08-20 08:02:48 +00:00
Jonas Maebe
7eef5e1c74 * don't mark compiler-generated routines as "synthetic", because that
makes them uncallable from actual Java code (javac hides them), which
    is not the idea (otherwise you can't e.g. create record types in Java)

git-svn-id: branches/jvmbackend@18459 -
2011-08-20 08:01:33 +00:00
Jonas Maebe
40e0b4677a + support for (only named, for now) records in the JVM target:
implemented via classes, all descending from system.FpcBaseRecordType
    (records are also considered to be "related" to system.FpcBaseRecordType
     on the JVM target)
  * several routines are auto-generated for all record-classes: apart
    from a default constructor (if there is none), also clone (which
    returns a new instance containing a deep copy of the current
    instance) and deepCopy (which copies all fields of one instance
    into another one)
   o added new field "synthetickind" to tprocdef that indicates what
     kind of synthetically generated method it is (if any), and
     mark such methods also as "synthetic" in the JVM assembler code
   o split off the JVM-specific parser code (e.g., to add default
     constructors) into pjvm.pas

git-svn-id: branches/jvmbackend@18450 -
2011-08-20 08:00:50 +00:00
Jonas Maebe
2514c4ddb1 * mark classes representing units as "final", since you're not supposed to
descend from them

git-svn-id: branches/jvmbackend@18446 -
2011-08-20 08:00:18 +00:00
Jonas Maebe
a6a60e3e26 * also mark all non-virtual methods as "final" (since regular methods
don't exist in Java)

git-svn-id: branches/jvmbackend@18440 -
2011-08-20 07:59:45 +00:00
Jonas Maebe
0700e2d7ef + support for {$namespace x.y.z} directive to specify the namespace
for the current unit and all types/routines declared in it. The
    unit itself becomes a member of this namespace as well, so in
    case it's called unit1, it will be x.y.z.unit1, and type tclass
    declared in it will be x.y.z.tclass. Only used for the JVM
    target currently

git-svn-id: branches/jvmbackend@18436 -
2011-08-20 07:59:26 +00:00
Jonas Maebe
1aac04a639 * mark classes that represent units, and classes declared in the interface
of a unit, as public (the rest has "package" visibility)

git-svn-id: branches/jvmbackend@18435 -
2011-08-20 07:59:21 +00:00
Jonas Maebe
20e55cd54e * mark unit-level routines as "final", since they can't be overridden
git-svn-id: branches/jvmbackend@18434 -
2011-08-20 07:59:17 +00:00
Jonas Maebe
6b176351e1 * removed jvmdef.jvminternalstaticfieldname() and now use newly created
symsym.internal_static_field_name() on all platforms to construct
    the internal (hidden) name of class fields

git-svn-id: branches/jvmbackend@18397 -
2011-08-20 07:56:13 +00:00
Jonas Maebe
121a141953 + support for final methods in Java classes
git-svn-id: branches/jvmbackend@18394 -
2011-08-20 07:55:55 +00:00
Jonas Maebe
8f2aacfed5 + support for (formal/untyped) constants (ordinal, floating point,
nil-pointers typecasted to a class type, strings)
   o escape ", \, #10 and #13 in string constants as required by Java

git-svn-id: branches/jvmbackend@18391 -
2011-08-20 07:55:41 +00:00