Bill Currie
3af031c33d
Move the rest of the obj specific stuff into class.c.
...
This gives better hiding of implementation details.
2012-12-20 10:10:41 +09:00
Bill Currie
45c753f639
Catch attempts to create a static instance of a class.
...
It is actually an error to create a static instance of a class.
2012-12-20 10:10:41 +09:00
Bill Currie
463e41082a
Support struct style initializers for vectors and quaternions.
...
The current implementation probably needs more work, but for the case where
I needed it, it does the job.
grid.r💯 vector size = {range, range, 0};
0115 store.f range, size
0116 store.f range, [$2ac]
0117 store.f .zero, [$2ad]
2012-12-16 14:24:19 +09:00
Bill Currie
2dc60d4f9a
Allow tests for full overlap of defs.
...
Not actually used yet, but I imagine I'll want it.
2012-12-13 14:42:51 +09:00
Bill Currie
204a0b3f72
Make def_visit_all return the actual result of visit.
...
This way, def_visit_all is a little more useful (though I think I might
redo the one case that's using this feature).
2012-12-13 09:47:00 +09:00
Bill Currie
75be251d65
Create and use def_visit_all.
...
Even though it turned out there were only two copies of the def alias
handling code, I got tired of writing it. The code is easier to read, too
:)
2012-12-12 12:01:31 +09:00
Bill Currie
045947706e
Compare the base def spaces in def_overlap.
...
The space field in alias defs is always null and thus aliases would never
overlap the aliased def. Oops.
2012-12-11 19:51:34 +09:00
Bill Currie
b5a72320bb
Make alias defs and temps more obvious in dumps.
2012-12-11 12:26:48 +09:00
Bill Currie
8f274f5b1d
Add convenience functions for getting a def's offset and size.
2012-12-10 14:40:43 +09:00
Bill Currie
4f70b48370
Add a function to check if two defs overlap.
...
Very useful for alias handling :)
2012-12-10 13:23:45 +09:00
Bill Currie
eb8fd55677
Move set.c into libQFutil.
...
Also move the ALLOC/FREE macros from qfcc.h to QF/alloc.h (needed to for
set.c).
Both modules are more generally useful than just for qfcc (eg, set
builtins for ruamoko).
2012-12-06 20:52:53 +09:00
Bill Currie
7071a46936
Make convert_value create a new value.
...
It operating in-place proved to be troublesome.
2012-12-05 22:16:08 +09:00
Bill Currie
2904c619c1
Don't bother creating an alias for a def of the same type.
2012-12-05 19:43:27 +09:00
Bill Currie
6074a6648f
Do some sanity checking on storage class and defspace type.
...
Params and locals in virtual spaces, static vars in backed. Otherwise,
whatever (for now). Now func-static.r aborts :)
2012-12-04 14:18:17 +09:00
Bill Currie
98a0afa38f
Add and use FREE() to complement ALLOC().
...
Now it will be easy to test memory access with valgrind (just compile with
DEBUG_QFCC_MEMORY defined).
2012-12-04 13:23:31 +09:00
Bill Currie
0872961269
Do a little bit of cleanup.
2012-12-04 12:48:52 +09:00
Bill Currie
7412a45c65
Attach alias defs to their base def.
...
With this, alias defs become singletons based on the def they alias and the
type and offset of the alias. Thus, the removal of the free_def call in
emit.c.
2012-12-03 12:40:00 +09:00
Bill Currie
919ea8192a
Make alias_def take an offset.
...
alias_def now always creates an offset def (though the usual case has an
offset of 0). The if the alias escapes the bounds of the base def, an
internal error will be generated.
2012-12-03 11:50:26 +09:00
Bill Currie
9d0332ae30
Make alaising a def to a larger type an internal error.
...
It really doesn't seem wise to allow the compiler to do so as it would
overwrite unrelated defs. The only time such a thing is valid is the return
statement (silly vm design), and that's read-only.
2012-12-03 11:38:55 +09:00
Bill Currie
9ca5a9e86c
Make aliasing an alias def an internal error.
...
I haven't seen the bug message show up, so it seems safe, and is probably a
good idea with what I have in mind.
2012-12-03 11:36:14 +09:00
Bill Currie
5725c5124c
Rename the storage_class_t enum values.
...
With the intoduction of the statement type enum came a prefix clash. As
"st" makes sense for "statement type", I decided that "storage class"
should be "sc". Although there haven't been any problems as of yet, I
decided it would be a good idea to clean up the clash now. It also helps
avoid confusion (I was a bit surprised after working with st_assign etc to
be reminded of st_extern etc).
2012-12-02 10:11:30 +09:00
Bill Currie
dbbca47a3b
Mark initialized struct/array defs as initalized.
...
Also, use the initialized flag for setting up the initalized var set in
flow_uninitialized().
2012-11-24 15:26:27 +09:00
Bill Currie
d8a5d6745f
Add a param flag to defs.
...
It is necessary to know if a def is a function parameter so it can be
treated as initialized by the flow analyzer. The support for the flag in
object files is, at this stage, purely for debugging purposes.
2012-11-20 17:50:59 +09:00
Bill Currie
158e261a8f
Give reusable temps their own linked list.
...
The next field is used for linking all defs in a space. Oops.
2012-11-19 10:33:03 +09:00
Bill Currie
1af4d5eeed
Ensure reused temps have the correct type.
...
The type of a temp may change through its life as it's really the location
and name that are reused.
2012-11-19 10:31:22 +09:00
Bill Currie
0c3aeb30aa
Reuse tempary variables.
...
Now that I've got nice code, it was worth doing. Unfortunatly, bsearch
style switch statements have problems.
switch.r:14: BUG: temp users went negative: <tmp 0x21b6840:-1>
switch.r:14: BUG: temp users went negative: <tmp 0x21b6840:-2>
switch.r:14: BUG: temp users went negative: <tmp 0x21b6840:-3>
switch.r:14: BUG: temp users went negative: <tmp 0x21b67d0:-1>
2012-11-18 19:10:18 +09:00
Bill Currie
ffa08a99c2
Store the initializer expression in the def.
...
Initially, this will be used for collecting the targets of a jumpb
instruction.
2012-11-15 13:44:07 +09:00
Bill Currie
28ce35f1c1
Make values independent objects.
...
values are now uniquely allocated (for the current object file). With
this, constants in dags will work.
2012-11-15 13:44:06 +09:00
Bill Currie
93b007b1f8
Take care of relocs when defining external defs.
...
For most of the cases, some relocs may have been lost, but they were
certainly lost for type encodings. Now that all seems to be fixed.
2012-11-12 16:14:09 +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
ec98e3e206
Mark alias def chains as a bug.
2012-05-03 13:27:30 +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
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
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
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
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
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
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
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
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
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
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
fe3d228658
Maintain a symbol table for entity fields.
2011-03-06 15:38:19 +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
cfefd79e07
Fix the source of bogus string relocs.
...
Nested aggregate initializers were corrupting themselves.
2011-03-05 09:21:12 +09:00