( ctorBinding: Binding, module: SourceModule, ctx: ThisReadsContext )
| 2008 | } |
| 2009 | |
| 2010 | const 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 | |
| 2050 | const isDeadTopLevelFunction = ( |
| 2051 | fn: Node, |
no test coverage detected