Commit Graph

13027 Commits

Author SHA1 Message Date
Jonas Maebe
16cb75a5da * also free the regular code generator when freeing the hl code generator
git-svn-id: branches/jvmbackend@18600 -
2011-08-20 08:14:05 +00:00
Jonas Maebe
4c6388df6f * fixed memory leaks when ending a macro
git-svn-id: branches/jvmbackend@18599 -
2011-08-20 08:14:00 +00:00
Jonas Maebe
f3f378496f * fixed memory leaks
git-svn-id: branches/jvmbackend@18598 -
2011-08-20 08:13:55 +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
54f96997b9 + support for JVM additions and some other fixes
git-svn-id: branches/jvmbackend@18596 -
2011-08-20 08:13:44 +00:00
Jonas Maebe
d0a3b49e6c * fixed memory leak
git-svn-id: branches/jvmbackend@18595 -
2011-08-20 08:13:36 +00:00
Jonas Maebe
f1652a6c87 * copy dispid in tprocdef.getcopy()
git-svn-id: branches/jvmbackend@18594 -
2011-08-20 08:13:31 +00:00
Jonas Maebe
7cf06b9aa6 * fixed accessing var-parameters from nested routines
o support for JVM arrays in JVM addrnodes and derefnodes (so we
     can take the address of var parameters to store them in the
     parentfpstruct and later dereference them)
   o process loadnode.left also in tjvmloadnode.pass_generate_code() when
     handling var-parameters

git-svn-id: branches/jvmbackend@18593 -
2011-08-20 08:13:27 +00:00
Jonas Maebe
23e4405c78 * copyout parameters also have to return "true" for is_addr_param_load()
git-svn-id: branches/jvmbackend@18592 -
2011-08-20 08:13:21 +00:00
Jonas Maebe
4be0ba267a * moved creating block/statement for reference temps into
maybereplacewithtempref() helper

git-svn-id: branches/jvmbackend@18591 -
2011-08-20 08:13:16 +00:00
Jonas Maebe
ad6ae44093 * force mode objfpc for synthetic method implementations (to guarantee
that e.g. "out" and &-escaping are possible)

git-svn-id: branches/jvmbackend@18590 -
2011-08-20 08:13:11 +00:00
Jonas Maebe
4fbc1b5369 * better internal names for anonymous records (can't use characters that
are not valid for Pascal identifiers though, because the names are used
    in auto-generated source code)

git-svn-id: branches/jvmbackend@18589 -
2011-08-20 08:13:05 +00:00
Jonas Maebe
8fa42c206f + support for nested procedures for the JVM target
o since the JVM target has no stack/framepointer that can be passed
     on to nested routines, all local variables and parameters accessed
     from nested routines are grouped into a local record whose address
     is passed to nested routines. The same technique is also required
     for LLVM in the future

git-svn-id: branches/jvmbackend@18588 -
2011-08-20 08:12:59 +00:00
Jonas Maebe
874095a1c0 * don't skip pushing self parameters for methods of empty structures
git-svn-id: branches/jvmbackend@18587 -
2011-08-20 08:12:53 +00:00
Jonas Maebe
00086c3dfc * don't give an internalerror when encountering an invalid type while
creating procdef's JVM mangled name, because this situation can also
    arise in case there's a simple error in the source code

git-svn-id: branches/jvmbackend@18586 -
2011-08-20 08:12:48 +00:00
Jonas Maebe
9d0fdb3150 * explicitly specify symtable to jvm_guarantee_record_typesym() instead of
hardcoding symtablestack.top

git-svn-id: branches/jvmbackend@18585 -
2011-08-20 08:12:43 +00:00
Jonas Maebe
0fad10179c * fixed some voidpointerdef handling
git-svn-id: branches/jvmbackend@18584 -
2011-08-20 08:12:39 +00:00
Jonas Maebe
ba5e264a93 * make the mangled names of symbols in the local scope of
procedures/functions/methods on the JVM platform unique

git-svn-id: branches/jvmbackend@18583 -
2011-08-20 08:12:34 +00:00
Jonas Maebe
1bc846dd3c + TSymtablestack.getcopyuntil() method that creates a copy of a
symtablestack up to and including a particular symtable

git-svn-id: branches/jvmbackend@18582 -
2011-08-20 08:12:29 +00:00
Jonas Maebe
e9e72e6de0 * fixed copyright date
git-svn-id: branches/jvmbackend@18581 -
2011-08-20 08:12:24 +00:00
Jonas Maebe
528882dc68 * allow typeconversions of formaldef to anything else (make sure to
transform into an as-node when converting into a class/array type)

git-svn-id: branches/jvmbackend@18580 -
2011-08-20 08:12:20 +00:00
Jonas Maebe
c995e56370 * internalerror if constructor not found in record
git-svn-id: branches/jvmbackend@18579 -
2011-08-20 08:12:15 +00:00
Jonas Maebe
223057f1a7 + support for is/as and Java interfaces
git-svn-id: branches/jvmbackend@18578 -
2011-08-20 08:12:09 +00:00
Jonas Maebe
225e866800 - removed superfluous check that could use uninitialized location
git-svn-id: branches/jvmbackend@18577 -
2011-08-20 08:12:04 +00:00
Jonas Maebe
8ec21eb426 * fixed flow control handling in case of empty try-blocks and in case of
no default exception catching block

git-svn-id: branches/jvmbackend@18576 -
2011-08-20 08:11:59 +00:00
Jonas Maebe
1dca48bce5 * set reused left node to nil for JVM loadvmtaddrnodes that need to call a
helper
  * never call a helper for classrefdefs (in that case we have to load the
    classrefdef itself, not the classrefdef for the class representing
    classrefdefs)

git-svn-id: branches/jvmbackend@18575 -
2011-08-20 08:11:54 +00:00
Jonas Maebe
0706cb5eb6 + support for pointers to types that are implicit pointer types in the JVM
(non-dynamic arrays, records, shortstrings)
  - removed the ability to typecast such types directly into related class
    types, you have to use the @-operator first now to get a pointer to
    the type
   o updated the RTL and internal compiler code to properly use this
     new convention
   o allowed removing several special cases from
     tjvmtypeconvnode.target_specific_general_typeconv(), and that
     method can probably be removed completely over time
  * no longer give compile time errors for pointer-related typecasts that
    will fail at run time, because the checking was too complex and could
    be worked around via actual pointer typecasts anyway
  * removed some unnecessary checkcast operations (for shortstring/
    shortstringclass)

git-svn-id: branches/jvmbackend@18574 -
2011-08-20 08:11:49 +00:00
Jonas Maebe
207a4a32d3 * internalerror in case a stringdef manages to get through to
tjvmvecnode.pass_generate_code() (should be handled earlier)

git-svn-id: branches/jvmbackend@18573 -
2011-08-20 08:11:43 +00:00
Jonas Maebe
564b8a2cf7 - removed "{$ifdef unsupported}" block for jvm (is handled in njvmmem
already)

git-svn-id: branches/jvmbackend@18572 -
2011-08-20 08:11:38 +00:00
Jonas Maebe
71cd31159c * encode java_jlstring instead of using a hardcoded string constant for
the type encoding of unicodestring

git-svn-id: branches/jvmbackend@18571 -
2011-08-20 08:11:33 +00:00
Jonas Maebe
6857dde33e + shortstring support for the JVM target (including accessing character 0 as
the "length byte")

git-svn-id: branches/jvmbackend@18570 -
2011-08-20 08:11:28 +00:00
Jonas Maebe
eb40756d35 * zero-extend byte/word field loads (get/putstatic sign-extends)
* move the incstack() from a load before the potential "and" to
    zero-extend, so that the maximum stack height get calculated
    properly

git-svn-id: branches/jvmbackend@18565 -
2011-08-20 08:11:03 +00:00
Jonas Maebe
6374b473ff * convert string constants passed to JLString to unicode
git-svn-id: branches/jvmbackend@18563 -
2011-08-20 08:10:46 +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
aa1f299a17 + added hook for "individual value to open array of one element"-conversion,
so it can be intercepted by the JVM backend (it has to create an actual
    array)
  + JVM support for the elem_2_open_array hook

git-svn-id: branches/jvmbackend@18561 -
2011-08-20 08:10:31 +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
b370314194 * fixed typecasting to/from classrefdef
git-svn-id: branches/jvmbackend@18558 -
2011-08-20 08:10:16 +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
9de14768bb * free temp location allocated for function result if not used
* don't free function result space on stack twice if the result
    is not used but a the same time has already been stored in a
    temporary funcretnode location

git-svn-id: branches/jvmbackend@18556 -
2011-08-20 08:10:05 +00:00
Jonas Maebe
60f8254d63 * don't internalerror when converting to an open array and passing as
var/out parameter (these conversions are replaced by another
    construct on non-JVM targets, so didn't cause a problem there)

git-svn-id: branches/jvmbackend@18555 -
2011-08-20 08:10:00 +00:00
Jonas Maebe
704753d3e8 * change the resultdef of nf_load_procvar typeconversion nodes from
voidpointerdef to java_jlobject (they're generated by generic code
    in nmem; avoids an ifdef for the jvm target there)

git-svn-id: branches/jvmbackend@18554 -
2011-08-20 08:09:55 +00:00
Jonas Maebe
aaff356c6d * moved $methodpointer type construction from psystem to pdecobj for JVM,
because java_jlobject needs to be available

git-svn-id: branches/jvmbackend@18553 -
2011-08-20 08:09:50 +00:00
Jonas Maebe
58d7a86252 + stubbed formal const/var/out support
git-svn-id: branches/jvmbackend@18552 -
2011-08-20 08:09:45 +00:00
Jonas Maebe
d7e78b9f95 * correct parameter encoding of formaldef (add array type for formal const,
remove double array type for formal var/out)

git-svn-id: branches/jvmbackend@18551 -
2011-08-20 08:09:40 +00:00
Jonas Maebe
2ed430de8c * refactored and fixed procvar typeconversion checking
git-svn-id: branches/jvmbackend@18550 -
2011-08-20 08:09:35 +00:00
Jonas Maebe
d74aef86b4 - removed a useless condition in the check to determine whether or not
we have to generate an as-node for a type conversion

git-svn-id: branches/jvmbackend@18549 -
2011-08-20 08:09:31 +00:00
Jonas Maebe
1b0b6a9d6d * also print method implementation when reusing a forward definition
git-svn-id: branches/jvmbackend@18548 -
2011-08-20 08:09:26 +00:00
Jonas Maebe
f187128428 * allow addrnodes for procdef (and procvardef in TP/Delphi mode), and
for JVM implicit pointer types (-> JLObject)

git-svn-id: branches/jvmbackend@18547 -
2011-08-20 08:09:21 +00:00
Jonas Maebe
17db9ed895 * allow some more valid type conversions
git-svn-id: branches/jvmbackend@18546 -
2011-08-20 08:09:16 +00:00
Jonas Maebe
b60e50b2b0 - reverted 679f3968901f0d565644d59e046eb25d5402f027, because it requires
support for concat_multi for ansistrings to prevent compilation
    problems there

git-svn-id: branches/jvmbackend@18545 -
2011-08-20 08:09:10 +00:00
Jonas Maebe
54bb881a1b * print an error for invalid type conversions
git-svn-id: branches/jvmbackend@18544 -
2011-08-20 08:09:05 +00:00
Jonas Maebe
63962043a5 * fixed fake nested procedures support
git-svn-id: branches/jvmbackend@18543 -
2011-08-20 08:09:00 +00:00
Jonas Maebe
000c502c9c + fake shortstring temp support
git-svn-id: branches/jvmbackend@18542 -
2011-08-20 08:08:54 +00:00
Jonas Maebe
1c1fe26ebd * refactored isstringconv/isrecordconv
* fixed checking of array element compatibility (also have to check
    for both strings/records)

git-svn-id: branches/jvmbackend@18541 -
2011-08-20 08:08:49 +00:00
Jonas Maebe
8ec1ba797d * put single quotes around identifiers so they cannot be confused with
opcodes by Jasmin

git-svn-id: branches/jvmbackend@18540 -
2011-08-20 08:08:44 +00:00
Jonas Maebe
4dfdcfd139 * fixed uninitialised var-parameters in isstringconv
git-svn-id: branches/jvmbackend@18539 -
2011-08-20 08:08:39 +00:00
Jonas Maebe
bdb6cf5561 * fixed uninitialised var-parameters in isrecordconv
git-svn-id: branches/jvmbackend@18538 -
2011-08-20 08:08:34 +00:00
Jonas Maebe
4cd9908339 * don't mangle local variable and parameter names using the method name,
since those names are only used for debug info. Only the names of
    staticvarsyms in local symtables (typed constants, variable initialisers)
    have to be mangled like that since they'll become fields in the global
    scope

git-svn-id: branches/jvmbackend@18536 -
2011-08-20 08:08:10 +00:00
Jonas Maebe
e403ddca0c * enabled generic multi-string concatenation optimization now that var
parameters for strings work (although they're not as efficient as
    function results for the JVM target)

git-svn-id: branches/jvmbackend@18535 -
2011-08-20 08:08:05 +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
2610cea230 - removed orphan helpers
git-svn-id: branches/jvmbackend@18533 -
2011-08-20 08:07:54 +00:00
Jonas Maebe
6614f3220c * check implementedinterfaces also when going from a Java class to
a Java interface

git-svn-id: branches/jvmbackend@18532 -
2011-08-20 08:07:50 +00:00
Jonas Maebe
cd42bdc42f * load implementedinterfaces for odt_javaclass
git-svn-id: branches/jvmbackend@18531 -
2011-08-20 08:07:45 +00:00
Jonas Maebe
4298992619 * fixed checkcast operations for unicodestrings: replace the definition
with java_jlstring in that case, because we have to insert the type
    without L prefix and ; suffix for that opcode (which is not done for
    objectdefs/recorddefs)

git-svn-id: branches/jvmbackend@18530 -
2011-08-20 08:07:40 +00:00
Jonas Maebe
b8f6c42ec7 * don't insert checkcast operations for types that are considered to be
te_equal

git-svn-id: branches/jvmbackend@18529 -
2011-08-20 08:07:35 +00:00
Jonas Maebe
e8ec2c45af * fixed invokeinterface usage: must also specify the number of stack
slots used by the call

git-svn-id: branches/jvmbackend@18528 -
2011-08-20 08:07:30 +00:00
Jonas Maebe
c9537e3347 + support for non-array/record var parameter on the JVM target using
copy-in/out

git-svn-id: branches/jvmbackend@18527 -
2011-08-20 08:07:24 +00:00
Jonas Maebe
e7eb34e3a6 * make current_except_loc also valid while processing the default exception
block, since it can contain an anonymous "raise" statement to reraise
    the exception

git-svn-id: branches/jvmbackend@18526 -
2011-08-20 08:07:17 +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
845f50448c + support for qword div/mod via helper (the JVM only supports signed
64 bit division natively)

git-svn-id: branches/jvmbackend@18523 -
2011-08-20 08:07:02 +00:00
Jonas Maebe
be1ff9ff92 * fixed handling of OP_SHL,OP_SHR,OP_SAR in op_ref_stack (second operand
is always a 32 bit int)

git-svn-id: branches/jvmbackend@18522 -
2011-08-20 08:06:57 +00:00
Jonas Maebe
2bb13723ae * don't use raw bitcasts for tc_int_2_real type conversions
git-svn-id: branches/jvmbackend@18521 -
2011-08-20 08:06:49 +00:00
Jonas Maebe
6a6ab5beac * converted SAR code to hlcgobj
git-svn-id: branches/jvmbackend@18520 -
2011-08-20 08:06:44 +00:00
Jonas Maebe
dbaaf1c3cd * fixed copy/paste errors in a_op_reg_ref() from a_op_ref_reg()
git-svn-id: branches/jvmbackend@18519 -
2011-08-20 08:06:39 +00:00
Jonas Maebe
3e5b70d80d * cpu64bitaddr -> cpu64bitalu check to determine whether we need special
handling for 64 add-nodes
  * call the generic ordinal handler for 64 add nodes on the JVM

git-svn-id: branches/jvmbackend@18518 -
2011-08-20 08:06:35 +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
6e0b73ad88 * handle string/jlstring/jlobject typecasts properly again after the reworked
typeconversion handling
  + support for class reference types in the JVM (although without class virtual
    methods, they're not that useful)

git-svn-id: branches/jvmbackend@18516 -
2011-08-20 08:06:25 +00:00
Jonas Maebe
10a7532968 * differentiate between typecasts on the assignment side or not, because we
cannot insert typecasting checks on the assignment side, only on the
    values that are being assigned
   o since valid_for_assignment() is called in tassignmentnode.typecheckpass()
     after typecheckpassing left and right, moved the conversion of the
     typecheck nodes into JVM-specific constructs from typecheckpass to
     pass_1, so that they can use the information whether they are on
     the assignment side or not
  * forbid casting a child type to a parent type on the assignment side on
    managed platforms, because that circumvents the type checking

git-svn-id: branches/jvmbackend@18515 -
2011-08-20 08:06:20 +00:00
Jonas Maebe
77707a447e * fixed fake ansistring length() support
git-svn-id: branches/jvmbackend@18514 -
2011-08-20 08:06:14 +00:00
Jonas Maebe
50dd6489c4 * support default properties for Java classes
git-svn-id: branches/jvmbackend@18513 -
2011-08-20 08:06:09 +00:00
Jonas Maebe
80a63197e3 + support for unaryminus for the JVM target (integer via generic code, float
JVM-specific code)

git-svn-id: branches/jvmbackend@18512 -
2011-08-20 08:06:05 +00:00
Jonas Maebe
f764a72d85 * fixed evaluation stack height count for OP_NEG and non-64 bit opertions
git-svn-id: branches/jvmbackend@18511 -
2011-08-20 08:06:00 +00:00
Jonas Maebe
694ccf3df3 + dummy support for untyped var/const/out parameters on the JVM target
o includes basic "auto-boxing" infrastructure to support Delphi.NET-
     compatible untyped parameters as described at
     http://hallvards.blogspot.com/2007/10/dn4dp24-net-vs-win32-untyped-parameters.html

git-svn-id: branches/jvmbackend@18510 -
2011-08-20 08:05:54 +00:00
Jonas Maebe
4c152ccb7d * converted tcgnotnode.second_integer() to hlcg
git-svn-id: branches/jvmbackend@18509 -
2011-08-20 08:05:48 +00:00
Jonas Maebe
3259eae110 * fixed typecasting checks from/to arrays of records
git-svn-id: branches/jvmbackend@18508 -
2011-08-20 08:05:43 +00:00
Jonas Maebe
739c654e3a + support for main programs for the JVM target
o moved several routines from pmodules to ngenutil and overrode them
     in njvmutil (for unit initialisation tables, resource strings, ...)
   o force the evaluation stack size to at least 1 for the main program,
     because the unit initialisation triggers are inserted there afterwards
     and they require one stack slot

git-svn-id: branches/jvmbackend@18507 -
2011-08-20 08:05:38 +00:00
Jonas Maebe
e775e2d9ae * moved gen_entry_code/gen_exit_code from ncgutil to hlcgobj,
and overrode both with empty stubs for the JVM

git-svn-id: branches/jvmbackend@18506 -
2011-08-20 08:05:33 +00:00
Jonas Maebe
f20e347c7e * dummy support for copying arrays of variant/set
git-svn-id: branches/jvmbackend@18505 -
2011-08-20 08:05:28 +00:00
Jonas Maebe
7a5d334951 + support for copy(dynarray)
git-svn-id: branches/jvmbackend@18504 -
2011-08-20 08:05:23 +00:00
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
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
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
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
Jonas Maebe
f57e9778d4 * migrated gen_initialize_code and gen_finalize_code from ncgutil to
hlcgobj so it can be overridden with target-specific code (e.g.,
    the JVM target has to add initialisation code to allocate regular
    arrays and records in constructors and unit/program initialisation)

git-svn-id: branches/jvmbackend@18452 -
2011-08-20 08:01:03 +00:00
Jonas Maebe
53e6853667 * removed a bunch of cg. and hlcg. prefixes (left-overs from migrations
of ncgutil routines)

git-svn-id: branches/jvmbackend@18451 -
2011-08-20 08:00:55 +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
f17936e598 * moved import_lib (for JVM package name) and jvm_full_typename()
from tobjectdef to tabstractrecorddef, since records are implemented
    via Java classes on the JVM target (and hence have an associated
    package name, and we have to be able to generate their JVM-style
    mangled name)
  * adapted ppudump to this change

git-svn-id: branches/jvmbackend@18449 -
2011-08-20 08:00:37 +00:00
Jonas Maebe
88df6573a0 * moved de2regtyp() from defutil to hlcgobj, so it can be overridden
(and override for the JVM, making the register type for records
     R_ADDRESSREGISTER instead of R_INTREGISTER there)

git-svn-id: branches/jvmbackend@18448 -
2011-08-20 08:00:31 +00:00
Jonas Maebe
921b54f9fb * properly handle virtual/override for Java classes, instead of semi-forcing
treating all methods as if they are declared virtual on the JVM platform

git-svn-id: branches/jvmbackend@18447 -
2011-08-20 08:00:25 +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
f1c7e018c4 * don't complain if the external name of a complete definition and that
of a forward definition don't match, since forward definitions can't
    have an external name (nor can they be used in a situation where it's
    necessary)

git-svn-id: branches/jvmbackend@18445 -
2011-08-20 08:00:13 +00:00
Jonas Maebe
fc7725efba + systems_managed_vm set of targets that run inside a managed vm
* don't define the pvmt (and related types) and methodpointertype
    for systems_managed_vm

git-svn-id: branches/jvmbackend@18444 -
2011-08-20 08:00:05 +00:00
Jonas Maebe
c5b39823e5 + internalerror when passing handling invalid integer size in loadstoreopc()
git-svn-id: branches/jvmbackend@18443 -
2011-08-20 07:59:59 +00:00
Jonas Maebe
009a30d8cf * reworked saving/restoring the scanner state (immediately replace scanner
with temporary one when saving, since it's also freed when restoring ->
    called replace_scanner() instead of save_scanner() now)
  * when using -vd, print out the text that is internally generated for
    injecting into the scanner

git-svn-id: branches/jvmbackend@18442 -
2011-08-20 07:59:54 +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
fc2d239f95 * fixed checking for missing "override" for Java code
git-svn-id: branches/jvmbackend@18438 -
2011-08-20 07:59:35 +00:00
Jonas Maebe
30d9fdb0af + is_class_or_interface_or_objc_or_java() function
git-svn-id: branches/jvmbackend@18437 -
2011-08-20 07:59:31 +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
3f436deb16 * set the visibility of a newly create staticsymtable to vis_private
(it's used for the implementation section, corrects the visibility
     of functions in the implementation of Pascal units for the JVM target)

git-svn-id: branches/jvmbackend@18433 -
2011-08-20 07:59:12 +00:00
Jonas Maebe
d47f26bbca * for now only auto-generate a parameterless constructor in case no
constructor is declared, rather than all constructors from the parent
    class (because it cannot be done via scanner-injection, since some
    parameter types of the parent constructors may not be visible in the
    current unit, and there is no full-blown tprocdef.getcopy yet nor
    a way to replace the type of the self-parameter afterwards)
  * added sanity checks when inserting the parameterless constructor
    (check for other identifiers called "create", and other parameterless
     methods)

git-svn-id: branches/jvmbackend@18432 -
2011-08-20 07:59:08 +00:00
Jonas Maebe
c05bc8a931 * let procdef typename-related routines return ansistrings instead of
shortstrings to prevent cut-offs
  + ReplaceCase() ansistring overload in cutils to support the above
  * always use the fully qualified name in case of nested types inside
    the parameter lists of procdefs
  * put extra information about array parameters between {} so they
    can be passed back into the parser

git-svn-id: branches/jvmbackend@18431 -
2011-08-20 07:59:02 +00:00
Jonas Maebe
0d9948a61b + tprocsym.find_procdef_bypara_no_rettype() that looks for a procdef
based on the parameters, but ignoring the result type. Used to
    find out whether a function/procedures with these parameters
    can still be added in terms of overloading (since overloading
    ignores different result types, it only depends on the parameters)

git-svn-id: branches/jvmbackend@18430 -
2011-08-20 07:58:58 +00:00
Jonas Maebe
fa49ddac11 * constructors are not inherited in Java
git-svn-id: branches/jvmbackend@18429 -
2011-08-20 07:58:53 +00:00
Jonas Maebe
42798fd26b * fixed saving/restoring scanner state
git-svn-id: branches/jvmbackend@18428 -
2011-08-20 07:58:49 +00:00
Jonas Maebe
019ca93a04 * symcreat functionality to use the parser from inside the compiler for
artificially generated stuff rather than directly working with defs/syms
   problems
    o scanner state saving/restoring, and avoiding problems in case of
      errors in the injected strings
    o in case of the actual application (adding overriding constructors):
      the parameters may be of types not visible in the current unit to
      newly written code -> can't just use the scanner...

git-svn-id: branches/jvmbackend@18427 -
2011-08-20 07:58:44 +00:00
Jonas Maebe
96b0ee0827 * added more options to format the result of tprocdef.fullprocname() via
a new customprocname() method and tprocnameoption flags (add parameter
    names, add "function"/"procedure", add name of owning struct or not,
    don't add the "class" prefix for class methods)
   Reason: for internal use by the compiler so it can output the procdef
    into something that can be fed back to the parser for reuse (seems
    easier than manually constructing a new procdef, or duplicating it
    inside of another objectdef)

git-svn-id: branches/jvmbackend@18426 -
2011-08-20 07:58:39 +00:00
Jonas Maebe
b6bae1e2e7 * do not automatically resolve constructor calls to constructors of parent
Java classes in case it is not declared in the specified Java class,
    because that will create an instance of such a parent class (in the
    future, we can may automatically clone inherited constructors)

git-svn-id: branches/jvmbackend@18425 -
2011-08-20 07:58:34 +00:00
Jonas Maebe
e58d783211 * dynamic arrays and open arrays need no conversion helper for JVM
git-svn-id: branches/jvmbackend@18424 -
2011-08-20 07:58:29 +00:00
Jonas Maebe
b4ffcaf88e * redirect the ttypeconvnode.typecheck* methods just like the firstpass
and code generation pass methods so they can be overridden

git-svn-id: branches/jvmbackend@18423 -
2011-08-20 07:58:25 +00:00
Jonas Maebe
60e0347bd9 * replaced partial manual declarations of some Java classes with
automatically generated full declarations by javapp, using the
    command line parameters:
    -protected java.lang.System java.lang.Object java.io.Serializable java.lang.Float java.lang.Double java.lang.String java.lang.StringBuilder java.lang.StringBuffer java.lang.CharSequence java.lang.AbstractStringBuilder java.lang.Appendable java.lang.Number java.lang.IndexOutOfBoundsException java.lang.RuntimeException java.lang.IllegalArgumentException java.lang.Exception java.lang.Throwable java.lang.LinkageError java.lang.Error java.lang.Comparable java.lang.Character java.text.Collator java.lang.Cloneable java.util.Comparator -i -o java_sys

git-svn-id: branches/jvmbackend@18422 -
2011-08-20 07:58:20 +00:00
Jonas Maebe
5abf6d0aa4 + thlcgobj support of the managed open array initialization fixes of
svn r17068,17071,17081,17136
  * changed all init_paras code in both thlcgobj and ncgutil to use
    location_get_data_ref() instead of direct a_load_loc_reg()/
    ref.base:=reg so it also works with the JVM target
  * changed all init_paras code so it works with targets that do
    not pass an implicit high parameter for open array (and a similar
    fix in ncgcal)
  + added support for initializing array (both regular and open)
    "out" parameters of reference counted types on the JVM target
    (the arrays will be initialised with nil rather than an empty
     array for implementation reasons, see comments in compproc.inc)
  * factored out calling of functions in the system unit directly
    from hlcgobj

git-svn-id: branches/jvmbackend@18421 -
2011-08-20 07:58:14 +00:00
Jonas Maebe
254636ab84 * don't create (useless) temporary array/record/... for the result
of functions at the caller side, since these will already be allocated
    at the callee side
  * added comment to cpupara explaining why we never allocate the function
    result on the caller side and then pass it as an invisible parameter,
    but instead always let the callee allocate it

git-svn-id: branches/jvmbackend@18420 -
2011-08-20 07:58:09 +00:00
Jonas Maebe
a82831b2e9 + support for compilerproc and "external name 'xxx'" (for normal procedures)
for the JVM target, by setting the "import_name" rather than the
    mangled name on that target

git-svn-id: branches/jvmbackend@18419 -
2011-08-20 07:58:04 +00:00
Jonas Maebe
4adb9a7ceb - removed (non-working) implicit try/finally support for the JVM, and
disabled it under all circumstances on platforms that use garbage
    collection for managed types since it's not required there

git-svn-id: branches/jvmbackend@18418 -
2011-08-20 07:58:00 +00:00
Jonas Maebe
761ff19c7f * initialise local dynamic array variables to empty arrays rather than
to "nil", so that returning them to Java code does not return a nil
    pointer

git-svn-id: branches/jvmbackend@18417 -
2011-08-20 07:57:55 +00:00
Jonas Maebe
f58de91f0c + support for JVM string constants
git-svn-id: branches/jvmbackend@18416 -
2011-08-20 07:57:50 +00:00
Jonas Maebe
7200245337 + cs_unicodestrings global switch to indicate that the default string type
is unicodestring (does *not* change the type of "char" to "unicodechar"
    (yet)). Not yet (un)selectable via a directive.
  + systems_default_unicodestring set containing systems on which the
    default string type is unicodestring

git-svn-id: branches/jvmbackend@18415 -
2011-08-20 07:57:45 +00:00
Jonas Maebe
b42731ff84 * disable SSA for the JVM target
git-svn-id: branches/jvmbackend@18414 -
2011-08-20 07:57:40 +00:00
Jonas Maebe
b5f2b463b8 * mention that Java classes also have anonymous/formal external definitions
git-svn-id: branches/jvmbackend@18413 -
2011-08-20 07:57:36 +00:00
Jonas Maebe
14e4f3459c + systems_garbage_collected_managed_types set in systems.pas
* don't call special helpers to assign refcounted types for
    systems_garbage_collected_managed_types

git-svn-id: branches/jvmbackend@18412 -
2011-08-20 07:57:31 +00:00
Jonas Maebe
87048f0cc8 * fixed range errors in case asizeint<>aint
git-svn-id: branches/jvmbackend@18411 -
2011-08-20 07:57:27 +00:00
Jonas Maebe
bf0b8503c9 * don't internalerror in decstack() if the evaluation stack becomes corrupted
in case -sr is used (-sr code cannot be compiled, and is only used for
    debugging; with -alr, the stack slot information is printed in the
    assembler file)

git-svn-id: branches/jvmbackend@18410 -
2011-08-20 07:57:22 +00:00
Jonas Maebe
94ff4508c7 + support for "external name 'xxx';" for methods in external Java classes to
solve problems with identifier conflicts

git-svn-id: branches/jvmbackend@18408 -
2011-08-20 07:57:12 +00:00
Jonas Maebe
f384c274bb * allow specifying an external name for fields in external Java classes/
interfaces using "var f: field; external name 'xxx';" (necessary for
    solving identifier clashes in imported classes)

git-svn-id: branches/jvmbackend@18406 -
2011-08-20 07:57:03 +00:00
Jonas Maebe
2f4599cc5b * also use the JVM-specific mangled name code for fields for Java interfaces
(since they also can have static fields)

git-svn-id: branches/jvmbackend@18403 -
2011-08-20 07:56:42 +00:00
Jonas Maebe
5f17c0e970 * do not check whether all interface methods are implemented in abstract
Java classes. TODO: do perform this check in the first non-abstract
    Java class that descends from such classes

git-svn-id: branches/jvmbackend@18402 -
2011-08-20 07:56:38 +00:00
Jonas Maebe
410094c1b8 * allow constants and final class vars in Java interfaces (required to
parse external interfaces)

git-svn-id: branches/jvmbackend@18401 -
2011-08-20 07:56:33 +00:00
Jonas Maebe
c0b4514b7c * also search for fully qualified nested types in Java classes/interfaces
* resolve anonymous external classes when handling nested type expressions

git-svn-id: branches/jvmbackend@18400 -
2011-08-20 07:56:29 +00:00
Jonas Maebe
30a6290aac + support for formal constants (= not typed constants) in Java interfaces,
like in Java (mainly for header translations)

git-svn-id: branches/jvmbackend@18399 -
2011-08-20 07:56:24 +00:00
Jonas Maebe
37b5c061e3 + support for "final" fields in *external* (Java and other) classes, enabled
via {$modeswitch finalfields} (on by default on the JVM target). The
    meaning is the same as in Java: a final (class) field can only be set
    in a (class) constructor of the class it's defined in, and can only be
    written once there (and *must* be set there). They are currently only
    supported for external classes since that basically turns them into
    constants, since for non-external classes we need full dataflow analysis
  o refactored pdecobj.parse_object_members() a bit in the process to reduce
    the amount of repetition (which would have been further increased for
    the support for final fields)
  o made error message about "wrong use of absolute" for fields etc generic,
    so it gives a proper error depending on which token was used (it had
    to be made generic for "final" support, but already was used for other
    things that were wrongly reported as "absolute" misusages)

git-svn-id: branches/jvmbackend@18398 -
2011-08-20 07:56:18 +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
0be352e9a9 * don't require "override" for overriding methods in external Java classes
just like for Objective-C and C++ (to make it easier for automatic
    parsers)

git-svn-id: branches/jvmbackend@18396 -
2011-08-20 07:56:08 +00:00
Jonas Maebe
9e8bb70548 + support for abstract methods in Java classes
git-svn-id: branches/jvmbackend@18395 -
2011-08-20 07:56:03 +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
3d4323a75d + support sealed/abstract Java classes (todo: allow abstract Java classes
to only partially implement an interface, and check in first non-abstract
    class in inheritance tree whether it implements all interface methods)

git-svn-id: branches/jvmbackend@18393 -
2011-08-20 07:55:50 +00:00
Jonas Maebe
2d5a542984 * don't allow static methods in Java interfaces
git-svn-id: branches/jvmbackend@18392 -
2011-08-20 07:55:45 +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
Jonas Maebe
737f9f5e90 * moved tabstractvarsym.jvmmangledbasename to the jvmdef unit as a separate
function, so it can be easily also used for constsym without adding
    JVM-specific routines to symtype or duplicating the routine without
    inheritance
  + added tconstsym support to jvmdef.jvmmangledbasename()

git-svn-id: branches/jvmbackend@18390 -
2011-08-20 07:55:36 +00:00
Jonas Maebe
59ccdd1de8 - removed unused local variables
git-svn-id: branches/jvmbackend@18389 -
2011-08-20 07:55:31 +00:00
Jonas Maebe
2c313e397e + support for regular arrays and open arrays
o support for copying value parameters at the callee side if they were
     passed by reference in hlcg
   o JVM g_concatcopy() implementation for arrays
   o moved code to get length of an array from njvminl to hlcgcpu so it can
     be reused elsewhere as well
   o export array copy helpers from system unit for use when assigning one
     array to another
   o some generic support for types that are normally not implicit pointers,
     but which are for the JVM target (such as normal arrays)
  * handle assigning nil to a dynamic array by generating a setlength(x,0)
    node instead of by hardcoding a call to fpc_dynarray_clear, so
    target-specific code can handle it if required
  * hook up gethltemp() for JVM ttgjvm so array temps are properly
    allocated

git-svn-id: branches/jvmbackend@18388 -
2011-08-20 07:55:27 +00:00
Jonas Maebe
0a3a62811b + try/except and try/finally support for JVM target:
o always create exceptvarsym entry for on-nodes (on all targets) to remove
     some special cases when an unnamed exception was caught
   o the JVM tryfinally node generates the finally code twice: once for the
     case where no exception occurs, and once when it does occur. The reason
     is that the JVM's static bytecode verification otherwise cannot prove
     that we will only reraise the caught exception when we caught one in
     the first place (the old "jsr" opcode to de-duplicate finally code
     is no longer used in JDK 1.6 because it suffered from the same problem,
     see Sun Java bug
     http://webcache.googleusercontent.com/search?q=cache:ZJFtvxuyhfMJ:bugs.sun.com/bugdatabase/view_bug.do%3Fbug_id%3D6491544 )

git-svn-id: branches/jvmbackend@18387 -
2011-08-20 07:55:21 +00:00
Jonas Maebe
d8191d48ab * also delete ppcjvm in the execlean target
git-svn-id: branches/jvmbackend@18385 -
2011-08-20 07:55:08 +00:00
Jonas Maebe
be4a27657b + support for nested Java classes
o tobjectdef.jvm_full_typename() now gets an extra parameter to determine
     whether or not the package name should be prepended, so it can be easily
     used to generate the name of the .j file and of the class name inside it

git-svn-id: branches/jvmbackend@18384 -
2011-08-20 07:55:03 +00:00
Jonas Maebe
fde622e050 * generate a loadvmtaddrnode wrapper around Java objectdef typenode arguments
to tasnode (like for regular Object Pascal classes)
  * don't collect WPO information for Java classes in tloadvmtaddrnode.pass_1()
    (devirtualization can't work for Java, since classes can always be loaded
     at run time, except for final/sealed classes -- but that's not yet
     implemented)
  + JVM is-node support, unified JVM type checking codegen for is- and as-nodes

git-svn-id: branches/jvmbackend@18383 -
2011-08-20 07:54:57 +00:00
Jonas Maebe
c1abc4a275 * call cgmessage() instead of message() for errors in
tloadvmtaddrnode.pass_typecheck(), because tas/isnode().pass_typecheck()
    checks codegenerror afterwards to determine whether an error occurred

git-svn-id: branches/jvmbackend@18382 -
2011-08-20 07:54:49 +00:00
Jonas Maebe
608572c63a * removed unused local variables
* fixed some "uninitialised function result" warnings for dummy routines

git-svn-id: branches/jvmbackend@18381 -
2011-08-20 07:54:37 +00:00
Jonas Maebe
678e6dceef * write floating point numbers using hex notation to prevent data loss
(requires patched Jasmin)

git-svn-id: branches/jvmbackend@18380 -
2011-08-20 07:54:29 +00:00
Jonas Maebe
e5ce390565 + support for indexing (dynamic) arrays on the JVM
git-svn-id: branches/jvmbackend@18379 -
2011-08-20 07:54:24 +00:00
Jonas Maebe
ee8b662fa1 + dynamic array support for the JVM target: setlength(), length(), high():
o since the JVM does not support call-by-reference, setlength() works
     by taking an argument pointing to the old array and one to the new
     array (the latter is always created in advance on the caller side,
     even if not strictly required, because we cannot easily create it
     on the callee side in an efficient way). Then we copy parts of the
     old array to the new array as necessary
   o to represent creating a new dynamic array, the JVM target uses
     an in_new_x tinlinenode
  + tasnode support for the JVM. Special: it can also be used to convert
    java.lang.Object to dynamic arrays, and dynamic arrays of java.lang.Object
    to dynamic arrays with more dimensions (arrays are special JVM objects,
    and such support is required for the setlength support)
  + check whether explicit type conversions are valid, and if so, add the
    necessary conversion code since we cannot simply reinterpret bit patterns
    in most cases in the JVM:
   o in case of class and/or dynamic array types, convert to an as-node
   o in case of int-to-float or float-to-int, use java.lang.Float/Double
     helpers (+ added the definitions of these helpers to the system unit)

git-svn-id: branches/jvmbackend@18378 -
2011-08-20 07:54:17 +00:00
Jonas Maebe
a2a6b2fd1d + "reference" temps that sort of implement pointer-style functionality for
platforms that don't support pointers (by make a copy of all registers
    part of a reference)

git-svn-id: branches/jvmbackend@18377 -
2011-08-20 07:54:10 +00:00
Jonas Maebe
0e87627218 + gethltemp() to allocate a temp specifying full type information even
for regular temps. This is required for targets that need special
    handling of the temps depending on the type
  * converted most gettemp() calls to gethltemp() calls

git-svn-id: branches/jvmbackend@18376 -
2011-08-20 07:54:04 +00:00
Jonas Maebe
8643ab7905 + hooks for target-specific handling of explicit type conversions and
as-nodes (required for JVM target: bit pattern reinterpretations
    have to be handled via conversion because of type safety reasons,
    and as-nodes will also have to be able to handled class<->dynarray
    checks/conversions)

git-svn-id: branches/jvmbackend@18375 -
2011-08-20 07:53:56 +00:00
Jonas Maebe
f47689a5fe * enable intercepting passes on tinlinenode(in_new_x); these cannot be
generated from Pascal source code, but they will be generated by the
    JVM backend to construct new array instances

git-svn-id: branches/jvmbackend@18374 -
2011-08-20 07:53:51 +00:00
Jonas Maebe
e56ad62f09 * second_real_to_real() converted to hlcg (in so far possible, no MM support)
git-svn-id: branches/jvmbackend@18373 -
2011-08-20 07:53:38 +00:00
Jonas Maebe
00c095fa70 * moved setlength() handling from pinline to ninl so it can be overridden
git-svn-id: branches/jvmbackend@18372 -
2011-08-20 07:53:28 +00:00
Jonas Maebe
b5ea6ab7d8 + thlcgobj.location_force_fpureg() implementation
git-svn-id: branches/jvmbackend@18370 -
2011-08-20 07:53:03 +00:00
Jonas Maebe
c9dbd60b92 * allow "static" for external methods (for Java classes)
git-svn-id: branches/jvmbackend@18369 -
2011-08-20 07:52:51 +00:00
Jonas Maebe
0ae4bbb0cf + JVM-specific versions of initialize_data_node()/finalize_data_node():
do nothing for finalization, assign nil pointer for dynamic arrays
    and refcounted strings (not required for JVM per se, but required
    because programmer's may use them without initialising them first
    and then they should be empty rather than invalid)

git-svn-id: branches/jvmbackend@18368 -
2011-08-20 07:52:39 +00:00
Jonas Maebe
09207563d5 + hlcg implementation of gen_load_para_value(); no support yet for copying
value parameters when necessary, nor for -gt variable trashing

git-svn-id: branches/jvmbackend@18367 -
2011-08-20 07:52:31 +00:00
Jonas Maebe
2a6caa539c + support for constant array indices in treference for the JVM target
(art_indexconst)

git-svn-id: branches/jvmbackend@18366 -
2011-08-20 07:52:27 +00:00
Jonas Maebe
5fd205c130 * fixed indentation of thlcgjvm.a_load_loc_stack() implementation
git-svn-id: branches/jvmbackend@18365 -
2011-08-20 07:52:22 +00:00
Jonas Maebe
ab5b1fb686 * turned call_fail_node, initialize_data_node, and finalize_data_node from
nutils.pas into virtual class methods of a new tnodeutils class defined
    in ngenutil (global factory: cnodeutils), so they can be overridden by
    architecture-specific implementations (required by the JVM backend)

git-svn-id: branches/jvmbackend@18364 -
2011-08-20 07:52:11 +00:00
Jonas Maebe
15aaf36b82 + pred/succ, inc/dec and assigned converted to hlcg
git-svn-id: branches/jvmbackend@18363 -
2011-08-20 07:51:50 +00:00
Jonas Maebe
df2d83f110 * fixed calculating the number of stack slots removed by a call
(pushedparasize is already expressed in number of stackslots rather
    than in bytes)
   o when determining the number of stack slots to pop after calling a function
     and not using its function result, round up the function result size to
     the nearest multiple of 4 before determining the number os tack slots (to
     correctly handle byte/word-sized results)

git-svn-id: branches/jvmbackend@18362 -
2011-08-20 07:51:42 +00:00
Jonas Maebe
13a459c2d7 * replaced all calls to cg.g_incr/decrrefcount/g_initialize/g_finalize with
calls to hlcg.*

git-svn-id: branches/jvmbackend@18361 -
2011-08-20 07:51:37 +00:00
Jonas Maebe
25f565751a + g_incrrefcount/g_decrrefcount/g_initialize/g_finalize() implementations for
the JVM (only g_initialize does something: set variable to nil)

git-svn-id: branches/jvmbackend@18360 -
2011-08-20 07:51:33 +00:00
Jonas Maebe
6c9256ee32 * made internalerror unique
git-svn-id: branches/jvmbackend@18359 -
2011-08-20 07:51:28 +00:00
Jonas Maebe
e326f46da5 * don't force the constant of a_cmp_const* to be an integer constant,
it can also be null

git-svn-id: branches/jvmbackend@18358 -
2011-08-20 07:51:24 +00:00
Jonas Maebe
9bd753ba7a * don't decrease the evaluation stack counter twice for a_load_*_ref
git-svn-id: branches/jvmbackend@18356 -
2011-08-20 07:51:07 +00:00
Jonas Maebe
e20919f065 + support for writing JVM line number information
* moved emitting line information from agjasmin to dbgjasm (+ it now
    also works if -al is not used)

git-svn-id: branches/jvmbackend@18355 -
2011-08-20 07:50:46 +00:00
Jonas Maebe
d456ec2ffe + support for JVM local variable and parameter debug information
o self is encoded as "this" for javac compatibility
  + ait_jvar (for the above) and ait_jcatch (similar, for future try/catch
    support) classes
  + support for smallset JVM type encoding (as int)

git-svn-id: branches/jvmbackend@18354 -
2011-08-20 07:50:41 +00:00
Jonas Maebe
b5e7989a06 * separate Jasmin operands by space instead of by ","
git-svn-id: branches/jvmbackend@18353 -
2011-08-20 07:50:35 +00:00
Jonas Maebe
730f75ed96 * use current_module.realmodulename^ (= unit name as declared in its main
source) instead of the filename of a unit's source as its Java class name

git-svn-id: branches/jvmbackend@18352 -
2011-08-20 07:50:29 +00:00
Jonas Maebe
002455ab5c + support for instance and class fields, and unit-level global variables
o hlcgobj support in tcgsubscriptnode.pass_2 for JVM-required functionality
   o slightly different handling for class fields for the JVM than for other
     platforms: instead of adding a unit-level staticvarsym with a hidden name,
     rename the original (unused) field and add the staticvarsym with the original
     name to the object symtable. This is required because the JVM code generator
     has to know the class the field belongs to, as well as its real name
   o moved tprocdef.makejvmmangledcallname() functionality mostly to
     jvmdef.jvmaddtypeownerprefix() because it's also required for mangling
     field symbol names
  * changed the interface of jvmdef from ansistring to shortstring because
    all of its results are also used in shortstring contexts (and they're
    unlikely to overflow the shortstring limit)
  * "protected", "private" (without strict) and implementation-only symbols
    now get "package" visibility instead of "public" visibility

git-svn-id: branches/jvmbackend@18349 -
2011-08-20 07:49:46 +00:00
Jonas Maebe
afceec23b2 - removed unused local variables
git-svn-id: branches/jvmbackend@18348 -
2011-08-20 07:49:41 +00:00
Jonas Maebe
532f16336a * force -dNOOPT when compiling a JVM compiler
git-svn-id: branches/jvmbackend@18347 -
2011-08-20 07:49:37 +00:00
Jonas Maebe
28740dce2d - removed extra "fordefinition" parameter again from tprocdef.mangledname(),
since the definition-specific adorning of JVM mangled names is Jasmin-
    specific, and such code has no place in symdef
  * moved code to adorn JVM mangled names for Jasmin definitions to agjasmin

git-svn-id: branches/jvmbackend@18346 -
2011-08-20 07:49:31 +00:00
Jonas Maebe
e269f68359 * require that class methods are "static" for Java classes
git-svn-id: branches/jvmbackend@18345 -
2011-08-20 07:49:24 +00:00
Jonas Maebe
83dc297346 + Java interface support, mostly the same as Objective-C protocols
(generalised some error messages that were specific to protocols
     so they can also be used for Java interfaces)
  o note, Java interface support requires a fix to Jasmin 2.4:
    http://sourceforge.net/tracker/?func=detail&aid=2897170&group_id=100746&atid=628212

git-svn-id: branches/jvmbackend@18344 -
2011-08-20 07:49:19 +00:00
Jonas Maebe
b0d050a490 * pass all .j files related to one unit in one go to Jasmin instead of
invoking Jasmin once for every generated .j file

git-svn-id: branches/jvmbackend@18343 -
2011-08-20 07:49:07 +00:00
Jonas Maebe
505660262d + sqr(float) and trunc() support
git-svn-id: branches/jvmbackend@18342 -
2011-08-20 07:48:47 +00:00
Jonas Maebe
d3a4866cf5 * reorder processing of left/right for add nodes somewhat to make
it easier for the register allocator/optimizer to reduce the
    number of intermediate stores to the stack

git-svn-id: branches/jvmbackend@18341 -
2011-08-20 07:48:42 +00:00
Jonas Maebe
fda72aaed6 * made the remove_dummy_load_stores() implementation more extensible
and skip comments (so it works again when -ar is used, because
    tlhcgjvm.inc/decstack() insert comments in that case)

git-svn-id: branches/jvmbackend@18340 -
2011-08-20 07:48:38 +00:00
Jonas Maebe
b023627f6a * converted tcgcasenode.pass_generate_code() to hlcgobj
o changed type of opsize field of tcgcasenode from tcgsize into tdef,
     and fixed compilation of other code generator units after this change

git-svn-id: branches/jvmbackend@18339 -
2011-08-20 07:48:33 +00:00
Jonas Maebe
71b348757b * reversed expected operand order of tjvmhlcg.a_cmp_*(), because
that's how these operations also work on other architectures
  * fixed tjvmaddnode.second_generic_compare() for this new order

git-svn-id: branches/jvmbackend@18338 -
2011-08-20 07:48:27 +00:00
Jonas Maebe
87925db8fb * fixed 64 bit shl/shr/sar operations: the second argument of the
operation is 32 bit, not 64 bit (both in the compiler and in the
    JVM)
  * request a 64 rather than a 32 bit shift operation from tjvmshlshrnode
    if the result is 64 bit (rather than in case shift value is 64 bit,
    since as described above that never happens)

git-svn-id: branches/jvmbackend@18337 -
2011-08-20 07:48:23 +00:00
Jonas Maebe
8f727557c0 + JVM support for int_to_int, int_to_real, bool_to_int and
int_to_bool type conversions (includes bool_to_bool)

git-svn-id: branches/jvmbackend@18336 -
2011-08-20 07:48:18 +00:00
Jonas Maebe
e699eb3cc5 + added "list" parameter to thlcgjvm.inc/decstack() methods, and
in case of -ar add to the assembler output the height of the
    evaluation stack every time it's increased or decreased (to
    more easily track missing/wrong inc/decstack() operations)

git-svn-id: branches/jvmbackend@18335 -
2011-08-20 07:48:00 +00:00
Jonas Maebe
e1b6398b47 * don't give an "abstract method called" error for g_rangecheck()
if range checking is disabled

git-svn-id: branches/jvmbackend@18334 -
2011-08-20 07:47:44 +00:00
Jonas Maebe
dd2862e25a + support for floating point constants
git-svn-id: branches/jvmbackend@18333 -
2011-08-20 07:47:29 +00:00
Jonas Maebe
a1c50d0576 * make sure that comparisons with NaN always return false
git-svn-id: branches/jvmbackend@18332 -
2011-08-20 07:47:21 +00:00
Jonas Maebe
f250d5d494 + full JVM implementation for add-nodes and mat-nodes, except for
u64bit division/mod, and no overflow checking for divisions
    (none yet for add nodes either, but that has to be implemented
     in hlcgcpu rather than in the add-nodes themselves)

git-svn-id: branches/jvmbackend@18331 -
2011-08-20 07:47:05 +00:00
Jonas Maebe
e9f1856a61 * converted non-exception-related nodes to thlcgobj
git-svn-id: branches/jvmbackend@18330 -
2011-08-20 07:46:46 +00:00
Jonas Maebe
332f613cd7 + thlcgobj.maketojumpbool() implementation
git-svn-id: branches/jvmbackend@18329 -
2011-08-20 07:46:41 +00:00