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 -
o support formal external definitions (like for objcclass)
o allow specifying an "import_dll" for external Java classes, which can
be used to specify the Java package name (like the dll for cppclass)
o take the package name into account when mangling the Java class name
o several messages that were specific to Objective-Pascal classes have
been generalised because they also apply to Java classes, same for
several compiler function names
o disabled some proccall directives for Java, but more needs to happen
(Java methods are always either instance-virtual or class-static)
git-svn-id: branches/jvmbackend@18319 -
* Disallow simultaneous use of method resolution and delegation for the same interface. An interface with method resolution must be implemented directly. This is Delphi compatible and resolves#18058.
git-svn-id: trunk@18179 -
so a proper error message is written (resolves#19871),
EOutOfMemory is not handle perfectly because it could be that the exception
handling requires again a memory allocation
git-svn-id: trunk@18132 -
* Factored repeating REX operations into a separate function.
* Fixed instruction matching bug which was preventing compilation of 3-operand SIMD instructions with RIP-relative operand + test.
* Do not adjust offset of RIP-relative reference if it is a literal number, this was causing 0x123(%rip) to assemble as 0x122(%rip) in 3-operand instructions. Now tasm2.pp is the same with and without -Aas. Also fixed the expected result, improved verbosity of diagnostic and removed %norun, so it is actually executed.
+ Disallow high-byte registers in instructions requiring REX + test.
git-svn-id: trunk@17478 -
* pdecobj.pas:
- parse_object_members: in record helpers class methods need to be declared as "static" like in records
- object_dec:
- allow "published" in helpers as well
- disallow inheritance for record helpers in mode Delphi (and remove the forward declaration flag in that case)
* pdecsub.pas:
pd_abstract: "abstract" isn't allowed in either mode
* pexpr.pas: multiple corrections because of "inherited" and records
- allow "inherited" for "record helpers" (except for mode Delphi)
- load the symbol from the correct class (I hope...)
- give a more precise error message if "inherited" is used in records
* ptype.pas: I forgot to adjust the "(bit)packed record" case
* symtable.pas:
- searchsym_in_helper: "result" was not initialized (and identation fix)
- search_last_objectpascal_helper:
- don't search if there are no helpers (useful for projects that does not contain helpers like the compiler itself)
- don't search if the type to search helpers for is defined locally
- don't search if the type is a anonymous record
- search_struct_member: search for symbols in helpers as well
- msg*:
* correct the message for "parser_e_not_allowed_in_helper"
* add message "parser_e_inherited_not_in_record" which is used to tell that the use of "inherited" is not allowed in records and (in mode Delphi) record helpers
git-svn-id: branches/svenbarth/classhelpers@17239 -
+ parsing of section directive for variables
+ section test
+ write section names in the assembler/binary writers correctly
* allow section only after ; and for embedded targets
git-svn-id: branches/usersections@17154 -
- remove thelpersearch again => adjustments to searchsym_in_class and calls to it
- rename sto_has_classhelper to sto_has_helper
* symbase.pas: make push and pop in tsymtablestack virtual
* symdef.pas:
- add a new class tdefawaresymtablestack which overrides push and pop of tsymtablestack and adjusts the new extendeddefs field of the current tmodule
- tobjectdef.create: sto_has_classhelper => sto_has_helper
* fmodule.pas:
- add new hash object list to tmodule (key: mangled type name) which holds object list instances that contain all helpers currently active for a given type (= key of the hash list)
- tmodule.create: the hash list owns the sublists (but those don't own the defs)
- tmodule.destroy: free the hash list
* pdecobjpas:
- rename parse_extended_class to parse_extended_type
- parsing of constructors:
# for all helper types: no class constructors allowed
# for record helpers: as long as constructors for records themselves are disabled they are for record helpers as well
- object_dec: manually add the helper to the extendeddefs if the overall owner of the current def is a static symtable (implementation section or program/library main file), because the symtable won't be popped and pushed then
* parser.pas: instantiate the new stack class
* psub.pas: backup the extendeddefs in specialize_objectdefs as well
* ptype.pas:
- generate_specialization: backup the extendeddefs as well
- record_dec: _RECORD is now consumed in read_named_type itself
- read_named_type: parse "record helper" if advanced record syntax is enabled
* symtable.pas:
- correct searchsym_in_class declaration => adjustments in this unit as well
- add the possibility to pass a context def to search_last_objectpascal_helper
- rename search_objectpascal_class_helper to search_objectpascal_helper
- rename search_class_helper to search_objc_helper
- searchsym_in_class:
# search for helpers in every level of the tree of the class
# the contextclassh can also be a subclass of the extendeddef
- searchsym_in_record: search for helper methods as well
- searchsym_in_helper:
# search for symbols in class and record helpers is the same except for the search in the class' ancestors
# search the extendeddef directly and rely on searchsym_in_class only for the class' ancestors as we need to find the helpers there as well
- search_last_objectpascal_helper: use the extendeddefs list of current_module instead of scanning the symbol stack itself
* pexpr.pas: adjustments because of renaming of sto_has_classhelper
* pinline.pas: adjustment because of removing of thelpersearch
* nflw.pas:
- renamed classhelper to helperdef
- adjusted search_last_objectpascal_helper call
* msg*:
- adjusted error message for constructors in records (this currently applies to record helpers as well)
- renamed parser_e_not_allowed_in_classhelper to parser_e_not_allowed_in_helper => adjustments in code
- added parser_e_no_class_constructors_in_helpers
* pdecsub.pas: adjusted renamed error message
* htypechk.pas: check for helpers in every step of the hierarchy
* nobj.pas: search_class_helper => search_objc_helper
* utils/ppudump.pas: adjust, because of renames
Note: the define "useoldsearch" will be only used for performance comparison on my (faster) Linux machine; that (and its associated code) will be removed afterwards
git-svn-id: branches/svenbarth/classhelpers@17151 -
This change became necessary of the following reasons:
- Records don't support inheritance, thus for "record helpers" some creativity would have been necessary to implement them; with the new implementation this is more easily
- the new approach allows for easy checks regarding virtual methods and their overrides which would have been more complicated in the old variant
- if someone feels the need the types of helpers (object, interface) can be added rather easily
- unnecessary things like VMT generation can be disabled now
details:
- msg*:
* moved some messages from parser to type
* adjusted a message ("class helper" => "helper")
- symdef.pas:
* renamed "helperparent" to "extendeddef" and changed its type from "tobjectdef" to "tabstractrecorddef", so records can be extended as well (somewhen in the near future)
* removed "finish_class_helper" method as it isn't necessary (luckily I haven't yet adjusted the ObjC variant)
* changed name of "is_objectpascal_classhelper" to "is_objectpascal_helper" to reflect that this function applies to all helper types
* tobjectdef.create: ImplementedInterfaces isn't created for odt_helper anymore
* tobjectdef.alignment: for helpers it's the same as for classes although this shouldn't be used anywhere...
* tobjectdef.vmtmethodoffset: set to 0 for helpers to be sure...
* tobjectdef.needs_inittable: not needed for helpers (no fields allowed)
* is_objectpascal_helper: only needs check for "odt_helper" object type
- symconst.pas:
* changed odt_classhelper to more general odt_helper
* added new type "thelpertype" which is used to check that "(record|class) helper" corresponds with the given extended type (as Delphi XE checks this as well this strict solution can be kept for modes Delphi and ObjFPC)
- symtable.pas:
* extended "searchsym_in_class" with the possibility to disable the search for helper methods (needed for inherited) => this implies changing all occurences of "searchsym_in_class" with a "true" except some special locations
* renamed "search_objectpascal_classhelper" to "search_objectpascal_helper"
* searchsym_in_class:
** when an extended method is defined with "overload" it can be that a same named method of the extended class might be called (sadly this means that this search was unnecessary...)
** contextclassh is the def of the helper in the case of an inherited call inside the helper's implementation
** when methods inside a helper are searched, it must be searched in the extended type first
- ptype.pas:
* single_type is used to parse the parent of a helper as well, so allow a helper if the stoParseClassParent is given (needs check in pdecobj.pas/parse_class_parents for normal classes)
* read_named_type: currently the only case when something <> ht_none is passed to the modified parse_objdec (see below) is when the combination "class helper" is encountered ("record helper" will be another one)
- pinline.pas: adjustment for extended "searchsym_in_class"
- pexpr.pas:
* adjustments regarding "searchsym_in_class" and "is_objectpascal_helper"
* factor/factor_read_id: moved the check for "TSomeClassType.SomeMethod" outside of the "is_class" check
* factor:
** in case of an inherited we need to search inside the extended type first (Note: this needs to be extended to find methods in the helper parent if no method is found in the extended type)
** we also need to disable the search for helper methods when searching for an inherited method (Note: it might be better to introduce a enum to decide whether a helper method should search before or after the methods of the extended type or even never)
- pdecsub.pas:
* insert_self_and_vmt_para: in a helper the type of Self is of the extended type
* pd_abstract, pd_final: more nice error message
* pd_override, pd_message, pd_reintroduce: adjusted checks because now "is_class" is no longer true for helpers
* proc_direcdata: allowed "abstract" for helpers (only to produce a more nice error message)
* parse_proc_direc: adjustment because of "is_objectpascal_helper"
- pdecobj.pas:
* adjustments regarding "is_objectpascal_helper"
* adjusted object_dec to take the type of the helper (class, record) as a parameter to be able to check whether the correct extended type was given
* struct_property_dec: properties are allowed in helpers
* parse_object_options: nothing to be parsed for helpers (at least I hope so ^^)
* parse_parent_classes:
** the parent of a helper is now parsed as a normal parent, the extended type is parsed in an extra procedure
** check for "sealed" no longer needed
** added check that the parsed parent of a helper is indeed a helper
** allow to parse the closing ")" of the helper's parent
* parse_extended_class:
** new procedure that parses the type which is extended
** it checks that the extended type is a class for "class helper" and a record for "record helper"
** it checks that a helper extends the same class or a subclass for class helpers
** it checks that a helper extends the same record for record helpers
* parse_object_members:
** "type", "const", "var" is allowed in helpers
** don't exclude flags regarding virtual methods, they are needed for the checks in mode Delphi (this implies that VMT loading must be disabled for helpers)
* object_dec:
** don't change "odt_helper" to "odt_class", but still include the "oo_is_classhelper" flag
** allow the parsing of object options (there are none)
** parse the extended type for helpers
- pdecl.pas
* adjustment because of extension of object_dec
* types_dec: remove the call to finish_classhelper
- objcdef.pas
* objcaddencodedtype, objcdochecktype: add references to helpers as implicit pointers although that should not be used in any way...
- nld.pas
* tloadnode.pass_typecheck: self is a reference to the extended type
- nflw.pas
* create_for_in_loop: adjustment because of changed procedure and inheritance type
- ncgrtti.pas
* TRTTIWriter.write_rtti_data: disable for helpers for now (I need to check what Delphi does here)
- ncgld.pas
* tcgloadnode.pass_generate_code: virtual methods of helpers are treated as normal methods
- ncgcal.pas
* tcgcallnode.pass_generate_code: virtual methods of helpers are treated as normal methods
- ncal.pas
* tcallnode.pass_typecheck: adjust for extension of tcallcandidates constructor
- htypechk.pas
* tcallcandidates declaration: extend some methods to (dis)allow the search for helper methods (needed for inherited)
* tcallcandidates.collect_overloads_in_struct:
** search first in helpers for methods and stop if none carries the "overload" flag
** move the addition of the procsyms to an extra nested procedure because it's used for helper methods and normal struct methods
git-svn-id: branches/svenbarth/classhelpers@16947 -
- pdecobj.pas: removed a check whether a class (helper) tries to inherit from a class helper, because now single_type handles this
- pexpr.pas:
* prohibit type casts to class helpers (note: this might be needed for ObjC categories as well)
* class helper references may only be used when inheriting from them (needs to be checked for ObjC categories as well)
- ptype.pas:
* single_type: extend check against categories for class helpers
* read_named_type: extend check against categories for class helpers
- symbase.pas: add a method that adds symbol table flags recursivly to a stack of symtables (it stops updating the symtables once a symtable already has that flag or it's a global-/staticsymtable)
- symdef.pas: adjusted the constructor of tobjectdef to use the new method for adding flags
git-svn-id: branches/svenbarth/classhelpers@16889 -
- compiler/symdef.pas: add "helperparent" which contains the class helper the current class helper "inherits" from (its real parent is the extended class); it's saved to ppu as well
- compiler/ppu.pas: increase ppu version
- compiler/pdecobj.pas:
* parse the "parent" of a class helper before parsing the extended class (the real parent)
* also disallow to inherit from class helpers for normal class (and to extend class helpers for class helpers)
* disallow the declarations of fields
* disallow the use of destructors
* don't parse abstract/sealed for class helpers
- compiler/ptyp.pas: _FOR is now parsed inside pdecobj.pas
- compiler/msg*:
* extended some messages for class helpers
* added some class helper related messages (perhaps the one or other will vanish again...)
git-svn-id: branches/svenbarth/classhelpers@16792 -
- allow operator also if return type match the structure type (before at least one parameter had to match)
- search both operands symbol tables for a suitable assignment operator
- test
based on patch of Blaise Thorn (issue #0018490)
git-svn-id: trunk@16762 -
change is that it is now also allowed to specify an external name for
formal external class definitions, but if they are later mixed with
regular class definitions the external names have to match.
o because the "external" status of methods is now set while parsing the
class rather than afterwards, some procdir compatibility checks had to
be inlined because they only have to be performed for
* also adapted the syntax for external cppclasses in the same way
* fixed return type of NSObject.retainCount and NSObject.hash
(NSUInteger instead of cint)
* moved "patches" directory from cocoaint/src to cocoaint/utils/cocoa-skel
so they are used by the conversion script when re-parsing the headers
* updated Objective-C header parser script to
o use the new external class syntax
o not write inheritance information for root classes (NSObject, NSProxy)
o use internal translation tables for some conflicting method names that
are named specially in objcbase.pp
and updated parsed headers
* fixed rtl/inc/objcbase.pp and tests to conform to the new external class
syntax
git-svn-id: trunk@16684 -
------------------------------------------------------------------------
r16513 compiler: add support for visibility blocks in records and type, const declarations:
- add parse_record_members function to parse record blocks based on parse_object_members code
- disable published section in records
- rename in_class argument in some functions to in_structure because the same code can work for records now which are not classes
------------------------------------------------------------------------
r16514 compiler: check visibility of record members, allow access to record consts and types:
- add searchsym_in_record function
- change is_visible_for_object to accept tabstractrecorddef instead of tobjectdef arguments because records also have visibility sections now
- change arguments in do_member_read, do_proc_call to tabstractrecorddef from tobjectdef to accept records
- rename classh arguments to structh and change their type to tabstractrecorddef to show that they can accept records now too
- move RttiName from tobjectdef to tabstractrecorddef
------------------------------------------------------------------------
r16515 compiler: add current_structdef: tabstractrecorddef and point current_objectdef to it
------------------------------------------------------------------------
r16516 compiler: allow access other record symbols than fields, first extended records tests
------------------------------------------------------------------------
r16519 compiler:
- move objname, objrealname fields from tobjectdef to tabstractrecorddef,
- load and save them from/to ppu file,
- use tabstarctrecorddef in some more places where previously code worked for tobjectdef
- change push_nested_hierarchy, pop_nested_hierarchy to handle records too
------------------------------------------------------------------------
r16526 compiler: implement record methods and class methods:
- rename tprocdef._class to tprocdef.struct and change the type from tobjectdef to tabstractrecorddef because methods can belong not to classes only now but to records too
- replace in many places use of current_objectdef to current_structdef with typcast where is needed
- add an argument to comp_expr, expr, factor, sub_expr to notify that we are searching type only symbol to solve the problem with records,objects,classes which contains fields with the same name as previosly declared type (like:
HWND = type Handle;
rec = record
hWnd: HWND;
end;)
- disable check in factor_read_id which was made for object that only static fields can be accessed as TObjectType.FieldName outside the object because it makes SizeOf(TObjectType.FieldName) imposible and since the same method was extended to handle records it also breaks a52 package compilation
- rename tcallcandidates.collect_overloads_in_class to tcallcandidates.collect_overloads_in_struct and addapt the code to handle overloads in records too
- fix searchsym_type to search also in object ancestors if we found an object symtable
- add pd_record, pd_notrecord flags to mark procedure modifies which can or can't be used with records. Disallow the next modifiers for records: abstract, dynamic, export, external, far, far16, final, forward, internconst, internproc, interrupt, message, near, override, public, reintroduce, virtual, weakexternal,
Allow the next modifiers for records: static
------------------------------------------------------------------------
r16530 compiler: fix compilation problems caused by tprocdef._class -> tprocdef.struct rename which was found by make fullcycle
------------------------------------------------------------------------
r16531 compiler: redo searchsym_type:
- remove complex condition which was used previosly to decide whether objectsymtable or recordsymtable requires a search for type or not - they require a search because contains types (although not all object types)
- don't search only for typesym but for other symbols too - for example UnitSym.TypeSym or ConstSym..ConstSym are also valid types. Skip the next symtypes during the search because they can't be used in type declaration: fieldvarsym, paravarsym, propertysym, procsym, labelsym
------------------------------------------------------------------------
r16541 compiler: move objectoptions to tabstractrecorddef because it will be needed for records too
------------------------------------------------------------------------
r16542 compiler: remove unneeded checks and typecasting caused by move of objectoptions into tabstractrecorddef
------------------------------------------------------------------------
r16543 compiler: move constructor, destructor parsers to interface section to allow future use by records + change current_objectdef to current_structdef for the same reason, make constructor return type = record for records
r16544 compiler: start parsing of record constructors and destructors:
- disallow record destructor
- raise internal error for constructor because it is not yet implemented
- handle class constructors and destructors for records
- move find_procdef_bytype to tabstractpointerdef
------------------------------------------------------------------------
r16545 compiler: fix static fields creation and access for records
+ extend test to check class constructor/destructor for records and static fields access
------------------------------------------------------------------------
r16546 tests: add a test which checks that records destructors are not allowed
------------------------------------------------------------------------
r16547 compiler: rename aclass->astruct in read_property_dec because records will have properties too
------------------------------------------------------------------------
r16548 compiler: implement properties in records:
- rename property_dec from pdecobj to struct_property_dec because pdecl also has property_dec and move it to interface to use by records + allow properties for records
- use struct_property_dec in record parser
- change structh type from objectdef to abstractrecorddef in read_property_dec to use by records
- disallow stored and default modifiers for records because records are not used for streaming
- fix misuse of search_sym_in_class for records in few places
------------------------------------------------------------------------
r16550 compiler: disallow regular class methods in records and allow only static class methods. delphi do so and it is logical because records have no inheritance. + tests
------------------------------------------------------------------------
r16560 compiler: a trial to implement record constructor
- map self to constructor result
- don't push vmt for records
At the moment generated assembler has errors although node tree is correct
------------------------------------------------------------------------
r16561 compiler:
- add mode switch extendedrecords to allow/disallow extended records syntax, add this mode switch to delphi mode by default
- disable/enable extended records parsing based on extendedreocrds mode switch
------------------------------------------------------------------------
r16562 compiler: fix record constructor return type when parsing procedure declaration
------------------------------------------------------------------------
r16568 compiler: partly revert r16560 and disable (at least temporary) constructors in records
------------------------------------------------------------------------
r16569 test: add records Self test
------------------------------------------------------------------------
r16570 compiler: generate debug info for record methods:
- extended write_symtable_procdefs to handle record definitions
- fix stabs info generator to use prefixed symbol names for record methods, also handle records static symbols the same way as for object types
- fix dwarf info record generation: add visibility info and write methods, also prefix record members the same way as object members
git-svn-id: trunk@16574 -
- disallow record destructor
- raise internal error for constructor because it is not yet implemented
- handle class constructors and destructors for records
- move find_procdef_bytype to tabstractpointerdef
git-svn-id: branches/paul/extended_records@16544 -
- add parse_record_members function to parse record blocks based on parse_object_members code
- disable published section in records
- rename in_class argument in some functions to in_structure because the same code can work for records now which are not classes
git-svn-id: branches/paul/extended_records@16513 -