Make llvm_context a class.

This commit is contained in:
2020-09-15 19:08:00 -07:00
parent 55486d511f
commit 0e3f16139d
5 changed files with 109 additions and 84 deletions

View File

@@ -16,11 +16,11 @@ void global_function::declare_llvm(llvm_context& ctx) {
}
void global_function::generate_llvm(llvm_context& ctx) {
ctx.builder.SetInsertPoint(&generated_function->getEntryBlock());
ctx.get_builder().SetInsertPoint(&generated_function->getEntryBlock());
for(auto& instruction : instructions) {
instruction->gen_llvm(ctx, generated_function);
}
ctx.builder.CreateRetVoid();
ctx.get_builder().CreateRetVoid();
}
void global_constructor::generate_llvm(llvm_context& ctx) {
@@ -29,11 +29,11 @@ void global_constructor::generate_llvm(llvm_context& ctx) {
std::vector<instruction_ptr> instructions;
instructions.push_back(instruction_ptr(new instruction_pack(tag, arity)));
instructions.push_back(instruction_ptr(new instruction_update(0)));
ctx.builder.SetInsertPoint(&new_function->getEntryBlock());
ctx.get_builder().SetInsertPoint(&new_function->getEntryBlock());
for (auto& instruction : instructions) {
instruction->gen_llvm(ctx, new_function);
}
ctx.builder.CreateRetVoid();
ctx.get_builder().CreateRetVoid();
}
global_function& global_scope::add_function(