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 abstract 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
// Set from an `@equality` pragma written against this
23
// definition. Class equality is synthesized only where it was
24
// asked for, on the class the pragma is on and no other.
25
wants_equality: bool public
26
27
description_for_walk: string => "class"
28
29
init(
30
location: LOCATION,
31
name: Identifiers.Identifier,
32
arguments: TypeExpressions.LIST?,
33
ancestors: TypeExpressions.LIST?,
34
modifiers: Modifiers.LIST,
35
body: Definitions.LIST
36
)
37
is
38
super.init(location, modifiers)
39
40
self.name = name
41
self.arguments = arguments
42
self.ancestors = ancestors
43
self.body = body
44
si
45
46
set_primary_params(primary_params: Trees.Variables.LIST?) is
47
self.primary_params = primary_params
48
si
49
50
walk(visitor: Visitor) is
51
let symbol_table = IoC.CONTAINER.instance.symbol_table
52
let logger = IoC.CONTAINER.instance.logger
53
let symbol_use_locations = IoC.CONTAINER.instance.symbol_use_locations
54
55
let symbol_table_mark = symbol_table.mark_scope_stack()
56
let diagnostics_mark = logger.mark()
57
let symbol_uses_mark = symbol_use_locations.mark()
58
59
try
60
_walk(visitor)
61
catch e: Exception
62
IoC.CONTAINER.instance.logger.exception(location, e, "exception walking {description_for_walk} syntax tree")
63
finally
64
logger.release(diagnostics_mark)
65
symbol_use_locations.release(symbol_uses_mark)
66
symbol_table.release_scope_stack(symbol_table_mark)
67
yrt
68
si
69
70
_walk(visitor: Visitor) is si
71
si
72
si