Commit Graph

9856 Commits

Author SHA1 Message Date
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 f68129dc0f Try to use type encodings for function return type
Now return statements in traces make much more sense.
2019-06-09 18:11:56 +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
Bill Currie 302934a1e4 Remove some dead code. 2018-10-15 20:52:46 +09:00
Bill Currie 2a2754e581 More ways to break qfcc :/ 2018-10-15 19:48:19 +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 0f5f2a125a Use a reliable reference for calculating progs offsets.
Now that pr->zone can be null, it cannot be used as a reference. Fixes
random crashes when using qfprogs (random due to heap randomization).
2018-10-13 23:23:45 +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
Bill Currie 668896aa82 More diagnostic improvements. 2018-10-12 16:01:11 +09:00
Bill Currie 71b3d30aa1 Make the ice a little more informative. 2018-10-12 14:51:39 +09:00
Bill Currie f58c2fef5a Switch QF's quaterions from wxyz to xyzw.
After messing with SIMD stuff for a little, I think I now understand why
the industry went with xyzw instead of the mathematical wxyz. Anyway, this
will make for less pain in the future (assuming I got everything).
2018-10-12 14:33:55 +09:00
Bill Currie b7aa5bb8fe Fix an oops messing up edict size. 2018-10-12 14:33:26 +09:00
Bill Currie f8606ebab8 Fix a object file segfault when spaces have no data.
ie, don't attempt to copy memory from a null pointer (just copy the null
pointer).
2018-10-12 14:00:34 +09:00
Bill Currie 3bd9f96b07 Make internal error messages a little more helpful.
They now include the file and line of the compiler as well.
2018-10-12 13:57:59 +09:00
Bill Currie 3656cb966c Fix some bison deprecation warnings. 2018-10-12 09:32:49 +09:00
Bill Currie 3bc664811e Fix lost error count tracking. 2018-10-11 22:03:14 +09:00