Commit Graph

385 Commits

Author SHA1 Message Date
Károly Balogh
56eeabd01b fixed a warning with DFA
git-svn-id: trunk@30015 -
2015-02-26 09:36:03 +00:00
sergei
657ac78304 * Improved handling of registers used in assembler blocks. Assembler nodes no longer have lists of used registers attached to them. Instead, each specified register creates an allocation/deallocation pair and an additional tai_regalloc.markused item directly in the asmlist. This way, register lists are no longer limited to integer registers, and parsing no longer depends on paramanager to know which registers are volatile.
If assembler block has no modified register list, it is still handled in pass2, by allocating all volatile registers (not only the integer ones as before).

git-svn-id: trunk@30011 -
2015-02-25 21:53:15 +00:00
svenbarth
5a344ee263 Rework the way how "specialize" is handled. Instead of initializing the specialization of a full type declaration (including unit name and parent types) it is now considered part of the specialized type itself. This means that for example the following code:
type
  TTestLongInt = specialize SomeOtherUnit.TTest<LongInt>;

will now have to read as

type
  TTestLongInt = SomeOtherUnit.specialize TTest<LongInt>;

While this is not backwards compatible this situation should arise seldomly enough and the benefits especially in context with generic functions/procedures/methods outway the drawbacks.

pbase.pas:
  * try_consume_unitsym: add a allow_specialize parameter that allows to parse "specialize" in front of a non-unit symbol; whether it was a specialization or not is reported using a new is_specialize parameter
  + add a new overload try_consume_unitsym_no_specialize that calls try_consume_unit sym with allow_specialize=false and a dummy is_specialize parameter
  * switch calls to try_consume_unitsym to try_consume_unitsym_no_specialize
pstatmnt.pas, try_statement:
  * switch call to try_consume_unitsym to try_consume_unitsym_no_specialize
  * adjust call to parse_nested_types
ptype.pas:
  + extend id_type with the possibility to disallow unit symbols (needed if a specialize was already parsed) and to report whether a specialize was parsed
  + extend parse_nested_types with the possibility to tell it whether specializations are allowed
  * have parse_nested_types specialize generic defs if one is encountered and local type defs are allowed
  * id_type: only allow "unitsym.specialize sym" or "specialize sym", but not "specialize unitsym.sym"
  * single_type: correctly handle specializations with "specialize" keyword
  * read_named_type.expr_type: there is no longer a need to check for "specialize" keyword
pexpr.pas:
  + new function handle_specialize_inline_specialization which tries to specialize a type symbol
  * handle_factor_typenode: handle specializations after a point that follows a record or object (why isn't this part of postfixoperators anyway? O.o)
  * postfixoperators: handle "specialize" after records and objectdefs
  * factor_read_id: handle "specialize" in front of an identifier (and after unit symbols)

+ added tests
* adjusted test webtbs/tw16090.pp

git-svn-id: trunk@29768 -
2015-02-20 16:23:40 +00:00
Jonas Maebe
270c2d700e * allow the "then" part of an if-statement to be terminated by any endtoken,
instead of only by "else" (mantis #25781)

git-svn-id: trunk@27696 -
2014-04-30 19:25:06 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
florian
b2b26f84cf * partially merged the mips-embedded branch of Michael Ring:
- startup code/controller units are not merged yet
  - assembler call does not pass the needed CPU type yet

git-svn-id: trunk@27188 -
2014-03-19 21:25:38 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
paul
6e7cc22207 compiler: don't allow to assign to for-in loop variable (bug #0025318)
git-svn-id: trunk@26108 -
2013-11-19 05:29:37 +00:00
paul
d25ae84113 compiler: don't output an error twice in 'on Exception do' block if Exception is not a valid type
git-svn-id: trunk@25419 -
2013-09-05 00:46:26 +00:00
paul
115ddf4364 compiler: modernize exception class parse:
- use specially implemented type search routine in case of declaration with colon (on E: Exception do)
  - parse nested types in case of declaration without colon (on Exception do)
  + test

fixes issue #0022225

git-svn-id: trunk@25412 -
2013-09-04 14:09:09 +00:00
svenbarth
407e9d173b Fix for Mantis #17598. When extended syntax is off allow the result of constructors to be dropped when the constructor is called as an instance method instead of a class method.
pstatmnt.pas, statement:
  * check whether the constructor is called as an instance or class method
nflw.pas, tlabelnode.pass_1:
  * don't check the owner of the labelsym when there is none (happens with internally created labels like for e.g. exception handling)

+ added test  

git-svn-id: trunk@25068 -
2013-07-09 07:56:45 +00:00
svenbarth
b6bfa864d4 Disallow the usage of the inline assembler inside generics, because there are currently two problems:
1. At least on x86 the assembler reader initializes the parameter location informations which results in InternalError 200301231
2. Assembler tokens are not stored in the token stream and thus won't be reproduced during specialization

x86/rax86int.pas, tx86intreader.Assemble:
  * check for "parse_generic" before calling generate_parameter_info
pstatmnt.pas, assembler_block & statement:
  * generate an error message if an asm statement should be parsed inside a generic

+ added test

git-svn-id: trunk@24892 -
2013-06-13 19:42:49 +00:00
Jonas Maebe
e621bff943 * don't make a deep copy of records (and in the future, objects) in with-
statements on the JVM target (mantis #24089)

git-svn-id: trunk@23945 -
2013-03-20 16:23:25 +00:00
paul
51825b6f2e compiler: change ret_in_param to accept tabstractprocdef instead of tproccalloption to allow check more options (required for record constructor implementation)
git-svn-id: trunk@23394 -
2013-01-16 01:14:23 +00:00
florian
fce9e953b4 + nested exit support
git-svn-id: trunk@23309 -
2013-01-04 19:09:04 +00:00
florian
728c074bd6 * accept with statements with generic variables having a generic parameter type, resolves #21329
git-svn-id: trunk@23243 -
2012-12-28 19:48:33 +00:00
florian
f6109d7c65 * improved error reporting by printing the type being found in with expressions
git-svn-id: trunk@23019 -
2012-11-18 17:09:36 +00:00
svenbarth
d87b203a0a Do not call ret_in_param of the current parameter manager when parsing a generic method/function. This fixes Mantis #21921.
* pparautl.pas, insert_funcret_para:
    assume that the result in a generic function/method can not be passed in a param
* pparautl.pas, insert_funcret_local: 
    don't call ret_in_param, but create the symbol as we need a valid funcretsym
* pstatmnt.pas, assembler_block:
    don't modify the framepointer for a generic method/function
* rautils.pas, TOperand.SetupResult:
    don't assume that we can't use the result for a generic function/method

git-svn-id: trunk@21608 -
2012-06-14 12:11:11 +00:00
pierre
600dd162af Merge of rev21557 by Foxsen
Make macro MIPS/CPUMIPS/MIPS32 common for big endian and little endian mips processors
use MIPSEL* for little endian systems
use MIPSEB* for big endian systems

git-svn-id: trunk@21599 -
2012-06-13 22:25:38 +00:00
pierre
c1269b0305 * Patch from Fuxin Zhang: po_assembler special code also disabled for mips and mipsel CPUs
git-svn-id: trunk@21535 -
2012-06-07 23:13:16 +00:00
florian
6c8eed21c4 + implement auto inlining (-Ooautoinline)
+ implement trashing of local variables if subroutine is inlined
* fix some errors releated to interproc. gotos and inlining
+ node_count function
* inline cannot be used with iochecking and safecall calling conventions
* track inherited usage
* don't inline if inherited is used

git-svn-id: trunk@21335 -
2012-05-19 13:30:02 +00:00
sergei
c08ab0f745 * Re-raising exceptions must be allowed only in 'except' block itself, not in 'try' block of a nested try..except statement. Mantis #21873.
git-svn-id: trunk@21100 -
2012-04-28 15:59:34 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
Jonas Maebe
1f9d8420b6 * set correct fileinfo for the asmnodes (so that the start fileinfo of
assembler functions doesn't get changed into the end fileinfo)

git-svn-id: trunk@20825 -
2012-04-11 18:05:16 +00:00
sergei
6cb6569d51 * Set pi_uses_exceptions flag when creating/firstpassing ttryexceptnode or ttryfinallynode, not when parsing try statements. It ensures that procedures with exception handling nodes created by compiler (constructors in the first place, but also for..in loops with TObject iterators, etc.) are handled the same way as ones containing exception nodes from user code.
* Modified code generation for constructors so they don't always use pi_needs_implicit_finally. It used to prevent stackframe optimization while not preventing regvar optimization ( tabstractvarsym.is_regvar() checks for pi_uses_exceptions but not for pi_needs_implicit_finally, and constructors were not getting pi_uses_exceptions), resulting in strange code using both exceptions and regvars.
Once setting of pi_uses_exception is fixed, the implicit finally frame can be omitted unless managed temps or local vars are actually present.

git-svn-id: trunk@19668 -
2011-11-22 11:59:44 +00:00
paul
1db610ecbd merge r17434 from cpstrnew branch by michael:
* Patch from Inoussa to fix constant strings with codepage

git-svn-id: trunk@19109 -
2011-09-17 13:19:59 +00:00
paul
8309809a0d compiler: use try_consume_unitsym for except variable parse. this is needed to reduce maintenance cost for later unit identifier search changes
git-svn-id: trunk@18826 -
2011-08-24 10:54:17 +00:00
Jonas Maebe
48d63f2c75 * when taking the address of an expression for a with-statement, make
it a typed address to prevent unnecessary checkcast instructions
    on the JVM target

git-svn-id: branches/jvmbackend@18740 -
2011-08-20 08:30:57 +00:00
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