Step 26B: drop containsValueFnRef
This commit is contained in:
1 parent
bde32ca7b5
commit
b9af80a1b2
2 files changed
+2
-86
No files matched your search
@@ -6860,91 +6860,6 @@ class BytecodeCompiler(
|
||||
}
|
||||
}
|
||||
|
||||
private fun containsValueFnRef(stmt: Statement): Boolean {
|
||||
if (stmt is BytecodeStatement) return containsValueFnRef(stmt.original)
|
||||
return when (stmt) {
|
||||
is ExpressionStatement -> containsValueFnRef(stmt.ref)
|
||||
is BlockStatement -> stmt.statements().any { containsValueFnRef(it) }
|
||||
is VarDeclStatement -> stmt.initializer?.let { containsValueFnRef(it) } ?: false
|
||||
is DestructuringVarDeclStatement -> {
|
||||
containsValueFnRef(stmt.initializer) || containsValueFnRef(stmt.pattern)
|
||||
}
|
||||
is net.sergeych.lyng.ForInStatement -> {
|
||||
containsValueFnRef(stmt.source) ||
|
||||
containsValueFnRef(stmt.body) ||
|
||||
(stmt.elseStatement?.let { containsValueFnRef(it) } ?: false)
|
||||
}
|
||||
is net.sergeych.lyng.WhileStatement -> {
|
||||
containsValueFnRef(stmt.condition) ||
|
||||
containsValueFnRef(stmt.body) ||
|
||||
(stmt.elseStatement?.let { containsValueFnRef(it) } ?: false)
|
||||
}
|
||||
is net.sergeych.lyng.DoWhileStatement -> {
|
||||
containsValueFnRef(stmt.body) ||
|
||||
containsValueFnRef(stmt.condition) ||
|
||||
(stmt.elseStatement?.let { containsValueFnRef(it) } ?: false)
|
||||
}
|
||||
is IfStatement -> {
|
||||
containsValueFnRef(stmt.condition) ||
|
||||
containsValueFnRef(stmt.ifBody) ||
|
||||
(stmt.elseBody?.let { containsValueFnRef(it) } ?: false)
|
||||
}
|
||||
is net.sergeych.lyng.ReturnStatement -> {
|
||||
stmt.resultExpr?.let { containsValueFnRef(it) } ?: false
|
||||
}
|
||||
is net.sergeych.lyng.ThrowStatement -> containsValueFnRef(stmt.throwExpr)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun containsValueFnRef(ref: ObjRef): Boolean {
|
||||
return when (ref) {
|
||||
is ValueFnRef -> true
|
||||
is BinaryOpRef -> containsValueFnRef(binaryLeft(ref)) || containsValueFnRef(binaryRight(ref))
|
||||
is UnaryOpRef -> containsValueFnRef(unaryOperand(ref))
|
||||
is CastRef -> containsValueFnRef(ref.castValueRef()) || containsValueFnRef(ref.castTypeRef())
|
||||
is AssignRef -> {
|
||||
val target = assignTarget(ref)
|
||||
if (target != null) {
|
||||
containsValueFnRef(target) || containsValueFnRef(assignValue(ref))
|
||||
} else {
|
||||
containsValueFnRef(ref.target) || containsValueFnRef(assignValue(ref))
|
||||
}
|
||||
}
|
||||
is AssignOpRef -> containsValueFnRef(ref.target) || containsValueFnRef(ref.value)
|
||||
is AssignIfNullRef -> containsValueFnRef(ref.target) || containsValueFnRef(ref.value)
|
||||
is IncDecRef -> containsValueFnRef(ref.target)
|
||||
is ConditionalRef -> {
|
||||
containsValueFnRef(ref.condition) ||
|
||||
containsValueFnRef(ref.ifTrue) ||
|
||||
containsValueFnRef(ref.ifFalse)
|
||||
}
|
||||
is ElvisRef -> containsValueFnRef(ref.left) || containsValueFnRef(ref.right)
|
||||
is FieldRef -> containsValueFnRef(ref.target)
|
||||
is IndexRef -> containsValueFnRef(ref.targetRef) || containsValueFnRef(ref.indexRef)
|
||||
is CallRef -> ref.tailBlock || containsValueFnRef(ref.target) || ref.args.any { arg ->
|
||||
val stmt = arg.value
|
||||
stmt is ExpressionStatement && containsValueFnRef(stmt.ref)
|
||||
}
|
||||
is MethodCallRef -> ref.tailBlock || containsValueFnRef(ref.receiver) || ref.args.any { arg ->
|
||||
val stmt = arg.value
|
||||
stmt is ExpressionStatement && containsValueFnRef(stmt.ref)
|
||||
}
|
||||
is ThisMethodSlotCallRef -> ref.hasTailBlock() || ref.arguments().any { arg ->
|
||||
val stmt = arg.value
|
||||
stmt is ExpressionStatement && containsValueFnRef(stmt.ref)
|
||||
}
|
||||
is ListLiteralRef -> ref.entries().any { entry ->
|
||||
when (entry) {
|
||||
is net.sergeych.lyng.ListEntry.Element -> containsValueFnRef(entry.ref)
|
||||
is net.sergeych.lyng.ListEntry.Spread -> containsValueFnRef(entry.ref)
|
||||
}
|
||||
}
|
||||
is StatementRef -> containsValueFnRef(ref.statement)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractRangeRef(source: Statement): RangeRef? {
|
||||
val target = if (source is BytecodeStatement) source.original else source
|
||||
val expr = target as? ExpressionStatement ?: return null
|
||||
|
||||
Reference in new issue
Block a user