Skip to content
← Back

src/syntax/trees/expressions/statement.ghul

1
namespace Syntax.Trees.Expressions is
2
use Source;
3
4
class STATEMENT: Expression is
5
statement: Statements.Statement;
6
temp: IR.TEMP? public;
7
8
// Set by the wrapping context (compile-expressions). Drives
9
// whether the inner statement must yield a value: an
10
// `if`/`case` in expression position always must; a
11
// `val ... lav` block must when its result is consumed and
12
// is void-tolerant otherwise (e.g. expression-statement
13
// position, or a void-returning `=>` body). The wrapping
14
// Statements.EXPRESSION.pre pushes its own want_value down
15
// when this expression is a STATEMENT.
16
want_value: bool public;
17
18
is_tuple_literal: bool => statement.is_tuple_literal;
19
20
init(location: LOCATION, statement: Statements.Statement) is
21
super.init(location);
22
23
self.statement = statement;
24
self.want_value = true;
25
si
26
27
clear() is
28
super.clear();
29
temp = null;
30
want_value = true;
31
si
32
33
set_expected_type(expected_type: Semantic.Types.Type?, error_message: string?) is
34
statement.set_expected_type(expected_type, error_message);
35
si
36
37
clear_expected_type() is
38
statement.clear_expected_type();
39
si
40
41
accept(visitor: Visitor) is
42
visitor.visit(self);
43
si
44
45
walk(visitor: Visitor) is
46
if !visitor.pre(self) then
47
statement.walk(visitor);
48
fi
49
50
accept(visitor);
51
si
52
si
53
si