Still cranking away at conditional compilation

This commit is contained in:
greg 2017-01-11 00:36:16 -08:00
parent 0b9dc113d1
commit d93b5c0a2e
2 changed files with 7 additions and 6 deletions

View File

@ -1,9 +1,8 @@
a = 1
if a {
a = 40
a = 42
} else {
a = 2
a = 23
}
a = a - 1
a

View File

@ -19,7 +19,6 @@ pub fn compilation_sequence(ast: AST, sourcefile: &str) {
};
compile_ast(ast, ll_filename);
println!("YOLO");
Command::new("llc")
.arg("-filetype=obj")
.arg(ll_filename)
@ -32,7 +31,6 @@ pub fn compilation_sequence(ast: AST, sourcefile: &str) {
.output()
.expect("failed to run gcc");
println!("ai");
for filename in [obj_filename].iter() {
Command::new("rm")
.arg(filename)
@ -181,16 +179,20 @@ impl CodeGen for Expression {
LLVMWrap::AppendBasicBlockInContext(data.context, func, "entry");
let merge_block =
LLVMWrap::AppendBasicBlockInContext(data.context, func, "entry");
LLVMWrap::BuildCondBr(data.builder, is_nonzero, then_block, else_block);
LLVMWrap::PositionBuilderAtEnd(data.builder, then_block);
let then_return = then_expr.codegen(data);
LLVMWrap::BuildBr(data.builder, merge_block);
LLVMWrap::PositionBuilderAtEnd(data.builder, else_block);
let else_return = match *else_expr {
Some(ref e) => e.codegen(data),
None => zero,
};
LLVMWrap::BuildBr(data.builder, merge_block);
LLVMWrap::PositionBuilderAtEnd(data.builder, else_block);
LLVMWrap::PositionBuilderAtEnd(data.builder, merge_block);
zero
}
Block(ref exprs) => {