( fn: FunctionNode, module: SourceModule, held: Held )
| 5352 | // what a method a value holds may write of it through `this`, as |
| 5353 | // `swap() { this.t = T }` does once the program calls `o.swap()` |
| 5354 | mayWritesThroughThis( |
| 5355 | fn: FunctionNode, |
| 5356 | module: SourceModule, |
| 5357 | held: Held |
| 5358 | ): Node[] { |
| 5359 | const key = `${held.depth}:${held.copied}` |
| 5360 | let byHeld = this.thisWritesByFn.get(fn) |
| 5361 | if (!byHeld) this.thisWritesByFn.set(fn, (byHeld = new Map())) |
| 5362 | let result = byHeld.get(key) |
| 5363 | if (result) return result |
| 5364 | byHeld.set(key, (result = [])) |
| 5365 | for (const node of [...fn.params, fn.body!]) { |
| 5366 | walk(node, child => { |
| 5367 | if (child.type === "ThisExpression") { |
| 5368 | const write = this.mayWriteFrom(child, module, held) |
| 5369 | if (write) result.push(write) |
| 5370 | } |
| 5371 | // a function other than an arrow has a `this` of its own |
| 5372 | return ( |
| 5373 | !isFunctionNode(child) || child.type === "ArrowFunctionExpression" |
| 5374 | ) |
| 5375 | }) |
| 5376 | } |
| 5377 | return result |
| 5378 | } |
| 5379 | |
| 5380 | // reads the whole program, whose other modules may write what one exports |
| 5381 | readView(view: ProgramView | undefined): void { |
no test coverage detected