Added basic for i loops. Missing some breaking tests and more tests. Also want to add for each at some point and it_index.
This commit is contained in:
20
Codegen.jai
20
Codegen.jai
@@ -494,6 +494,26 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
|
||||
emit_node(state, node.children[0], 0);
|
||||
append(*state.builder, ";");
|
||||
}
|
||||
case .For; {
|
||||
if node.parent.kind != .For {
|
||||
indent(*state.builder, indentation);
|
||||
}
|
||||
|
||||
append(*state.builder, "for ");
|
||||
|
||||
loop_ident := node.token.ident_value;
|
||||
begin_val := node.children[0].integer_value;
|
||||
end_val := node.children[1].integer_value;
|
||||
print_to_builder(*state.builder, "(int % = %; % < %; %++)\n", loop_ident, begin_val, loop_ident, end_val, loop_ident);
|
||||
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "{\n");
|
||||
|
||||
emit_block(state, node.children[2], indentation + 1);
|
||||
|
||||
indent(*state.builder, indentation);
|
||||
append(*state.builder, "}\n");
|
||||
}
|
||||
case .If; {
|
||||
if node.parent.kind != .If {
|
||||
indent(*state.builder, indentation);
|
||||
|
||||
Reference in New Issue
Block a user