MCPcopy Create free account
hub / github.com/arktypeio/arktype / writesThrough

Method writesThrough

ark/aot/graph.ts:5226–5251  ·  view source on GitHub ↗
(binding: Binding, module: SourceModule)

Source from the content-addressed store, hash-verified

5224 // e.g. `o.a = 1`, `list.push(x)` or `Object.assign(o, x)`, changing what a
5225 // binding holds without assigning it
5226 writesThrough(binding: Binding, module: SourceModule): Node[] {
5227 let result = this.writesByBinding.get(binding)
5228 if (!result) {
5229 result = []
5230 this.writesByBinding.set(binding, result)
5231 for (const reference of binding.references) {
5232 if (reference.isWrite) continue
5233 const write = this.writeFrom(reference.id, module)
5234 if (write) result.push(write)
5235 }
5236 // e.g. `static { this.T = User }`, writing its class
5237 if (binding.kind === "class") {
5238 walk(binding.declaration, node => {
5239 if (
5240 node.type === "MemberExpression" &&
5241 unwrapChain(node.object).type === "ThisExpression" &&
5242 staticOwnerOf(node) === binding.declaration &&
5243 isWriteTarget(node)
5244 )
5245 result!.push(writeOf(node))
5246 return true
5247 })
5248 }
5249 }
5250 return result
5251 }
5252
5253 private writeFrom(node: Node, module: SourceModule): Node | undefined {
5254 for (;;) {

Callers 6

keyKindOfMethod · 0.95
namespaceKindOfMethod · 0.95
bindingInitOfMethod · 0.95
bindingLiteralOfMethod · 0.95
writeFromMethod · 0.95
instanceClassOfMethod · 0.95

Calls 9

writeFromMethod · 0.95
walkFunction · 0.90
unwrapChainFunction · 0.90
isWriteTargetFunction · 0.90
staticOwnerOfFunction · 0.85
writeOfFunction · 0.85
getMethod · 0.65
setMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected