aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen.c b/src/codegen.c
index dd21ad7..1db5625 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -20,8 +20,8 @@ static size_t codegenexpr(LLVMBuilderRef, struct ast, struct lexemes,
void
codegen(struct ast ast, struct lexemes toks)
{
- exit(EXIT_SUCCESS);
LLVMModuleRef mod = LLVMModuleCreateWithName("oryx");
+ LLVMBuilderRef builder = LLVMCreateBuilder();
for (size_t i = 0; i < ast.len;) {
if (ast.kinds[i] != ASTCDECL)
@@ -59,7 +59,6 @@ codegen(struct ast ast, struct lexemes toks)
LLVMValueRef fn = LLVMAddFunction(mod, fnname, fnproto);
LLVMBasicBlockRef entry = LLVMAppendBasicBlock(fn, "entry");
- LLVMBuilderRef builder = LLVMCreateBuilder();
LLVMPositionBuilderAtEnd(builder, entry);
free(fnname);
@@ -67,9 +66,10 @@ codegen(struct ast ast, struct lexemes toks)
for (i = ast.kids[body].lhs; i <= ast.kids[body].rhs;)
i = codegenstmt(builder, ast, toks, i);
- LLVMDisposeBuilder(builder);
}
+ LLVMDisposeBuilder(builder);
+
char *error = NULL;
LLVMVerifyModule(mod, LLVMAbortProcessAction, &error);
LLVMDisposeMessage(error);