Appearance
| 1 | namespace Syntax.Trees.Expressions is | |
| 2 | ||
| 3 | use Source | |
| 4 | ||
| 5 | // `await E` expression. The operand is anything that resolves the | |
| 6 | // awaiter pattern (see `Semantic.AWAITABLE_RESOLVER`); the AWAIT is | |
| 7 | // typed as whatever the awaiter's `get_result` returns. | |
| 8 | class AWAIT: Expression is | |
| 9 | operand: Expression | |
| 10 | ||
| 11 | // The resolved awaiter pattern for the operand's type, settled | |
| 12 | // by compile-expressions and read back when the suspend is | |
| 13 | // emitted. Null when the operand is not awaitable. | |
| 14 | awaitable: Semantic.AWAITABLE? public => await_state.awaitable, = value is await_state.awaitable = value si | |
| 15 | ||
| 16 | await_state: Syntax.Process.AWAIT_STATE field | |
| 17 | ||
| 18 | // The frame field the awaited result is held in across the | |
| 19 | // suspend, or null when the result is void. Allocated where the | |
| 20 | // result type is worked out rather than while the await is | |
| 21 | // emitted, for the same reason SPILL's is. | |
| 22 | result_field: Semantic.Symbols.Field? public => await_state.result_field, = value is await_state.result_field = value si | |
| 23 | ||
| 24 | // The frame field holding the awaiter between registering the | |
| 25 | // continuation and being resumed. Allocated alongside the | |
| 26 | // result field, and for the same reason. | |
| 27 | awaiter_field: Semantic.Symbols.Field? public => await_state.awaiter_field, = value is await_state.awaiter_field = value si | |
| 28 | ||
| 29 | init(location: LOCATION, operand: Expression) is | |
| 30 | super.init(location) | |
| 31 | ||
| 32 | self.operand = operand | |
| 33 | si | |
| 34 | ||
| 35 | clear_outputs() is | |
| 36 | super.clear_outputs() | |
| 37 | await_state.clear_outputs() | |
| 38 | si | |
| 39 | ||
| 40 | clear() is | |
| 41 | super.clear() | |
| 42 | await_state.clear() | |
| 43 | si | |
| 44 | ||
| 45 | accept(visitor: Visitor) is | |
| 46 | visitor.visit(self) | |
| 47 | si | |
| 48 | ||
| 49 | walk(visitor: Visitor) is | |
| 50 | if !visitor.pre(self) then | |
| 51 | operand.walk(visitor) | |
| 52 | fi | |
| 53 | accept(visitor) | |
| 54 | si | |
| 55 | si | |
| 56 | si |