Commit Graph

357 Commits

Author SHA1 Message Date
Jonas Maebe
0a3a62811b + try/except and try/finally support for JVM target:
o always create exceptvarsym entry for on-nodes (on all targets) to remove
     some special cases when an unnamed exception was caught
   o the JVM tryfinally node generates the finally code twice: once for the
     case where no exception occurs, and once when it does occur. The reason
     is that the JVM's static bytecode verification otherwise cannot prove
     that we will only reraise the caught exception when we caught one in
     the first place (the old "jsr" opcode to de-duplicate finally code
     is no longer used in JDK 1.6 because it suffered from the same problem,
     see Sun Java bug
     http://webcache.googleusercontent.com/search?q=cache:ZJFtvxuyhfMJ:bugs.sun.com/bugdatabase/view_bug.do%3Fbug_id%3D6491544 )

git-svn-id: branches/jvmbackend@18387 -
2011-08-20 07:55:21 +00:00
Jonas Maebe
ab5b1fb686 * turned call_fail_node, initialize_data_node, and finalize_data_node from
nutils.pas into virtual class methods of a new tnodeutils class defined
    in ngenutil (global factory: cnodeutils), so they can be overridden by
    architecture-specific implementations (required by the JVM backend)

git-svn-id: branches/jvmbackend@18364 -
2011-08-20 07:52:11 +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
ad9956022c * don't omit stackframe on avr for assembler routines
git-svn-id: branches/avr@17031 -
2011-02-26 21:02:50 +00:00
Jonas Maebe
2222f2c44b * renamed is_class_or_interface_or_dispinterface_or_objc() into
is_implicit_pointer_object_type() to better indicate the purpose of
    that routine, and to avoid having to change its name every time
    a new object type with this property is added

git-svn-id: trunk@16664 -
2010-12-30 15:19:54 +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
florian
0a625c856d + don't allow non local gotos across procedures containing exception frames
git-svn-id: trunk@16268 -
2010-10-30 20:22:23 +00:00
florian
38b90c987b + enable non local goto in macpas mode, test/tmacnonlocalgoto.pp does not fail anymore
git-svn-id: trunk@16265 -
2010-10-30 15:23:11 +00:00
Jonas Maebe
14b95b3b9b * always force range checking for the upper and lower bounds of for-loops if
they are constants (instead of only on 32 bit systems), and always use the
    actual upper/lower bound of the loop variable instead of hardcoding the
    bounds of longint (mantis #17646)

git-svn-id: trunk@16213 -
2010-10-24 14:55:48 +00:00
Jonas Maebe
bd0567563c * don't crash in {$x-} mode if a call cannot be resolved due to an error
in the expression (mantis #17455)

git-svn-id: trunk@16061 -
2010-09-29 12:11:22 +00:00
florian
24fea58b92 + initial implementation of iso style gotos in iso mode
* made setjmp/longjmp accessible to the compiler by compiler proc, they are used by the iso goto code

git-svn-id: trunk@15711 -
2010-08-05 19:20:46 +00:00
florian
591dbb66df * ignore leading 0's in labels in iso mode
git-svn-id: trunk@15690 -
2010-08-02 19:36:50 +00:00
Jonas Maebe
d6d411442b * more small indentation fixes
git-svn-id: trunk@15455 -
2010-06-19 16:22:56 +00:00
Jonas Maebe
e66dbe1317 * fixed indentation of for-in code
git-svn-id: trunk@15450 -
2010-06-19 15:10:44 +00:00
florian
af3eee54cd * make nested comment warning go away
git-svn-id: trunk@15208 -
2010-05-02 19:24:15 +00:00
Jonas Maebe
a48a37d38b * fixed extended syntax checking {$x-} by moving it from the typecheck pass
to the parser, so that it only looks at what the programmer wrote rather
    than at all statements that the compiler may generate internally
    (mantis #11619)
  + several tests for {$x-} mode
  * modified tenumerators1 so it compiles without extended syntax enabled
    (to check for..in with {$x-})

git-svn-id: trunk@15075 -
2010-03-27 12:51:27 +00:00
Jonas Maebe
88f5addd1c * do not typecheck statements before checking whether they are valid,
because the associated simplifications can turn invalid statements
    into valid statements (based on patch by Aleksa Todorovic, mantis
    #15594)

git-svn-id: trunk@14998 -
2010-03-09 21:13:22 +00:00
Jonas Maebe
d60e1f674c * automatically try to call procvars that are subscripted or used in a
with-statement, both in FPC and TP/Delphi modes (mantis #15728)

git-svn-id: trunk@14881 -
2010-02-10 16:12:18 +00:00
florian
c6ffbe9eda * support string constants > 255 chars
* don't cut off anymore string constants silently at 255 chars

git-svn-id: trunk@14789 -
2010-01-24 09:28:46 +00:00
paul
009ef9184d compiler: add dispinterfaces to most of places where something is comparing to usual interfaces since they are not very different things
git-svn-id: trunk@14751 -
2010-01-19 15:24:39 +00:00
florian
448f3d99c1 * cleanup of case <string> of code by Sergei Gorelkin, resolves #13700
git-svn-id: trunk@14467 -
2009-12-23 19:27:50 +00:00
paul
d89463588c compiler: don't compile incorrect statements if operators are involved (issue #0015338) + test
git-svn-id: trunk@14458 -
2009-12-21 06:57:38 +00:00
Jonas Maebe
40f88809af * don't error out or generate invalid code for "with x do ;"
(Delphi/TP-compatible, mantis #15274)

git-svn-id: trunk@14370 -
2009-12-08 19:45:08 +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
florian
44aed2af60 o patch by Michael Denisenko, resolves #14734:
* fixes memory leaks in case of string code
  * replace usage of strcmp
  * improved tests

git-svn-id: trunk@13830 -
2009-10-09 20:40:22 +00:00
Jonas Maebe
d34276c575 --- Merging r13696 through r13760 into '.':
U    ide/fpusrscr.pas
U    rtl/unix/video.pp
U    rtl/i386/i386.inc
U    rtl/win/wininc/defines.inc
U    rtl/win/systhrd.inc
U    rtl/linux/m68k/dllprt0.as
U    rtl/linux/i386/syscall.inc
U    rtl/linux/i386/dllprt0.as
U    rtl/linux/i386/si_c.inc
U    rtl/linux/i386/si_prc.inc
U    rtl/linux/i386/si_c21.inc
U    rtl/linux/i386/si_g.inc
U    rtl/linux/i386/si_c21g.inc
U    rtl/linux/i386/si_uc.inc
U    rtl/linux/i386/si_dll.inc
U    rtl/linux/x86_64/dllprt0.as
A    tests/test/packages/hash/sha1test.pp
U    tests/webtbs/tw12038.pp
U    compiler/cclasses.pas
U    compiler/symdef.pas
U    compiler/ncon.pas
U    compiler/ncgrtti.pas
U    compiler/cgbase.pas
U    compiler/pstatmnt.pas
U    compiler/systems/t_linux.pas
U    compiler/pass_1.pas
U    compiler/x86/cgx86.pas
U    compiler/x86/agx86att.pas
U    compiler/x86/aasmcpu.pas
U    compiler/aasmbase.pas
A    packages/fcl-xml/tests/extras.pp
A    packages/fcl-xml/tests/extras2.pp
--- Merging r13696 through r13760 into 'packages/fcl-xml/tests/README_DOM.txt':
U    packages/fcl-xml/tests/README_DOM.txt
--- Merging r13696 through r13760 into '.':
U    packages/fcl-xml/tests/domunit.pp
U    packages/fcl-xml/src/xpath.pp
U    packages/Makefile
U    packages/gmp/src/gmp.pas
U    packages/gmp/readme
U    packages/fcl-db/src/base/db.pas
U    packages/fcl-db/src/base/database.inc
U    packages/sqlite/src/sqlite3.inc
U    packages/fcl-web/src/custweb.pp
U    packages/hash/fpmake.pp
U    packages/hash/Makefile.fpc
A    packages/hash/src/sha1.pp
U    packages/hash/Makefile
U    packages/hash/examples/Makefile.fpc
A    packages/hash/examples/sha1test.pp
U    packages/hash/examples/Makefile
U    packages/Makefile.fpc
U    packages/fcl-base/src/ascii85.pp
U    packages/fcl-base/src/custapp.pp
U    packages/chm/src/chmwriter.pas
U    packages/chm/src/paslzx.pas
U    packages/chm/src/chmreader.pas
--- Merging r13761 into '.':
U    compiler/powerpc/agppcvasm.pas
U    compiler/ppcgen/agppcgas.pas

git-svn-id: branches/objc@13762 -
2009-09-27 14:13:44 +00:00
florian
02eeb3dad6 o update by Michael Denisenko for case <string> of
* memory management fixed
  * idention fixed

git-svn-id: trunk@13712 -
2009-09-14 21:44:11 +00:00
Jonas Maebe
ed9656d1e6 Merged revisions 13627-13631,13637-13638,13640,13642-13648,13650-13653,13656-13658,13660,13664-13667,13672-13675,13680,13682,13687 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13697 -
2009-09-12 12:42:38 +00:00
florian
cf215d5097 o patch by Michael V. Denisenko to handle case <string> of (see also #13700)
+ compiler implementation
  + tests

git-svn-id: trunk@13642 -
2009-09-03 20:21:30 +00:00
Jonas Maebe
a149674a75 Merged revisions 13458-13596 via svnmerge from
svn+ssh://jonas@svn.freepascal.org/FPC/svn/fpc/trunk

git-svn-id: branches/objc@13598 -
2009-08-25 19:47:36 +00:00
florian
c0d4efed2e * forbid passing derived classes to call by reference parent classes (for objects, this is still allowed), resolves #13135
git-svn-id: trunk@13551 -
2009-08-17 21:46:25 +00:00
Jonas Maebe
5a2ccfff52 --WARNING: start build process with FPC 2.2.4; won't work when
starting with a previous 2.3.1 or compiler built from the objc branch
  + added basic objcprotocol support (only for external protocols
    currently)
     o use in type declaration: "type xp = objcprotocol ... end;"
     o when defining a root class that implements it:
       "type yc = objcclass(xp) ... end" (note: no support yet
       for something like "objcclass(id,xp)" or so)
     o when defining a non-root class that implements a protocol:
       "type zc = objcclass(nsobject,xp) ... end"
     o includes support for "required" and "optional" sections
     o no support yet for the objcprotocol(<protocol>) expression
       that enables getting a class instance representing the
       protocol (e.g., for use with "conformsToProtocol:")
     o message names have to specified in protocol declarations,
       but if an objcclass implements a protocol, the message names do
       not have to be repeated (but if they are, they have to match;
       the same goes when overriding inherited methods)
  + allow specifying the external name of Objective-C classes and
    protocols, since classes and protocols can have the same name
    (and you cannot use the same Pascal identifier in such caseq)
  + added NSObject protocol, and make the NSObject class use it
  + added missing NSObject class methods that have the same name
    as instance methods (added "class" name prefix to avoid clashes)
  * fixed several cases where the compiler did not treat Objective-C
    classes/protocols the same as Object Pascal classes/interfaces
    (a.o., forward declarations, alignment, regvars, several type
     conversions, ...)
  * allow "override" directive in objcclass declarations, and print
    a hint if it's forgotten in an external declaration (because it
    doesn't really matter there, and may make automated header
    conversion harder than necessary) and an error if will be used in
    a non-external declaration (because it is not possible to start
    a new vmt entry-tree in Objective-C, you can only override parent
    methods)
  * reject objcclasses/protocols as parameters to typeof()
  * don't try to test VMT validity of objcclasses/protocols

git-svn-id: branches/objc@13375 -
2009-07-09 20:48:28 +00:00
Jonas Maebe
3dd32daa03 * always create a temp for MacPas objects in with-expressions (mantis
#13210)

git-svn-id: trunk@12753 -
2009-02-19 22:43:59 +00:00
yury
fcceb9cfa1 * Removed/ifdefed/commented unused local variables.
git-svn-id: trunk@11430 -
2008-07-20 23:00:31 +00:00
florian
19e723c869 * germanism fixed (aktexceptblock -> current_exceptblock)
git-svn-id: trunk@11410 -
2008-07-19 17:06:16 +00:00
Jonas Maebe
f36e5411af * split cpu64bit compiler define into
a) cpu64bitaddr, which means that we are generating a compiler which
       will generate code for targets with a 64 bit address space/abi
    b) cpu64bitalu, which means that we are generating a compiler which
       will generate code for a cpu with support for 64 bit integer
       operations (possibly running in a 32 bit address space, depending
       on the cpu64bitaddr define)
   All cpus which had cpu64bit set now have both the above defines set,
   and none of the 32 bit cpus have cpu64bitalu set (and none will
   compile with it currently)
  + pint and puint types, similar to aint/aword (not pword because that
    that conflicts with pword=^word)
  * several changes from aint/aword to pint/pword
  * some changes of tcgsize2size[OS_INT] to sizeof(pint)

git-svn-id: trunk@10320 -
2008-02-13 20:44:00 +00:00
florian
bc73f9021c Merged revisions 5891-10167,10169-10180 via svnmerge from
http://svn.freepascal.org/svn/fpc/branches/avr

........
  r5891 | florian | 2007-01-11 17:30:12 +0100 (Do, 11 Jan 2007) | 2 lines
  
  + some initial work
........
  r10170 | florian | 2008-02-03 11:02:04 +0100 (So, 03 Feb 2008) | 2 lines
  
  * continued to work on avr port
........
  r10180 | florian | 2008-02-03 15:29:30 +0100 (So, 03 Feb 2008) | 2 lines
  
  + a lot of skeleton code for avr added
........

git-svn-id: trunk@10186 -
2008-02-03 17:21:52 +00:00
peter
505e4f7809 * don't give illegal expression for errorn statements. The error is already given
or can be ignored during a generic template parsing

git-svn-id: trunk@9520 -
2007-12-23 20:57:59 +00:00
florian
50cc61c8fd * ignore register list in pure assembler routines, resolves #9335
git-svn-id: trunk@8978 -
2007-10-28 20:41:19 +00:00
Jonas Maebe
12b4f034ea * only allow using array elements as for-loop counter variables
in TP mode

git-svn-id: trunk@8907 -
2007-10-21 22:39:49 +00:00
peter
6434772c3c * error message when a goto label is optimized away
git-svn-id: trunk@8837 -
2007-10-17 21:52:25 +00:00
Jonas Maebe
c89ea4412f * disallow using inline nodes with a non-void resultdef as statements
(e.g. length, lo/hi, ord, etc). Not the same as mantis #9918, but
    somewhat related

git-svn-id: trunk@8770 -
2007-10-12 11:54:37 +00:00
Jonas Maebe
c408d9bb1d * fixed regression of webtbs/tw2789 caused by r8270 (setting vs_read
without vsf_must_be_valid means that it's not really read, but
    only used by sizeof or so)

git-svn-id: trunk@8273 -
2007-08-12 19:52:57 +00:00
Jonas Maebe
12791bf4f1 * avoid spurious uninitialised warnings about array elements used as
for-loop counters

git-svn-id: trunk@8270 -
2007-08-12 13:19:30 +00:00
peter
1dd62b8686 * write also asmblocklabel for a connected labelsym
git-svn-id: trunk@8159 -
2007-07-23 21:01:32 +00:00
daniel
9adb202a92 * Rework the constexprint to allow operations from low(int64) to high(qword).
+ Some initial work on a formaldef which also carries the typinfo of a parameter.

git-svn-id: trunk@7639 -
2007-06-13 07:41:18 +00:00
Jonas Maebe
69cf42c4f7 * fixed val(s,int64) (it accepted values in the range
high(int64+1)..high(qword) if written in decimal notation) + test
  * fixed range checking of qword constants parsed by the compiler
    (they always gave a range error if > high(int64), because the compiler
     internally stores them as int64)
  * turn off range checking flag of rdconstnodes created by the parser
    from _INTCONST, because those are already range checked by the
    way they are parsed using val()

git-svn-id: trunk@6814 -
2007-03-12 22:22:43 +00:00
Jonas Maebe
4e96fe8fac * fixed with-support for classrefdefs (mantis 8150), with thanks to
Thorsten Engler for supplying an initial patch

git-svn-id: trunk@6088 -
2007-01-20 20:04:54 +00:00
Jonas Maebe
2ad3ef968f * properly detect when we can't take the address of a with-expression
and assign it to a temp in that case (mantis #8141)

git-svn-id: trunk@6071 -
2007-01-19 13:01:07 +00:00