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

Method fixedDepthOfBinding

ark/aot/sameEachRun.ts:279–295  ·  view source on GitHub ↗
(
		binding: Binding,
		module: SourceModule,
		seen: Set<Binding>
	)

Source from the content-addressed store, hash-verified

277
278 // how many levels down what a const holds can be written, which nothing does
279 private fixedDepthOfBinding(
280 binding: Binding,
281 module: SourceModule,
282 seen: Set<Binding>
283 ): number | undefined {
284 if (seen.has(binding) || binding.kind !== "const") return
285 seen.add(binding)
286 const init = initOf(binding)
287 const depth = init ? this.fixedDepthOf(init, module, seen) : undefined
288 if (!depth) return depth as 0 | undefined
289 return (
290 this.graph.mayWritesOf(binding, module, heldAs(depth)).length ||
291 this.graph.elsewhereOf(module, binding, depth)
292 ) ?
293 undefined
294 : depth
295 }
296
297 // what an expression's text alone decides, as how many levels down it holds
298 // what could be written: 0 for a primitive

Callers 2

isSameReadMethod · 0.95
fixedDepthOfMethod · 0.95

Calls 7

fixedDepthOfMethod · 0.95
initOfFunction · 0.90
heldAsFunction · 0.90
mayWritesOfMethod · 0.80
elsewhereOfMethod · 0.80
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected