Bill Currie
4324486ae6
Give - unary expressions special treatment.
...
The progs engine has no neg instruction, so need to implement -val as
nil - val
2011-03-03 18:13:30 +09:00
Bill Currie
f9e177efd6
Obtain the label to be removed from the correct place.
...
This fixes the undetected dead block after "if return else return".
2011-03-03 17:50:46 +09:00
Bill Currie
ed901bd48f
Drop unused labels rather than adding them to the statement block.
...
However, even unused labels create a new statement block if necessary.
2011-03-03 17:35:06 +09:00
Bill Currie
b5e7e666e9
Fix some missed branch/goto expression changes.
2011-03-03 17:33:53 +09:00
Bill Currie
c5ecc170b6
Give labels a usage count to detect unused labels.
2011-03-03 15:28:49 +09:00
Bill Currie
90640614ef
Compare symbols using the right method.
...
That fixme was right :)
2011-03-03 15:02:26 +09:00
Bill Currie
610d775bd1
Treat void values as the largest type.
...
This fixes passing nil through a structure return value.
2011-03-03 14:56:21 +09:00
Bill Currie
bad5fddec4
Fix overloaded function resolution.
...
Update the expression symbol pointer, not just the symbol name.
2011-03-03 14:44:48 +09:00
Bill Currie
fff4fc693e
Fix value hashing and comparison in switch expressions.
2011-03-03 14:02:18 +09:00
Bill Currie
74e6b13aee
Use alias expressions where possible when testing an expression.
2011-03-03 13:47:28 +09:00
Bill Currie
d937172243
Create and use alias operands for alias expressions.
...
This avoids the alias expression modifying the operand used in other
expressions.
2011-03-03 13:46:07 +09:00
Bill Currie
022fde666f
Implement unary expression statements.
2011-03-03 13:10:07 +09:00
Bill Currie
45de7327dc
Implement alias expressions (finally).
...
Alias expressions are like cast expressions, but never do any conversions.
2011-03-03 11:06:10 +09:00
Bill Currie
848994323e
Support enums in expressions that support scalar types.
2011-03-03 10:36:43 +09:00
Bill Currie
c12211d8bb
Support enum results for boolean expressions.
...
eg enum BOOL x = a && b;
2011-03-02 22:46:55 +09:00
Bill Currie
c06dd776d2
Fix expression initializers for arrays and structs.
2011-03-02 22:28:17 +09:00
Bill Currie
76f912c7a1
Fix function typedefs.
2011-03-02 22:23:24 +09:00
Bill Currie
aa4ed00090
Fix the message type used to check arguments.
2011-03-02 22:13:16 +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
29985efcef
Expose some linker functions to the rest of the compiler.
...
They proved to be useful for cleaning up the final compilation stages.
2011-03-02 20:48:55 +09:00
Bill Currie
8cdd28f534
Use qfo_to_progs() for dumping qfo data.
...
Yay, less duplicate code, and better yet, qfo_to_progs gets some much
needed testing :).
2011-03-02 19:08:11 +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
824d8bfc3c
Remove some now unnecessary functions.
2011-03-02 14:21:20 +09:00
Bill Currie
065d3e0dd7
Partial linking for a single qfo file now seems to work.
2011-03-02 14:03:41 +09:00
Bill Currie
bfeece3255
Fix the bogus declarations of obj_msgSend and obj_msgSend_super.
2011-03-02 12:35:10 +09:00
Bill Currie
fda46a4aca
Handle the special defs.
2011-03-02 12:26:53 +09:00
Bill Currie
330e76a9ac
Set the correct storage class for struct and enum specifiers.
2011-03-02 11:29:08 +09:00
Bill Currie
54317965cc
Handle relocs.
...
With this, the building of the work qfo seems to be almost finished, just
the special defs to go. Next step will be to stitch all the parts of the
work qfo into a real qfo.
However, still have to fix the relocs for the type descriptors, but they
are not critical to the linker's functioning.
2011-03-02 11:16:35 +09:00
Bill Currie
8669dc373f
Add some documentation.
2011-03-02 11:13:44 +09:00
Bill Currie
65bd215058
Minor rearrangements.
2011-03-01 15:35:14 +09:00
Bill Currie
2cb1c74718
More progress on the linker.
...
Need to finish up defs and handle relocs, and then take care of special
defs (@self etc), but things are getting very close.
2011-03-01 15:18:47 +09:00
Bill Currie
9f126ed805
Add some quick type access macros.
2011-03-01 15:18:12 +09:00
Bill Currie
b584a22d6b
Fix external function declarations.
...
Use spec.storage rather than current_storage.
2011-03-01 11:08:33 +09:00
Bill Currie
cce6838e16
Ensure .ctor is declared static.
2011-03-01 11:08:32 +09:00
Bill Currie
c36919aae7
Fix verbosity and diagnostic messages.
2011-03-01 11:08:32 +09:00
Bill Currie
cfff2b1037
Add defs from near and far data spaces.
2011-03-01 10:52:27 +09:00
Bill Currie
21558864b9
Make defrefs a little more stupid.
...
Stupid code does little well :P
I forgot that spaces get realloced, and I don't remember why I had the def
list pointer separate anyway.
2011-03-01 09:19:04 +09:00
Bill Currie
1416b996d3
Ensure the type space pointer is cleared with each object file.
2011-03-01 09:18:09 +09:00
Bill Currie
30272968c9
Update the def's type pointer.
2011-03-01 09:17:32 +09:00
Bill Currie
1837518d05
Split the space processing into two passes.
...
This allows strings and types to be handled before code and data.
2011-03-01 08:48:58 +09:00
Bill Currie
eb11a19ed4
Split the type processing into two passes.
...
This allows all duplicate types to be "merged" before adding any new
types, thus avoiding any accidental duplication caused by possible
differences in order between defs and the type descriptors.
2011-03-01 08:46:02 +09:00
Bill Currie
05e6f00e72
Initialize the new type def.
...
Oops :P
2011-03-01 08:16:14 +09:00
Bill Currie
3761cddca6
Finally, some real progress on the linker.
...
There is still much to be done, but this seems to be a workable approach.
2011-02-28 23:18:07 +09:00
Bill Currie
bad7078797
Don't set the space defs pointer if there are no defs.
2011-02-28 23:16:59 +09:00
Bill Currie
5d9fbc2d6d
Set the space ids to the destination space.
...
This is mostly redundant, but it allows qfo spaces to get out of order
without breaking everything.
2011-02-28 23:16:19 +09:00
Bill Currie
b544196c21
Change ptrfld to fldptr for consistency with type.h.
2011-02-28 23:12:32 +09:00
Bill Currie
8b661bbb89
Rename qfo_reloc_t's def to target and correct its usage.
2011-02-27 11:37:24 +09:00
Bill Currie
c8f1b5b1f0
Fix the missing type encoding for structures.
...
There should be a better way (probably by doing the encoding as needed
rather than in chain_type), but this seems to work for now.
2011-02-27 00:39:40 +09:00
Bill Currie
438d14d852
More or less fix qfprogs when dumping info from qfo files.
...
Relocations are still broken, but everything seems to be working and
qfprogs now seems to be generally usable.
2011-02-27 00:36:45 +09:00
Bill Currie
4f6d18a328
Encode the basic type for functions, fields and pointers.
...
Very important for distinguishing them from other types.
2011-02-27 00:33:16 +09:00