feat: defer 延迟执行 — defer { stmts; } 在 return 前按 LIFO 执行

Token(73): +TOK_DEFER, AST(28): +AST_DEFER_STMT, 新增 38_defer.l
parser: defer { ... } 块 + defer expr; 表达式两种形式
codegen: defer 栈压入 block, emit_deferred() 在 return 前 LIFO 发射

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 13:51:10 +08:00
parent e60021b684
commit 0088347576
10 changed files with 62 additions and 6 deletions
+3
View File
@@ -472,6 +472,9 @@ void analyze_node(AstNode* node, Scope* scope, ErrorList* errors, Arena* a) {
case AST_EXPR_STMT:
analyze_expr(node->as.expr_stmt.expr, scope, errors, a);
break;
case AST_DEFER_STMT:
analyze_node(node->as.defer_stmt.body, scope, errors, a);
break;
default:
analyze_expr(node, scope, errors, a);