Browse Source

Added codegen/typecheck support for unary operator expressions

constants
Tristan B. V. Kildaire 10 months ago
parent
commit
aff0da5116
  1. 27
      source/tlang/compiler/typecheck/core.d

27
source/tlang/compiler/typecheck/core.d

@ -345,6 +345,33 @@ public final class TypeChecker
BinOpInstr addInst = new BinOpInstr(vLhsInstr, vRhsInstr, binOperator);
addInstr(addInst);
}
/* Unary operator expressions */
else if(cast(UnaryOperatorExpression)statement)
{
UnaryOperatorExpression unaryOpExp = cast(UnaryOperatorExpression)statement;
SymbolType unaryOperator = unaryOpExp.getOperator();
/**
* Typechecking (TODO)
*/
Type expType = popType();
/* TODO: Ad type check for operator */
/**
* Codegen
*
* Retrieve the instruction
*
*/
Instruction expInstr = popInstr();
gprintln("UnaryOperatorCGen: "~expInstr.toString(), DebugType.ERROR);
UnaryOpInstr addInst = new UnaryOpInstr(expInstr, unaryOperator);
addInstr(addInst);
}
/* Function calls */
else if(cast(FunctionCall)statement)
{

Loading…
Cancel
Save