Appearance
| 1 | namespace Syntax is | |
| 2 | use Collections.LIST; | |
| 3 | ||
| 4 | // Splices freshly-parsed (donor) function bodies onto the retained AST's | |
| 5 | // function nodes, for the incremental body re-walk. The retained FUNCTION | |
| 6 | // node — its symbol, its node→scope association — is kept untouched; only | |
| 7 | // the body child is replaced. | |
| 8 | class BODY_SPLICE is | |
| 9 | // For each retained↔donor pair, give the retained function the | |
| 10 | // donor's body. A property accessor's body is also referenced by its | |
| 11 | // PROPERTY node's read_body / assign_body field (the resolve passes | |
| 12 | // descend the PROPERTY node), so that reference is kept in sync. | |
| 13 | apply(pairs: LIST[FUNCTION_PAIR]) static is | |
| 14 | for pair in pairs do | |
| 15 | let retained = pair.retained; | |
| 16 | let body = pair.donor.body; | |
| 17 | ||
| 18 | retained.body = body; | |
| 19 | ||
| 20 | let property = retained.for_property; | |
| 21 | ||
| 22 | if property? then | |
| 23 | if property.read_function == retained then | |
| 24 | property.read_body = body; | |
| 25 | elif property.assign_function == retained then | |
| 26 | property.assign_body = body; | |
| 27 | fi | |
| 28 | fi | |
| 29 | od | |
| 30 | si | |
| 31 | si | |
| 32 | si |