Commit graph

7136 commits

Author SHA1 Message Date
Bill Currie
ac14db7b1b Create a function to ease param list building.
This is especially useful for QuakePascal, but it will mean I'll be able to
get rid of the parameter reversals in Ruamoko later on.
2011-01-13 14:45:53 +09:00
Bill Currie
258c896e4d Create a function to build if/else blocks. 2011-01-13 14:33:16 +09:00
Bill Currie
638f4445cc More return code cleanup.
Don't use the true void return in traditional mode.
Prefer the true void return over "done" at the end of functions.
Don't emit the above if the last emitted statement is a return and there is
no label at the end of the function.
2011-01-13 00:46:46 +09:00
Bill Currie
3c9991364b Add a "void return" instruction.
I got fed up with always having to explicty return something.
2011-01-13 00:29:56 +09:00
Bill Currie
9ce9b70484 Add variadic functions.
Already extending QuakePascal, and many basics aren't there yet :P
2011-01-12 23:39:59 +09:00
Bill Currie
02b3dde83b Make QuakePascal programs runnable.
Generate a mini-main function (".main", to avoid namespace pollution) that
calls the function named by "program", and make qwaq check for ".main" as
well as "main". If both are present, ".main" will take priority.
2011-01-12 23:39:22 +09:00
Bill Currie
332b7da127 Minor header cleanup. 2011-01-12 23:34:15 +09:00
Bill Currie
96ba4605fa Fix the micro-optimization that avoided emitting x = x
The check was broken by alias defs. If a def is aliased, the alias must be
checked.
2011-01-12 23:33:51 +09:00
Bill Currie
c787923c99 Forgot to remove that print_expr. 2011-01-11 12:11:54 +09:00
Bill Currie
08bf7e24de Produce nicer code for post-op.
The temp notice is still there for arrays (that's caused by issues in
constfold.c, not easily fixilbe), but it's harmless and correct (and nice)
code is much more important.
2011-01-11 12:07:48 +09:00
Bill Currie
ad787ae98a Set the expression type to the correct value for addresses. 2011-01-11 12:06:40 +09:00
Bill Currie
21d7c78eb7 Allow deep copying of expression trees.
Certain expression types (eg labels) are created fresh.
2011-01-11 12:05:29 +09:00
Bill Currie
c73ac30e3f Turns out decrementing the users was very very bad. 2011-01-11 10:56:36 +09:00
Bill Currie
099eb2d31c Ignore the new files. 2011-01-11 09:08:27 +09:00
Bill Currie
4af5dad424 More math identities.
I forgot about 0 for multiplication and division. Detects division by zero.
2011-01-11 08:49:43 +09:00
Bill Currie
5b43fc1de3 Improve interaction between temps and const_folding.
Unfortunately, this seems to overdo the decrementing, so it could be
dangerous, but the ruamoko directory builds properly.
2011-01-11 08:47:52 +09:00
Bill Currie
abe471110c Make inc/dec_users return the the expression.
Just for convenience.
2011-01-11 08:44:43 +09:00
Bill Currie
18ae178eaf Make new_vector_expr and new_quaternion_expr const-correct. 2011-01-11 08:43:34 +09:00
Bill Currie
13503198e5 Add quat_origin convenience constant.
Same as vec3_origin in that all elements are zero.
2011-01-11 08:41:40 +09:00
Bill Currie
4da2657bfe Fix most of the notice spam (hacky).
The implementation and declaration of OP_DONE disagree (not sure what to do
about it yet), so give it special treatment when emitting.
2011-01-11 08:07:04 +09:00
Bill Currie
f2fb853052 Fix for parallel make. 2011-01-10 13:29:51 +09:00
Bill Currie
ded741430b Add some missing static declarations. 2011-01-10 13:23:39 +09:00
Bill Currie
5f70e27613 Quaternions use quaternion_val, not vector_val :P 2011-01-10 13:23:12 +09:00
Bill Currie
cbe245725b Install the symbol file so menus can be debugged. 2011-01-10 12:26:11 +09:00
Bill Currie
cd38bd71fa Swap the order of scale and base for calculating the array index.
fold_constants doesn't like dags very much, but it can do the right thing
if the expressions are in the right order. This is merely a workaround
until I get to work on the code generator itself.
2011-01-10 12:26:11 +09:00
Bill Currie
5864c198cc Property list tests are working. 2011-01-10 12:26:11 +09:00
Bill Currie
d327c860cb Get messages working again. 2011-01-10 12:26:11 +09:00
Bill Currie
9e06220dc5 Missed a class -> class pointer change. 2011-01-10 12:26:11 +09:00
Bill Currie
cb0bc7229a Resurect the debugging messages in rua_obj.c
Yet another debug flag: SYS_RUA_OBJ
2011-01-10 12:26:10 +09:00
Bill Currie
aac8185e4e Print some addresses in hex. 2011-01-10 12:25:31 +09:00
Bill Currie
6ebee4ad0e Get the type of Method right.
It's a direct structure rather than a pointer.
2011-01-10 12:25:31 +09:00
Bill Currie
ba27db6b93 Use some math identities to eliminate operations on non-constants. 2011-01-10 12:25:31 +09:00
Bill Currie
6650b35201 Make PR_Get_Param_Def aware of @args. 2011-01-10 12:25:31 +09:00
Bill Currie
75ec6bf244 Clean out some unnecessary types from the progs engine and clean up the mess.
This is a nasty commit, sorry, but 99% of the commit is interdependent.
2011-01-10 12:25:31 +09:00
Bill Currie
c69ac1f56f Don't segfault when build_builtin_function detects an error. 2011-01-10 12:25:31 +09:00
Bill Currie
806d9110a2 Support both (* *) and // style comments. 2011-01-10 12:25:31 +09:00
Bill Currie
a17e73c863 Generate code.
It's now time to work on the revamp of the symbols, trees, etc.
2011-01-10 12:25:31 +09:00
Bill Currie
e34f7caeb0 Use op instead of integer_val for ADDOP etc. 2011-01-10 12:25:31 +09:00
Bill Currie
edaa6235e7 Get functions/procedures emitted.
No actual code is emitted, though.
2011-01-10 12:25:31 +09:00
Bill Currie
74016573b4 Need frame grabbing after all. 2011-01-10 12:25:31 +09:00
Bill Currie
129a36064f Fix a typo that broke procedure declarations. 2011-01-10 12:25:31 +09:00
Bill Currie
7971b0868e Break out the begin_function code into its own function. 2011-01-10 12:25:31 +09:00
Bill Currie
c5d0acf0fa Allow arrays to have ranges (not fully implmented) 2011-01-10 12:25:31 +09:00
Bill Currie
25c36a51a8 -f and -F were reversed in the usage. 2011-01-10 12:25:31 +09:00
Bill Currie
fed82466cc The first stages of Quake-Pascal.
At present, this parses a subset of the pascal language with a few type
extensions. There is already work on the type system.
2011-01-10 12:25:31 +09:00
Bill Currie
ae4ca52661 Make function.h more independent. 2011-01-10 12:25:31 +09:00
Bill Currie
66ac56063f Break out the frame macro code from qc-lex.l 2011-01-10 12:25:31 +09:00
Bill Currie
2b539ee4ae Add include for stdlib.h
This is needed for size_t when hash.h is the first file included.
2011-01-10 12:25:30 +09:00
Bill Currie
a09f02db1a Break out the debug and string functions from qc-lex.l. 2011-01-10 12:25:30 +09:00
Bill Currie
695f71eeb6 Get clost to the look I wanted for symtab_flat_copy's graph. 2011-01-10 12:25:30 +09:00