Commit Graph

34802 Commits

Author SHA1 Message Date
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
6c35ea202b + added several reflection classes for use in array processing
git-svn-id: branches/jvmbackend@18502 -
2011-08-20 08:05:12 +00:00
Jonas Maebe
49de6346ce * replaced manual array copy loops with calls to JLSystem.arraycopy(); still
separate helper per array element type because there is no generic array
    type, and we need to get the length of the arrays

git-svn-id: branches/jvmbackend@18501 -
2011-08-20 08:05:07 +00:00
Jonas Maebe
622107c605 * moved support for copy() from pinline to ninl, so it can be (partially)
overridden for targets that require it

git-svn-id: branches/jvmbackend@18500 -
2011-08-20 08:05:02 +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
fab08ca975 * allow classrefdef declarations for java classes (not yet properly
handled though)

git-svn-id: branches/jvmbackend@18494 -
2011-08-20 08:04:30 +00:00
Jonas Maebe
f2374ce24d * save block_type before creating a temporary scanner and restore afterwards,
because creating a new scanner sets the block_type back to bt_general
    (while we want to inject something in the current context)

git-svn-id: branches/jvmbackend@18493 -
2011-08-20 08:04:25 +00:00
Jonas Maebe
be92f47cc7 * don't simply replace the resultdef of typeconverted nodes if the new
and old def have a different deftype (see added comment why)

git-svn-id: branches/jvmbackend@18492 -
2011-08-20 08:04:21 +00:00
Jonas Maebe
df7100ff80 + support for anonymous record types for the JVM targets: automatically
generate a name and typesym for them

git-svn-id: branches/jvmbackend@18491 -
2011-08-20 08:04:16 +00:00
Jonas Maebe
4c0849a592 * fixed fpc_unicodestr_compare_equal (has to return 0 in case of
equality, not 1)

git-svn-id: branches/jvmbackend@18490 -
2011-08-20 08:04:11 +00:00
Jonas Maebe
1daff40e8e * fixed subscripting records containing unicodestrings and other
traditionally reference-counted types on the JVM target

git-svn-id: branches/jvmbackend@18489 -
2011-08-20 08:04:06 +00:00
Jonas Maebe
f27ebf8b6d + explicitly add constructors of parent class that do not appear in the
current class, since constructors are not automatically inherited in
    Java
   o tprocdef.getcopy() implementation, which returns an (unfinished) copy
     of a tprocdef. Finalise by calling symcreat.finish_copied_procdef()
   o made it possible to specify an existing procdef as argument to
     read_proc(), in which case it won't try to parse a procedure declaration,
     but only a body and associate it with the passed procdef. This is
     required for the inherited constructor support, since we cannot generate
     a textual representation of inherited constructors that is guaranteed to
     parse in the context of the current unit (e.g., if they use types from
     a unit that is not in the uses clause of the current unit)
   o folded tprocsym.find_procdef_bypara_no_rettype() into
     Tprocsym.Find_procdef_bypara, by interpreting specifying nil as
     retdef as not having to check the return def (required to compare
     parent constructors with child constructors to see whether they
     match, since the returndef will always be the current class type)

git-svn-id: branches/jvmbackend@18488 -
2011-08-20 08:04:01 +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
11fbd8d9a4 + support properties in Java classes & interfaces
git-svn-id: branches/jvmbackend@18486 -
2011-08-20 08:03:52 +00:00
Jonas Maebe
ee9cfc8916 * handle constsyms without an associated type by generating a default type
git-svn-id: branches/jvmbackend@18485 -
2011-08-20 08:03:47 +00:00
Jonas Maebe
41624e8102 * pd.owner.defowner -> pd.struct
git-svn-id: branches/jvmbackend@18484 -
2011-08-20 08:03:42 +00:00
Jonas Maebe
1b401399a4 * pd.owner.defowner -> pd.struct
git-svn-id: branches/jvmbackend@18483 -
2011-08-20 08:03:38 +00:00
Jonas Maebe
834ea45be8 * (class_)constructor/destructor_head() now also parses hints,
handles modifiers and adds the procdefinition. This code was
    duplicated in several places (for objects and records)
  * properly handle introducing artificial class constructors
    (the manually constructed procdefs were wrong, now use
     str_parse_method_dec)

git-svn-id: branches/jvmbackend@18482 -
2011-08-20 08:03:33 +00:00
Jonas Maebe
474b7446ad * set isclassmethod also for class constructors/destructors in
implement_empty()

git-svn-id: branches/jvmbackend@18481 -
2011-08-20 08:03:28 +00:00
Jonas Maebe
33bd3d7aa9 * set isclassmethod also for class constructors/destructors in
implement_anon_inherited()

git-svn-id: branches/jvmbackend@18480 -
2011-08-20 08:03:23 +00:00
Jonas Maebe
990a4ccb64 - disabled genmultistringadd() for the JVM target for now
git-svn-id: branches/jvmbackend@18479 -
2011-08-20 08:03:19 +00:00
Jonas Maebe
2964ea3e9b * don't generate typed constant initializers for interfaces (since they
can't have class constructors)

git-svn-id: branches/jvmbackend@18478 -
2011-08-20 08:03:14 +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
23539dcfaf * only call add_synthetic_method_implementations() for the localst after
parsing a routine if the localst is in fact a localsymtable, otherwise
    they can be generated twice for for the staticsymtable (the localst
    of the init/final code of a unit is the staticsymtable)

git-svn-id: branches/jvmbackend@18476 -
2011-08-20 08:03:03 +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
91e06f7139 * also process nested records/objects when generating implementations
for synthetic methods

git-svn-id: branches/jvmbackend@18474 -
2011-08-20 08:02:52 +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
fa841f8011 * migrated most typed constant parsing code to separate methods so
that the actual generation of the data can be overridden

git-svn-id: branches/jvmbackend@18472 -
2011-08-20 08:02:43 +00:00
Jonas Maebe
d248b5992e * moved most code from ptconst to ngtcon; it will be generalised so
it can either generate an asmlist containing data definitions (like
    it does now), or a node tree with explicit initialisation statements
    (for the JVM target)

git-svn-id: branches/jvmbackend@18471 -
2011-08-20 08:02:38 +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
d759598c70 * set the namespace of the system unit to org.freepascal.rtl
git-svn-id: branches/jvmbackend@18469 -
2011-08-20 08:02:27 +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
03af03e696 * changed TObject from an alias for JLObject into a derived class from
JLObject with the method "Free" and a virtual destructor "Destroy"
    (and Free is automatically called from the "finalize" method,
     which in turn is called by the JVM when the instance is collected;
     note that there is no final collection before the JVM shuts down,
     so it may never be called if you don't call Free explicitly yourself)
  * if you don't specify an explicit ancestor for a Java class, set
    the parent to TObject instead of to JLObject (for better compatibility
    with regular Pascal code)

git-svn-id: branches/jvmbackend@18466 -
2011-08-20 08:02:12 +00:00
Jonas Maebe
00df370d36 * don't give an internalerror when adding a constructor to a Java
class (by default it will never be called either though)

git-svn-id: branches/jvmbackend@18465 -
2011-08-20 08:02:06 +00:00
Jonas Maebe
d6a56cfda6 * change the realname of procsyms belonging to overriding methods to
that of the overridden method for Java classes, since the realname
    is used as method identifier (and overriding is name-based and
    case-sensitive in Java)

git-svn-id: branches/jvmbackend@18464 -
2011-08-20 08:02:02 +00:00
Jonas Maebe
7310bbbaf6 * set import_lib to current namespace (if any) for records
git-svn-id: branches/jvmbackend@18463 -
2011-08-20 08:01:56 +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
6bcf796f8b * get the real objectdef before checking whether it's equal to
java_jlobject/java_fpcbaserecordtype in trecorddef.is_related()
    (could be a formal external definition)

git-svn-id: branches/jvmbackend@18461 -
2011-08-20 08:01:46 +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
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
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
Jonas Maebe
89e70f347c * do nothing for initialising temps in advance for the JVM target as that
happens automatically when required (for constructing arrays/records;
    reference counted types don't need special treatment since everything
    is garbage collected)

git-svn-id: branches/jvmbackend@18453 -
2011-08-20 08:01:10 +00:00