Commit graph

1571 commits

Author SHA1 Message Date
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
Bill Currie
55043310fc Fix the QFO_POINTER macro 2011-02-27 00:31:52 +09:00
Bill Currie
9cf63dbbdf Clean up the create of the obj_module_s structure. 2011-02-26 22:06:22 +09:00
Bill Currie
cbfbc0b01a Ensure type_ClassPtr is chained before it is used. 2011-02-26 22:05:53 +09:00
Bill Currie
a7ae71efad Fix some type encoding problems found using qfprogs. 2011-02-25 15:59:23 +09:00
Bill Currie
58ac212b54 Fix qfo function dumping. 2011-02-25 13:37:23 +09:00
Bill Currie
2b3436beed Fix qfo reloc dumping. 2011-02-25 13:29:09 +09:00
Bill Currie
f43eda63fe Fix qfo global dumping. 2011-02-25 09:39:07 +09:00
Bill Currie
65c7d421c6 Update the qfo access macros for the new format. 2011-02-25 09:38:22 +09:00
Bill Currie
f362e74f98 Update the header. 2011-02-24 15:24:35 +09:00
Bill Currie
a106c1fb51 Add a field for loose relocation records.
Loose relocation records are those that are not bound to a def or a
function.
2011-02-24 15:21:06 +09:00
Bill Currie
8f1e2c143a Clean up some fixmes. 2011-02-24 14:08:42 +09:00
Bill Currie
c10a551c84 Rename new_defspace() and defspace_new_loc(). 2011-02-24 13:07:36 +09:00
Bill Currie
88cd37a3e2 Header update for the renamed files. 2011-02-24 13:00:19 +09:00
Bill Currie
5efeb7ebf8 Rename some files that have been bugging me. 2011-02-24 12:59:18 +09:00
Bill Currie
66b255afbf First stage of the linker rewrite.
Strings, code and data spaces are "merged". Various offsets are updated.
Still to do:
 o  Merge reloc, def, function and line data.
 o  Merge type data.
 o  Update def and function type pointers.
 o  Resolve external defs and check for duplicate defs.
 o  Perform relocations.
 o  anything else I've forgotten :)
2011-02-24 12:18:35 +09:00
Bill Currie
74497f00e1 Read qfo object files :) 2011-02-23 18:10:38 +09:00
Bill Currie
33810e9c91 Write out object files in the new format. 2011-02-23 15:05:33 +09:00
Bill Currie
1f7c39b918 Chain @va_list's type.
Oops :P
2011-02-23 14:49:00 +09:00
Bill Currie
a1ea492889 Remove some redundant fields from qfo objects. 2011-02-23 10:40:35 +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
e68e6d0858 Create defs for entity fields in the entity space. 2011-02-22 15:43:15 +09:00
Bill Currie
e1158a83f0 Begin work on rewriting obj_file.c for the new format. 2011-02-22 15:42:49 +09:00
Bill Currie
64cf07351f Encode types to string and qfo representation on creation. 2011-02-22 13:36:16 +09:00
Bill Currie
a07cd17f38 Update TODO.
Remove old entries and add some new ones.
2011-02-22 12:23:00 +09:00
Bill Currie
b50b392746 Fix field def allocation for function fields.
Assignment of nil to a field function is permitted, but trying to use one
as a builtin or as a normal function is treated as an error.
.void (float y) func;       OK
.void (float y) bi = #0;    error
.void (float y) ni = nil;   OK
.void (float y) co = { };   error
2011-02-22 12:07:31 +09:00
Bill Currie
7d1f2c4ef3 Fix field def allocation for non-function fields. 2011-02-22 10:43:35 +09:00
Bill Currie
ecbb904d6b More docs and clearer types. 2011-02-22 09:23:04 +09:00
Bill Currie
b7c6c4af5d Better variable naming in init_elements(). 2011-02-22 09:22:04 +09:00
Bill Currie
497db3ac81 Fix the return symbol extraction when appending a return statement.
The code is still icky, though :P
2011-02-22 09:20:52 +09:00
Bill Currie
4fd6bdae6f Allow nil to be assigned to field variables.
Note, this is the field variable itself, not the field in the entity.
eg:
	.integer x = nil;
2011-02-22 09:19:01 +09:00
Bill Currie
87b240f469 Use special treatment for .float ()foo; functions.
The parser wants to treat .float () foo; as a function returning a float
field, but qcc treats it as a field holding a function variable.
Fortuantely, field types are always "simple" (ie, at worst, just more
field type wrappers around the non-field type), so all that's needed to
obtain qcc grammar is to reach into the field type layers and do the
function type calculation based on the non-field type found there.
2011-02-22 08:54:01 +09:00
Bill Currie
96c6b31c66 Update qfo version and correct some comments and types. 2011-02-21 18:24:34 +09:00
Bill Currie
4c11304c8d Documentation tweaks. 2011-02-21 08:41:03 +09:00
Bill Currie
bffc1dd239 Clean up objective-qc type encoding.
Structures etc now never encode the fields as well (I might revert that
at some time). Type parsing has been removed: it has proven unnecessary
and overly complicated, and the new qfo encoding should be more useful.
2011-02-18 20:51:04 +09:00
Bill Currie
41523852cd Cleaner def and string emittion for types.
Use local defines for emitting defs and strings as everything goes to the
same locations.
2011-02-18 12:44:11 +09:00
Bill Currie
7251bc91fa Enhanced type encoding.
This creates a compact representation of types as seen by qfcc. This is
intended mainly for debuggers.
2011-02-18 09:06:05 +09:00
Bill Currie
0f0ed3dae2 Allow null types in defs again.
However, only at the lowest level. This is needed for my type encoding.
2011-02-18 09:04:33 +09:00
Bill Currie
bceb98e5a4 Create structures for new qfo format.
This breaks a lot of existing code, so that code has been commented out
for now.
2011-02-17 15:02:09 +09:00
Bill Currie
9c9a71f1af Allow defs to specify use of offset relocations.
Access to struct fields in near data can be done using only one operand,
but offset relocs need to be used. However, as not all defs want offset
relocs, a flag has been added to the def struct.
2011-02-15 22:55:15 +09:00
Bill Currie
d04865884f Set the method's function pointer. 2011-02-15 22:27:13 +09:00
Bill Currie
3721b2edca Method lists are made of methods, not integers :P 2011-02-15 22:26:44 +09:00
Bill Currie
c068138d91 More addresses in hex. 2011-02-15 22:26:09 +09:00
Bill Currie
814e36d3c8 Correct an error message and tidy some code. 2011-02-15 22:25:40 +09:00
Bill Currie
4336fc2c73 Move method function defs into the far data space.
As they are never referenced directly by instructions, there's no need for
them to be in the near data space, taking precious def locations.
2011-02-15 15:33:18 +09:00
Bill Currie
5252d72856 Correct the type for _OBJ_SELECTOR_TABLE. 2011-02-15 15:33:12 +09:00
Bill Currie
b3da6ef3d4 Allow zero size arrays to match sized arrays of the same type.
This allows externally declared arrays to not specify a size.
2011-02-15 12:08:03 +09:00
Bill Currie
b2d4aee61e Reimplement selector expressions to work with far data.
They currently execute a lea instruction every method call, but the
optimizer should take care of that once its written.
2011-02-15 10:48:05 +09:00
Bill Currie
6bd63f811f Preserve any relocs when converting a def from extern to otherwise. 2011-02-15 10:47:16 +09:00
Bill Currie
62456dc1e9 Yet another test. 2011-02-15 09:48:10 +09:00
Bill Currie
4e86b28b59 Use the def type rather than expression type to select the init method.
Local defs may be initialized with non-constant expressions, which
includes function calls. Both function calls and aggregate initializers
use block expressions.
2011-02-15 09:38:44 +09:00
Bill Currie
19f6faf0ad Fix aggregate initializers.
Initializing arrays and structs seems to be working.
2011-02-15 09:30:37 +09:00
Bill Currie
d162838299 Resurrect constant_expr(). 2011-02-15 09:28:27 +09:00
Bill Currie
bc882ddc3c Fix the parser side of aggregate initializers. 2011-02-14 23:31:37 +09:00
Bill Currie
09af401f0c Reset current_func at the end of each function. 2011-02-14 23:10:46 +09:00