Core: Add defer
This commit is contained in:
@@ -241,6 +241,7 @@ CORE_Static Ast_Scope *
|
||||
begin_stmt_scope(Allocator *scratch, Token *pos) {
|
||||
AST_NEW(Scope, SCOPE, pos, AST_STMT);
|
||||
result->stmts = {scratch};
|
||||
result->defers = {scratch};
|
||||
result->file = pctx->currently_parsed_file;
|
||||
result->module = pctx->currently_parsed_file->module;
|
||||
result->scope_id = pctx->scope_ids++;
|
||||
@@ -253,6 +254,7 @@ begin_stmt_scope(Allocator *scratch, Token *pos) {
|
||||
CORE_Static void
|
||||
finalize_stmt_scope(Ast_Scope *scope) {
|
||||
scope->stmts = scope->stmts.tight_copy(pctx->perm);
|
||||
scope->defers = scope->defers.tight_copy(pctx->perm);
|
||||
pctx->currently_parsed_scope = scope->parent_scope;
|
||||
}
|
||||
|
||||
@@ -583,6 +585,11 @@ void next(Ast_Iter *iter) {
|
||||
For(node->vars) iter->stack.add(it);
|
||||
} break;
|
||||
|
||||
case AST_DEFER: {
|
||||
auto node = (Ast_Defer *)ast;
|
||||
iter->stack.add(node->scope);
|
||||
} break;
|
||||
|
||||
case AST_BREAK:
|
||||
case AST_PASS:
|
||||
case AST_CONTINUE:
|
||||
|
||||
Reference in New Issue
Block a user