Commit Graph

190 Commits

Author SHA1 Message Date
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
paul
86482658a8 compiler: fix tgeneric11 test:
- add stoAllowSpecialization to TSingleTypeOption enum to differentiate between any new type definition and only generic specialization
  - allow only specializations for class parents (not any other type definition)
  - allow specialization for method arguments and return types (maybe this must be allowed only in delphi mode but in this case tgeneric11 must fail)

git-svn-id: trunk@16738 -
2011-01-08 16:14:22 +00:00
paul
d37fde7302 compiler: simplify _CLASS token handling in object declarations by Sven Barth (issue #18425)
git-svn-id: trunk@16733 -
2011-01-08 05:24:25 +00:00
paul
e0e01899e5 compiler: move parse_generic_parameters to the interface of pdecl unit, move insert_generic_parameter_types to pdecl unit to access them from pdecsub (preparations for generic methods implementation)
git-svn-id: trunk@16724 -
2011-01-06 17:53:46 +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
paul
d55a141d70 compiler: allow generics as class parents + fixed test
git-svn-id: trunk@16708 -
2011-01-05 05:03:21 +00:00
paul
fa41b6ffe3 compiler: allow generic classes to derive from generic classes and generic interfaces
- change id_type to single_type in readImplementedInterfacesAndProtocols to allow use of interface specializations inside class parent block
  - change single_type boolean arguments to set, add stoParseClassParent option to that set
  - move parse_generic variable assignment from parse_object_members to outer routine to setup it before parsing class parents
  - return paticular generic in generate_specialization instead of undefineddef to pass class/interface checks inside parent class block
  - add test for delphi mode
  - modify tw11431 to be syntatically correct

git-svn-id: trunk@16706 -
2011-01-04 18:20:40 +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
e8502b8ec2 compiler: make current_genericdef, current_specializedef tstoreddef instead of tabstractrecorddef to implement generic arrays
git-svn-id: trunk@16671 -
2010-12-31 04:39:16 +00:00
paul
52667b6822 compiler: implement generics for records based on generic objects implementation + 1 test
git-svn-id: trunk@16670 -
2010-12-31 03:43:16 +00:00
paul
101f545ad0 compiler: don't allow generic object types (interfaces,dispinterfaces,objclasses,...) to have type,var,const sections if regular object types don't have them. currently only objects, classes and records are allowed to have nested type,var,const sections.
git-svn-id: trunk@16669 -
2010-12-31 02:31:51 +00:00
paul
2af416e145 compiler: move current_objectdef variable to implementation of pdecobj and use explicit type conversion to tobjectdef in other places where current_objectdef is needed
git-svn-id: trunk@16660 -
2010-12-30 07:40:31 +00:00
paul
ee78cf0f06 compiler: use current_structdef in more places where current_objectdef was used, change type of current_genericdef and current_specializedef to tabstractrecorddef for future use with generic records
git-svn-id: trunk@16659 -
2010-12-30 07:33:57 +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
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
17815ce7a2 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

git-svn-id: branches/paul/extended_records@16548 -
2010-12-11 08:42:26 +00:00
paul
4e73e280f9 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
git-svn-id: branches/paul/extended_records@16543 -
2010-12-11 07:29:08 +00:00
paul
56bf42de57 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

git-svn-id: branches/paul/extended_records@16526 -
2010-12-09 02:24:46 +00:00
Jonas Maebe
3a089cea10 * give an error when trying to let an objcclass conform to a
forward-declared objcprotocol (mantis #17341)

git-svn-id: trunk@16523 -
2010-12-08 22:17:24 +00:00
paul
af39178e06 compiler: redo type search in parent classes. previous trial breaks objective pascal implementation
git-svn-id: trunk@16505 -
2010-12-05 10:59:11 +00:00
paul
515c99cc01 compiler: cleanup
git-svn-id: trunk@16492 -
2010-12-02 03:06:01 +00:00
paul
2155dadf5e compiler: push to the stack not only nested hierarchy but also class hierarchy for each nested entry both in method declaration and for method body, also push child hierarchy while parsing object members because in other case parent types are invisible for descendants (fixes mantis #0018124, mantis #0018127 and more) + extended test
git-svn-id: trunk@16491 -
2010-12-02 03:04:23 +00:00
florian
d30952b408 * patch by Aleksa Todorovic which adds the ability to reference current generic class. Each reference to current generic class is "translated" to appropriate specialization of that generic class. There are two tests as part of the patch to test that it works. The patch, also, rejects declaring generic inside another generic. 0010479 is easy to implement with this patch applied, resolves #11777
git-svn-id: trunk@16423 -
2010-11-24 21:57:41 +00:00
paul
f5751d81db compiler: reset section type to regular fields section after the "public", "protected", ... and other section visibility keywords
git-svn-id: trunk@16302 -
2010-11-04 15:12:17 +00:00
Jonas Maebe
1c9fed7ae3 * resolve anonymous external objcclass definitions to the real type also when
a) defining a child class
     b) checking for type conversion compatibility

git-svn-id: trunk@16013 -
2010-09-19 16:05:32 +00:00
paul
790f6b0a4b compiler: use delphi syntax for type, const and var section declarations in classes instead of fpc generics syntax
rtl: fix fgl to use the new syntax
tests: fix generics tests to use the new syntax

git-svn-id: trunk@15646 -
2010-07-27 00:59:32 +00:00
Jonas Maebe
62d677eb92 + support for formally declared objcclasses ("type x=objcclass;external;")
+ tests

git-svn-id: trunk@15476 -
2010-06-25 15:08:37 +00:00
paul
ceccce93f5 compiler: add class constructors, class destructors to the initfinal table as regular initialization/finalization sections (class constructors is still not striped away with the class)
git-svn-id: trunk@15143 -
2010-04-15 07:37:41 +00:00
paul
24d8a7d833 compiler: start implementation of class constructors/destructors: parsing is ready but at the moment neither class constructors nor destructors are called - this is to be implemented
git-svn-id: trunk@15109 -
2010-04-03 09:14:12 +00:00
paul
8a0028a62e compiler: support *sealed* and *abstract* for objects (issue #0016174)
git-svn-id: trunk@15105 -
2010-04-01 14:36:33 +00:00
paul
973d947d6c compiler: allow const, type, var and class var sections for objects + test
git-svn-id: trunk@15092 -
2010-03-30 04:22:19 +00:00
paul
06a37d1fb1 compiler: remove dummy assignment
git-svn-id: trunk@15090 -
2010-03-30 01:12:14 +00:00
Jonas Maebe
e693b47234 * don't insert bogus vmt field in forward-defined classes
git-svn-id: trunk@14961 -
2010-03-01 14:57:14 +00:00
Jonas Maebe
4469501835 * fixed indentation, simplified calling read_record_fields()
git-svn-id: trunk@14837 -
2010-01-31 20:54:48 +00:00
paul
bd6f1d7447 compiler: auto generate method/property dispid if it is not set explicitly
git-svn-id: trunk@14766 -
2010-01-22 02:46:03 +00:00
paul
166f8a63a2 compiler: implement class constants + tests
git-svn-id: trunk@14609 -
2010-01-11 08:43:10 +00:00
paul
91ed1c6e6f compiler: types in classes:
- fix type visibility (was always public)
  - fix parsing of class sections after the type declaration
  - allow nested classes declarations
  + tests

git-svn-id: trunk@14607 -
2010-01-11 06:22:57 +00:00
paul
8de3b267a9 compiler: fix message regards VAR and TYPE sections in objects
git-svn-id: trunk@14606 -
2010-01-11 02:39:10 +00:00
paul
cb54b3e7a9 compiler: allow class to have local type sections + tests
git-svn-id: trunk@14605 -
2010-01-11 02:35:10 +00:00
paul
4b53a54b51 compiler: implement 'var' and 'class var' sections for classes + tests
git-svn-id: trunk@14598 -
2010-01-10 13:48:43 +00:00
paul
3ed4c58502 compiler:
- implement class properties: properties which can access only static fields and static class methods
  - tests
  - fix a possibility to call an instance method from the class method

git-svn-id: trunk@14585 -
2010-01-09 18:37:54 +00:00
Jonas Maebe
f8754d8fab + Objective-C category support (old and new ABI, both external and
implemented in Pascal). See
    http://wiki.freepascal.org/FPC_PasCocoa#Category_declaration for syntax
    details

git-svn-id: trunk@14196 -
2009-11-16 00:12:08 +00:00
Jonas Maebe
60a9ef963d * finished basic support for calling methods from external C++ classes
(slightly modified patch by Sven Barth, mantis #15082)

git-svn-id: trunk@14185 -
2009-11-15 14:55:40 +00:00
Jonas Maebe
559e284bd0 * merged r13762-14047 from trunk
git-svn-id: branches/objc@14048 -
2009-11-04 15:50:26 +00:00
paul
aa5a5e79ce merge revisions: 13909,13923,13924,13934,13935,13942,13943,13944,13946,13948,13950,13951,13952,13983,13994:
rtl: add enumerators to the basic classes
tests: add enumerators test which compiles and work both by fpc and dcc
compiler: 
  + start for-in loop implementation: implement for-in loop for types (enumerations and ranges), strings, arrays and sets. todo: perform type checking, optimize array and string loops - use temp for expression, implement for-in loop for classes
test:
  + add a simple test for the 'for-in' loop
compiler: fix string for-in loop. now it uses a temp variable to store string expression result
complier: fix for-in array loop. use a temp variable for the loop expression only if loop is not an open array loop
complier: continue enumerator implementation:
  + add operator enumerator which give an ability to add enumerator for an existent type (for example to override builtin string enumerator)
  + add class enumerator support via delphi compatible GetEnumerator method + enumerator class/object template (function MoveNext: Boolean; property Current)
  + tests
compiler: fix for-in loop for arrays. delphi does not copy arrays to a temp variable and it is possible to change array during loop. + test
compiler: add reference for the enumerator operator when it is used + another test for operator enumerator for a class
compiler: add reference for the enumerator operator when it is used + another test for operator enumerator for a class
compiler: enumerator directive support:
  + allow to mark methods and properties by 'enumerator MoveNext' and 'enumerator Current' modifiers. Parser checks return types and duplicates.
  + prefer *marked* by enumerator directive methods and properties than GetEnumerator and Current builtin symbols
  + increase ppu version
  + test
rtl: add IEnumerator and IEnumerable interfaces declarations
tests: for-in loop tests:
  + add small comment at the top of test program
compiler: allow 'enumerator MoveNext' for the interface function declaration + test
compiler: move all for-in loop helpers to the nflw unit
compiler: don't allow the compiler to choose the non-valid enumerator operator for the for-in loop

git-svn-id: trunk@14008 -
2009-11-02 03:24:48 +00:00
paul
e784ec1079 merge revisions 13898-13899:
- compiler: allow message after the *deprecated* keyword
 - compiler: raise an internal error if deprecated message is trying to set to a non clear string pointer

git-svn-id: trunk@13997 -
2009-11-01 14:06:30 +00:00
florian
eb433d1bdd * merged sealed and abstract support by Paul Ishenin
-- Zusammenführen von r13884 in ».«:
U    compiler/msgtxt.inc
U    compiler/msgidx.inc
U    compiler/pdecsub.pas
U    compiler/pdecobj.pas
U    compiler/tokens.pas
U    compiler/ppu.pas
U    compiler/symconst.pas
U    compiler/msg/errore.msg
U    compiler/utils/ppudump.pp
-- Zusammenführen von r13885 in ».«:
A    tests/test/tsealed1.pp
A    tests/test/tabstract1.pp
A    tests/test/tsealed2.pp
-- Zusammenführen von r13893 in ».«:
A    tests/test/tsealed3.pp
A    tests/test/tsealed4.pp

git-svn-id: trunk@13908 -
2009-10-18 20:05:29 +00:00
Jonas Maebe
4c57a5f504 + support multiple inheritance for obj-c protocols
* don't allocate tobjectdef.implementedinterfaces for corba interfaces
    since the compiler doesn't support multiple inheritance for them
  * extended/corrected related tobjc22 test
  * increased ppu version, because implementedinterfaces is now
    present in different cases

git-svn-id: branches/objc@13738 -
2009-09-18 11:35:13 +00:00
Jonas Maebe
f586299b6a * don't warn that a constructor is necessary for objc classes/protocols
(since they can't have a constructor)

git-svn-id: branches/objc@13632 -
2009-09-01 13:54:12 +00:00