Skip to content
← Back

src/syntax/trees/definitions/classy.ghul

1
namespace Syntax.Trees.Definitions is
2
3
use Source;
4
5
use System.Exception;
6
7
class Classy: MODIFIABLE, ScopeCarrier is
8
scope: Semantic.Scope? public;
9
10
name: Identifiers.Identifier;
11
arguments: TypeExpressions.LIST?;
12
ancestors: TypeExpressions.LIST?;
13
body: LIST;
14
15
// Primary-constructor parameters parsed from the optional (...)
16
// block after the class/struct name. Null when no primary form
17
// was written. Consumed by the lower-primary-constructors
18
// visitor in the rewrite-syntax-trees pass and cleared back to
19
// null before downstream phases see the node.
20
primary_params: Trees.Variables.LIST?;
21
22
description_for_walk: string => "class";
23
24
init(
25
location: LOCATION,
26
name: Identifiers.Identifier,
27
arguments: TypeExpressions.LIST?,
28
ancestors: TypeExpressions.LIST?,
29
modifiers: Modifiers.LIST,
30
body: Definitions.LIST
31
)
32
is
33
super.init(location, modifiers);
34
35
self.name = name;
36
self.arguments = arguments;
37
self.ancestors = ancestors;
38
self.body = body;
39
si
40
41
set_primary_params(primary_params: Trees.Variables.LIST?) is
42
self.primary_params = primary_params;
43
si
44
45
walk(visitor: Visitor) is
46
let symbol_table = IoC.CONTAINER.instance.symbol_table;
47
let logger = IoC.CONTAINER.instance.logger;
48
let symbol_use_locations = IoC.CONTAINER.instance.symbol_use_locations;
49
50
let symbol_table_mark = symbol_table.mark_scope_stack();
51
let diagnostics_mark = logger.mark();
52
let symbol_uses_mark = symbol_use_locations.mark();
53
54
try
55
_walk(visitor);
56
catch e: Exception
57
IoC.CONTAINER.instance.logger.exception(location, e, "exception walking {description_for_walk} syntax tree");
58
finally
59
logger.release(diagnostics_mark);
60
symbol_use_locations.release(symbol_uses_mark);
61
symbol_table.release_scope_stack(symbol_table_mark);
62
yrt
63
si
64
65
_walk(visitor: Visitor);
66
si
67
si