Bill Currie
913b9f52e0
Add an offset alias expression
...
This should make dealing with def elements (vector etc) easier.
2019-06-10 18:13:28 +09:00
Bill Currie
efdfc7436f
Move ev_types into types.[ch]
...
No wonder I couldn't find it the other day...
2019-06-10 18:04:25 +09:00
Bill Currie
08ab42fc15
Handle vector expressions as sub-expressions
...
Now my little game builds again :)
2019-06-10 15:50:35 +09:00
Bill Currie
49ed4310fd
Fix assigning int to enum or enum to int
...
Or float, for v6 progs.
2019-06-10 08:46:40 +09:00
Bill Currie
83fb588727
Support vector/quaternion division by float
...
Implemented via v*(1/f) or q*(1/f) to give CSE a chance to optimize the
division if necessary as otherwise the engine would have to divide every
time.
2019-06-10 08:44:36 +09:00
Bill Currie
7dc1a0640a
Delay creating actual enum symbols
...
In order to keep enumerator type and enum type the same, the values need
to have their type set after the enum type is finalized, and then the
appropriate symbols created in the parent scope. This fixes the infinite
recursion when assigning an enum value to its own type.
2019-06-10 07:44:23 +09:00
Bill Currie
f81484a068
Test compiling enums
...
It turns out the enumerator type and enum type wind up with different
instances of the same type (due to the way type chaining works). This
results in infinite recursion in assign_expr and check_types_compatible.
2019-06-10 07:17:41 +09:00
Bill Currie
ef4ad52239
Make binary_expr fold constants
...
This is where constant folding should have happened all along. While
unary_expr should fold constants too, it seems to already try to do so
and it's a bit much of a mess to clean up right now.
2019-06-10 00:36:13 +09:00
Bill Currie
bf0543f7fb
Be paranoid about temp var sizes
...
Prevents array index errors.
2019-06-10 00:19:48 +09:00
Bill Currie
28a2b96800
Implement automatic array sizing from initializer
2019-06-09 23:11:38 +09:00
Bill Currie
00f12263ca
Fix casting arrays to pointers
2019-06-09 22:55:38 +09:00
Bill Currie
3196bcc851
Allow fold_constants to handle some math identities
...
Such as x*0 -> 0, x*1 -> x, x+0 ->x, etc.
2019-06-09 22:34:23 +09:00
Bill Currie
c98d1ff08c
Document some problems with nil
...
While he's a pretty cool character in HZD, he seems to have some
identity problems when in a compiler.
2019-06-09 22:29:51 +09:00
Bill Currie
439cd15620
Do type promotion for short
...
fold_constants used to do this when it was overly aggressive. Fixes the
ICE when accessing an array in a struct via a pointer.
2019-06-09 22:27:53 +09:00
Bill Currie
227ac46ffe
Clean up array expression processing
...
And make sure constants are folded since fold_constants is no longer
recursive.
2019-06-09 22:25:55 +09:00
Bill Currie
f70801fa52
Add a test for accessing an array in a struct
...
That's accessed via a pointer. Whee. However, at this stage, the problem
is really a promotion issue for short -> integer.
2019-06-09 21:44:58 +09:00
Bill Currie
e46a44d9c6
Update TODO
2019-06-09 21:37:46 +09:00
Bill Currie
6253623e9b
Remove some weird dereference code
...
It appears to have been an attempt at optimizing dereferences, but it
instead just utterly mangled them.
2019-06-09 21:37:46 +09:00
Bill Currie
f49303e774
Emit code for address expressions
...
It helps if the necessary code is actually emitted in the first place.
2019-06-09 21:37:46 +09:00
Bill Currie
8cef85e5de
Cast scalar types when necessary on assignment
...
This fixes type promotion errors that broke some tests.
2019-06-09 20:12:50 +09:00
Bill Currie
e849c2d1ce
Mark block expr result as rvalue when used as one
...
At least for return. There may be other cases that need it, but this
fixes comma-expr.r (minus int->float promotion issues).
2019-06-09 19:29:21 +09:00
Bill Currie
d9c9686288
Make initialized globals non-constant
...
This is for modern code. Traditional code still treats initialized
globals as constant and nosave. This will make a bit of a mess of
modern code that expects traditional behavior.
2019-06-09 19:23:23 +09:00
Bill Currie
b7b6a89b91
Simplify fold_constants
...
While this does break automatic type promotion, it does stop
fold_constants recursing through complex expressions: only the top level
expression needs to be folded, and then only if both sides are actually
constant.
2019-06-09 19:20:35 +09:00
Bill Currie
2ee36e8b99
Rename qfot_type_t.ty to meta
...
When I did up a ruamoko implementation of a type encoding dumper, I
named the field meta, which feels much better than ty.
2019-06-09 18:10:07 +09:00
Bill Currie
f093516962
Move qfo type encoding structs
...
This makes them available to the gamecode VM, and thus the debugger.
2019-06-09 18:07:58 +09:00
Bill Currie
7fce68649a
Implement comma expressions
...
Doesn't quite work (attempt to suppress warning for return a = 3, 5;
failed).
2019-06-09 16:56:20 +09:00
Bill Currie
689d1ad3ec
Remove some debug prints
2019-06-09 16:45:01 +09:00
Bill Currie
33c2eb430f
Stop bison complaining about %expect
...
And make sure warnings get fixed.
2019-06-09 16:19:27 +09:00
Bill Currie
1db600548e
Fix for decl test scope issue
2019-06-09 13:55:07 +09:00
Bill Currie
ec89149b29
Build for loop decl inits correctly
...
The multiple expressions are chained together and evaluate in left to
right order.
2019-06-09 13:54:03 +09:00
Bill Currie
d29ea55826
Add a test for for loop declarations
...
I think the compiler segfaulting indicates a test failure.
2019-06-09 13:02:36 +09:00
Bill Currie
625e767684
Update qf dependency stuff for recent automake
...
Not sure just what version of automake broke things, but I do remember
having a bad time getting the dependencies to work in the first place.
At least now they should be more reliable (until automake changes
things).
2019-06-09 13:00:55 +09:00
Bill Currie
5bd3c8c985
Allow variable declarations in for loops
...
Matches C, C++ and C#
2019-06-08 21:52:17 +09:00
Bill Currie
be4c3a82a2
Detect redefinitions of structs and unions
...
While the redefinition was being detected, it was misreported as the tag
being wrong, and on the wrong line, too.
2019-06-08 19:25:25 +09:00
Bill Currie
f2102187b9
Clean up emit_protocol_list
...
Now it uses emit_structure, which will make it easier should things go
wrong.
2019-06-08 19:23:49 +09:00
Bill Currie
6acbdcb3e5
Correct a typo
2019-06-08 19:23:10 +09:00
Bill Currie
df0316bb13
Clean up some comment FIXMEs
2019-06-08 19:22:29 +09:00
Bill Currie
e217bdd55f
Assign vector expressions to a temp for return
...
Rather than direct to .return, allowing return of vector expressions
with function calls without trashing the vector.
2019-06-08 13:36:03 +09:00
Bill Currie
ebab6574b9
Allow taking the address of a temporary variable
2019-06-08 13:35:47 +09:00
Bill Currie
e27da9c7db
Avoid folding constants in assign_expr
...
This prevents fold_constants from complaining about attempts to take
the address of a vector.
2019-06-08 13:31:30 +09:00
Bill Currie
398e1cf83a
Use output file as base for dot files
...
Ensures the output goes not go into the source directory when using a
separate build tree.
2019-06-08 13:30:06 +09:00
Bill Currie
3327127e36
Fix a typo in a comment
2019-06-08 13:28:29 +09:00
Bill Currie
4ef4a7e955
Start work on simple names in symbol tables
...
I don't remember what the goal was (stopped working on it eight months
ago), but some possibilities include:
- better handling of nil (have trouble with assigning into struts)
- automatic forward declarations ala C# and jai (I was watching vids
about jai at the time)
- something for pascal
- simply that the default symbol type should not be var (in which case,
goal accomplished)
2019-06-06 07:01:44 +09:00
Bill Currie
7e31704ebe
Be more informative for pass by value size errors
2019-06-06 06:46:38 +09:00
Bill Currie
a5da8da1dc
Be more informative for symbol type internal errors
2019-06-06 06:45:48 +09:00
Bill Currie
d00a2ef82d
Convert constant vector expressions in binary expressions
...
Fixes not being able to compare with eg [1, 2, 3]
2019-06-06 06:44:19 +09:00
Bill Currie
319ecfbbfa
Create a usable dot for vector expressions
...
It leaves a lot to be desired, but it beats "FIXME".
2019-06-06 06:42:31 +09:00
Bill Currie
607ec3124e
More dead code removal.
...
I have no idea why this hung around. It appears to be old array/struct
initialization.
2018-10-15 22:12:40 +09:00
Bill Currie
ff5c1cd4c2
Clean up redundant type parameter to initialize_def.
2018-10-15 22:11:20 +09:00
Bill Currie
1746ce3af5
Make int type name reflect its keyword.
...
Makes qc error messages make more sense.
2018-10-15 20:54:05 +09:00