Commit graph

1151 commits

Author SHA1 Message Date
Bill Currie
54c8a10fe4 Don't trip over incomplete structs (again:P) 2011-02-03 21:31:14 +09:00
Bill Currie
12d8658ece Create a typedef for obj_module_t. 2011-02-03 18:05:46 +09:00
Bill Currie
b07392b818 Allow ivars to use C syntax declarations. 2011-02-03 18:04:41 +09:00
Bill Currie
dc6296e9b1 Allow ivars to use typedefs and other classes. 2011-02-03 18:03:37 +09:00
Bill Currie
2203903bb2 Temporarily splice the class's ivar chain into the symbol table.
The root class's ivar symbol table needs to be connected to the global
symbol table while building the current class's ivar symbol table. This
allows access to other classes and typedefs.
2011-02-03 18:02:49 +09:00
Bill Currie
79df3d2cca Put newly created classes into the symbol table. 2011-02-03 17:28:49 +09:00
Bill Currie
564b7b9968 Use abstract_decl instead of type wherever a generic type is needed. 2011-02-03 10:53:59 +09:00
Bill Currie
a208aed6ef Fix a segfault when encoding incomplete structs. 2011-02-03 10:52:42 +09:00
Bill Currie
22ccd41164 Give struct types a name.
Use the struct/union's name (minus "tag ") for the type name.
2011-02-03 10:52:12 +09:00
Bill Currie
d12cdca758 Functions and enums now seem to be working properly.
find_type now operates recursively (depth-first) so built up typechains
work as expected.

@overload is treated as a specifier (directly as a storage class, similaar
to typedef).
2011-02-03 10:48:12 +09:00
Bill Currie
52799a4e1c Must merge specifiers :P 2011-02-02 22:59:08 +09:00
Bill Currie
4420a7125e Ensure structs get added to the symbol table. 2011-02-02 22:53:53 +09:00
Bill Currie
a4eaa2a89b Allow typedefed types and classes in parameters. 2011-02-02 21:58:53 +09:00
Bill Currie
aeecdc84dc Get typedef working. 2011-02-02 21:58:11 +09:00
Bill Currie
cca829aa6b Remove a stray semicolon from the grammar. 2011-02-02 21:57:41 +09:00
Bill Currie
400abe7fce Allow freeing of typechains. 2011-02-02 15:15:24 +09:00
Bill Currie
1fe031e8cb Build C style var/func/abs decl types from the outside in.
QuakeC style are built from the inside out.
2011-02-02 15:15:04 +09:00
Bill Currie
7fb8c8247e Don't do a find_type on the parsed function.
This is needed for C style declarations, but breaks QuakeC style. The fix
is to do the find_type once the return type has been filled in.
2011-02-02 15:08:59 +09:00
Bill Currie
1452da676d Allow types to be built from the outside in.
This is required for C style decl processing.
2011-02-02 15:07:44 +09:00
Bill Currie
ac91e9376b The big type-system rewrite. Horribly broken :)
While broken, it is good enough to compile modulo.r.

This gives qfcc C's type system with QC specifics bolted on top (rather
than trying to cram C's type system into QC's). Pointers and arrays now
use C syntax and semantics (though I think there's a lot of breakage in
there at the moment). Functions themselves are still dual mode: both QC
style and C style are available.
2011-02-01 21:23:03 +09:00
Bill Currie
d11d128c96 Avoid segfaulting on errors. 2011-02-01 21:18:39 +09:00
Bill Currie
80ce179bc2 Scan the param list for problems with void. 2011-02-01 21:18:08 +09:00
Bill Currie
c53001800a Create a struct for representing specifiers.
The specifiers are yet to come (next few commits), but this will be
necessary when they do.
2011-02-01 21:15:51 +09:00
Bill Currie
917c5f08b0 Make a var representing the default type.
The default type for vars is integer for ruamoko and float for v6 qc.
2011-02-01 21:12:02 +09:00
Bill Currie
54c14eb899 Add "return" to pascal.
I'm still not sure I'll keep it, but it's useful for testing.
2011-01-30 22:16:59 +09:00
Bill Currie
e7424e1496 Don't segfault on bare return statements.
I will probably need to do something about the required operand for v6
progs, but this will do for now.
2011-01-30 21:43:56 +09:00
Bill Currie
440a13b649 Untwist params' knickers for pascal, too. 2011-01-30 21:42:10 +09:00
Bill Currie
861ab93274 Don't type-check against the wrong type :P 2011-01-29 09:56:08 +09:00
Bill Currie
afc6605739 Don't set the space for external defs. 2011-01-29 09:55:14 +09:00
Bill Currie
d80a3413e5 Fix a segfault when freeing locations.
When chasing linked lists with a double pointer, must check the first
dereference and not the pointer itself.
2011-01-29 09:54:47 +09:00
Bill Currie
e1226bd3f1 Quaternions aren't vectors :P 2011-01-28 21:57:04 +09:00
Bill Currie
2cce903cc9 Set the default storage class for local vars. 2011-01-28 21:56:17 +09:00
Bill Currie
bc7d42d176 Immediate constants now work, though still not shared. 2011-01-28 21:39:01 +09:00
Bill Currie
3c95667b79 Print data contents for most simple types. 2011-01-28 21:21:29 +09:00
Bill Currie
4476074021 Print more addresses as hex. 2011-01-28 18:03:26 +09:00
Bill Currie
4837e0bd18 Fix most of the FIXMEs in qfcc.c.
Functions and defs seem to be relocated correctly. Constants are very
broken, however.
2011-01-28 15:17:30 +09:00
Bill Currie
834417b8c8 Add "debug" diagnotic printing, and use it.
Debug diagnostics are silent for verbosity levels less than 1.
2011-01-28 13:28:45 +09:00
Bill Currie
a37bdd9fb5 Free removed sblocks. 2011-01-28 13:23:20 +09:00
Bill Currie
80424f6ad5 Ensure functions are always properly terminated.
Control that reaches the end of a function must see a return statement.
2011-01-28 13:14:30 +09:00
Bill Currie
9159daf99d Do simple unreachable block analysis and dead block removal. 2011-01-28 11:45:04 +09:00
Bill Currie
90a2738459 Add the label to the block to which it refers. 2011-01-28 11:41:53 +09:00
Bill Currie
c158b14286 Remove the labels list from the pr struct.
I'm not sure they were ever needed.
2011-01-28 11:40:25 +09:00
Bill Currie
4738c767a2 Fix branch label handling.
Conditional branches and goto now go to the correct location.
2011-01-27 21:11:32 +09:00
Bill Currie
95b17d9fd4 Rename add_statement_ref to add_statement_def_ref. 2011-01-27 21:10:37 +09:00
Bill Currie
bd78b8a7ee Enable more end-of-compilation code. 2011-01-27 15:44:12 +09:00
Bill Currie
cdea1d07aa Produce code for progs.src mode.
Separate compilation will take fixing object files.

The generated code is broken due to various relocation fixups being
broken, and float immediates seem to be badly broken.

Debug information is broken too.
2011-01-27 15:44:11 +09:00
Bill Currie
c7bbd40df6 Give special treatment to opcodes that have void operand types. 2011-01-27 15:44:11 +09:00
Bill Currie
71b5decbe8 Get assignments to .return working.
I really do not like the mechanism I currently use for handling pointer
derefences vs pointer assignments, but this will have to do for now until
I can get qfcc producing code again.
2011-01-27 15:44:11 +09:00
Bill Currie
56106892c8 The & operator produces a pointer, not void. 2011-01-27 15:44:10 +09:00
Bill Currie
1c3cc571f1 Pascal variables need defs too. 2011-01-27 15:44:10 +09:00