Commit Graph

454 Commits

Author SHA1 Message Date
paul
b8589d98cc compiler: Don't allow duplicate property/procedure identifiers inside object declaration. The code which allowed this for delphi mode was initially written based on invalid test from mantis #0009176. Fixes bug #0020580.
git-svn-id: trunk@19564 -
2011-10-31 05:35:40 +00:00
paul
ceb141523d compiler: store property parameters in a parasymtables together with property. restore those parameters for descendant properties (fixes mantis #0020421 but maybe not very optimal)
git-svn-id: trunk@19400 -
2011-10-07 05:58:58 +00:00
florian
df75368d0b --- Merging r19281 into '.':
U    compiler\pdecsub.pas
U    compiler\symdef.pas
U    compiler\pdecobj.pas
U    compiler\htypechk.pas
U    compiler\ncal.pas
U    compiler\symtable.pas
--- Recording mergeinfo for merge of r19281 into '.':
 U   .
--- Merging r19282 into '.':
A    tests\webtbf\tw19975.pp
--- Recording mergeinfo for merge of r19282 into '.':
 G   .

git-svn-id: trunk@19343 -
2011-10-03 20:43:19 +00:00
paul
389c033a29 compiler: fix private and protected members visibility check for nested records (issue #0018768)
git-svn-id: trunk@19000 -
2011-09-07 01:51:13 +00:00
paul
dd5aa12531 compiler: fix strict private visibility check for nested types (issue #0018767)
git-svn-id: trunk@18999 -
2011-09-07 01:32:43 +00:00
paul
7dd8a97487 compiler: allow "with" to search members in nested types properly
git-svn-id: trunk@18987 -
2011-09-06 10:23:57 +00:00
florian
a1381c1240 * some aint -> tcgint changes to avoid range check errors on systems with sizeof(aint)<4
git-svn-id: trunk@18966 -
2011-09-04 14:26:27 +00:00
paul
4b24a58871 compiler: remove/hide few unused variables
git-svn-id: trunk@18912 -
2011-08-30 01:32:23 +00:00
paul
de21de2024 compiler: implement delphi like namespaces
git-svn-id: branches/paul/namespaces@18859 -
2011-08-27 03:52:07 +00:00
Jonas Maebe
3b9e1a4398 * fixed wrong class cast in r18226
git-svn-id: trunk@18261 -
2011-08-18 11:53:02 +00:00
florian
79a96ab287 + ttypesym.prettyname
* write names of specialization type syms more pretty

git-svn-id: trunk@18241 -
2011-08-17 11:10:00 +00:00
florian
2f58065873 * don't warn about unsed symbols in generic procedures/methods, resolves #18907
git-svn-id: trunk@18226 -
2011-08-16 19:48:36 +00:00
Jonas Maebe
0398ff6bf5 * also save/restore the size of the padding of record/objectsymtables
* when creating a child class, ignore the padding added to the parent
    in case of objcclasses (gcc/clang also do that; maybe the same
    has to be done for cppclass as well)
  -> objcclass layouts seem to finally completely match the gcc ones

git-svn-id: trunk@18119 -
2011-08-06 18:01:39 +00:00
Jonas Maebe
86b088f398 * store the current field alignment of tobjectdefs that use C_alignment,
because it influences the offset at which the next field in child classes
    should be placed in case it also uses C_alignment
  * also pad objectdefs based on the packrecords setting (Delphi-compatible)
  -> field offset calculation in objcclasses is now correct if they are
     compiled with {$packrecords c}

git-svn-id: trunk@18114 -
2011-08-06 13:11:23 +00:00
florian
570f3c4b39 * merges recent class helper fixes by Sven Barth
git-svn-id: trunk@17887 -
2011-06-30 18:54:46 +00:00
florian
60e16260e1 o adjust define handling to resolve #19519
* ensure that all defines are written when running the compiler with -va
  * even if a define is defined/undefined, write a message if it is written again

git-svn-id: trunk@17714 -
2011-06-10 19:03:27 +00:00
Jonas Maebe
b0e83a06af * fixed crash when trying to index a record without a default property
git-svn-id: trunk@17480 -
2011-05-17 13:13:59 +00:00
svenbarth
35b47e491c Rebase to revision 17306
git-svn-id: branches/svenbarth/classhelpers@17314 -
2011-04-13 10:04:14 +00:00
florian
4d19f6c532 * patch by Jeppe Johansen to be able to generate debug info if an rtl without variant support is used, resolves #18483
git-svn-id: trunk@17300 -
2011-04-10 21:11:03 +00:00
svenbarth
16e500ee3c Removed old search algorithm
git-svn-id: branches/svenbarth/classhelpers@17242 -
2011-04-03 19:29:31 +00:00
svenbarth
d0705a1779 Rebase to revision 17236
git-svn-id: branches/svenbarth/classhelpers@17241 -
2011-04-03 17:24:35 +00:00
svenbarth
a944be69a6 * nflw.pas: search for enumerators in helpers for records as well
* 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 -
2011-04-03 14:03:17 +00:00
Jonas Maebe
10674153cf * set result of searchsym_in_record() in case nothing was found
git-svn-id: trunk@17161 -
2011-03-21 12:42:23 +00:00
svenbarth
f7f357f18e * symconst.pas:
- 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 -
2011-03-20 11:27:27 +00:00
svenbarth
80e6498921 Rebase to revision 17096
git-svn-id: branches/svenbarth/classhelpers@17099 -
2011-03-09 16:29:47 +00:00
svenbarth
5218666328 * ncgrtti.pas: RTTI generation for helpers is handled like that for classes
* pdecl.pas: prohibit generic helper declarations
* pdecobj.pas: helpers extending generic types are not allowed (theoretically one could experiment with allowing this for Delphi style generics...)
* symtable.pas:
- is_visible_for_object: helpers can access (strict) protected fields of extended types
- searchsym_in_helper: use the correct contextclass and the correct search function
- search_default_property: search for default properties in helpers first
* symsym.pas: added a global variable that allows to track whether we are parsing inside a special system function
* pexpr.pas:
- statement_syssym: track the current syssym
- factor.factor_read_id: helper types are allowed inside "sizeof", "bitsizeof" and "typeinfo"

git-svn-id: branches/svenbarth/classhelpers@17097 -
2011-03-09 15:42:38 +00:00
svenbarth
878c8c7806 Implemented correct handling of inherited methods.
- symtable.pas:
* I extended "searchsym_in_class" with a parameter to decide whether helpers should be searched before the normal class' methods, after them or not at all (as I'm not using that anymore, I might revert this to a simple Boolean again)
* Added a new function "searchsym_in_helper" which implements the algorithm to search for a symbol inside a helper's implementation. For more information on this algorithm please read the comment at the top of that function ("searchsym_in_class" also calls this function in the case that "classh" is a helper)
- pexpr.pas:
* fixes for extended "searchsym_in_class"
* in case of "inherited" and a helper the new "searchsym_in_helper" is called with the "hasinherited" parameter set to true
- pinline.pas:
fixes for extended "searchsym_in_class"
- symconst.pas:
added new enumeration for helper search order (might be removed again)

git-svn-id: branches/svenbarth/classhelpers@17070 -
2011-03-03 22:00:36 +00:00
florian
26fbfaf5a7 + introduce the usage of asizeint/asizeuint for cpus with sizeof("alu")<>sizeof(pointer)
git-svn-id: trunk@17011 -
2011-02-26 20:10:03 +00:00
svenbarth
963a4d7b23 Commit of a completely restructured helper implementation. Instead of changing objectdefs with odt_classhelper to odt_class, they'll have the odt_helper type assigned to and this will be kept. This also implies that the parent of a helper is its true parent while the extended type is set to a field in tobjectdef (extendeddef).
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 -
2011-02-20 11:41:55 +00:00
svenbarth
d12b198c7f Rebase to revision 16888
git-svn-id: branches/svenbarth/classhelpers@16891 -
2011-02-07 20:30:48 +00:00
florian
ec2d294287 * compiler works again compiled with $R+
git-svn-id: trunk@16848 -
2011-01-30 12:45:04 +00:00
svenbarth
e19bcfae38 Added a flag set to TSymtable that tells whether it contains a class helper symbol, which is currently only used for static- and globalsymtables.
symconst.pas: added new enum tsymtableoption with set tsymtableoptions; currently it contains only sto_has_classhelper, but refactoring tstoredsymtable.b_needs_init_final is on the todo list
ppu.pas: added a new entry type that will hold the symtable options (91)
symbase.pas: added a new field "tableoptions" to TSymtable which will hold the flags of the symtable (only saved by tstoredsymtable)
symdef.pas: when a tobjectdef is created as a odt_classhelper or odt_objccategory the flag sto_has_classhelper is added to its owning global- or staticsymtable
symtable.pas: 
* load and write the symtable's options as a small set to an entry before the definition entries
* tabstractlocalsymtable needed to annoy me by not calling "inherited writeppu" which does the same as tabstractsymtable did before
* search_last_objectpascal_classhelper: check whether the static- or globalsymtable contains a class helper at all; if not then just continue with the next
utils/ppudump.pas:
* added reading of symtableoptions entry (as readsymtableoptions) based on the reading of tsym options
* added the reading of symtableoptions before every read of the contents of a TSymtable (definitions, symbols)

git-svn-id: branches/svenbarth/classhelpers@16845 -
2011-01-30 09:19:59 +00:00
svenbarth
07eebff55c Rebase to revision 16827
adjusted nflw.pas to compile again

git-svn-id: branches/svenbarth/classhelpers@16831 -
2011-01-28 22:15:34 +00:00
svenbarth
a317827456 symtable.pas:
- moved "find_last_classhelper" out of "search_objectpascal_class_helper" so that it can be used in the "for ... in" code.
- renamed "find_last_classhelper" to "search_last_objectpascal_classhelper"
- fixed the unintentional use of a parameter ("srsymtable") of the parent function (it was intended as a variable from the beginning)
- "search_objectpascal_class_helper" now also checks whether the matched class helper method is visible; for this a new parameter for the contextclass was added which is passed when called from "searchsym_in_class"
nflw.pas: before checking for a "GetEnumerator" method in the class we now check whether one of the class helpers in the hierarchy that is available for that class (using "search_last_objectpascal_classhelper") implements such a method (I need yet to check whether Delphi supports the addition of "Current" and "MoveNext" as well)

git-svn-id: branches/svenbarth/classhelpers@16829 -
2011-01-28 21:05:29 +00:00
svenbarth
dde7290439 compiler/symtable.pas:
Add function to search for class helper symbols. This is completely different from the ObjC one (Note to self: rename that function), because in Delphi only one class helper can be in scope at a given time. Also class helper symbols are searched BEFORE the symbols of the class.

So the search works like this:
1) search the last available class helper for the given class 
2) search for the given symbol (method/property) in the found class helper (if any)
3) if not found then use the helper parent of the class helper and continue with (2)

Especially step 1 might easily lead to longer compile times if no class helper for a class is in scope, but many units are included. I'll need to test this by cycling the compiler with and without that search and will then decided whether I should think about something better.

Note: Overloaded methods are not yet supported.

git-svn-id: branches/svenbarth/classhelpers@16794 -
2011-01-19 19:53:32 +00:00
paul
0c9b40acb7 compiler: record operators
- 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 -
2011-01-14 02:25:48 +00:00
paul
368c215070 compiler: always derive DispInterface from IDispatch, this solve a problem with assigning dispinterface to IUnknown or IDispatch variables
git-svn-id: trunk@16756 -
2011-01-13 04:43:49 +00:00
svenbarth
a9b64c80ad Rebase to revision 16728
git-svn-id: branches/svenbarth/classhelpers@16732 -
2011-01-07 23:06:09 +00:00
svenbarth
aed9f0a5f7 Added first version of class helper support (not fully working and not fully featured)
- tokens: added support for "helper" token
- symconst.tobjecttyp: added a new entry "odt_classhelper"
- symdef: added two functions to check whether a "tdef" instance is a class helper in general ("is_classhelper") or an Object Pascal class helper in particular ("is_objectpascal_classhelper")
- symdef.tobjectdef: added a new method "finish_classhelper" which calls "create_class_helper_for_procdef" for every method (maybe this can be used for Objective-C categories as well)
- symdef.tobjectdef.create: "ImplementedInterfaces" must be created for class helpers as well
- symtable.searchsym_in_class: class helper methods must be searched for Object Pascal classes as well (this is currently wrong, as those must be searched before the class symbols, but for a first test it's sufficient)
- ptype.read_named_type: "helper for" currently indicates a class helper ("for" should be checked inside "object_dec" though, as after "helper" there might be a parent class helper)
- pdecobj.parse_parent_classes: parse the name of the extended class and disable sealed check for those
- pdecobj.object_dec: "odt_classhelper" are changed to "odt_class" and "oo_is_classhelper" is added to the object options
- pdecl.types_dec: create class helper symbols by using "finish_classhelper"

git-svn-id: branches/svenbarth/classhelpers@16729 -
2011-01-07 21:38:56 +00:00
paul
2599cc63bd compiler: implement generic procedural types
- store type parameter in parasymtable, push it to the symtablestack before parsing arguments and return type
  - move procedure/function declaration parsing to procvar_dec subroutine
  - don't skip parasymtable while searching types because they store type parameters now
  - add TParaSymTable.ReadOnly field to prevent adding defs into symtable. Add defs to the parent symtable in this case (we are adding this symtable to stack to read type parameters only, add defs should go to parent in this case as it was before)

git-svn-id: trunk@16719 -
2011-01-06 11:53:51 +00:00
Jonas Maebe
3ca3276400 * changed syntax of external objcclasses (see wiki/FPC_PasCocoa). Another
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 -
2011-01-02 14:50:46 +00:00
paul
55a0fefb1f compiler: implement generic array type:
- add tarraysymtable to store generic type symbols
  - process generic and specialize declarations similar to generic records and classes
  - fix insert_generic_parameter_types to use def passed in argument instead of current_structdef because generic array type can't be assigned to the current_structdef variable
  - increase ppu version because of arraydef changes
  - tests

git-svn-id: trunk@16681 -
2011-01-02 13:16:17 +00:00
paul
210e78e4fa compiler: allow objects and records to have members which point to themself. only don't permit this to regular fields.
- remove testcurobject hack and perform a check only for regular fields
  - move is_holded_by to interface and rename it to is_owned_by
  - don't check static symbols in _needs_init_final because they always point to symbols registered on unit level
  - don't check object type in id_type, read_named_type when we are looking for type of structure member - the only check will be performed for record/object fields now
  + tests

git-svn-id: trunk@16646 -
2010-12-27 05:47:25 +00:00
paul
66b128efb3 compiler: map delphi Implicit operator to := operator of FPC, add Explicit operator for delphi only (for now) which works when explicit type conversion happens + extend test
git-svn-id: trunk@16636 -
2010-12-25 11:08:02 +00:00
paul
4531e1231b compiler: implement Inc, Dec class operators
- extend tok2node array to store inline function number for the case when nodetype = inlinen, add Inc, Dec operators to array
 - implement inline function support in isunaryoverloaded
 - check for operator overload if Inc, Dec is not used for standard types
 - extend test to check Inc,Dec operators

git-svn-id: trunk@16629 -
2010-12-24 09:26:52 +00:00
paul
22ddd23d03 compiler: fix error in overloaded_names array. "In" operator has "is" name and vice versa. Add token in comment for each overloaded_names entry to prevent similar errors in future.
git-svn-id: trunk@16617 -
2010-12-23 06:44:47 +00:00
paul
bf3c098c18 compiler: check that records methods have implementation too. previously check worked only for some object types
git-svn-id: trunk@16609 -
2010-12-22 03:40:04 +00:00
paul
8c0c614d5a compiler: allow <> operator overload. search for "<>" operator first for "<>" expressions and if not found then use "=" operator + test
git-svn-id: trunk@16603 -
2010-12-21 04:44:37 +00:00
paul
d1026bb052 compiler: reintegrate branch http://svn.freepascal.org/svn/fpc/branches/paul/extended_records
------------------------------------------------------------------------
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 -
2010-12-17 02:19:09 +00:00
paul
289c9bd192 compiler: remove unneeded checks and typecasting caused by move of objectoptions into tabstractrecorddef
git-svn-id: branches/paul/extended_records@16542 -
2010-12-11 07:00:46 +00:00