Binary operator expressions now work

This commit is contained in:
Tristan B. Velloza Kildaire 2022-02-20 16:37:45 +02:00
parent 6222aabc8b
commit ba63f85df9
3 changed files with 17 additions and 8 deletions

View File

@ -310,6 +310,21 @@ public final class TypeChecker
*/
Type vRhsType = popType();
Type vLhsType = popType();
/**
* TODO:
* Types must either BE THE SAME or BE COMPATIBLE
*/
if(isSameType(vLhsType, vRhsType))
{
/* Left type + Right type = left/right type (just use left - it doesn't matter) */
addType(vLhsType);
}
else
{
gprintln("Binary operator expression requires both types be same, but got '"~vRhsType.toString()~"' and '"~vLhsType.toString()~"'", DebugType.ERROR);
assert(false);
}
/**

View File

@ -1,6 +1,7 @@
module simple;
int j = 1+func(2,test());
j = 2+func(2,test());
int func(int x1, byte x2)
{

9
test.d
View File

@ -21,13 +21,6 @@ asm
asm
{
mov RSP, R15;
mov R13B, 65;
}
int h = -1;
h = *((&h)-4);
import std.stdio;
writeln(h);
}