Appearance
| 1 | namespace Syntax.Trees.Definitions is | |
| 2 | ||
| 3 | use Source | |
| 4 | ||
| 5 | class LIST: Definition, Collections.Iterable[Definition] is | |
| 6 | definitions: Collections.MutableList[Definition] | |
| 7 | ||
| 8 | // Bare statements parsed at the file root (a file with no namespace). | |
| 9 | // Set only on the root list; synthesise-top-level-entry consumes it | |
| 10 | // into a global entry-point function before declare-symbols. Not | |
| 11 | // walked here: it carries no symbols until that synthesis. | |
| 12 | top_level_statements: Statements.LIST? public | |
| 13 | ||
| 14 | // `@@pragma` lines parsed before everything else in the file. Set | |
| 15 | // only on the root list. Not walked: the passes that apply them | |
| 16 | // (suppression regions, attribute resolution) visit their arguments | |
| 17 | // explicitly, and a whole-file pragma has no scope of its own to | |
| 18 | // enter. | |
| 19 | file_pragmas: Collections.List[Pragmas.PRAGMA]? public | |
| 20 | ||
| 21 | iterator: Collections.Iterator[Definition] => definitions.iterator | |
| 22 | ||
| 23 | uses: Collections.List[USE] is | |
| 24 | let result = Collections.LIST[USE](definitions.count) | |
| 25 | ||
| 26 | for d in definitions do | |
| 27 | let d_without_pragmas = d.without_pragmas | |
| 28 | ||
| 29 | if isa USE(d_without_pragmas) then | |
| 30 | result.add(d_without_pragmas) | |
| 31 | fi | |
| 32 | od | |
| 33 | ||
| 34 | return result | |
| 35 | si | |
| 36 | ||
| 37 | init(location: LOCATION, definitions: Collections.Iterable[Definition]) is | |
| 38 | super.init(location) | |
| 39 | ||
| 40 | self.definitions = Collections.LIST[Definition](definitions) | |
| 41 | si | |
| 42 | ||
| 43 | add(definition: Definition) is | |
| 44 | definitions.add(definition) | |
| 45 | si | |
| 46 | ||
| 47 | push(definition: Definition) is | |
| 48 | let nd = Collections.LIST[Definition](definitions.count + 1) | |
| 49 | ||
| 50 | nd.add(definition) | |
| 51 | nd.add_range(definitions) | |
| 52 | ||
| 53 | definitions = nd | |
| 54 | si | |
| 55 | ||
| 56 | remove(definition: Definition) is | |
| 57 | definitions.remove(definition) | |
| 58 | si | |
| 59 | ||
| 60 | clear_definitions() is | |
| 61 | definitions.clear() | |
| 62 | si | |
| 63 | ||
| 64 | accept(visitor: Visitor) is | |
| 65 | visitor.visit(self) | |
| 66 | si | |
| 67 | ||
| 68 | walk(visitor: Visitor) is | |
| 69 | if !visitor.pre(self) then | |
| 70 | let i mut = 0 | |
| 71 | ||
| 72 | while i < definitions.count do | |
| 73 | definitions[i].walk(visitor) | |
| 74 | ||
| 75 | i = i + 1 | |
| 76 | od | |
| 77 | fi | |
| 78 | ||
| 79 | accept(visitor) | |
| 80 | si | |
| 81 | si | |
| 82 | si |