Bill Currie
ee1f5f9478
Add support for binary alias expressions
...
Doesn't quite work yet.
2019-06-10 23:48:58 +09:00
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
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
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
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
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
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
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
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
Bill Currie
302934a1e4
Remove some dead code.
2018-10-15 20:52:46 +09:00
Bill Currie
6c53be928b
Support returning vector expressions.
...
Currently fails due to a scheduling problem when the vector expression
contains functions.
2018-10-13 23:32:53 +09:00
Bill Currie
aaab18c9a7
Nuke a dead field.
...
It looks like ex_temp_t.expr was never really used, and I have no idea
what I had intended (not surprising after ~17 years).
2018-10-13 12:07:50 +09:00
Bill Currie
2f2edae43b
Make error, warning and notice give compiler file/line too.
...
But only when verbosity > 1 (-vv).
2018-10-13 09:31:00 +09:00
Bill Currie
4828934e50
Fix a equality check typo.
...
Fixes bad code generation when assigning to vector.x in a function with no
parameters and the vector is the first local var.
2018-10-12 23:39:05 +09:00
Bill Currie
78e0a8dc52
Support assigning non-constant vector expressions.
2018-10-12 22:05:17 +09:00
Bill Currie
e03dfa29b4
Clean up the module .ctor construction a little.
2018-10-12 21:09:36 +09:00
Bill Currie
f56d25cda6
Don't double print messages.
2018-10-12 20:46:45 +09:00