Skip to content
← Back

src/syntax/process/compile-expressions/spliced_literal_scanner.ghul

1
namespace Syntax.Process is
2
3
// Collects the function literals held anywhere in an expression
4
// that a pack adaptation is about to take out of the tree.
5
// Generate-il emits a closure body by walking the literal that
6
// carries it, so a literal left behind the splice names a method
7
// with no body; the adapter that replaces the expression carries
8
// these along instead.
9
//
10
// Stops at each literal rather than descending into it: walking one
11
// reaches whatever it nests.
12
class SPLICED_LITERAL_SCANNER: Visitor is
13
_found: Collections.LIST[Trees.Expressions.FUNCTION]
14
15
init() is
16
super.init()
17
18
_found = Collections.LIST[Trees.Expressions.FUNCTION]()
19
si
20
21
scan(expression: Trees.Expressions.Expression) -> Collections.List[Trees.Expressions.FUNCTION] is
22
_found = Collections.LIST[Trees.Expressions.FUNCTION]()
23
24
expression.walk(self)
25
26
return _found
27
si
28
29
pre(function: Trees.Expressions.FUNCTION) -> bool is
30
_found.add(function)
31
32
return true
33
si
34
35
pre(function: Trees.Definitions.FUNCTION) -> bool => true
36
si
37
si