binop type check

This commit is contained in:
2013-06-02 00:10:20 +02:00
parent 792c8b578a
commit 868d3b2741

View File

@@ -43,6 +43,10 @@ void CodeGenVisitor::visit(BinOpExpression* e) {
return; return;
} }
if (lhs->getType() != rhs->getType()) {
throw "lhs type of binop != rhs type of binop";
}
switch (e->getOp()) { switch (e->getOp()) {
case BinOp::PLUS: case BinOp::PLUS:
value_ = builder_->CreateAdd(lhs, rhs, "addtmp"); value_ = builder_->CreateAdd(lhs, rhs, "addtmp");
@@ -63,7 +67,7 @@ void CodeGenVisitor::visit(BinOpExpression* e) {
value_ = builder_->CreateICmpSLT(lhs, rhs, "cmptmp"); value_ = builder_->CreateICmpSLT(lhs, rhs, "cmptmp");
break; break;
default: default:
// TODO error throw "Unkown Operator, This is a Bug!";
break; break;
} }
} }