Bill Currie
0594609b3a
Get the label from the right expression.
2011-01-19 22:25:43 +09:00
Bill Currie
5deda9c9b9
Clean out ex_def as ex_symbol replaces it.
2011-01-19 22:25:04 +09:00
Bill Currie
b5424bca7d
Start work on getting expressions converted to internal statements.
2011-01-19 15:47:45 +09:00
Bill Currie
cac2e04b18
Avoid namespace issues with dstatements.
2011-01-19 11:35:34 +09:00
Bill Currie
f2ef24d0cc
Make symbols use the new value struct for constants.
2011-01-19 11:09:54 +09:00
Bill Currie
e08efe036b
Move the constant expression values into their own struct.
2011-01-19 08:43:24 +09:00
Bill Currie
ff6e1b4d6c
Get functions attempting to generate code.
...
However, the statements are only printed as expressions.
2011-01-19 08:38:09 +09:00
Bill Currie
33db650161
Add QuatInverse to calculate 1/q.
...
There's still no direct quaternion division because I don't know if the
definition of q1/q2 is (1/q2)*q1 or q1*(1/q2) (it does make a difference).
2011-01-18 22:22:18 +09:00
Bill Currie
87ce9f5333
Get basic function creation working.
...
Even more FIXMEs, but the pascal parser can now create functions. The
function records even get emitted.
2011-01-18 12:47:13 +09:00
Bill Currie
8fb1b49a9d
Add support for function symbols.
2011-01-18 10:46:42 +09:00
Bill Currie
b186173d18
Fix a segfault in structure finalization.
2011-01-18 08:59:44 +09:00
Bill Currie
21c0c960ae
Initialize data before types.
...
This is needed for string data. It might be better to init saved strings
separately, but this works for now.
2011-01-18 08:58:43 +09:00
Bill Currie
3fe7a7250a
Handle unnamed structures in make_structure.
...
Symbols may not have null names.
2011-01-18 08:56:47 +09:00
Bill Currie
b76a5c5284
Add my QuakePascal test program.
...
Trivial as it is...
2011-01-17 22:44:58 +09:00
Bill Currie
ea3895805b
Rewrite much to use symbols and symtabs. Gut emit.c. Massive breakage.
...
That which isn't rewritten is horribly broken. However, this does include a
nice mechanism for building QC structs for emitting data.
emit.c has been gutted in the spirit of "throw one away".
There is much work to be done to get even variables emitted, let alone
code. Things should be a little more fun from here on.
2011-01-17 22:34:41 +09:00
Bill Currie
85de101aa3
Break out the defspace code.
...
This also makes some improvements to the free block handling code.
2011-01-17 22:34:41 +09:00
Bill Currie
d3a98af783
Make internal_error globally available.
2011-01-17 22:34:41 +09:00
Bill Currie
537b930ba6
Add new_symbol_type to ease creation of typed symbols.
...
This is inteded for code generation functions that need to create
variables and structures.
2011-01-17 12:04:41 +09:00
Bill Currie
ffea505678
Cleanup QC's constant handling based on QP.
2011-01-14 12:10:28 +09:00
Bill Currie
c38ea0b1bc
Correct the spelling of "nil".
2011-01-14 12:07:40 +09:00
Bill Currie
fb8b3d1211
Rework the lexer and parser to use symbols instead of defs.
...
Currently parses the test program just fine, but code generation is very
very broken.
2011-01-13 14:58:16 +09:00
Bill Currie
8f71986306
Add symbol expressions (like def expressions).
...
They will eventually replace def expressions. Currently quite broken.
2011-01-13 14:54:24 +09:00
Bill Currie
008f4e1929
Don't return .return in advanced mode.
2011-01-13 14:50:25 +09:00
Bill Currie
5b8725ca66
Rewrite the symbol (table) management in light of actual usage.
2011-01-13 14:48:38 +09:00
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