Commit Graph

239 Commits

Author SHA1 Message Date
Sven/Sarah Barth
30a7199165 * make the VMT symbol and type def of the corresponding class or object instead of having them be global
* bump PPU version to avoid potential compilation errors due to this

Based on code by Blaise.ru
2022-05-26 21:42:51 +02:00
Jonas Maebe
4ba19f5418 * add support for creating non-address-only procvars to
cprocvar.getreusableprocaddr()

git-svn-id: trunk@44516 -
2020-04-02 21:21:36 +00:00
svenbarth
36e32ee607 * more correct method names (based on patch by Blaise.ru)
git-svn-id: trunk@43676 -
2019-12-11 22:43:00 +00:00
svenbarth
46a366d6ae * clear up file comment (based on patch by Blaise.ru)
git-svn-id: trunk@43675 -
2019-12-11 22:42:56 +00:00
svenbarth
bf5d75e594 * move the common sequence to build a VMT for an objectdef into a separate procedure (based on a patch by Blaise.ru)
git-svn-id: trunk@43674 -
2019-12-11 22:42:53 +00:00
svenbarth
a6354741e6 * TVMTBuilder.build_interface_mappings does not need to be public (based on patch by Blaise.ru)
git-svn-id: trunk@43673 -
2019-12-11 22:42:48 +00:00
svenbarth
f2818bfe7a * apply patch by Blaise.ru to remove last remnants of VMT regeneration which is no longer needed/used
git-svn-id: trunk@43628 -
2019-12-02 22:29:29 +00:00
svenbarth
3ced30f816 * apply (adjusted) patch by Blaise.ru: vmtentries is always created since 2008, so treat it as such (also fixes a memory leak in tobjectdef.getcopy)
git-svn-id: trunk@43626 -
2019-12-02 06:59:05 +00:00
svenbarth
4b3ce0c023 * the symbol of the interface wrapper function needs to be considered as referenced as well
git-svn-id: trunk@43545 -
2019-11-21 21:44:57 +00:00
Jonas Maebe
d8903ce6b3 - removed maxcrecordalign parameter/field from recordsymtables, as this value
cannot be modified in the settings (so we can directly use the one from
    current_settings)

git-svn-id: trunk@42447 -
2019-07-14 19:24:32 +00:00
Jonas Maebe
7f772683cb * fix tobjectdef.vmt_def to search in the correct symtable
* always register vmt defs (so they get written to the ppu) in case of llvm,
    because it may need this def in case a method from a class defined in the
    implementation of unit gets called from an inlined routine that gets
    inlined in another unit (normally that vmt def would not get written to
    the ppu file, as it can't be referenced from the interface and it's also
    not necessarily directly referenced from the inline routine's nodes)
    (fixes sdo_dataobject compilation with LLVM after enabling cross-unit
     inlining of methods accessing static symbol table symbols)

git-svn-id: trunk@42342 -
2019-07-07 21:33:51 +00:00
Jonas Maebe
e008785152 * insert the hidden parameters for objectdef methods after resolving
overrides but before generating the VMT, so that these hidden parameters
    are part of the procdefs stored in the VMT (fixes some LLVM type errors
    after r41716)

git-svn-id: trunk@41884 -
2019-04-16 16:11:50 +00:00
Jonas Maebe
7b313a2c15 * stop searching for methods to implement interfaces in parent classes after
encountering a method with the correct name that does not have the
    "overload" directive (same logic as when looking for a call candidate,
    to avoid errors when using a Pascal-level wrapper to call interface
    methods, and Delphi-compatible since it always required "overload" for
    overloaded methods)
   o also catches calling convention mismatches like in webtbs/tw27349

git-svn-id: trunk@40683 -
2018-12-28 18:25:58 +00:00
Jonas Maebe
9c6838ecca * do not allow implementing interface methods using methods that are not
visible in the current class

git-svn-id: trunk@40645 -
2018-12-25 17:51:30 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
florian
668b198d7c * fix for issue #29936: check if the internal needed types are available
git-svn-id: trunk@35310 -
2017-01-15 20:54:07 +00:00
nickysn
f62be8f6e6 * use sizesinttype instead of ptrsinttype to refer to vInstanceSize and
vInstanceSize2 in the VMT

git-svn-id: trunk@34623 -
2016-10-04 15:25:13 +00:00
svenbarth
61551cbb0f * move properties and functions of TVMT to the end of the record, so that one only needs to adjust the total entry count TVMTBuilder.generate_vmt_def()
git-svn-id: trunk@34223 -
2016-07-29 13:54:36 +00:00
svenbarth
f18e6cec0b * correctly enumerate the fields of the TVMT record after the previous extension of it (GetvParent and vParent are two new symbols and TVMT does not only contain fieldvarsyms now) so that the VMT def can be correctly generated
git-svn-id: trunk@34173 -
2016-07-22 13:07:37 +00:00
Jonas Maebe
59eff35c5d * give fields added for VMT definition of TP-style objects the same
name as the equivalent fields for class VMTs, so we can access them
    using common code

git-svn-id: trunk@32763 -
2015-12-27 14:21:59 +00:00
svenbarth
39016c032e Fix for Mantis #28442. Do not generate the VMT record definition for generic classes. It isn't used anyway.
nobj.pas, TVMTBuilder:
  * generate_vmt_def: check for df_generic (not is_generic!) and abort if set

+ added test

git-svn-id: trunk@31301 -
2015-08-07 15:02:55 +00:00
Jonas Maebe
6f5905684f + support for specifying the name of fields added to anonymous record
types that are constructed on the fly by the high level typed const
    builder

git-svn-id: trunk@31249 -
2015-07-30 16:57:58 +00:00
Jonas Maebe
b55c7df996 * factored out internal type prefixes
git-svn-id: trunk@31248 -
2015-07-30 16:57:55 +00:00
Jonas Maebe
508828958c * changed getprocaddressprocvar() into a tprocvardef.getreusableprocaddr()
class method

git-svn-id: trunk@31148 -
2015-06-23 21:23:22 +00:00
Jonas Maebe
3f736f6114 * handle the loading of VMT entries at the node level, so it's done in a
type-safe way (for LLVM, and also internal consistency checking between
    the VMT as generated in nobj.pas and ncgvmt.pas)
   o also converted the VMT validity checking to the node level

git-svn-id: trunk@30950 -
2015-05-31 16:50:47 +00:00
nickysn
89e9fac562 * TVMTBuilder.intf_allocate_vtbls: fixed the Ioffset calculation in i8086 far
data memory models

git-svn-id: trunk@27728 -
2014-05-03 17:05:50 +00:00
Jonas Maebe
43992495cb * moved jvm tprocdef name mangling to jvm-specific descendant class
git-svn-id: trunk@27395 -
2014-03-30 21:04:29 +00:00
sergei
d54d38b4ab * Moved all code responsible for writing VMTs and interface wrappers (nobj.TVMTWriter, ncgutil.gen_intf_wrappers, ptype.write_persistent_type_info) into a new unit ncgvmt.pas.
This improves compiling speed a bit (two iterations over symtables replaced by one, code generator is created once per unit rather than once per class).
In perspective it makes possible to reduce amount of generated smartlink sections and global labels.

git-svn-id: trunk@24269 -
2013-04-19 13:31:27 +00:00
florian
63f6afffd5 + make empty proc. removal switchable by removeemptyprocs
git-svn-id: trunk@23621 -
2013-02-14 21:40:04 +00:00
florian
4d3df8f518 * stupid typo in TVMTWriter.RedirectToEmpty fixed, resolves #23763
git-svn-id: trunk@23569 -
2013-02-03 22:02:02 +00:00
Jonas Maebe
e7315d035c * inherit po_auto_raised_visibility flag when the visibility of a method is
raised because it was automatically raised in the parent class (can happen
    for the JVM target when letting the compiler generate getters/setters for
    properties)

git-svn-id: trunk@23522 -
2013-01-26 16:52:28 +00:00
sergei
ad1621df3f * Revert part of r22548, correct fix for the issue is provided by r23188.
Only referencing data labels from code should change "GOT is needed" property. Writing data labels or referencing them from data should have no effect on it.

git-svn-id: trunk@23363 -
2013-01-11 15:31:12 +00:00
florian
198907797b * don't replace vmt entries of empty methods by FPC_EMPTYMETHOD
if the code is compiled for x86 and returns the result in an fpu register

git-svn-id: trunk@23304 -
2013-01-03 23:01:07 +00:00
florian
24f518f232 + redirect calls to empty virtual methods to FPC_EMPTYMETHOD
* do empty subroutine/method optimization only for O2 and higer

git-svn-id: trunk@23276 -
2013-01-01 16:43:27 +00:00
Jonas Maebe
4aa05f5133 + support for automatically generating setters/getters for properties on the
JVM target, since Java bytecode itself has no support for properties and
    hence exposing properties to external Java code can only be done through
    getters/setters. Use the new parameters to do so:
      -CTautogetterprefix=XXX
      -CTautosetterprefix=YYY
    The getter/setter will get the same visibility as the property. If a
    getter/setter with the same naming convention was already specified for a
    property and this getter/setter is declared in the same class as the
    property, then the visibility of this existing getter/setter is
    modified and no new routine is generated.

    Newly generated getters/setters are virtual methods, because that is
    the only way in Java bytecode to allow redefining these getters/setters
    in child classes. However, that also means that using these switches can
    change the behvaviour of code, since normally the used property definition
    is only determined by the declared type of its associated class instance,
    and not by the actual instance type. The compiler will therefore warn when
    such an automatically generated getter/setter is overridden by another
    automatically generated getter/setter in a child class.

git-svn-id: trunk@22959 -
2012-11-08 20:18:08 +00:00
pierre
78d31eb3cd Add missing of pi_needs_got found by sparc compiler compiled with -dCHECK_PIC
git-svn-id: trunk@22548 -
2012-10-05 15:02:47 +00:00
Jonas Maebe
fe90823b01 * support the "overload" modifier for Objective-C methods
* only check whether the message identifier of an Objective-C method
    matches the one from a method with the same name in a parent class
    if the parameters match (todo: should be refined to "if the
    encoded Objective-C selector names match")

git-svn-id: trunk@22373 -
2012-09-11 21:58:40 +00:00
Jonas Maebe
c2be657671 * give an error instead of a note on the JVM target when overriding a
method by one with a lower visibility, because calling the overriding
    method results in a java.lang.AbstractMethodError in that case

git-svn-id: trunk@21839 -
2012-07-10 09:20:11 +00:00
Jonas Maebe
50659b7e7f * give an error if a routine definition defines default values for
parameters that do not appear in forward/interface definitions
    (mantis #19434)
  * added test for #17136 already works

git-svn-id: trunk@21524 -
2012-06-07 22:36:39 +00:00
Jonas Maebe
834026bfb5 * synchronised with trunk up to r21067
git-svn-id: branches/jvmbackend@21068 -
2012-04-26 21:24:20 +00:00
Jonas Maebe
6502717e67 * align all code/data sections to sizeof(pint), instead of sometimes
to 0 or 1 (section alignment <> alignment of individual data
    elements in section on some platforms, such as AIX)
  * set constalignmin and varalignmin to 8 bytes for AIX/ppc64

git-svn-id: trunk@21044 -
2012-04-25 20:27:41 +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
sergei
429af6f40b * nobj.pas, finished refactoring VMT generation code, now all child structures except RTTI are written to same data section with VMT itself and their labels are local (since child structures are accessible only through VMT, smartlinking them into different sections is useless).
* Reference GUID/string labels of implemented interfaces instead of duplicating them on every occurrence.

git-svn-id: trunk@20344 -
2012-02-13 18:49:48 +00:00
sergei
3eeca2b172 * Emit published method table into single object section (previously every method name was written into a section of its own), labels for method names no longer have to be global.
* Pass target asmlist as parameter to genpublishedmethodstable and generate_field_table.
* Omit field table if there are no published fields (Delphi compatible).

git-svn-id: trunk@20310 -
2012-02-11 13:51:29 +00:00
sergei
3b006c4a9c nobj.pas, cleanup/refactoring:
- removed empty destructors, overriding destructor without calling inherited is incorrect (although harmless here).
* pass target asmlist as parameter to message table generation procedures, instead of using global variables.

git-svn-id: trunk@20303 -
2012-02-11 09:27:03 +00:00
Jonas Maebe
3b47c40ed2 * check whether methods that implement interface methods are public
or published, because interface methods are always public and
    hence mapping them to a private/protected method increases the
    visibility of the underlying method (error on JVM target because
    the JVM doesn't like that, warning on other platforms)

git-svn-id: branches/jvmbackend@19156 -
2011-09-19 21:22:44 +00:00
Jonas Maebe
c163a327d7 * fixed abstract method accounting for external Objective-C/Java classes:
in that case if an "override" directive is missing but we interpret
    the declaration as an "override" anyway, make sure to replace the vmtpd
    with the overriding definition or child classes will keep seeing
    the abstract method in the base class and keep decreasing their abstract
    method count below zero
  * only decrease the abstract method count in case we're not processing
    category methods

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

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

git-svn-id: branches/jvmbackend@18695 -
2011-08-20 08:25:24 +00:00
Jonas Maebe
7e7bdc3c55 * make the real name of methods implementing interface methods the same as
as the real name of the declaration in the interface, so that the JVM
    case-sensitive mapping works out
  * process the interface mappings for the compiler-constructed classes for
    enums and procvars

git-svn-id: branches/jvmbackend@18693 -
2011-08-20 08:25:14 +00:00