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
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
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
5f70e27613
Quaternions use quaternion_val, not vector_val :P
2011-01-10 13:23:12 +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
d327c860cb
Get messages working again.
2011-01-10 12:26:11 +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
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
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
Bill Currie
782a4c9a8d
New symbol table code.
2011-01-10 12:25:30 +09:00
Bill Currie
fbdbcfada4
Remove deprecated @argc and @argv
2011-01-05 13:10:57 +09:00
Bill Currie
a27ea057c4
Add a test for calling class methods.
2011-01-03 18:11:46 +09:00
Bill Currie
02f78e46f8
More expression docs.
2011-01-03 16:25:59 +09:00
Bill Currie
5627e43465
Use the method's selector rather than its def name in error messages.
2011-01-03 16:25:29 +09:00
Bill Currie
a1f36a9944
Make new_function take a def rather than a name.
...
Moves into new_function some code that should have been there in the first
place.
2011-01-03 16:25:29 +09:00
Bill Currie
4c69a97ac7
Allow normal declarations within a class implementation.
...
I had always been under the assumption that such was illegal in
Objective-C, but after working on Forge, I now know otherwise.
2011-01-03 16:25:29 +09:00
Bill Currie
dc5bafb8fb
Minimal error recovery.
...
No more bailing on the first syntax error. While the recovery is not
perfect (things can get right twisted), qfcc will now continue parsing
after a syntax error.
2011-01-03 16:25:29 +09:00
Bill Currie
a4635d79e8
Slightly more informative error locations.
...
Inside a class or protocol definition is not "at top level" ;)
2011-01-03 16:25:29 +09:00
Bill Currie
530e8fae34
Rework class_type_t to be more useful.
...
This allows current_class to refer to procols as well (for error
reporting).
2011-01-03 16:25:29 +09:00
Bill Currie
f738ef5dba
Remove redundant RETURN statement rule.
...
The same effect can be achieved with one rule using opt_expr.
2011-01-03 16:19:28 +09:00
Bill Currie
58042719e5
A little more documentation for expressions.
2011-01-03 16:19:28 +09:00
Bill Currie
1a767849ab
Sort the options in the switch.
...
Should make finding them a little easier.
2010-12-24 17:35:33 +09:00
Bill Currie
d6b3d4891a
Finally, help output for qfprogs.
...
Nothing great, but better than nothing.
2010-12-24 17:33:57 +09:00
Bill Currie
f4d8b82115
Rearrange the options into alpha order.
2010-12-24 17:08:48 +09:00
Bill Currie
28740bb57f
Add unsigned integer constant support.
2010-12-23 19:32:28 +09:00
Bill Currie
6c631c6d5d
Start documenting qfcc.
2010-12-19 11:35:18 +09:00
Bill Currie
52e844ee48
Produce slightly better v6 modulo code for complex inputs.
...
I'm having problems with temp defs, but I imagine this code is rarely used
so I won't worry about it for now. It will, however, make a good test case
for when I rework emit.c after I do some reading.
2010-12-19 11:23:33 +09:00
Bill Currie
b90833d86f
v6 modulo test
2010-12-19 11:19:23 +09:00
Bill Currie
fa08e4afb7
Print users info when dumping statements.
2010-12-19 11:16:04 +09:00
Bill Currie
f5706f9c44
Make control of expression dumping less of a hassle.
2010-12-19 11:15:13 +09:00
Bill Currie
d981968208
v6 modulo implementation now produces good code.
...
At least for simple inputs, anyway. That needs to be tested next.
2010-12-18 22:21:55 +09:00
Bill Currie
00e50c0ad3
Rewrite the v6 modulo implementation.
...
While trying to understand bind expressions, I discovered that the v6
modulo code was incorrect. This version is correct but uses one too many
temps. That's next.
2010-12-18 22:21:55 +09:00
Bill Currie
8197d34eda
Objective-C warnings documentation from gcc.
2010-12-16 20:12:24 +09:00
Bill Currie
699799bfc8
Don't warn when adding a new method to an implementation.
...
Methods defined in the implementation but not declared in the interface are
just fine.
2010-12-16 20:04:08 +09:00
Bill Currie
eace5b3c81
Get message checking working properly.
2010-12-16 16:41:16 +09:00
Bill Currie
4481ba9b0d
Allow explicit references to classes and categories.
...
Use "@reference ClassName;" or "@reference ClassName(CategoryName);" to
create a refence to the class or category, forcing the defining object file
to be linked into the program when the object file is part of a library.
2010-12-12 20:27:56 +09:00
Bill Currie
2c84ae4898
Don't let casting in constfold increment users.
...
This fixes Deek's temp notice. No new notices have shown up, so this should
be the correct fix. The constant folding code no longer calls cast_expr
directly, but rather uses an internal wrapper that decrements users after
cast_expr increments it, resulting in a no-op.
2010-12-12 15:37:26 +09:00
Bill Currie
ac88c86dd3
Scripts now treat {}()': as single character tokens.
2010-11-28 15:31:30 +09:00
Bill Currie
023d3c89ec
Source formatting.
2010-11-24 17:01:18 +09:00
Bill Currie
9a3f4d5a01
Handle method parameters that use incomplete types.
...
Compare the method's type pointers rather than the type strings as the pointer
won't change with the struct is completed.
2010-11-24 17:01:18 +09:00
Bill Currie
e28ee0378f
Gracefully handle returning NIL though a bad type.
2010-11-24 17:01:18 +09:00
Bill Currie
67beaf4487
Nil is a constant, so allow it in global initializers.
2010-11-24 17:01:18 +09:00
Bill Currie
799d46f83d
Check for incomplete types and better param/return size checking.
2010-11-24 17:01:17 +09:00
Bill Currie
a623fb53a7
Proper support for empty structs and unions.
...
They now have a single private, void, unnamed member, resulting in a size of
1 word. This makes empty structs useful for typed opaque handles.
2010-11-24 17:01:17 +09:00
Bill Currie
e5e560cbaf
Ensure struct params are small enough to fit in the param slots.
2010-11-24 17:01:17 +09:00
Bill Currie
06cbb941f1
"make dist" fixes
...
Since we're using git now, having a rule to make ChangeLog is reasonable.
Also, forgot the remove mention of qfcc.lsm.in when I nuked the file.
2010-08-21 13:09:53 +09:00
Bill Currie
669771681a
split up and modernize configure.ac
...
Most of the guts of configure.ac have been moved to config.d and are then
brought in by m4_include. This will make maintaining configure.ac much easier.
Also drop use of PROGRAM and VERSION, using PACKAGE_NAME, PACKAGE_VERSION, and
on occasion, PACKAGE_STRING instead, and clean out some old files we no longer
need.
2010-08-19 15:01:43 +09:00
Bill Currie
d045045693
get the grouping right
2010-08-11 23:42:14 +00:00
Bill Currie
f04bc64ef1
clean up a bunch of doxygen warnings
2010-08-11 23:41:30 +00:00
Bill Currie
0dfff8fd58
ignore stuff
2010-08-07 10:42:09 +00:00
Bill Currie
17d84613a9
found a test file lurking around
2010-08-05 02:36:51 +00:00
Bill Currie
51a32f4f87
minor comment about scoping in traditional mode
2010-02-22 13:44:52 +00:00
Bill Currie
fac98536f0
make sure def->space points to the space the def's location is allocated from to ensure that freeing the location works properly (fixes the bogus address triggered by prozaccoop: thanks, phrosty)
2010-02-22 13:11:41 +00:00
Bill Currie
56d01ce267
found an uncontrollable warning
2010-02-20 12:01:49 +00:00