previous behavior when parsing a statement where a block is typically expected would fail to associate the statement with the parent block it's in, resulting in variable declarations ending up in global scope.
this fixes#197
Do not assume that the destination is a temporary location,
as our peephole optimizer will break this. For example, the
following IR code (generated via from `x ^= gety()`):
(0) binst6 <- BITXOR x, call5
(0) x <- STORE_F binst6
after peephole optimization becomes:
(7) x <- BITXOR x, call5
Therefore we cannot assume that the output of the virtual
xor instruction can be utilized as a temporary value.
BITXOR becomes `(x | y) - (x & y)`, which would wrongly be
generated as:
x = x | y;
temp0 = x & y;
x = x - temp0;
While this particular case can be fixed by using temp0 first
and then x, the cross-product case would not be so simple.
Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
Fixes#190
Some vinstrs are currently broken when using peephole
optimization as they appear as writing to a temporary ssa
output before being stored into their real destination,
causing the store to be optimized out, but the generated
code relies on having the destination as another temporary
value available.
Let's just add a 2nd temp to be used in those cases.
Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
These kinds of expressions currently cannot be handled
without pionter support in the qcvm without scanning the
ast from within ast_member::codegen for an assignments as
seen in the added test case.
This change makes code like that return a pointer type which
will cause an error that we did not get a vector or field
back. With pointer support this pointer could actually be
used instead.
So at least it shouldn't silently produce broken code
anymore.
Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
we initialized the parser with malloc -> memset to zero ->
placement new. With gcc the latter caused the memset to be
optimized out, causing uninitialized value accesses.