Implement "avvertite don ulrico" statement.
This commit is contained in:
parent
6c86720a1d
commit
5bd3ac2be5
|
@ -102,6 +102,7 @@ public:
|
||||||
llvm::Value* visitLoopStatement(const LoopStatement* l);
|
llvm::Value* visitLoopStatement(const LoopStatement* l);
|
||||||
llvm::Value* visitInputStatement(const InputStatement* s);
|
llvm::Value* visitInputStatement(const InputStatement* s);
|
||||||
llvm::Value* visitPrintStatement(const PrintStatement* p);
|
llvm::Value* visitPrintStatement(const PrintStatement* p);
|
||||||
|
llvm::Value* visitAbortStatement(const AbortStatement* a);
|
||||||
llvm::Value* visitExpressionStatement(const ExpressionStatement* s) {
|
llvm::Value* visitExpressionStatement(const ExpressionStatement* s) {
|
||||||
visit(s->getExpression());
|
visit(s->getExpression());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -166,6 +167,8 @@ llvm::Value* NestedScopes::lookup(const std::string& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRGenerator::declareBuiltins() {
|
void IRGenerator::declareBuiltins() {
|
||||||
|
module_->getOrInsertFunction("abort", llvm::FunctionType::get(builder_.getVoidTy(), false));
|
||||||
|
|
||||||
llvm::FunctionType* printf_type =
|
llvm::FunctionType* printf_type =
|
||||||
llvm::FunctionType::get(builder_.getInt32Ty(), {builder_.getInt8PtrTy()}, true);
|
llvm::FunctionType::get(builder_.getInt32Ty(), {builder_.getInt8PtrTy()}, true);
|
||||||
auto no_alias = llvm::AttributeList().addAttribute(context_, 1, llvm::Attribute::NoAlias);
|
auto no_alias = llvm::AttributeList().addAttribute(context_, 1, llvm::Attribute::NoAlias);
|
||||||
|
@ -535,6 +538,13 @@ llvm::Value* IRGenerator::visitPrintStatement(const PrintStatement* p) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llvm::Value* IRGenerator::visitAbortStatement(const AbortStatement*) {
|
||||||
|
auto abort_builtin = module_->getFunction("abort");
|
||||||
|
assert(abort_builtin && "Builtin abort was not declared");
|
||||||
|
builder_.CreateCall(abort_builtin);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
llvm::Value* IRGenerator::visitBinaryExpression(const BinaryExpression* e) {
|
llvm::Value* IRGenerator::visitBinaryExpression(const BinaryExpression* e) {
|
||||||
auto lhs = visit(e->getLeft());
|
auto lhs = visit(e->getLeft());
|
||||||
auto rhs = visit(e->getRight());
|
auto rhs = visit(e->getRight());
|
||||||
|
|
Reference in New Issue
Block a user