Commit graph

9387 commits

Author SHA1 Message Date
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
1fdc32bb39 Check for null VM pointer accesses.
Currently only four words of "null pointer protection" are available, but
it's a start.
2012-12-22 14:24:11 +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
cc5e0f9957 Use git-version-gen to create meaningful version strings.
git-version-gen is taken from autoconf-2.69 with the change of adding
--tags to the git command line since we don't sign our tags (yet).
2012-12-21 18:43:03 +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
Bill Currie
13f09b10d6 Generate MOVEPs for attached identifiers.
The "address operator" has been stripped from the identifer so it needs to
be rebuilt, and the identifier itself is returned as the destination.
2012-12-20 20:58:19 +09:00
Bill Currie
453dacb356 Nuke dag_set_live_vars.
It is no longer needed thanks to the exit dummy node used for making
globals live.
2012-12-20 20:57:11 +09:00
Bill Currie
cc0373cdca Correct a pair of spelling mistakes.
Hopefully, noone would ever see them anyway.
2012-12-20 20:55:25 +09:00
Bill Currie
a51ca44b05 Record MOVEP's destination pointer only when variable.
If MOVEP's destination is variable, then the actual destination isn't (at
this stage) knowable, so it can't be attached to the dagnode and thus must
be a child.
2012-12-20 19:08:50 +09:00
Bill Currie
4d587eaa25 Use flow_analyze_statement to get statement operands.
Getting the operands directly from the statement was missing the
destination operand of movep when movep's op_c was a constant pointer and
thus the flowvar wasn't being counted/created early enough. This led to a
segfault in the set code when attempting to add -1 to the set.
2012-12-20 19:02:55 +09:00
Bill Currie
5ec4598fce Fix a double out-by-one error.
This fixes the aliasing problem brought to light by the recent dead-code
removal work.

* taniwha dons a brown paper bag.
2012-12-20 16:33:01 +09:00
Bill Currie
580fba2cd1 Print the type of temporary operands.
It turns out the recent dead-block code "broke" vector component access
from objects. The breakage is really highlighting a problem with temporary
operands and aliasing. The problem was hiding behind a basic-block split
that the recent dead-block work mended and thus exposed the bug.
2012-12-20 14:47:18 +09:00
Bill Currie
7642c666db Implement protocol checking in categories. 2012-12-20 13:42:19 +09:00
Bill Currie
0cc90c006b Implement protocol checking.
It's very basic and incomplete (doesn't check categories), but it's a good
start.
2012-12-20 13:12:26 +09:00
Bill Currie
6d6f231bd2 Fix mangling of types when attaching protocols.
The protocol attachment test was in the wrong place, and there were some
typos in compare_protocols and procollist_find_protocol.
2012-12-20 13:12:05 +09:00
Bill Currie
211a7a8bbb Create and use more type checking functions. 2012-12-20 11:11:59 +09:00
Bill Currie
8c2af5cff7 Add more convenience functions.
Cleans up obj_types_assignable a little.
2012-12-20 10:10:41 +09:00
Bill Currie
3af031c33d Move the rest of the obj specific stuff into class.c.
This gives better hiding of implementation details.
2012-12-20 10:10:41 +09:00
Bill Currie
7cb2e40bce Add is_pointer convenience function. 2012-12-20 10:10:41 +09:00
Bill Currie
64c98bd4c3 Rename is_id to obj_is_id.
Better naming convenion.
2012-12-20 10:10:41 +09:00
Bill Currie
686858a59d Use the symtab to check for qualified id.
type_id is implemented as a pointer to "struct obj_object" (ie, not really
a class), so the correct check is to ensure the type is:
 1  a pointer
 2  to a struct
 3  using the same symbol table as type_obj_object
2012-12-20 10:10:41 +09:00
Bill Currie
4f81a659b4 Move is_id() from type to class.
type_id's implementation should remain "private" to class.c
2012-12-20 10:10:41 +09:00
Bill Currie
f181772a76 Attach protocolrefs to class types.
The protocolrefs (as protocollist_t) are attached to the type as a
qualifier.
2012-12-20 10:10:41 +09:00
Bill Currie
45c753f639 Catch attempts to create a static instance of a class.
It is actually an error to create a static instance of a class.
2012-12-20 10:10:41 +09:00
Bill Currie
f7006f13e8 Add .m to the list of recognized language extensions. 2012-12-20 10:10:41 +09:00
Bill Currie
4868a245b3 Fix the "for new syntax" FIXME.
Empty structs are now (correctly) invalid. The hack of using an empty
struct to represent a handle returned from a builtin has been unnecessary
since opaque structs were implemented: now a pointer to an opaque struct
can be used. This is mostly safe as handles are aways negative and thus
attempting to dereference such a pointer should result in a VM error. It
will be even safer once const is implemented and the pointers can be made
constant (eg, typedef struct handle * const handle;)
2012-12-20 10:10:41 +09:00
Bill Currie
3e94869f1e Remove the function overloading FIXMEs.
It seems they were fixed a long time ago.
2012-12-20 10:10:41 +09:00
Bill Currie
c68578d15d Rename CONST to VALUE.
VALUE is a much more accurate name, and this allows for "const" to be
implemented at some stage.
2012-12-20 10:10:41 +09:00
Bill Currie
fe7cd7e7a7 Catch omitted parameter names from function definitions.
void foo (int); is fine for a prototype (or, presumably, a qc function
variable), but not for an actual function body. This fixes the segmentation
fault when the parameter name is omitted.
2012-12-20 10:10:41 +09:00
Bill Currie
cd7c53d223 Parse id <protocol> and classname <protocol>.
This is needed to allow compile-time protocol conformance checks, though
nothing along those lines has been implemented yet.

id has been changed from TYPE to OBJECT, required to allow id <proto> to be
parsed. OBJECT uses symbol, allowing id to be redefined once suitable work
has been done on the parser.
2012-12-20 10:10:41 +09:00
Bill Currie
97c89c667d Add more todo items. 2012-12-19 21:52:10 +09:00
Bill Currie
b5baf0914b Fix the old dead block removal code.
It uses the new block merge code. Now forgotten return statements are
detected properly (naive dead block removal) and all unreachable code is
eliminated (flow analysis unreachable node removal).
2012-12-19 20:09:59 +09:00
Bill Currie
ab6a3fefd9 Revert "Remove the dead block removal code."
This reverts commit 83ead0842f.

Note: does not compile.

It turns out basic dead block removal is needed for the "control reaches
end of non-void function" warning to work correctly.
2012-12-19 20:05:12 +09:00
Bill Currie
65561fc219 Clean up statement blocks.
Empty sblocks are removed (unless it's the only sblock), and blocks that
are split unnecessarily are merged.

This mostly fixes bogus "no return" warnings.
2012-12-19 19:46:58 +09:00
Bill Currie
427d52511c Fix an uninitialized variable warning.
It's a false positive, but best to be safe.
2012-12-19 17:13:32 +09:00
Bill Currie
21b5ea8075 Remove unreachable nodes.
Any nodes still marked as unreachable (dfn < 0) need to be removed so
graph->dfo is valid (only one node 0).
2012-12-19 17:08:48 +09:00
Bill Currie
3270bb3f5e Make node numbering int rather than unsigned.
(unsigned) -1 is not what I wanted :P
2012-12-19 16:50:06 +09:00
Bill Currie
927335a29c Break out the successors and edges code.
This will make for nicer code when everything is looped for unreachable
node removal.
2012-12-19 16:23:08 +09:00
Bill Currie
c7ae58d7a3 Allow flownodes and sblocks to be numbered independently.
The numbering will need to be independent when unreachable nodes are
removed.
2012-12-19 16:22:15 +09:00
Bill Currie
9d35ca607f Mark all nodes as unreachable.
flow_build_dfst() marks a reacable node as such by setting the node's dfn
to a value >= 0.
2012-12-19 16:00:58 +09:00