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

Function ctorExposesPrototype

ark/aot/usage.ts:2010–2048  ·  view source on GitHub ↗
(
	ctorBinding: Binding,
	module: SourceModule,
	ctx: ThisReadsContext
)

Source from the content-addressed store, hash-verified

2008}
2009
2010const ctorExposesPrototype = (
2011 ctorBinding: Binding,
2012 module: SourceModule,
2013 ctx: ThisReadsContext
2014): boolean => {
2015 if (ctorBinding.exportNames.length > 0 && ctx.hasEscapedPrototype) return true
2016 for (const ref of ctorBinding.references) {
2017 if (ref.isWrite) return true
2018 const [op, use] = operatorOf(ref.id)
2019 if (
2020 use?.type === "MemberExpression" &&
2021 use.object === op &&
2022 memberNameOf(use) === "prototype"
2023 ) {
2024 const [protoOp, protoUse] = operatorOf(use)
2025 if (isSubProtoCreate(protoOp, protoUse, module)) continue
2026 if (
2027 protoUse?.type === "BinaryExpression" &&
2028 isEqualityOperator(protoUse.operator)
2029 )
2030 continue
2031 if (
2032 protoUse?.type === "MemberExpression" &&
2033 protoUse.object === protoOp
2034 ) {
2035 if (isDiscardedProtoMethodWrite(protoUse)) continue
2036 if (
2037 !isWriteTarget(protoUse) &&
2038 staticMemberKeyOf(protoUse, module) !== undefined
2039 )
2040 continue
2041 }
2042 return true
2043 }
2044 if (use?.type === "NewExpression" && use.callee === op)
2045 if (instanceExposesComputed(use, module)) return true
2046 }
2047 return false
2048}
2049
2050const isDeadTopLevelFunction = (
2051 fn: Node,

Callers 1

computeSkippedFunctionFunction · 0.85

Calls 8

operatorOfFunction · 0.90
memberNameOfFunction · 0.90
isWriteTargetFunction · 0.90
isSubProtoCreateFunction · 0.85
isEqualityOperatorFunction · 0.85
staticMemberKeyOfFunction · 0.85
instanceExposesComputedFunction · 0.85

Tested by

no test coverage detected