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