Minor: Extract 'this' local variable name in DefaultImpls

This commit is contained in:
Yan Zhulanow
2019-01-31 21:18:57 +03:00
parent 65b6098242
commit 6a81c2e1e4
3 changed files with 7 additions and 5 deletions
@@ -100,6 +100,8 @@ public class AsmUtil {
public static final String THIS = "this";
public static final String THIS_IN_DEFAULT_IMPLS = "$this";
public static final String LABELED_THIS_FIELD = THIS + "_";
public static final String LABELED_THIS_PARAMETER = "$" + THIS + "$";
@@ -199,7 +199,7 @@ class KotlinStackFrame(frame: StackFrameProxyImpl) : JavaStackFrame(StackFrameDe
.filter { !isHidden(it, inlineDepth) }
.partition {
it.name() == THIS
|| it.name() == AsmUtil.getCapturedFieldName(AsmUtil.THIS)
|| it.name() == AsmUtil.THIS_IN_DEFAULT_IMPLS
|| it.name().startsWith(AsmUtil.LABELED_THIS_PARAMETER)
|| (VariableFinder.inlinedThisRegex.matches(it.name()))
}
@@ -231,7 +231,7 @@ class KotlinStackFrame(frame: StackFrameProxyImpl) : JavaStackFrame(StackFrameDe
val label = name.drop(AsmUtil.LABELED_THIS_PARAMETER.length)
clone(getThisName(label), label)
}
name == AsmUtil.getCapturedFieldName(AsmUtil.THIS) -> clone(THIS + " (outer)", null)
name == AsmUtil.THIS_IN_DEFAULT_IMPLS -> clone(THIS + " (outer)", null)
name == AsmUtil.RECEIVER_PARAMETER_NAME -> clone(THIS + " (receiver)", null)
VariableFinder.inlinedThisRegex.matches(name) -> {
val label = generateThisLabel(frame.getValue(this)?.type())
@@ -265,7 +265,7 @@ class VariableFinder private constructor(private val context: ExecutionContext,
if (isInsideDefaultImpls()) {
val variables = frameProxy.safeVisibleVariables()
findLocalVariable(variables, kind, getCapturedFieldName(AsmUtil.THIS))?.let { return it }
findLocalVariable(variables, kind, AsmUtil.THIS_IN_DEFAULT_IMPLS)?.let { return it }
}
val variables = frameProxy.safeVisibleVariables()
@@ -383,7 +383,7 @@ class VariableFinder private constructor(private val context: ExecutionContext,
fun isReceiverOrPassedThis(name: String) =
name.startsWith(AsmUtil.LABELED_THIS_PARAMETER)
|| name == AsmUtil.RECEIVER_PARAMETER_NAME
|| name == getCapturedFieldName(AsmUtil.THIS)
|| name == AsmUtil.THIS_IN_DEFAULT_IMPLS
|| inlinedThisRegex.matches(name)
if (kind is VariableKind.ExtensionThis) {
@@ -426,7 +426,7 @@ class VariableFinder private constructor(private val context: ExecutionContext,
// Recursive search in outer and captured this
fields.namedEntitySequence(parent)
.filter { it.name == getCapturedFieldName(AsmUtil.THIS) || it.name == AsmUtil.CAPTURED_THIS_FIELD }
.filter { it.name == AsmUtil.THIS_IN_DEFAULT_IMPLS || it.name == AsmUtil.CAPTURED_THIS_FIELD }
.mapNotNull { findCapturedVariable(kind, it.value()) }
.firstOrNull()
?.let { return it }