Appearance
| 1 | namespace Syntax.Process is | |
| 2 | use Source | |
| 3 | ||
| 4 | // Gives a type implementing `Collections.Iterator[T]` the `reset` | |
| 5 | // it declared none of. The decision needs resolved ancestors - the | |
| 6 | // trait can be reached through another one - so it is taken here | |
| 7 | // rather than at rewrite time, and before overrides are resolved, | |
| 8 | // which is what would otherwise report the missing member. | |
| 9 | class SYNTHESIZE_ITERATOR_RESET: Visitor is | |
| 10 | _symbol_table: Semantic.SYMBOL_TABLE | |
| 11 | _synthesis: Semantic.Symbols.ITERATOR_RESET_SYNTHESIS | |
| 12 | ||
| 13 | init( | |
| 14 | symbol_table: Semantic.SYMBOL_TABLE, | |
| 15 | innate_symbol_lookup: Semantic.Lookups.InnateSymbolLookup | |
| 16 | ) is | |
| 17 | super.init() | |
| 18 | ||
| 19 | _symbol_table = symbol_table | |
| 20 | _synthesis = | |
| 21 | Semantic.Symbols.ITERATOR_RESET_SYNTHESIS(innate_symbol_lookup) | |
| 22 | si | |
| 23 | ||
| 24 | apply(root: Trees.Node) is | |
| 25 | root.walk(self) | |
| 26 | si | |
| 27 | ||
| 28 | pre(`class: Trees.Definitions.CLASS) -> bool is | |
| 29 | _settle(`class) | |
| 30 | ||
| 31 | return false | |
| 32 | si | |
| 33 | ||
| 34 | pre(`struct: Trees.Definitions.STRUCT) -> bool is | |
| 35 | _settle(`struct) | |
| 36 | ||
| 37 | return false | |
| 38 | si | |
| 39 | ||
| 40 | _settle(definition: Trees.Node) is | |
| 41 | if let classy: Semantic.Symbols.Classy = | |
| 42 | _symbol_table.scope_for(definition) | |
| 43 | then | |
| 44 | let _ = _synthesis.try_synthesize(classy) | |
| 45 | fi | |
| 46 | si | |
| 47 | si | |
| 48 | si |