Appearance
| 1 | namespace Syntax.Process is | |
| 2 | use Logging; | |
| 3 | ||
| 4 | use Trees; | |
| 5 | ||
| 6 | // Walks the edited file's declaration skeleton, entering the retained | |
| 7 | // scopes, and re-declares each function's body through DECLARE_MEMBERS - | |
| 8 | // the declare-symbols half of the incremental body re-walk. | |
| 9 | // | |
| 10 | // The interface declarations are not re-declared: ScopedVisitor's | |
| 11 | // inherited `pre`/`visit` for namespace / class / trait / … only *enter* | |
| 12 | // the retained scopes (a lookup, not a fresh declaration), so the | |
| 13 | // retained interface symbols are kept and declare-symbols' non-idempotency | |
| 14 | // is never exercised. Only the new body subtrees get fresh block scopes | |
| 15 | // and locals. | |
| 16 | class BODY_DECLARER: ScopedVisitor is | |
| 17 | _declare_members: DECLARE_MEMBERS; | |
| 18 | ||
| 19 | init( | |
| 20 | logger: Logger, | |
| 21 | symbol_table: Semantic.SYMBOL_TABLE, | |
| 22 | namespaces: Semantic.NAMESPACES, | |
| 23 | declare_members: DECLARE_MEMBERS | |
| 24 | ) is | |
| 25 | super.init(logger, symbol_table, namespaces); | |
| 26 | ||
| 27 | _declare_members = declare_members; | |
| 28 | si | |
| 29 | ||
| 30 | // At a function: enter its retained scope, declare the new body, and | |
| 31 | // return true so the skeleton walk does not also descend the body. | |
| 32 | // `visit(function)` (inherited) leaves the scope. | |
| 33 | pre(function: Trees.Definitions.FUNCTION) -> bool is | |
| 34 | enter_scope(function); | |
| 35 | ||
| 36 | _declare_members.declare_body(function); | |
| 37 | ||
| 38 | return true; | |
| 39 | si | |
| 40 | ||
| 41 | // Property and indexer accessor bodies are reached through the | |
| 42 | // synthesised sibling `$get_`/`$set_` (and `get_`/`set_`) FUNCTION | |
| 43 | // nodes, so the declaration node itself is not descended. | |
| 44 | pre(property: Trees.Definitions.PROPERTY) -> bool => true; | |
| 45 | ||
| 46 | pre(indexer: Trees.Definitions.INDEXER) -> bool => true; | |
| 47 | si | |
| 48 | si |