Commit Graph

2190 Commits

Author SHA1 Message Date
Bill Currie 89ae5cbf7c Remove the old hacks for qp-lex, too. 2013-01-10 19:42:34 +09:00
Bill Currie 737347b0f6 Remove the prototypes hack.
While configure isn't testing yet, we need recent bison and flex, so many
of the old hacks are no longer necessary.
2013-01-10 19:27:22 +09:00
Bill Currie 39ae720613 Fix an error in qfcc's man page.
--qccx-escapes doesn't take an arguement :P
2013-01-08 16:19:40 +09:00
Bill Currie 76a69d9a53 Implement fteqcc's "nosave" specifier.
Of course, it's "@nosave" for traditional progs, but that's only a define
away.
2013-01-07 14:35:34 +09:00
Bill Currie 955e3ee258 Initialize the type to be ev_func.
This fixes the returning of the wrong function symbol when resolving
overloaded functions and one of the functions takes no parameters.
2013-01-07 13:52:48 +09:00
Bill Currie 338bb9bba0 Look up the function symbol when resolving overloaded functions.
This fixes the bogus undefined symbol errors when resolving unambigous
overloaded functions.
2013-01-07 13:51:01 +09:00
Bill Currie e0e69ac71a Fix some signed/unsigned comparison warnings.
It seems mingw's gcc treats pointer subtraction differently to how linux's
gcc does.
2013-01-05 17:52:48 +09:00
Bill Currie 34c0c82408 Add support for binary constants using the 0b prefix.
Just because :P (now that gcc support it, it seems worthwhile, I guess)
2013-01-04 19:32:04 +09:00
Bill Currie b225879d16 Print all four sets with a legent for live vars.
Much more informative :)
2012-12-26 11:54:49 +09:00
Bill Currie c5179c9e99 Add MOVEP's opc to the use set.
MOVEP's opc itself is always known and used, whether it's a constant
pointer or variable doesn't matter. This fixes the lost pointer calculation
for va_list.list[j] = object_from_plist (item);
2012-12-26 11:53:06 +09:00
Bill Currie 412fb4aacd Fix a static out of bounds error.
I really must compile with optimizations more often :P
2012-12-26 11:51:40 +09:00
Bill Currie 88c765e210 Add a test for returning @param into an array. 2012-12-26 11:49:39 +09:00
Bill Currie 386a729209 Remove dead nodes from dags.
Dead nodes are those that generate unused values (unassigned leaf nodes,
expressions or destinationless move(p) nodes). The revoval is done by the
flow analysis code (via the dags code) so that any pre and post removal
flow analysis and manipulation may be done (eg, available expressions).
2012-12-25 17:07:58 +09:00
Bill Currie 1e3154ecd5 Do not always reset current_storage.
resetting current_storage in external_def_list's empty rule breaks the
block storage scopes (extern { ... } etc);
2012-12-25 13:43:52 +09:00
Bill Currie e414117fe8 Move jump threading into the dead-code removal loop.
Dead code removal can give more opportunities to the useless branch removal
in the jump threading code.
2012-12-25 13:33:31 +09:00
Bill Currie 07187cae7c Remove useless conditional branches too.
"if x" jumping to the next statement is pretty useless.
2012-12-25 13:23:14 +09:00
Bill Currie 92fffb3c7e Check for a flow var for temp aliases. 2012-12-25 13:22:31 +09:00
Bill Currie 9d27764576 Use new_binary_expr to recreate the assignment.
assign_expr mangles the destination expression for dereferenced
assignments into something that is invalid as an lvalue, so simply use
new_binary_expr with the same opcode.
2012-12-24 20:12:56 +09:00
Bill Currie 0fc8aa54e1 Make expr->next edges constrained.
It turns out expression trees are (mostly?) valid DAGs, so all edges being
constrained works, though the graphs get a little tall (but easier to read).
2012-12-24 20:06:38 +09:00
Bill Currie 79519bc357 Avoid testing block expressions in truth assignments.
This fixes the infinite loop in if ((x = self.heat && x))

Really, I think I need to revisit the whole expression tree code. It's
proving to be rather fragile.
2012-12-24 20:01:16 +09:00
Bill Currie 60af059b6e Allow arbitrary expressions in a bool's block.
This generates correct code for "if ((x = y))": the assignment still
occurs.
2012-12-23 19:57:39 +09:00
Bill Currie f6c4e06183 Reimplement assignment as truth value.
The source of the assignment is used as the value to test, and the
assignment itself is inserted into the boolean expressions's block. This
fixes the inernal error for "if ((x = 0))".
2012-12-23 19:53:31 +09:00
Bill Currie a881fb5f5b Make float values obvious in expression dot dumps. 2012-12-23 19:34:25 +09:00
Bill Currie f65ce22ddc Fold constants for the return value of test_expr.
More constantness preservation.
2012-12-23 19:32:32 +09:00
Bill Currie 22db05dc9c Alias value expressions by aliasing the value.
This keeps constant expressions constant, even through aliasing.
2012-12-23 19:31:09 +09:00
Bill Currie b295524385 Add new_value_expr().
This simplifies creating a new expression for an arbitrary value object.
2012-12-23 19:29:50 +09:00
Bill Currie 42ba0c9d54 Add alias_value() function.
alias_value returns a new value where only the type is different, the
bit-pattern of the value itself is untouched.
2012-12-23 19:25:35 +09:00
Bill Currie 82ded2b638 Split the test for assignment and parenthesis.
This will make it easier to fix the internal error for "if (x = 0)".
2012-12-23 14:55:16 +09:00
Bill Currie b9a0e2ce03 Catch the error for undefined++. 2012-12-23 14:47:29 +09:00
Bill Currie a778d45ebf Drop non-function symbols returned from function_symbol.
In such situations, everything is a mess from earlier errors.
2012-12-23 14:25:09 +09:00
Bill Currie aae0e21a5b Treat class instance access as a normal error.
Normally, it will happen only as a follow-on error, but I can think of a
way to force it without other errors, so treating it as an internal error
is a bit harsh.
2012-12-23 06:01:20 +09:00
Bill Currie 996b2734a4 Reset current_class in the top-level error rules.
This fixes a weird internal error after a parse error in an ivar
declaration.
2012-12-23 05:57:13 +09:00
Bill Currie 1c76ccc425 Always set current_symtab in class_init().
But reset current_symtab to its prior value when done. This fixes a
segfault caused by initializing the class system while parsing a struct
(eg, one of the members is of type id).
2012-12-22 20:06:14 +09:00
Bill Currie ff4b232d92 Reset current_storage when resetting current_symtab.
This helps prevent an internal error caused by ealier errors.
2012-12-22 20:04:11 +09:00
Bill Currie 85387e02cf Avoid class segfaults caused by parse errors. 2012-12-22 19:35:19 +09:00
Bill Currie 681bd6f4b2 Don't try to emit code if there have been errors.
The expression tree can't really be trusted if there have been errors.
While warnings as errors are another matter, it's not worth sorting out.
2012-12-22 19:22:08 +09:00
Bill Currie adf3e36aee Get the tempop alias's type from the right place.
Temporyary aliases use only the low-level type, not the full type
descriptor. Fixes the segfault when dumping dot graphs.
2012-12-22 17:06:00 +09:00
Bill Currie 513d67c6c3 Splut up the keywrods table into categories.
The keywords table was rather awkward to edit (and sometimes confusing).
Worse, because the hash table used to look up the keywords was initialized
only once, changing modes in the same execution of qfcc would not work
properly as keywords would not be added or removed as appropriate.

Now there are four categories of keywords:
 o  "core"  Always available. They form the core of QuakeC except for two
            extensions.
 o  "@"     In extended and advanced modes, the preceeding @ is optional,
            but tranditional mode requires the keywords to be preceeded by
            an @. They are the C keywords that QuakeC did not use, but can
            be implemented in v6 progs under certain circumstances.
 o  "QF"    These keywords require the QuakeForge VM to be usable.
 o  "Obj"   These keywords form Ruamoko/Objective-QuakeC and require both
            advanced mode and the QuakeForge VM.
2012-12-22 16:31:14 +09:00
Bill Currie 7d928047ae Remove support for break as an identifier.
I never really liked it, but I have a better solution in the pipe-line.
2012-12-22 16:29:43 +09:00
Bill Currie 33bb422849 Force .param_N to be live when adding the edge to its node.
This fixes the segfault/null pointer access in sendv.r. While I wanted to
use the edge setting code to set the live bit, I didn't expect it to be
this easy. def_visit_all is proving to be worth every bit it consumes :)
2012-12-22 14:38:38 +09:00
Bill Currie a95f679283 Add a test for compiling calls to obj_msg_sendv.
It seems dag_set_live_vars still served a purpose after all, but I don't
feel like bringing it as I'd rather implement its param handing in
dagnode_set_edges. I've now got a test case for it, though the test
currently causes the VM to segfault (even with pr_boundscheck 2!).
2012-12-22 14:05:12 +09:00
Bill Currie 175935ed8b Turn on bounds checking in the test harness.
Definitely want bounds checking for the tests.
2012-12-22 14:04:14 +09:00
Bill Currie 6eb6b6c0ba Change pointer_t to unsigned and clean up the mess.
It doesn't make sense to have negative pointers. The size of the commit is
from enabling gcc's -Wtype-limits warning and cleaning up that mess too.
2012-12-21 21:53:13 +09:00
Bill Currie 7701393bd4 Append a new sblock for return when necessary.
If the final block ends in a conditional statement, appending return to the
block will hide the conditional statement from the flow analyzer. This may
cause the conditional statement's destination node be become unreachable
according to the analyzer and thus eliminated. The label for the branch
then loses its target sblock and thus the code generator will produce a
zero-distance jump resulting in an infinite loop.

Thus, if the final block ends in a conditional statement (or, for
completeness, a call statement), append a new empty block before adding the
return statement.
2012-12-21 20:11:27 +09:00
Bill Currie cb39cfc9ae Turn on the runaway loop detector for the test harness.
Definitely don't want any tests hanging.
2012-12-21 20:01:53 +09:00
Bill Currie 452728126d Check the expression type when casting constants.
Not all constant expressions are ex_value. This fixes the bogus errors and
ice in paroxysm.
2012-12-21 17:12:41 +09:00
Bill Currie 84a68b139e Rename set_iter_t's value to element.
Correct terminology and all :)
2012-12-21 14:09:00 +09:00
Bill Currie 37a282d916 Initialize the immediate before putting it in the hash table.
This fixes the excessive globals used on constants.
2012-12-21 13:17:07 +09:00
Bill Currie 6c2d0b04d3 Directly generate MOVEP for variable destination pointers.
When the destination pointer is variable, the MOVEP node will not have any
identifiers attached to it, so generate_moveps must not be used.
2012-12-20 21:28:34 +09:00
Bill Currie 7b1850917d Force RETURN's operand to be live.
This seems to be the final fix to get return-ivar.r working.
2012-12-20 21:18:27 +09:00