Commit Graph

4161 Commits

Author SHA1 Message Date
paul
d62ad56b74 tests: forgot to add { %fail} directive
git-svn-id: trunk@16628 -
2010-12-24 07:36:01 +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
714c4164ad tests: add also test for +,-,or,xor,and operators
git-svn-id: trunk@16625 -
2010-12-24 06:05:17 +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
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
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
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
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
sergei
49e3c30bd1 * Changed the test so it uses typecasting instead of calling the conversion helpers from VarUtils.
git-svn-id: trunk@16589 -
2010-12-18 18:43:40 +00:00
Jonas Maebe
2ee7a0f95d * corrected expected line numbers after r16573
git-svn-id: trunk@16576 -
2010-12-17 09:55:55 +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
pierre
96b8699af5 * Skip library tests for go32v2 target
git-svn-id: trunk@16573 -
2010-12-16 16:08:11 +00:00
pierre
818c88dbbf * Fix cprefix problems for tconstref4 test and add cppdecl modifier
git-svn-id: trunk@16572 -
2010-12-16 16:02:24 +00:00
paul
d83eab7ae8 test: add records Self test
git-svn-id: branches/paul/extended_records@16569 -
2010-12-16 04:20:41 +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
4c7e2679df tests: add a test which checks that records destructors are not allowed
git-svn-id: branches/paul/extended_records@16546 -
2010-12-11 07:58:14 +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
Jonas Maebe
f4c31ecf3c + widestringmanager.codepointlengthproc added, which can be used to
determine the length of a multi-byte character. The return values
    are defined to be the same as those of POSIX' mblen: -1 =
    invalid/incomplete sequence, 0 = #0, > 0 = length of sequence in
    bytes.
  + default implementation for widestringmanager.codepointlengthproc
    (assumes all code points have length 1) and Unix implementation
    (based on mb(r)len); Windows implementation is still required
  * replaced default implementation of
    widestringmanager.CharLengthPCharProc with strlen() of the input
    instead of an error (correct if all code points have length 1,
    still needs Windows implementation)
  + implemented fpc_text_read_{wide,unicode}str() and
    fpc_text_read_widechar() (mantis #18163); fpc_text_read_widechar()
    uses the new widestringmanager.codepointlengthproc()
  + unicodestring support for readstr/writestr
  * fixed declaration of fpc_Write_Text_UnicodeStr (unicodestring
    instead of widestring parameter)
  * extended test/twide*.pp tests to test the new/fixed functionality

git-svn-id: trunk@16533 -
2010-12-10 14:10:01 +00:00
sergei
5bf51c991c * VarUtils, fixed missing support for interfaces
- NoInterfaces() not used anymore, removed
+ Basic test for VariantArray of IInterface

git-svn-id: trunk@16527 -
2010-12-09 16:38:55 +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
d7c8d9e620 compiler: allow access other record symbols than fields, first extended records tests
git-svn-id: branches/paul/extended_records@16516 -
2010-12-07 09:53:57 +00:00
florian
34dc727f0b + test for last commit
git-svn-id: trunk@16497 -
2010-12-02 17:32:48 +00:00
paul
8b209be7e9 compiler: put static variables into unit level and not into parent class/object/record (fixes bug #0018131)
git-svn-id: trunk@16494 -
2010-12-02 05:56:13 +00:00
paul
ab4a5c74c1 compiler: allow TFoo.TBar types for object methods (bug #0018123)
git-svn-id: trunk@16493 -
2010-12-02 03:53:02 +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
paul
668cd1f3c0 compiler: change check for current in try_consume_unitsym - don't use current_unit in check because specialize code does not replace this variable (fixes bug #0015591)
git-svn-id: trunk@16489 -
2010-12-01 08:18:51 +00:00
paul
ba75daa50d compiler: change find_module_from_symtable to support not only unit symtables but also other symtables with valid moduleid (fixes bug #0016090)
git-svn-id: trunk@16487 -
2010-12-01 04:33:47 +00:00
paul
26032c3574 test: add { %norun } directive to tw12249
git-svn-id: trunk@16481 -
2010-11-30 08:14:31 +00:00
paul
433f18e60c compiler: resolve only current typeblock forward declarations when the type block is finished (fixes bug #0018086)
git-svn-id: trunk@16480 -
2010-11-30 00:02:06 +00:00
florian
d99081fa47 + additional test
git-svn-id: trunk@16478 -
2010-11-29 21:18:59 +00:00
florian
f570934b45 * patch by Aleksa Todorovic to fix generic interfaces, resolves #16100
git-svn-id: trunk@16477 -
2010-11-29 21:13:09 +00:00
Jonas Maebe
5cbe12c622 * don't overwrite the target value of interlockedcompareexchange*() if the
value is different from the comparand (patch by "FVI", mantis #18082)
  * sign extend the loaded value of interlockedcompareexchange() on PowerPC64,
    because the function arguments are longints

git-svn-id: trunk@16475 -
2010-11-29 12:53:10 +00:00
florian
7d1627e9ca * patch by Aleksa Todorovic to handle access to types inside generics correctly
when they are used as class variables, resolves #18096

git-svn-id: trunk@16474 -
2010-11-29 09:37:09 +00:00
paul
0d57d38d7c compiler: fix visibility of inherited protected members (mantis #0018087) and strict private/protected members (mantis #0018085) to nested classes
git-svn-id: trunk@16473 -
2010-11-29 04:08:00 +00:00
florian
97ac6ab928 + test for #17184
git-svn-id: trunk@16470 -
2010-11-28 20:23:45 +00:00
florian
e4ecee317e * finer grained convert levels for strings, prefers widestring<->unicodestring over other conversions, resolves #18075
git-svn-id: trunk@16460 -
2010-11-28 10:05:09 +00:00
sergei
7dd93b1282 * Variant types: renamed varunicodestring to varustring and changed its value to $102 (for Delphi compatibility), introduced varUStrArg=$73, added some description comments.
* ncal.pas, translate_disp_call:
  * pass UnicodeString as varUStrArg
  * do not typecast ordinal consts to Integer, so typecasts in source (if any) are preserved.
+ test for correct passing of Dispatch method arguments, concludes work on Mantis #17904.

git-svn-id: trunk@16456 -
2010-11-27 16:17:43 +00:00
Jonas Maebe
edfb31c020 * when looking for overloaded conversion (assignment) operators, only ignore
those for variants. All defined operators are guaranteed to be valid by
    the code that checks them when they are defined (mantis #17846)

git-svn-id: trunk@16449 -
2010-11-26 15:37:31 +00:00
Jonas Maebe
11399b9b13 + test from mantis #16365, already works
git-svn-id: trunk@16447 -
2010-11-26 14:38:15 +00:00
paul
8aef216f21 compiler: allow nested objects to refence owner class in method arguments (issue #0017986)
git-svn-id: trunk@16440 -
2010-11-26 07:55:55 +00:00
paul
0c23029d8f compiler: add all nested classes to the symtable stack while parsing method header (issue #0017952)
git-svn-id: trunk@16439 -
2010-11-26 07:30:20 +00:00
florian
ef0899425b * adds assign methods to the fgl classes based on a patch by Aleksa Todorovic, resolves #10479
git-svn-id: trunk@16429 -
2010-11-25 14:12:13 +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
Jonas Maebe
749991ec02 + support extra parameter for initialize() that indicates how many elements
should be initialised, similar to how this was already allowed for
    finalize() (mantis #17998)

git-svn-id: trunk@16407 -
2010-11-23 15:14:40 +00:00
Jonas Maebe
6eecf71698 * halt(1) on error
git-svn-id: trunk@16402 -
2010-11-22 13:36:58 +00:00
Jonas Maebe
44178f41b6 * don't overwrite register variables when evaluating <=/>= expressions with
smallsets (left is overwritten by an "and", so it cannot be const; mantis
    #18013)

git-svn-id: trunk@16400 -
2010-11-22 12:58:08 +00:00