From 868d3b27419a0ee592fe4dfbfeecf5e8042064d7 Mon Sep 17 00:00:00 2001 From: Peter Dahlberg Date: Sun, 2 Jun 2013 00:10:20 +0200 Subject: [PATCH] binop type check --- src/AST/CodeGenVisitor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AST/CodeGenVisitor.cpp b/src/AST/CodeGenVisitor.cpp index 74fcd46..8244096 100644 --- a/src/AST/CodeGenVisitor.cpp +++ b/src/AST/CodeGenVisitor.cpp @@ -43,6 +43,10 @@ void CodeGenVisitor::visit(BinOpExpression* e) { return; } + if (lhs->getType() != rhs->getType()) { + throw "lhs type of binop != rhs type of binop"; + } + switch (e->getOp()) { case BinOp::PLUS: value_ = builder_->CreateAdd(lhs, rhs, "addtmp"); @@ -63,7 +67,7 @@ void CodeGenVisitor::visit(BinOpExpression* e) { value_ = builder_->CreateICmpSLT(lhs, rhs, "cmptmp"); break; default: - // TODO error + throw "Unkown Operator, This is a Bug!"; break; } }