Commit graph

2026 commits

Author SHA1 Message Date
Bill Currie
144387c3e3 Add shared.h to the dist files. 2012-10-26 16:16:46 +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
358ea4ef9a Fall back to execve/wait when execvp and waitpid are unavailable. 2012-08-19 13:18:38 +09:00
Bill Currie
b6125276e4 Fix the mis-handling of the progs.dat line in preprogs.src
Gah, must have lost a line at some stage. Also, handle line number
directives.
2012-07-14 19:01:47 +09:00
Bill Currie
7444371162 Disable bolding for special chars.
If an escape sequence is used to access a char, the the programmer probably
wanted that char, regardless of the current bolding mode.
2012-07-14 17:47:34 +09:00
Bill Currie
3b8141691e Fix a bunch of continue vs break issues. 2012-07-14 17:26:13 +09:00
Bill Currie
1364bff91b Add an extended mode to qfcc.
Extended mode allows extra keywords (switch, for, etc) that are compatible
with v6 progs.
2012-07-14 17:16:33 +09:00
Bill Currie
4055d9a435 Add support for \s escapes to qfcc.
I guess \s is an fteqcc extention for toggling bold characters. At the
request of freewill.
2012-07-14 11:47:26 +09:00
Bill Currie
dbc203b625 And a few more bits of whitespace. 2012-05-23 08:21:27 +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
0036a5e113 Ensure edict_size is never 0.
Avoids division by / in NUM_FOR_EDICT
2012-05-06 21:35:42 +09:00
Bill Currie
1dd5cccda2 Correct some more error messages. 2012-05-06 18:52:05 +09:00
Bill Currie
a0788c6cdf Implement constant folding for unary operators.
Including conversions between float and int :)
2012-05-06 18:49:07 +09:00
Bill Currie
f781e9078c Correct some typos in error messages. 2012-05-06 18:43:18 +09:00
Bill Currie
954e03c3f7 Report the correct function name for the largest locals.
I must have been tired when I adapted that code.

* taniwha dons brown paper bag
2012-05-06 13:02:11 +09:00
Bill Currie
55ecf94f2d Don't draw arrows leaving return statements.
Return statements never flow to the next block (or any other block, for
that matter), so drawing arrows leaving them not only messes up dot's
graphs, but is quite missleading.
2012-05-05 18:04:10 +09:00
Bill Currie
56410ddc58 Prevent merged if/goto losing its way.
When mering if/goto (ie, if skipping a goto), the rest of the dead code
remover is used to delete the goto. That part of the code unuses the goto's
label. The if was getting the goto's label without the lable's used count
being incremented (the usaged temporarily increases by one). I have no idea
why the problem showed up randomly, but this seems to fix it (it fixes /a/
bug, anyway).
2012-05-04 22:35:20 +09:00
Bill Currie
953e789db2 Handle movement of the final block.
Moving a final block caused segfaults and weird flow graph corruptions.
2012-05-04 19:48:32 +09:00
Bill Currie
e8c17c68e6 Fix a segfault when the switch expression errors. 2012-05-04 18:13:11 +09:00
Bill Currie
5df25133b3 Implement code movement for unconditional jumps.
That is, when the destination of the jump is reachable via only the jump.
2012-05-04 18:00:05 +09:00
Bill Currie
33bfac0508 Process all basic blocks for jump threading.
I'd copied the for loop from the dead block removal code, but jump
threading doesn't need to look at the following block...
2012-05-04 14:10:30 +09:00
Bill Currie
f169a7732d Factor out label unuse.
I expect to need this more often in the future.
2012-05-04 14:01:39 +09:00
Bill Currie
d2da3b8246 Update old test for new syntax. 2012-05-04 11:04:58 +09:00
Bill Currie
75aa28cfac Mark all subsequent blocks as reachable after if/goto merge.
If an if/goto merge is done in the first dead block pass, no blocks after
the merge have their rechable flag set because they've never been tested.
2012-05-04 10:58:18 +09:00
Bill Currie
8ddd58f951 Fix the dropping of the block after the merged if/goto.
The naive implementation of the if/goto merging was letting the old target
of the if get dropped because the block would lose its label and thus be
judged unreachable because the preceeding goto block was still in the list.
Instead, when the if/goto are "merged", mark the goto block as unreachable,
the following block as reachable, and break out of the analysis loop to
force the removal of the goto block. Since the dead block removal function
loops until no action is taken, all other dead blocks will be removed.
2012-05-04 10:07:55 +09:00
Bill Currie
e866619de6 Output basic block flow diagrams to files.
The output can be controlled via --block-dot (not yet documented). The
files a named <sourcefile>.<function>.<stage>.dot. Currently, stage will be
one of "initial" (after expression to statement conversion), "thread"
(after jump threading), "dead" (after dead block removal), "final" (final
state before actual code emission).
2012-05-04 09:45:51 +09:00
Bill Currie
3da44ace52 Merge if and goto blocks when if only skips over the goto. 2012-05-03 22:21:32 +09:00
Bill Currie
6afdfb5fac Unuse label expressions that are no longer necessary. 2012-05-03 22:20:00 +09:00
Bill Currie
402a578bf8 Add some more helper functions.
Things were getting messy with the strcmps.
2012-05-03 22:17:23 +09:00
Bill Currie
88bed3644e Rename some helper functions. 2012-05-03 22:11:52 +09:00
Bill Currie
159f1bafea Add a little more info to statement flow diagrams.
The relative block number and the label user count are printed now.
2012-05-03 22:09:49 +09:00
Bill Currie
6900907129 Remove dead labels when jump threading.
This lets the dead block removal do a better job.
2012-05-03 19:32:44 +09:00
Bill Currie
ab73a267cd Do not unconditionally remove labels from blocks.
Labels can be shared between multiple flow-control instructions, so use the
label's used counter to determine when to remove the label. This was
causing problems with the jump threading.
2012-05-03 19:22:57 +09:00
Bill Currie
c79620f04c Make statement blocks more identifiable. 2012-05-03 19:10:44 +09:00
Bill Currie
43b5edf46b Implement jump threading.
First real optimization :)
2012-05-03 17:42:58 +09:00
Bill Currie
78a9ba2557 Make expression alias chains not-a-bug.
The common cause seems to be casting a cast (very common, and I'm not sure
just realiasing the expression would be right). It does't cause any harm
(particularly, it doesn't trigger alias def chains), so I won't worry about
it.
2012-05-03 13:57:31 +09:00
Bill Currie
006882407d Fix the source of alias def chains.
The actual bug might still be elsewhere, but at least now I know the alias
chains were coming from accessing .return and .param_N, which are unions
(not directly usable by the progs engine). Emitting a reference to a union
(or struct) would create an alias def, but an alias expression was created
in the expression tree to simplify return/param access. The double layer
(sometimes 3 or 4) alias isn't really neaded, so rather than layering the
aliases, just re-alias the alaised def.
2012-05-03 13:28:16 +09:00
Bill Currie
ec98e3e206 Mark alias def chains as a bug. 2012-05-03 13:27:30 +09:00
Bill Currie
5f676c367f Add a non-error diagnostic that can't be silenced.
It is inteded for flagging buggy conditions in the compiler, particularly
after having fixed the original bug (in case something comes back from the
dead).
2012-05-03 13:24:24 +09:00
Bill Currie
3306039da2 Print the destination type for alias expression bubbles. 2012-05-03 11:55:19 +09:00
Bill Currie
cb8fe4eb38 Correct a "spelling" error. 2012-05-03 11:54:36 +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
44fcd76475 Add some missing command line option docs. 2012-05-03 00:03:13 +09:00
Bill Currie
15de69d868 Use dstring for progdefs.h writing.
And finally get qfcc into the thing :P
2012-05-02 23:39:49 +09:00
Bill Currie
04b9b3a11d Fix progdefs.h writing. 2012-05-02 22:44:45 +09:00
Bill Currie
ce278b2fbf Ensure .zero does not get a vector field for v6 progs.
v6 progs expects .zero to be only 1 word. The code actually tried to keep
vector out of .zero, but it seems I'd rearranged the structure defintion
without updating the code that kills the vector field. Problem spotted by
divVerent.
2012-05-02 22:29:17 +09:00
Bill Currie
4fe7efbed8 Add a test for end of function conditional return.
divVerent was telling Spike about such a bug in fteqcc and I though I'd
better get in an explicit test for qfcc.
2012-04-30 20:27:24 +09:00
Bill Currie
e06ee34287 Allow quat * vec in ruamoko. 2012-04-26 12:00:27 +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
eefa89e72e Remove the AM_CONDITIONALs from tools.
Now that the tools directories aren't entered when those tools aren't being
built, there's no reason to use AM_CONDITIONAL in there.
2012-02-10 02:50:42 +09:00
Bill Currie
9fbff2f4d5 Do an audit of the Makefile.am files.
o All instances of LIBADD/LDADD have a corresponding DEPENDENCIES
    specificatiion.
  o libraries now use a lib_ldflags macro to keep things consistent
  o duplication of source/lib names has been minimized (particularly in
    the libraries; more work needs to be done for the executables)
  o automake spec blocks have been organized (again, more work needs to be
    done for the executables)
2012-02-07 16:04:19 +09:00
Bill Currie
c8163fc0de Add an option to prevent the use of default paths.
Despair has things locked down such that running qfcc during a build fails
due to lack of read access to /usr/local/lib. This is actually a good
thing as accidentally hitting old includes/libs (when a file gets deleted
in the tree) hides bugs. Thus, --no-default-paths to turn off default
search paths.
2012-01-04 13:53:04 +09:00
Jeff Teunissen
6ead583195 Ruamoko: Implement infinity.
The special token __INFINITY__, like __FILE__ and friends, will expand to
a floating-point expression containing a value the C compiler considers
infinite. Obviously, this assumes that the system has relatively modern
float hardware -- but if it doesn't, having Ruamoko be able to represent
float infinity is the least of your problems. :)
2011-12-14 12:20:10 -05:00
Bill Currie
ea02f3cd44 Fix a missed byteswap when loading qfo files. 2011-11-15 17:36:55 +09:00
Bill Currie
a71acc9ae5 Move the essential init code into Sys_Init(). 2011-09-11 14:56:47 +09:00
Bill Currie
e42c5a4272 More tests and fix vector/quaternion global dumps. 2011-08-11 14:58:13 +09:00
Bill Currie
c6e0e094d8 Fix an unterminated array.
That was sneaky. It took building qfcc on an arm to trigger that bug.
2011-07-30 15:01:16 +09:00
Bill Currie
d910c14935 Clean up some doxygen warnings. 2011-07-10 19:12:07 +09:00
Bill Currie
617e70c8e3 Clean up a bunch of bison unused warnings. 2011-06-21 19:52:47 +09:00
Bill Currie
0f7390dd60 Clean up all the "set but not used" warnings.
gcc on my system is failing to treat this specific warning as an error :/
2011-06-19 10:48:02 +09:00
Bill Currie
c7612dcd99 Make statement dumps a little more informative. 2011-04-10 09:08:46 +09:00
Bill Currie
fd6e341e06 Clean up cast_expr() a little bit. 2011-04-10 00:29:27 +09:00
Bill Currie
57ed603658 Extract values from constant defs. 2011-04-09 12:42:41 +09:00
Bill Currie
cc714864a8 Support converting to/from unsigned values. 2011-04-09 11:32:33 +09:00
Bill Currie
55cc0f9206 Bring back the unsigned type (PROGS version bump)
This is only low-level support (the unsigned keyword still does not work),
but sufficient to make switch statements using jump tables work.
2011-04-09 10:07:47 +09:00
Bill Currie
b522853765 Ensure the target of def_op relocs gets updated.
These occur only when switch statements use jump tables, thus why the
problem went unnoticed :/
2011-04-08 17:09:40 +09:00
Bill Currie
237f11c472 Fix cast expressions.
Casting between ints and floats needs special treatment to get the
conversion operator, but other casts need to be aliases.
2011-04-08 13:55:26 +09:00
Bill Currie
c4a398850a Fix defs as constants for vectors and quaternions. 2011-04-04 21:31:59 +09:00
Bill Currie
38b25e0c38 Do not double-allocate space for immediates.
Caused by changed semantics in def creation.
2011-04-03 13:11:50 +09:00
Bill Currie
92ba110a87 Ensure a field def is emitted for @this. 2011-04-03 13:03:48 +09:00
Bill Currie
7f67e6eb17 Refactor the def handling code a little. 2011-04-03 13:03:22 +09:00
Bill Currie
6d0b13dbf0 Resolve types whenever possible. 2011-04-03 13:02:04 +09:00
Bill Currie
2c9c1bd968 Ensure defs for @self and @this are generated. 2011-04-03 13:00:48 +09:00
Bill Currie
2de7733b6a Fix initialized variable type handling.
Same problem as initialized constants :P
2011-03-30 21:21:38 +09:00
Bill Currie
8e18c76bde Make initialized variables defs rather than immediate constants. 2011-03-30 19:58:09 +09:00
Bill Currie
7dbd2ec172 Allow field aliasing.
Initializing a field variable to another field will set the new field to
point to the same location. No type checking is done.

eg:
.SEL thinkMethod = think;
2011-03-30 09:33:47 +09:00
Bill Currie
550fff5467 Allow assignments between any field types. 2011-03-30 08:14:17 +09:00
Bill Currie
75c3653be4 Implement some missed relocs. 2011-03-30 08:13:13 +09:00
Bill Currie
1911cc1472 Mingw build fixes. 2011-03-27 08:26:42 +09:00
Bill Currie
896791b209 Correct the spelling of "int" and clean up the mess. 2011-03-25 16:53:04 +09:00
Bill Currie
1617f0765e Support the default type without segfaulting. 2011-03-25 09:59:48 +09:00
Bill Currie
a7cfe3b215 Preserve the current class across protocol defs.
It seems that protocol defs are allowed in class implementations, so don't
let the protocol def kill the current class for the class implementation.
2011-03-24 11:55:17 +09:00
Bill Currie
71af121665 Detect missing @end tags.
Give a warning when @end is forgotten in class implementations.
2011-03-24 11:44:22 +09:00
Bill Currie
8d3508cf20 Allocate space for temp defs using size rather than type.
Statement operands throw away the high level type information, so store
type size in the operand and use this size for allocating space for temps
rather than using the low-level type.
2011-03-23 21:32:14 +09:00
Bill Currie
9b62c8c126 Rename ty_type_e to ty_meta_e and type_t.ty to type_t.meta 2011-03-22 16:06:47 +09:00
Bill Currie
d4be914019 Fix initialized vector variables.
The whole initialized variable system is wonky, but it will do for now.
2011-03-22 15:10:06 +09:00
Bill Currie
a9eb793a5e Yay, even more tests :P 2011-03-22 15:00:46 +09:00
Bill Currie
6a49861b49 Fix the bogus source file for "redefined" functions. 2011-03-22 13:45:44 +09:00
Bill Currie
7dbd5f656c Fix traditional vector component access. 2011-03-22 13:05:42 +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
1219df0872 Fix field immediates.
Field immediates need to be treated the same way as pointer immediates when
merging values.
2011-03-21 18:11:46 +09:00
Bill Currie
46093c0937 Use the correct meta type for spacial types.
Although vector and quaternion types have symbol tables, they are not
really structs, so set the meta type to "none", allowing the types to be
encoded correctly.
2011-03-21 17:26:49 +09:00
Bill Currie
cefe7e2e94 Use the correct source of defs for field defs. 2011-03-21 17:07:40 +09:00
Bill Currie
0c0f4360da Make field defs "nosave".
The engine treats fielddefs with DEF_SAVEGLOBAL set as bogus.
2011-03-21 17:06:45 +09:00
Bill Currie
f5ce9e2004 Fix a merge induced error in overloaded functions. 2011-03-20 19:04:18 +09:00
Bill Currie
1ada2a96cf Merge branch 'master' into qfcc-codegen
Conflicts:
	tools/qfcc/source/expr.c
	tools/qfcc/source/function.c
	tools/qwaq/test.r
2011-03-20 15:58:31 +09:00
Bill Currie
a919e5f619 Make class_check_ivars() use class_add_ivars() to add the ivars.
This avoids implementation ivar blocks trashing the ivar offsets in
derived classes.
2011-03-20 13:35:59 +09:00
Bill Currie
8c8a6a4d63 The function return type is the address of the type descriptor... 2011-03-17 20:31:20 +09:00
Bill Currie
01144d23cf Add a new gcc warning option and fix the two bugs it found. 2011-03-17 19:58:56 +09:00
Bill Currie
5aa0b34570 Add the cast statement to the statement block.
*sob*
2011-03-10 20:43:53 +09:00
Bill Currie
f663f587fe Fix the missing local defs for builtin functions. 2011-03-10 20:16:35 +09:00
Bill Currie
899af3119b Use the correct type when generating a move expression. 2011-03-10 19:30:21 +09:00
Bill Currie
2129eaaf20 Dereference moves need movepi rather than movei. 2011-03-10 19:29:23 +09:00
Bill Currie
8d69c5c898 More tests 2011-03-09 20:34:23 +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
2464a89d37 Preserve relocs across def churning.
Freeing then re-allocating a def to change its storage from external is
really not the right way to do it, but for now this fixes the loss of the
relocs. With this, the menus seem to work :)
2011-03-09 10:52:29 +09:00
Bill Currie
39278ba8cc Explicitly select between direct and indirect moves. 2011-03-09 10:30:57 +09:00
Bill Currie
b95cdc33d9 Set instace_size to the correct size. 2011-03-08 22:45:34 +09:00
Bill Currie
55eed1ae07 Make module dumping a little more informative. 2011-03-08 22:43:53 +09:00
Bill Currie
7c770b75c5 Do not creat field defs for local storage.
This prevents field params and local vars from messing up the real field
defs.
2011-03-08 19:56:02 +09:00
Bill Currie
f66e20db17 Set the dereferenced type in the field value. 2011-03-08 19:29:36 +09:00
Bill Currie
7198be5726 Treat entities a bit like structures in field_expr ().
Look in the entity field symbol table for the field before looking in the
normal symbol table. This allows entity fields to be accessed even when
the current scope has symbol of the same name. However, checking the
normal symbol table where there is no such field allows for field
variables when I get around to implementing them.
2011-03-08 19:28:11 +09:00
Bill Currie
505bde308e Fix the handling of @system defs.
When treating a def as external, actually say it is external.
2011-03-07 20:53:27 +09:00
Bill Currie
8dbf8a97ea Be more informative with ext/def internal errors. 2011-03-07 20:52:31 +09:00
Bill Currie
6312ccba81 Fix storage class blocks.
@extern { defs }; etc
2011-03-07 20:51:51 +09:00
Bill Currie
4db8ebb6af Support qcc style local function variables. 2011-03-07 20:04:05 +09:00
Bill Currie
853cc53d0f FIx the handling of storage class. 2011-03-07 17:49:01 +09:00
Bill Currie
7649549de6 Handle external field declarations. 2011-03-07 17:23:52 +09:00
Bill Currie
49e446b637 Make field defs global.
It turns out that field defs need to be global after all, so use separate
field def tables in the linker.
2011-03-07 14:45:50 +09:00
Bill Currie
041c5d53b8 Check for the vector being a constant before trying to get its value. 2011-03-07 14:04:36 +09:00
Bill Currie
c069bafad8 Support casting from enum to float. 2011-03-07 14:04:05 +09:00
Bill Currie
5a78758781 Support return in void functions in v6 code. 2011-03-07 13:52:28 +09:00
Bill Currie
1246fd9e30 Use the correct size when growing a data space. 2011-03-07 13:36:00 +09:00
Bill Currie
02a70ebe1c Remove the auxfunction manipulation from the compiler proper.
It was broken code in the first place (realloc and pointers), and is
redundant with the new linking process.
2011-03-07 13:33:02 +09:00
Bill Currie
16103f9018 Fix param mangling for qc style functions. 2011-03-07 10:43:38 +09:00
Bill Currie
29cac0fe3a Optionally create *_[xyz] symbols for accessing vector components.
"vector-components" in code options controls this feature. The default is
off for advanced code and on for traditional code. Disabling
vector-components prevents the comonent names polluting the namespace and
reduces the number of globals needed for vector fields if the components
of that field are never used.
2011-03-07 10:21:40 +09:00
Bill Currie
0b3d0011c5 Implement vector and quaternion component access. 2011-03-07 10:02:20 +09:00
Bill Currie
f0e47f2334 Clean up some code duplication. 2011-03-07 10:01:21 +09:00
Bill Currie
a6f222106e Fix taking the address of normal variables.
Treat them the same as structure variables.
2011-03-07 09:58:51 +09:00
Bill Currie
3c1784d46c Fold constants on both sides of = to ensure correct expression types. 2011-03-07 08:33:30 +09:00
Bill Currie
66447df6b3 Undo the offset relocation of local defs.
The debug info expects local defs to be 0 based, so once relocations in
the progs data have been completed, undo the local def offset relocation
so that the correct offsets will be written to the debug info.
2011-03-06 21:05:25 +09:00
Bill Currie
b2f0c9a127 Dump the local defs for functions when debug info is available. 2011-03-06 21:03:12 +09:00
Bill Currie
b49d90e769 Do not lose the block expression when taking its address. 2011-03-06 16:32:51 +09:00
Bill Currie
c78d15b331 Support taking the address of block expressions that have a result. 2011-03-06 16:05:38 +09:00
Bill Currie
993d05b3d3 Support taking the address of alias expressions.
Taking the address of an alias expression undoes the alias but uses the
aliased type.
2011-03-06 15:58:49 +09:00
Bill Currie
b74c644a10 Perform offset field relocations. 2011-03-06 15:41:38 +09:00
Bill Currie
8712d30d1a Make entity field defs static.
Entity field defs need to be static in order to avoid clashing with their
field variables.
2011-03-06 15:41:15 +09:00
Bill Currie
c4e9a45d91 Do not lose the entity field defs. 2011-03-06 15:40:07 +09:00
Bill Currie
b7aa2f6786 Support access to struct fields in a structure in an entity. 2011-03-06 15:39:27 +09:00
Bill Currie
fe3d228658 Maintain a symbol table for entity fields. 2011-03-06 15:38:19 +09:00
Bill Currie
c29e0250e4 Make def_field_Ofs reloc dumps more informative. 2011-03-06 15:34:53 +09:00
Bill Currie
02766f0795 Do not try to dump def values from spaces with no data. 2011-03-06 15:33:53 +09:00
Bill Currie
1eb759bb8a Update reloc_names.
I really need to get reloc_names unduplicated.
2011-03-06 15:33:10 +09:00
Bill Currie
d1187f0857 Set the edict area size when dumping qfo files. 2011-03-06 13:41:00 +09:00
Bill Currie
7bfaf107ce Set the output file name as early as possible. 2011-03-06 13:40:24 +09:00
Bill Currie
417d1b4442 Fix structure copy into and out of entities. 2011-03-06 13:19:20 +09:00
Bill Currie
dc7a78b2ff Fix case label type conversions.
The previous method made too many assumptions.
2011-03-06 11:41:01 +09:00
Bill Currie
fe4df03896 Add is_float ().
For now, it checks just floats, but I might one day add doubles.
2011-03-06 11:35:15 +09:00
Bill Currie
85bffbcad0 Add is_integral() to check for integral types (integer, short, enum). 2011-03-06 11:25:12 +09:00
Bill Currie
17a9dff769 Avoid freeing an operand twice.
Due to the way operands are used, they can be freed twice in dead-statement
removal. Detect the double-free and ignore it.
2011-03-06 11:19:09 +09:00
Bill Currie
28f4de94d2 Fix switch statements so the work in the new scheme.
Convert case labels to be the same type as the switch expression.
Use alias expressions for the various test expressions.
2011-03-06 00:29:29 +09:00
Bill Currie
8cfa80b5d4 Implement think expressions. 2011-03-05 18:01:37 +09:00
Bill Currie
7209c61912 Fix initializing local float variables with an integer constant.
Run the assignment expression through fold_constants to handle any
necessary conversions and error checking.
2011-03-05 17:23:58 +09:00
Bill Currie
a3c1f339fc Gracefully handle undefined symbols in entity field expressions. 2011-03-05 17:22:04 +09:00
Bill Currie
fbea276ede Yet more tests. 2011-03-05 17:21:19 +09:00
Bill Currie
7314b944d5 Bring back the offset alias support.
Accidently nuked it when fixing .return etc.
2011-03-05 16:31:32 +09:00
Bill Currie
e7e8220246 Dump code addresses as hex, too. 2011-03-05 16:25:56 +09:00
Bill Currie
2f74e6e4bf Nuke the old progs global.
It is no longer needed thanks to the new qfo conversion functions.
2011-03-05 16:24:53 +09:00
Bill Currie
fcb567fc98 Use the correct function number when updating the function def.
Functions are 1 based in progs bug 0 based in qfo files.
2011-03-05 16:00:39 +09:00
Bill Currie
535dfad305 Emit defs for far data.
They will break when the offsets exceed 64k, but they are needed for
debugging.
2011-03-05 15:59:14 +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
1dea86a3e4 Update debug info loading when dumping qfo files. 2011-03-05 14:53:41 +09:00
Bill Currie
cfefd79e07 Fix the source of bogus string relocs.
Nested aggregate initializers were corrupting themselves.
2011-03-05 09:21:12 +09:00
Bill Currie
7c95913c61 Avoid segfaulting with bad string relocs. 2011-03-05 09:07:16 +09:00
Bill Currie
8eb5fd653a Perform the relocations!!!
line numbers seem to be broken, but the code itself looks good.
2011-03-05 08:41:14 +09:00
Bill Currie
fe7be543f8 Correctly update the offset of code relocs. 2011-03-05 08:39:47 +09:00
Bill Currie
7fd839a5ed Handle chains of alias defs so relocs will be emitted. 2011-03-05 08:39:16 +09:00
Bill Currie
bbedbf5c9c Add the .return etc symbols to the symbol table.
This puts their defs into the object file.
2011-03-05 08:37:51 +09:00
Bill Currie
c3f1c186f8 Resolve types of .return etc. 2011-03-05 08:36:55 +09:00
Bill Currie
af7bc81e16 Chain the types for the linker. 2011-03-05 08:35:56 +09:00
Bill Currie
0bd0f783b2 Update def offsets with their final locations. 2011-03-04 23:37:46 +09:00
Bill Currie
6d02555ca9 Reorganize the offset calculations.
keep the offset calculations separate from the data transfers for better
clarity in what is happening.
2011-03-04 23:31:09 +09:00
Bill Currie
e62163e569 Nuke any invalidated relocs. 2011-03-04 21:46:19 +09:00
Bill Currie
2565e0db32 Update reloc targets when linking. 2011-03-04 21:29:47 +09:00
Bill Currie
bc78b84869 Set the target of string relocs to the string index. 2011-03-04 21:29:10 +09:00
Bill Currie
7fb22bd1e4 Make D_STRING() more useful and add D_GETSTR() 2011-03-04 21:28:12 +09:00
Bill Currie
e04f6266b1 Nuke def_list from defref_t.
It didn't work :/.
2011-03-04 20:40:01 +09:00
Bill Currie
5a552d8841 Add the null function. 2011-03-04 20:29:40 +09:00
Bill Currie
368a3826be Redo the offset and size calculations for qfo_to_progs(). 2011-03-04 20:14:02 +09:00
Bill Currie
cd12a78f93 Replace some accidentally deleted code.
Forgot to commit it the first time round, then rebase messed me up and I
didn't notice until after pushing. *sigh*
2011-03-04 19:02:47 +09:00
Bill Currie
72fae608e5 Write the function start address to the progs file.
Oops:P
2011-03-04 18:46:28 +09:00
Bill Currie
2211a807d4 Do not relocate builtin functions. 2011-03-04 18:46:25 +09:00
Bill Currie
d6d8b5b49d Generate the debug symbol file. 2011-03-04 18:46:05 +09:00
Bill Currie
9a96febdf5 Fix the hordes of bogus defs.
They were caused by unused external defs, so not processing unused externs
in the first place is the simplest solution.
2011-03-04 14:51:09 +09:00
Bill Currie
7b7f4c70e0 Correct non-external def processing. 2011-03-04 14:33:03 +09:00
Bill Currie
c5dac6d1d1 Transfer the type encoding.
oops
2011-03-04 14:29:22 +09:00
Bill Currie
d0b4546383 qfprogs isn't yet fully functional... 2011-03-04 13:54:29 +09:00
Bill Currie
2992d66f87 Simplify the tag used for anonymous structs etc.
Hopefully two files with the same file name won't have anonymous stucts on
the same line.
2011-03-04 13:52:32 +09:00
Bill Currie
e525727a24 Add a null type descriptor to the linker output. 2011-03-04 11:38:33 +09:00
Bill Currie
3a828ca5c2 Ensure work spaces are always connected to their data. 2011-03-04 11:18:56 +09:00
Bill Currie
45c3dd67a8 Some test updates. 2011-03-04 08:27:26 +09:00
Bill Currie
4192ef835c Delay initialization of obj_module_t as long as possible.
This keeps the type descriptor out of progs that never use any
Objective-QC features.
2011-03-04 08:25:50 +09:00
Bill Currie
c99f3aba0e Add the new header files for make dist. 2011-03-04 00:11:13 +09:00
Bill Currie
fd24524e13 More tests.
I really need to sort out some test automation.
2011-03-03 22:32:22 +09:00
Bill Currie
ee9045c377 Emit code for jump tables.
With this, the entirety of the ruamoko tree builds (though the progs will
be broken in various ways: mostly unrelocated references).
2011-03-03 19:09:00 +09:00
Bill Currie
a281033920 Alais the jump table's array to an integer.
As per the previous commit, I'm not sure this is the right thing to do, but
it works for now.
2011-03-03 19:07:37 +09:00
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
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
Bill Currie
5fa349927f Preserve the ivars inheritance chain across build_struct().
build_struct() unlinks the structure symbol table from its parent, but
that breaks the ivar inheritance chain.
2011-02-14 23:10:46 +09:00
Bill Currie
5707888fcf Fix some error-recovery segfaults. 2011-02-14 23:10:46 +09:00
Bill Currie
f1fccb19dd Allow same-type re-declarations of uninitialized variables.
This is especially important for declaring variables that were previously
declared external.
2011-02-14 23:10:46 +09:00
Bill Currie
b3d5789377 More tests. 2011-02-14 23:10:46 +09:00
Bill Currie
23b01be214 Handle invalid initializers gracefully. 2011-02-14 23:10:46 +09:00
Bill Currie
4c63a0bad6 Generate a warning when creating a var with no type.
This makes the internal error in new_def() non-functional, but the warning
will catch the bug and there's no harm in leaving the test in new_def().
2011-02-14 23:10:46 +09:00
Bill Currie
ee866ae3a6 Enable the small struct optimization.
For now, anyway. It would probably be much better to handle this sort of
thing in the optimizer stage.
2011-02-14 23:10:45 +09:00
Bill Currie
bcaf3687c5 Fix loading structs into params via an offset pointer.
For certain values of "fix" :/. The code is ugly, but it does the right
thing: calculate the effect address and use the resulting pointer in a
move instruction.
2011-02-14 23:10:45 +09:00
Bill Currie
352be1f8bd Handle null string pointers. 2011-02-14 23:10:45 +09:00
Bill Currie
e10d561459 Treat small structs as integers (disabled).
This is more to stash away a potential optimization. I need to fix the
real problem first.
2011-02-14 23:10:45 +09:00
Bill Currie
6b29568fa9 Set the source file and line when copying an expression.
This fixes the crazy line numbers in the debug info.
2011-02-14 23:10:45 +09:00
Bill Currie
fc18ebd923 Add the source line number to most node labels. 2011-02-14 23:10:45 +09:00
Bill Currie
3e5989463f Update the def_tail when removing the last def from the space. 2011-02-14 23:10:45 +09:00
Bill Currie
11485556e5 Quote expression names to avoid problems with null pointers. 2011-02-14 23:10:45 +09:00
Bill Currie
c139099294 Put another bandaid on the type creation system.
It seems that building types is very fragile: all too easy to fix things
in one place and break something somewhere else. I guess the type system
will need a comlete rewrite at some stage.
2011-02-14 23:10:45 +09:00
Bill Currie
e3325b199e More tests. 2011-02-14 23:10:45 +09:00
Bill Currie
e0d61705b4 And fix build_struct for built-in struct types.
The previous fix broke builtin structs (eg, @param). Calling find_type()
for built-in structs has proven to be a bad idea :)
2011-02-13 21:07:22 +09:00
Bill Currie
a19b7ec8f9 Make struct decls actually work.
find_type() does type comparisons based on tag name for struct/union/enum
but when it returns the previous tag (eg, from "struct foo;") the returned
type has a null symtab pointer, so setting the symtab pointer in the type
before calling find_type() only throws away the symtab. Thus, since
find_type() doesn't check the symtab pointer when comparing the types, set
the symtab pointer after calling find_type().
2011-02-13 20:56:12 +09:00
Bill Currie
acced90101 Create the symbol for the struct as early as possible. 2011-02-13 20:55:33 +09:00
Bill Currie
b545f72f93 Report errors for incomplete types and missing fields. 2011-02-13 20:23:08 +09:00
Bill Currie
c336aaeb80 Handle incomplete types gracefully. 2011-02-13 19:26:20 +09:00
Bill Currie
ef32d1fb6d Save away some of my tests. 2011-02-13 19:02:39 +09:00
Bill Currie
976ff8a6bb Allow cast expressions to be lvalues.
These really need to be alias expressions rather than cast expressions
so the two can be separated as cast expressions should not be lvalues.
2011-02-13 17:54:15 +09:00
Bill Currie
fa742ceed6 Handle @self and @this correctly. 2011-02-13 17:52:19 +09:00
Bill Currie
547f361bd3 Allow (void) qc-style functions. 2011-02-13 17:37:11 +09:00
Bill Currie
d75c35ba30 Allow qc style function params.
Due to ambiguities in the grammar, qc-style function params and c-style
function params had to be completely separated. This means that qc-style
functions can not use pointers and must use qc-style function declarations
for parameters, and c-style functions must use c-style param declarations.
While this rule is tedious for converting the Ruamoko library, it does
actually make for a more consistent language.
2011-02-13 17:07:14 +09:00
Bill Currie
8a314e9e87 Class pointers need to be directly addressable. 2011-02-13 16:05:50 +09:00
Bill Currie
0b5565396b Add a class type to symbols and rework the CLASS_NAME handling.
This fixes the problem with [Array alloc] producing a warning about Class
not repsonding to -alloc.
2011-02-13 16:05:09 +09:00
Bill Currie
3f690eacb1 Fix another double insertion of a symbol. 2011-02-13 15:28:49 +09:00
Bill Currie
127a1c8772 Fix the creation of enum values. 2011-02-13 15:19:55 +09:00
Bill Currie
f24de89a2a Handle type-modified constants.
The fix for pointers broke constants (particularly, enums). Oops.
2011-02-13 14:13:32 +09:00
Bill Currie
fa6b8d773c Correctly emit class and category symtab references. 2011-02-13 13:21:00 +09:00
Bill Currie
c4f364fd37 Emit pointers properly.
Rename ReuseConstant to emit_value and use emit_value to emit any non-short
constant. This fixes the null pointer in the call to __obj_exec_class.
2011-02-13 10:09:42 +09:00
Bill Currie
1bcf434b20 Move _OBJ_MODULE to the far data space. 2011-02-12 23:00:04 +09:00
Bill Currie
d42a379924 Dump the contents of a pointer def. 2011-02-12 22:59:29 +09:00
Bill Currie
eede83dea1 Avoid crashing when a null class pointer is found. 2011-02-12 22:58:50 +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
181596f5bf Make relocation records store the space of the relocation.
The space is meaningless for op_* relocations as they are always in the
code space, but def_* relocations need to know which space holds the
location to be adjusted.
2011-02-12 22:34:38 +09:00
Bill Currie
cfdc2e5d6b Complete the documentation for relocations.
This covers only in-memory storage of relocation records, not object file
relocations.
2011-02-12 15:55:58 +09:00
Bill Currie
8c01497936 Give __obj_exec_class a sterner beating.
When linking a def into a defspace, ensure it can be removed. This fixes
the missing __obj_exec_class def in qwaq.
2011-02-11 22:29:57 +09:00
Bill Currie
75d90d2f00 Propogate the specifiers through external_decl_list. 2011-02-11 22:29:57 +09:00
Bill Currie
0efc759f2d Catch attempts to create a def with a null type. 2011-02-11 22:29:57 +09:00
Bill Currie
5f3c1872b9 Put class and category reference/name symbols in the symbol table.
This fixes the undefined defs in qwaq.
2011-02-11 22:29:57 +09:00
Bill Currie
179c1f7058 Support move statements (structure copy). 2011-02-11 22:29:57 +09:00
Bill Currie
e19f7e3521 Sort out the parameters for QC style functions :) 2011-02-11 22:29:57 +09:00
Bill Currie
370f0b97ed Produce cleaner output for a = b op c. 2011-02-11 22:29:57 +09:00
Bill Currie
d93d8d7d46 Remove the dirty hack used for accessing params and the return value.
Instead of using the equivalent of *(float*)&.return, now use the
equivalent of (float).return. No conversion is done in the "cast".

NOTE: this sort of cast should be separated from normal casts.
2011-02-11 22:29:38 +09:00
Bill Currie
f5412c2b20 Remove a fixme. 2011-02-11 22:29:38 +09:00