Appearance
| 1 | namespace Syntax.Trees.Statements is | |
| 2 | use Source | |
| 3 | ||
| 4 | class DO: Statement, ScopeCarrier is | |
| 5 | scope: Semantic.Scope? public | |
| 6 | ||
| 7 | condition: Expressions.Expression? | |
| 8 | binding: REFUTABLE_BINDING? | |
| 9 | body: Statements.LIST | |
| 10 | ||
| 11 | // Pushed expected type from the wrapping context when the loop | |
| 12 | // is an expression; compile-expressions unwraps the optional and | |
| 13 | // threads it onto every valued break so they infer against T. | |
| 14 | expected_state: Syntax.Process.EXPECTED_TYPE_STATE field | |
| 15 | ||
| 16 | expected_type: Semantic.Types.Type? => expected_state.expected_type | |
| 17 | expected_type_error_message: string? => expected_state.expected_type_error_message | |
| 18 | ||
| 19 | set_expected_type(expected_type: Semantic.Types.Type?, error_message: string?) is | |
| 20 | expected_state.set(expected_type, error_message) | |
| 21 | si | |
| 22 | ||
| 23 | clear_expected_type() is | |
| 24 | expected_state.clear() | |
| 25 | si | |
| 26 | ||
| 27 | clear() is | |
| 28 | super.clear() | |
| 29 | expected_state.clear() | |
| 30 | si | |
| 31 | ||
| 32 | init(location: LOCATION, condition: Expressions.Expression?, body: Statements.LIST) is | |
| 33 | init(location, condition, null, body) | |
| 34 | si | |
| 35 | ||
| 36 | init( | |
| 37 | location: LOCATION, | |
| 38 | condition: Expressions.Expression?, | |
| 39 | binding: REFUTABLE_BINDING?, | |
| 40 | body: Statements.LIST | |
| 41 | ) is | |
| 42 | super.init(location) | |
| 43 | ||
| 44 | self.condition = condition | |
| 45 | self.binding = binding | |
| 46 | self.body = body | |
| 47 | si | |
| 48 | ||
| 49 | debug_location: LOCATION is | |
| 50 | if let self.condition? then | |
| 51 | return location.start_position :: condition.location | |
| 52 | elif let self.binding? then | |
| 53 | return location.start_position :: binding.location | |
| 54 | fi | |
| 55 | ||
| 56 | return location.start_position | |
| 57 | si | |
| 58 | ||
| 59 | accept(visitor: Visitor) is | |
| 60 | visitor.visit(self) | |
| 61 | si | |
| 62 | ||
| 63 | walk(visitor: Visitor) is | |
| 64 | if !visitor.pre(self) then | |
| 65 | if let self.binding? then | |
| 66 | binding.walk(visitor) | |
| 67 | fi | |
| 68 | ||
| 69 | if let self.condition? then | |
| 70 | condition.walk(visitor) | |
| 71 | fi | |
| 72 | ||
| 73 | body.walk(visitor) | |
| 74 | fi | |
| 75 | ||
| 76 | accept(visitor) | |
| 77 | si | |
| 78 | si | |
| 79 | si |