Skip to content
← Back

src/syntax/trees/statements/return.ghul

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;
18
19
super(location);
20
21
clear() is
22
super.clear();
23
val_block_target = null;
24
si
25
26
accept(visitor: Visitor) is
27
visitor.visit(self);
28
si
29
30
walk(visitor: Visitor) is
31
if !visitor.pre(self) then
32
if expression? then
33
expression.walk(visitor);
34
fi
35
fi
36
37
accept(visitor);
38
si
39
si
40
si