Appearance
| 1 | namespace Syntax.Trees.Statements is | |
| 2 | ||
| 3 | use Source | |
| 4 | ||
| 5 | class RETURN(location: LOCATION, expression: Expressions.Expression? public): Statement is | |
| 6 | expects_semicolon: bool => true | |
| 7 | ||
| 8 | // like `throw` it doesn't return a value, but it can be used in an expression - | |
| 9 | // it actually short-circuits the expression and returns from the function | |
| 10 | provides_value: bool => true | |
| 11 | ||
| 12 | // Resolved at compile-expressions time: the innermost | |
| 13 | // enclosing `val ... lav` block, if any. Non-null means this | |
| 14 | // return exits that block (contributing its expression's type | |
| 15 | // to the block's value LUB) rather than the enclosing | |
| 16 | // function. Null is the ordinary function-return path. | |
| 17 | val_block_target: Expressions.VAL_BLOCK? public => return_state.val_block_target, = value is return_state.val_block_target = value si | |
| 18 | ||
| 19 | return_state: Syntax.Process.RETURN_STATE field | |
| 20 | ||
| 21 | super(location) | |
| 22 | ||
| 23 | clear() is | |
| 24 | super.clear() | |
| 25 | return_state.clear() | |
| 26 | si | |
| 27 | ||
| 28 | clear_outputs() is | |
| 29 | super.clear_outputs() | |
| 30 | return_state.clear() | |
| 31 | si | |
| 32 | ||
| 33 | accept(visitor: Visitor) is | |
| 34 | visitor.visit(self) | |
| 35 | si | |
| 36 | ||
| 37 | walk(visitor: Visitor) is | |
| 38 | if !visitor.pre(self) then | |
| 39 | if expression? then | |
| 40 | expression.walk(visitor) | |
| 41 | fi | |
| 42 | fi | |
| 43 | ||
| 44 | accept(visitor) | |
| 45 | si | |
| 46 | si | |
| 47 | si |