condtional multi-unwrap and guard clauses
This commit is contained in:
@@ -136,14 +136,18 @@ Stmt :: struct {
|
||||
pointer_capture: bool,
|
||||
target: Expr_Id,
|
||||
expr: Expr_Id,
|
||||
// `If` statements use `expr` as the condition, `body` as the then-block, and
|
||||
// `else_body` as the else-block. An `else if` chain is represented as an
|
||||
// `else_body` holding a single nested `If` statement.
|
||||
// `If` statements use `expr` as the condition, `captures` as optional
|
||||
// unwrap binding names, `guard` as the optional post-unwrap boolean
|
||||
// condition, `body` as the then-block, and `else_body` as the else-block.
|
||||
// An `else if` chain is represented as an `else_body` holding a single
|
||||
// nested `If` statement.
|
||||
// `While` statements use `expr` as the condition, `body` as the loop body,
|
||||
// and `update` as the optional post-iteration statement.
|
||||
// `For` statements use `expr` as the iterable, `name` as the item capture,
|
||||
// `index_name` as the optional index capture, and `pointer_capture` to
|
||||
// distinguish `|@item|` from copy capture.
|
||||
captures: []symbol.Id,
|
||||
guard: Expr_Id,
|
||||
body: []Stmt_Id,
|
||||
else_body: []Stmt_Id,
|
||||
update: Stmt_Id,
|
||||
@@ -263,6 +267,7 @@ destroy_module :: proc(module: ^Module) {
|
||||
delete(expr.args, module.allocator)
|
||||
}
|
||||
for statement in module.statements {
|
||||
delete(statement.captures, module.allocator)
|
||||
delete(statement.body, module.allocator)
|
||||
delete(statement.else_body, module.allocator)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user