More error handling again
This commit is contained in:
@@ -125,13 +125,13 @@ void CodeGenVisitor::visit(ForStatement* e)
|
|||||||
void CodeGenVisitor::visit(FunctionCallExpression* e) {
|
void CodeGenVisitor::visit(FunctionCallExpression* e) {
|
||||||
llvm::Function* cf = module_->getFunction(e->getId());
|
llvm::Function* cf = module_->getFunction(e->getId());
|
||||||
if (!cf) {
|
if (!cf) {
|
||||||
// TODO error
|
throw "function to call not found";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto values = e->getValues()->getValues();
|
auto values = e->getValues()->getValues();
|
||||||
if (cf->arg_size() != values.size()) {
|
if (cf->arg_size() != values.size()) {
|
||||||
// TODO error
|
throw "argument size mismatch";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ void CodeGenVisitor::visit(FunctionCallExpression* e) {
|
|||||||
Expression *expr = (*iter);
|
Expression *expr = (*iter);
|
||||||
expr->accept(this);
|
expr->accept(this);
|
||||||
if (!value_) {
|
if (!value_) {
|
||||||
// TODO error
|
throw "error evaluating expression";
|
||||||
}
|
}
|
||||||
args.push_back(value_);
|
args.push_back(value_);
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ void CodeGenVisitor::visit(IfStatement* e) {
|
|||||||
|
|
||||||
f->getBasicBlockList().push_back(elseBB);
|
f->getBasicBlockList().push_back(elseBB);
|
||||||
builder_->SetInsertPoint(elseBB);
|
builder_->SetInsertPoint(elseBB);
|
||||||
// we cna add an else part here later ...
|
// we can add an else part here later ...
|
||||||
|
|
||||||
builder_->CreateBr(mergeBB);
|
builder_->CreateBr(mergeBB);
|
||||||
|
|
||||||
@@ -319,7 +319,6 @@ void CodeGenVisitor::visit(RandomIfStatement* e) {
|
|||||||
|
|
||||||
void CodeGenVisitor::visit(ReturnStatement* e) {
|
void CodeGenVisitor::visit(ReturnStatement* e) {
|
||||||
e->getExpr()->accept(this);
|
e->getExpr()->accept(this);
|
||||||
|
|
||||||
if (!value_) {
|
if (!value_) {
|
||||||
throw "error evaluating expression";
|
throw "error evaluating expression";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user