Commit Graph

12059 Commits

Author SHA1 Message Date
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
e098046608 compiler: fix typo
git-svn-id: trunk@16645 -
2010-12-27 03:43:42 +00:00
paul
51a9d3280c compiler: require at least one argument of class operator to be of type of structure where this operator is declared
git-svn-id: trunk@16644 -
2010-12-27 02:33:17 +00:00
paul
77fa5b7fb9 compiler: read and write full token size instead of 1 byte because TToken has more than 255 elements now
git-svn-id: trunk@16642 -
2010-12-26 15:15:20 +00:00
paul
ee6fe6c4f5 compiler: add unary plus node, search for unary plus operator if a type cannot be handled by compiler, increase ppu version because of node types change
git-svn-id: trunk@16640 -
2010-12-26 12:19:28 +00:00
paul
c0c7e40b65 compiler: allow Inc, Dec, Explicit operators for other fpc modes
git-svn-id: trunk@16637 -
2010-12-25 11:31:07 +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
sergei
2ff5f7a000 * For object fullrtti, add a parent 'field' regardless of whether its type needs inittable.
git-svn-id: trunk@16635 -
2010-12-24 16:20:44 +00:00
Jonas Maebe
814658847e * fixed comments for some comments, they were offset by one line (patch by
Dmitry Boyarintsev, mantis #17486)

git-svn-id: trunk@16634 -
2010-12-24 15:58:41 +00:00
Jonas Maebe
780e75bfac o patch by Jeppe Johansen to fix mantis #17472:
* generate add.w instead of add for thumb-2 in case one of the registers
      is > r8
    * add register interferences for the "add" instruction so the register
      allocator can detect invalid instruction forms (even for assembler code)
    * fixed error in thumb2.inc detected by the previous change

git-svn-id: trunk@16633 -
2010-12-24 15:54:39 +00:00
sergei
8cbef5627e Fixed rtti/finalization of objects that have ancestors and fields of managed types:
* Link rtti to ancestor by writing rtti of ancestor as a field of type tkObject and offset zero. This is a cheat from formal point of view (as it replaces inheritance with aggregation), but is fine for the intended purpose of representing memory layout. Now RTL can handle entire instance of descendant object, and such objects can be statically allocated without leaks.
* Bypass finalization in inherited object destructors, as the instance is now entirely finalized in outermost destructor.
+ test

git-svn-id: trunk@16632 -
2010-12-24 14:46:29 +00:00
paul
cdca5f42b7 compiler: extend internal error 200305061 check for records
git-svn-id: trunk@16630 -
2010-12-24 09:27:34 +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
8c8c1fc151 compiler:
- parse operator return type the same way as we parse function return type - which pushing structures into the symtable and allowing self references, 
  - this change allows class operators to have return type = structure where they are defined
  - extend test to check LogicalNot operator which can be finally compiled now

git-svn-id: trunk@16627 -
2010-12-24 07:22:48 +00:00
paul
3c6fde4acc compiler: rename parser_e_constructors_always_objects message to parser_e_only_methods_allowed and extended the meaning it has, don't allow class constructors to be declared outside the class/record + test
git-svn-id: trunk@16626 -
2010-12-24 06:41:41 +00:00
paul
b811f1be15 compiler: implement delphi style class operators:
- add delphi operator tokens into token enum
  - move optoken search from parse_proc_dec to parse_proc_head and add delphi operator name search
  - map delphi operators to existent fpc operators and skip some delphi operators for now
  - implement store operators in record symtable and search in it

git-svn-id: trunk@16624 -
2010-12-24 05:43:36 +00:00
paul
525f4fea43 compiler: prepare collect_overloads_in_struct to work with operators, replace tprocsym argument in proc_add to tsymtable because tprocsym is only used to get the symtable
git-svn-id: trunk@16623 -
2010-12-24 03:17:43 +00:00
paul
d97cf8ed9d compiler: implement IN operator which was known by compiler but was not supported. + test
git-svn-id: trunk@16622 -
2010-12-24 02:25:22 +00:00
Jonas Maebe
067536f8da * pass large "const" record parameters by reference for non-cdecl/cppdecl
(mantis #17442)

git-svn-id: trunk@16620 -
2010-12-23 16:11:06 +00:00
Jonas Maebe
d10f46ec59 * skip instructions containing a reference with a segment prefix (fixes
mantis #18113)

git-svn-id: trunk@16619 -
2010-12-23 15:24:29 +00:00
Jonas Maebe
c8115921f1 * fixed comment typo
git-svn-id: trunk@16618 -
2010-12-23 15:14:30 +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
sergei
cd1f8e14f4 * TRTTIWriter improvements:
* Emit typename for Variants (Delphi compatible)
  * For objects, write record-style RTTI instead of class-style. Objects cannot have published symbols, so class-style RTTI for them is always empty, thus typeinfo() was returning a useless stub. The new behavior is closer to Delphi, but still different (Delphi typeinfo() returns pointer to what is initrtti in FPC, while we return fullrtti).

git-svn-id: trunk@16612 -
2010-12-22 14:45:40 +00:00
sergei
b50cf9a42a * TRTTIWriter.fields_write_rtti_data: refactoring. Since TAsmList allows random access, a separate loop iteration to count fields is redundant. Simply count the actually written fields, then insert result before field data.
git-svn-id: trunk@16611 -
2010-12-22 12:42:16 +00:00
Jonas Maebe
ce93333bda * fixed end of LaTeX environment after r16574 (mantis #18286)
git-svn-id: trunk@16610 -
2010-12-22 09:29:03 +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
92d6503704 compiler: rename _EQUAL token to _EQ to prevent problems with adding delphi operator names which contains "EQUAL" name, also rename _UNEQUAL to _NE for consistency
git-svn-id: trunk@16608 -
2010-12-22 02:01:40 +00:00
sergei
b3aa9ac813 * Refactored TRTTIWriter by separating some commonly used code into procedures. Improves readability and reduces amount of typing; functionality stays unchanged.
git-svn-id: trunk@16607 -
2010-12-21 22:33:48 +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
Jonas Maebe
cec5843f95 * renamed objcdef.addencodedtype to objcaddencodedtype for consistency
reasons, and to prevent name clashes

git-svn-id: trunk@16598 -
2010-12-19 19:37:47 +00:00
sergei
331a72c8d6 * ncnv.pas, insert_varargstypeconv(): Do not cast a string literal to AnsiString if it has been already casted to Wide/UnicodeString, resolves #18266.
git-svn-id: trunk@16593 -
2010-12-19 15:08:42 +00:00
paul
0f15d89f0a compiler: formatting
git-svn-id: trunk@16590 -
2010-12-19 12:45:20 +00:00
paul
f3af6a83f7 compiler: put static symbol for typed consts declared in classes/records/objects into unit symtable to fix problems with linking and add absolute symbol into record symtable pointed to that static symbol (fixes test test/terecs3.pp on unixes)
git-svn-id: trunk@16588 -
2010-12-18 18:22:31 +00:00
sergei
34ffb184a8 * MASM and NASM assembler writers, added check for InlineLevel>0 so it suppresses entire source file processing, not just output of source lines. Without this, auto-generated instructions cause output of bogus line information. GAS writer already has similar check.
git-svn-id: trunk@16581 -
2010-12-17 18:03:56 +00:00
paul
54b5172286 compiler: fix compiler crash (bug #0018222)
- don't use source pointeddef for copied tpointerdef,tclassrefdef if pointteddef is a forward def because in this case when forward def will be resolved copied def will point to garbage
  - put copied def into list of defs awaiting resolve if it was copied from forward def
  + test

git-svn-id: trunk@16575 -
2010-12-17 07:50:47 +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
915c412ae3 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: branches/paul/extended_records@16570 -
2010-12-16 06:12:05 +00:00
paul
742b0bb686 compiler: partly revert r16560 and disable (at least temporary) constructors in records
git-svn-id: branches/paul/extended_records@16568 -
2010-12-16 03:37:16 +00:00
Jonas Maebe
709f1e8344 * also recognise non-GOT based RIP-relative address expressions as PIC
git-svn-id: trunk@16565 -
2010-12-15 13:39:27 +00:00
paul
8c56269076 compiler: fix record constructor return type when parsing procedure declaration
git-svn-id: branches/paul/extended_records@16562 -
2010-12-13 07:04:56 +00:00
paul
726ea27bc0 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

git-svn-id: branches/paul/extended_records@16561 -
2010-12-13 07:03:53 +00:00
paul
11d4eddf67 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

git-svn-id: branches/paul/extended_records@16560 -
2010-12-13 06:39:29 +00:00
florian
142e42bd81 o NativeNT target patch by Sven Barth, resolves with r16553 and r16554 #18195
* enables some disabled features for NativeNT in the compiler (all except stackcheck).

git-svn-id: trunk@16555 -
2010-12-11 20:41:37 +00:00
paul
582ab2dd32 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
git-svn-id: branches/paul/extended_records@16550 -
2010-12-11 10:21: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
69d3bb2ffc compiler: rename aclass->astruct in read_property_dec because records will have properties too
git-svn-id: branches/paul/extended_records@16547 -
2010-12-11 08:08:22 +00:00
paul
52cd624a76 compiler: fix static fields creation and access for records
+ extend test to check class constructor/destructor for records and static fields access

git-svn-id: branches/paul/extended_records@16545 -
2010-12-11 07:48:13 +00:00
paul
7852295f26 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

git-svn-id: branches/paul/extended_records@16544 -
2010-12-11 07:31:27 +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
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