mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Support branch statements break/continue/fallthrough
This commit is contained in:
+12
-2
@@ -68,7 +68,7 @@ gb_internal cgProcedure *cg_procedure_create(cgModule *m, Entity *entity, bool i
|
|||||||
p->children.allocator = a;
|
p->children.allocator = a;
|
||||||
// p->defer_stmts.allocator = a;
|
// p->defer_stmts.allocator = a;
|
||||||
// p->blocks.allocator = a;
|
// p->blocks.allocator = a;
|
||||||
// p->branch_blocks.allocator = a;
|
p->branch_blocks.allocator = a;
|
||||||
p->context_stack.allocator = a;
|
p->context_stack.allocator = a;
|
||||||
p->scope_stack.allocator = a;
|
p->scope_stack.allocator = a;
|
||||||
map_init(&p->variable_map);
|
map_init(&p->variable_map);
|
||||||
@@ -128,7 +128,7 @@ gb_internal cgProcedure *cg_procedure_create_dummy(cgModule *m, String const &li
|
|||||||
p->children.allocator = a;
|
p->children.allocator = a;
|
||||||
// p->defer_stmts.allocator = a;
|
// p->defer_stmts.allocator = a;
|
||||||
// p->blocks.allocator = a;
|
// p->blocks.allocator = a;
|
||||||
// p->branch_blocks.allocator = a;
|
p->branch_blocks.allocator = a;
|
||||||
p->scope_stack.allocator = a;
|
p->scope_stack.allocator = a;
|
||||||
p->context_stack.allocator = a;
|
p->context_stack.allocator = a;
|
||||||
map_init(&p->variable_map);
|
map_init(&p->variable_map);
|
||||||
@@ -165,6 +165,16 @@ gb_internal void cg_procedure_begin(cgProcedure *p) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DeclInfo *decl = decl_info_of_entity(p->entity);
|
||||||
|
if (decl != nullptr) {
|
||||||
|
for_array(i, decl->labels) {
|
||||||
|
BlockLabel bl = decl->labels[i];
|
||||||
|
cgBranchBlocks bb = {bl.label, nullptr, nullptr};
|
||||||
|
array_add(&p->branch_blocks, bb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GB_ASSERT(p->type->kind == Type_Proc);
|
GB_ASSERT(p->type->kind == Type_Proc);
|
||||||
TypeProc *pt = &p->type->Proc;
|
TypeProc *pt = &p->type->Proc;
|
||||||
if (pt->params == nullptr) {
|
if (pt->params == nullptr) {
|
||||||
|
|||||||
+2
-6
@@ -1330,14 +1330,10 @@ gb_internal void cg_build_stmt(cgProcedure *p, Ast *node) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (block != nullptr) {
|
GB_ASSERT(block != nullptr);
|
||||||
cg_emit_defer_stmts(p, cgDeferExit_Branch, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
cg_emit_defer_stmts(p, cgDeferExit_Branch, block);
|
||||||
tb_inst_goto(p->func, block);
|
tb_inst_goto(p->func, block);
|
||||||
tb_inst_set_control(p->func, block);
|
|
||||||
tb_inst_unreachable(p->func);
|
|
||||||
|
|
||||||
tb_inst_set_control(p->func, prev_block);
|
tb_inst_set_control(p->func, prev_block);
|
||||||
case_end;
|
case_end;
|
||||||
|
|||||||
Reference in New Issue
Block a user