Commit graph

8946 commits

Author SHA1 Message Date
Bill Currie
6ec5bb1884 Change the FIXME to a comment as to why nothing is done.
Of course, the relocation record still needs to be written (don't know why
it isn't), but that's next :)
2012-11-11 20:36:25 +09:00
Bill Currie
d13ce81b4f Ensure the type's encoding string is valid.
When encoding a type to a qfo file, the type's encoding string is written
and thus needs to be valid prior to actually doing the encoding. The
problem occurs mostly in self-referential structs (particularly, obj_class)
because the struct is being encoded prior to the pointer to the struct.
2012-11-11 20:22:48 +09:00
Bill Currie
8710977323 Rework transfer_type to avoid infinite recursion.
This is similar to the problem with infinite recursion when encoding types.
The problem is with structs with self-referential pointers (eg, struct foo
{struct foo *bar}). The solution is to copy the type data to a buffer and
mark the buffer as transfered before actually processing the type. Further
processing of the type is done via the buffer.
2012-11-11 20:20:07 +09:00
Bill Currie
edd381931e Create obj_object after obj_class.
obj_class is self-referential,but obj_object refers to obj_class. This gets
obj_class encoded properly.
2012-11-11 19:08:15 +09:00
Bill Currie
96110a0f54 Treat messages to id and Class separately.
As id and Class do not point to real objects as such, trying to get the
class from their types doesn't work, so instead send the message to a
"null" class that skips the method checks.
2012-11-11 17:39:12 +09:00
Bill Currie
ee28f3869c Fix the checking for assignments between id and Class.
With Class now being struct obj_class rather than an actual class or
object, checking for Class now needs to be explicit.
2012-11-11 17:24:33 +09:00
Bill Currie
694b268f53 Correct the type of id.
It should be struct obj_object * rather than Object *.
2012-11-11 17:22:57 +09:00
Bill Currie
35a88d873c Rework the builtin class creation once again.
Now the classes are built "properly" (using the same tools as the parser
itself), and the structs (obj_object, obj_class and obj_protocol) are built
separately, but using the class ivars.
2012-11-11 16:23:04 +09:00
Bill Currie
b36bd3a988 Remove the list offsets from the class ivars.
Even just before, type_obj_object, type_obj_class and type_obj_protocol
were a bit bogus (still are), but now the arrays used to list their ivars
are correct. I plan to create the above mentioned types using
class_to_struct to do it properly.
2012-11-11 09:52:55 +09:00
Bill Currie
0cf16ac558 Make _OBJ_CLASS_foo the correct type.
It needs to be type_obj_class, but I had gotten confused earlier when
rearranging the type names as I was having trouble with "not a class"
errors.
2012-11-10 13:45:38 +09:00
Bill Currie
06fd912a09 Make super_class for the internal Protocol and Class objects.
They're based on Object, and that needs to be represented properly.
2012-11-10 13:01:56 +09:00
Bill Currie
86091856be Revamp the static class creation.
Type names are cleaned up, as is the creation. Also, the class pointer in
the type encoding now gets emitted. However, Still need to actually create
_OBJ_CLASS_Class and fix the type encoding reloc handling in the linker.
2012-11-10 12:56:19 +09:00
Bill Currie
d33d062bd1 Rearrange class_message_response.
Even if an object doesn't seem to respond to a message, return the message
so unrelated warnings or errors don't occur.
2012-11-09 19:18:09 +09:00
Bill Currie
218424d0ae Add debug.r to libcsqc. 2012-11-09 19:11:30 +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
9cb0ca6fed Catch symtab operations with an invalid symtab.
Just via a simple segfault, but it's better than silently missing incorrect
usage.
2012-11-09 14:36:19 +09:00
Bill Currie
49cc4fed0c Give the builtin structures proper tags.
With the previous commit, the structures were being created before a valid
source file name was available and thus qfcc would segfault when trying to
generate a tag. Now, the tags look better anyway :).
2012-11-09 14:00:10 +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
f307c7bebc Rework the unary_expr grammar to allow ++*foo.
This required throwing out the primary rules that snax did up to help me
with conflicts many years ago, but they were now getting in the way. Now
the productions from primary are merged in with unary_expr.
2012-11-09 12:32:38 +09:00
Bill Currie
6ff2644ab5 Fix simple pointer dereferences.
It turns out no code was being generated for x = *y. Ouch. I suspect I need
to take a better look at expr_deref at some time in the not too distant
future.

Conflicts:
	tools/qfcc/source/statements.c
2012-11-09 12:32:35 +09:00
Bill Currie
7a2f7e8982 Add some safety checks to progs global dumping.
Getting segfaults in the debug tools is not fun :P

Conflicts:
	tools/qfcc/source/dump_globals.c
2012-11-09 12:30:14 +09:00
Bill Currie
cc24e2e67e Initialize global string vars correctly.
Ouch, I'd fixed that for arrays, but not normal vars.
2012-11-09 12:23:04 +09:00
Bill Currie
9095e1eabc Rework build_switch to use initialize_def.
This required support for label reference expressions, whose purpose is to
represent the address of a label.
2012-11-09 12:22:34 +09:00
Bill Currie
48fe9f729d Add partial support for pointer arithmetic.
Only pointer +/- integral is supported. pointer - pointer will come later.
2012-11-09 12:21:45 +09:00
Bill Currie
afbab60c25 Create linker_find_def.
It turns out I didn't need it, but it could be useful in the future, so
I'll leave it in.
2012-11-09 11:57:06 +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
1d060d1ac1 Quote string values when dumping globals.
Much nicer :)
2012-11-08 21:13:24 +09:00
Bill Currie
eb86a66ce5 Do some class object type renaming.
type_object -> type_obj_object
type_Class -> type_obj_class
type_ClassPtr -> type_Class

In the process, one more FIXME is gone :)
2012-11-08 20:58:48 +09:00
Bill Currie
07e67da838 Add class versions of retain and friends.
As class objects don't have retain counts (they're usually static, even!!),
allowing the instance implementations of retain, release, and autorelease
attempt to modify the non-existant retainCount would be a recipe for severe
headaches. We also don't want the retainCount returning "random" values.
2012-11-08 20:41:56 +09:00
Bill Currie
6b46cde7c8 Move retainCount out of Object.
Going by "standard" Objective-C, retainCount really doesn't belong in
Object itself. The way GNUStep does it is to stash retainCount in memory
just below the object by allocating extra bytes for the count and returning
a pointer just beyond those extra bytes. Now Ruamoko does the same. This
fixes the inconsistencies in structure layouts for Protocol and class
structs between qfcc generated (internal) structs and user visible structs.
2012-11-08 20:24:25 +09:00
Bill Currie
377f8f9d56 Use an explicit flag for class initialization.
Much cleaner than messing with class_Class, which is about to go away.
2012-11-08 17:14:33 +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
950a3aa83d Avoid infinite recursion when encoding struct types.
Structures (especially hard-coded ones) can be really nasty as they can
refer to themselves. Avoid the recursion by setting the type_def field of
the type before doing the recursive encodings in the structure encoder.
2012-11-08 17:06:38 +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
a3a22f2a1b Add the ability to dump qfo type encoding. 2012-11-08 17:06:38 +09:00
Bill Currie
09d1cd61f3 Don't convert a qfo to progs unnecessarily.
This avoids segfaults on reloctions for external defs.
2012-11-08 17:06:29 +09:00
Bill Currie
61ef901254 Tweak some FIXMEs. 2012-11-08 17:03:02 +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
5c79953a7e Put quotes around strings for statement operands.
This makes reading output a bit easier (especially if the string is empty
or just whitespace).
2012-10-30 12:31:28 +09:00
Bill Currie
f8bdd909cc Separate out C and html quoting into separate functions.
Dot sometimes wants normal C quotes, othertimes html. Quite annoying,
really, but this is cleaner anyway.
2012-10-30 12:31:22 +09:00
Bill Currie
f680521e0f Escape unprintable chars. 2012-10-27 11:45:51 +09:00
Bill Currie
1f9735d0cb Correct the dump format for conj.q. 2012-10-27 11:45:10 +09:00
Bill Currie
ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Bill Currie
034139b806 Move some code around so it's more accessible. 2012-10-27 11:43:29 +09:00
Bill Currie
7519ec7bbd Fix the bogus missing return warning.
Pascal's return mechanism is such that void return is always used.
2012-10-26 20:11:38 +09:00
Bill Currie
3f351a5c88 Fix a printf format goof.
Forgot to compile test :/
2012-10-26 19:38:59 +09:00
Bill Currie
52b9721027 Add the COMMA token to the pascal parser.
I guess I forgot I needed to keep token numbers in sync between pascal and
qc/ruamoko.
2012-10-26 19:06:10 +09:00
Bill Currie
72045f1a5b Delay storage setting for pascal functions.
The function def must not be local. This fixes the null function call in
gcd.pas.
2012-10-26 19:03:00 +09:00
Bill Currie
27b83a8d65 Clean up all extra aborts, using internal_error instead.
Some internal_error calls have no message, but at least things will be more
consistent.
2012-10-26 19:02:02 +09:00