Skip to content
← Back

src/ir/emitter/srm_emission_plan.ghul

1
@@IF.dotnet()
2
3
namespace IR.Emitter is
4
use Semantic.Symbols.Field
5
use Semantic.Symbols.Function
6
7
// One type in the plan, with the members it was numbered for.
8
class SRM_PLANNED_TYPE(
9
type: SRM_EMITTED_TYPE,
10
fields: Collections.List[Field],
11
methods: Collections.List[Function]
12
)
13
14
// The sequence the numbering pass assigned rows to.
15
//
16
// Both passes used to derive that sequence from the symbol table
17
// independently, which is only sound while the table does not
18
// change between them. It does: compiling a state machine's body
19
// declares the frame fields that body needs, and the numbering pass
20
// has already run by then. A member appearing in between is
21
// numbered by neither pass and written by one, so the type's member
22
// run comes out longer than its successor's first-row pointer
23
// assumed — and run-style tables are not validated, so the assembly
24
// loads with members reparented onto the wrong type.
25
//
26
// Recording the sequence makes the second pass replay the first
27
// rather than independently agree with it. A member declared too
28
// late is then absent rather than misplaced, and absent says so:
29
// it has no row, so the first reference to it fails.
30
class SRM_EMISSION_PLAN is
31
_types: Collections.LIST[SRM_PLANNED_TYPE]
32
33
init() is
34
_types = Collections.LIST[SRM_PLANNED_TYPE]()
35
si
36
37
types: Collections.List[SRM_PLANNED_TYPE] => _types
38
39
add(
40
type: SRM_EMITTED_TYPE,
41
fields: Collections.List[Field],
42
methods: Collections.List[Function]
43
) is
44
_types.add(SRM_PLANNED_TYPE(type, fields, methods))
45
si
46
si
47
si