void-payloads, multi-pattern arms, and range patterns (match statements)
This commit is contained in:
@@ -178,10 +178,14 @@ Stmt :: struct {
|
||||
// `Defer` statements use `update` as the deferred statement (which may itself
|
||||
// be a `Block`).
|
||||
// `Match` statements use `expr` as the subject and `body` as the list of arm
|
||||
// statements (each a `Match_Arm`). A `Match_Arm` uses `expr` as its pattern
|
||||
// (`INVALID_EXPR` marks the `else` arm), `captures` for the optional payload
|
||||
// capture (0 or 1 name, tagged-union variants only), and `body` as the arm body.
|
||||
// statements (each a `Match_Arm`). A `Match_Arm` uses `patterns` as its pattern
|
||||
// list (empty marks the `else` arm; more than one is a multi-pattern arm),
|
||||
// `captures` for the optional payload capture (0 or 1 name, tagged-union variants
|
||||
// only) with `pointer_capture` distinguishing `|@cap|` from `|cap|`, and `body`
|
||||
// as the arm body.
|
||||
captures: []symbol.Id,
|
||||
// `Match_Arm` pattern list; empty ⇒ the `else` arm.
|
||||
patterns: []Expr_Id,
|
||||
guard: Expr_Id,
|
||||
body: []Stmt_Id,
|
||||
else_body: []Stmt_Id,
|
||||
@@ -303,6 +307,7 @@ destroy_module :: proc(module: ^Module) {
|
||||
}
|
||||
for statement in module.statements {
|
||||
delete(statement.captures, module.allocator)
|
||||
delete(statement.patterns, module.allocator)
|
||||
delete(statement.body, module.allocator)
|
||||
delete(statement.else_body, module.allocator)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user