From 00035eb0292921028da0810bb7691eca76bf92f1 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Sun, 2 Jun 2013 00:11:07 +0200 Subject: [PATCH] Guess what ... yes! error handling --- src/AST/CodeGenVisitor.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/AST/CodeGenVisitor.cpp b/src/AST/CodeGenVisitor.cpp index ae65bfd..66e4d01 100644 --- a/src/AST/CodeGenVisitor.cpp +++ b/src/AST/CodeGenVisitor.cpp @@ -24,7 +24,6 @@ CodeGenVisitor::~CodeGenVisitor() { void CodeGenVisitor::visit(AssignmentExpression* e) { value_ = 0; e->getExpr()->accept(this); - if (value_ == 0) { throw "error creating expression"; } @@ -34,14 +33,16 @@ void CodeGenVisitor::visit(AssignmentExpression* e) { void CodeGenVisitor::visit(BinOpExpression* e) { e->getLeftExp()->accept(this); - llvm::Value* lhs = value_; - e->getRightExp()->accept(this); - llvm::Value* rhs = value_; - - if ((!lhs) || (!rhs)) { - // TODO error - return; + if (!value_) { + throw "error evaluating expression (lhs)"; } + llvm::Value* lhs = value_; + + e->getRightExp()->accept(this); + if (!value_) { + throw "error evaluating expression (rhs)"; + } + llvm::Value* rhs = value_; if (lhs->getType() != rhs->getType()) { throw "lhs type of binop != rhs type of binop";