Guess what ... yes! error handling

This commit is contained in:
Markus Hauschild
2013-06-02 00:11:07 +02:00
parent 27c0fb6156
commit 00035eb029

View File

@@ -24,7 +24,6 @@ CodeGenVisitor::~CodeGenVisitor() {
void CodeGenVisitor::visit(AssignmentExpression* e) { void CodeGenVisitor::visit(AssignmentExpression* e) {
value_ = 0; value_ = 0;
e->getExpr()->accept(this); e->getExpr()->accept(this);
if (value_ == 0) { if (value_ == 0) {
throw "error creating expression"; throw "error creating expression";
} }
@@ -34,14 +33,16 @@ void CodeGenVisitor::visit(AssignmentExpression* e) {
void CodeGenVisitor::visit(BinOpExpression* e) { void CodeGenVisitor::visit(BinOpExpression* e) {
e->getLeftExp()->accept(this); e->getLeftExp()->accept(this);
llvm::Value* lhs = value_; if (!value_) {
e->getRightExp()->accept(this); throw "error evaluating expression (lhs)";
llvm::Value* rhs = value_;
if ((!lhs) || (!rhs)) {
// TODO error
return;
} }
llvm::Value* lhs = value_;
e->getRightExp()->accept(this);
if (!value_) {
throw "error evaluating expression (rhs)";
}
llvm::Value* rhs = value_;
if (lhs->getType() != rhs->getType()) { if (lhs->getType() != rhs->getType()) {
throw "lhs type of binop != rhs type of binop"; throw "lhs type of binop != rhs type of binop";