Commit Graph

237 Commits

Author SHA1 Message Date
Bill Currie 9691b50f0f Make .type_encodings more useful.
Rather than just a pointer, it is now a struct with a pointer and size
indicating the extent of the type encodings block.
2012-11-15 11:57:16 +09:00
Bill Currie e05c12e16d Make linker_add_def take a pointer for the value.
While it looks like I might not use it for the type encodings, it should be
useful in the future.
2012-11-14 13:12:58 +09:00
Bill Currie fd8c639773 Initialize current_symtab early, with pr.symtab.
This (with the previous commit) fixes the problems with the tags for
builtin structs.
2012-11-09 14:37:28 +09:00
Bill Currie 9fd8741b4f Move the state clearing into InitData.
Now, for each compilation, or before linking, only InitData needs to be
called. Fixes the double chaining internal error when compiling and linking
in the same command.
2012-11-09 13:56:45 +09:00
Bill Currie 4ef4711c3b Make the type encodings findable.
The base of the type encodings block is given by the .type_encodings def.
The block begins with a "null" type (4 words of 0), followed by the first
type encoding.

At some stage, I will need to add information for extended def information
(32 bit offset, type encoding, other?), but this is good for initial
testing.
2012-11-09 11:43:19 +09:00
Bill Currie 7e293a38e8 Check for double-chaining of types.
Chaining a type twice will form a loop in the type list, causing find_type
to go into an infinite loop.
2012-11-08 17:14:33 +09:00
Bill Currie 7a25283beb Clear out the type encoding def from all types.
The encodings of static types were getting corrupted because their defs
were not necessarily in the same places between compilations when compiling
multiple files.
2012-11-08 17:06:38 +09:00
Bill Currie ed4018fd8d Clear out the function overloading tables between compiles.
Fixes some issues with multiple compiles (especially mixed languages!).
2012-11-01 20:53:33 +09:00
Bill Currie ea34a5b753 Fix some nasty memory errors.
Three cheers for valgrind!!!
2012-11-01 20:53:28 +09:00
Bill Currie f14d8060e0 Merge qfpc into qfcc.
Since gnu bison and flex are required anyway, no harm in using their api
prefix options. Now, qfcc can compile both QC/Ruamoko and Pascal files
(Pascal is (currently?) NOT supported in progs.src mode), selecting the
language based on the extension: .r, .qc and .c select QC/Ruamoko, .pas and
.p select Pascal, while anything else is treated as an object file (as
before).
2012-10-26 16:01:41 +09:00
Bill Currie 23a38738fc Massive whitespace cleanup.
Lots of trailing whitespace and otherwise blank lines.
2012-05-22 08:23:22 +09:00
Bill Currie e267e0a664 Allow control of progdefs.h CRC writing.
CRC writing defaults to off for non-v6 progs, but on for v6 progs. The
--progdefs option forces CRC writing.
2012-05-03 00:22:24 +09:00
Bill Currie bc1b483525 Nuke the rcsid stuff.
It's pretty useless in git.
2012-04-22 10:56:32 +09:00
Bill Currie f1d9570dc8 Fix constant value type handling.
Rename immediate.[ch] to value.[ch] and clean up the mess.

Add convert_value() to convert the type of a value (only scalar types).
2011-03-22 12:24:39 +09:00
Bill Currie cbbbf87e20 Resurrect the stats output. 2011-03-09 15:51:17 +09:00
Bill Currie 8368f57fbf Close a potential buffer overflow. 2011-03-09 11:09:46 +09:00
Bill Currie 4d90eba2ad Remove some unused globals. 2011-03-09 11:08:30 +09:00
Bill Currie fe3d228658 Maintain a symbol table for entity fields. 2011-03-06 15:38:19 +09:00
Bill Currie 7bfaf107ce Set the output file name as early as possible. 2011-03-06 13:40:24 +09:00
Bill Currie 97b1ceceb0 Fix line number info.
line number info is now 1 based rather than 0 based (to better detect when
a function does not have line number info).
2011-03-05 15:40:08 +09:00
Bill Currie af7bc81e16 Chain the types for the linker. 2011-03-05 08:35:56 +09:00
Bill Currie d6d8b5b49d Generate the debug symbol file. 2011-03-04 18:46:05 +09:00
Bill Currie 4a99f8dcbd Write the linker output to progs.dat.
There is much breakage, but qfcc now produces a progs.dat from either
progs.src or object files. Better yet, the progs.src result is passed
through the linker, removing much duplicate code.
2011-03-02 20:51:00 +09:00
Bill Currie ecb995a8f7 Rewrite qfo_to_progs() to go direct from qfo to progs.dat.
Relocs and debug info is currently broken.
2011-03-02 19:06:43 +09:00
Bill Currie c10a551c84 Rename new_defspace() and defspace_new_loc(). 2011-02-24 13:07:36 +09:00
Bill Currie c585a17db9 Give type data a null pointer.
Pointers to the void type descriptor looked just like null pointers and
that was terribly confusing. Avoid that confusion by pre-allocating a
small amount of data in order to reserve space for a null descriptor.
2011-02-23 08:08:26 +09:00
Bill Currie 64cf07351f Encode types to string and qfo representation on creation. 2011-02-22 13:36:16 +09:00
Bill Currie 3505de6868 Point the near and far data spaced into the merged data space.
This lets the relocations work on the final data without having to adjust
their locations.
2011-02-12 22:35:44 +09:00
Bill Currie d66a441867 Write out the far data space as well as the near.
This causes the Objective-QC structs to be emitted now that they havve been
moved to the far data space. Relocs are broken, though.
2011-02-09 21:45:29 +09:00
Bill Currie 244d969ae3 Ensure any tail bytes in the strings data are zeroed. 2011-02-09 18:32:37 +09:00
Bill Currie 5eff00fdeb Fix debug information. 2011-02-09 08:47:01 +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 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 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 5231e8e9f8 Handle .zero, .return and .param* properly. 2011-01-26 08:01:24 +09:00
Bill Currie a648f043de Give functions their own defspace.
The defspace is propogated through the function's sub-scopes.
2011-01-25 12:34:45 +09:00
Bill Currie d618e51dc8 Move save_string and make_string into strpool
Might not be the perfect place, but at least they're strongly related.
2011-01-24 21:32:48 +09:00
Bill Currie afc5b2827d Simplify def handling, use far data.
Since there is now a proper symbol table, defs are now just references to
memory locations and the symbol table takes care of duplicates.

Also, start using far data for ObjQC structures.

The qfo functions have been stubbed out until I figure out what to do with
object files in the new scheme.
2011-01-24 15:41:43 +09:00
Bill Currie 4ac80c2932 Get qfcc running again.
It segs when it tries to link, but that's because a real object file has
not been created yet. However, I can get my tree and flow diagrams :)
2011-01-22 15:52:57 +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 e08efe036b Move the constant expression values into their own struct. 2011-01-19 08:43:24 +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 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 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 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 a09f02db1a Break out the debug and string functions from qc-lex.l. 2011-01-10 12:25:30 +09:00
Bill Currie ac88c86dd3 Scripts now treat {}()': as single character tokens. 2010-11-28 15:31:30 +09:00
Bill Currie c542138300 more not-really initialized data 2009-12-20 11:54:19 +00:00