Convert ParameterInfo.java into Kotlin
This commit is contained in:
+3
-3
@@ -309,9 +309,9 @@ class AnonymousObjectTransformer(
|
||||
}
|
||||
|
||||
if (size != 0) { //skip this
|
||||
descTypes.add(info.getType())
|
||||
descTypes.add(info.type)
|
||||
}
|
||||
size += info.getType().size
|
||||
size += info.type.size
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ class AnonymousObjectTransformer(
|
||||
if (fake.functionalArgument is LambdaInfo) {
|
||||
//set remap value to skip this fake (captured with lambda already skipped)
|
||||
val composed = StackValue.field(
|
||||
fake.getType(),
|
||||
fake.type,
|
||||
oldObjectType,
|
||||
fake.newFieldName,
|
||||
false,
|
||||
|
||||
@@ -63,7 +63,7 @@ public class CapturedParamInfo extends ParameterInfo {
|
||||
@NotNull
|
||||
public CapturedParamInfo cloneWithNewDeclarationIndex(int newDeclarationIndex) {
|
||||
CapturedParamInfo result = new CapturedParamInfo(
|
||||
desc, newFieldName, isSkipped, getIndex(), getRemapValue(), skipInConstructor, newDeclarationIndex
|
||||
desc, newFieldName, isSkipped(), getIndex(), getRemapValue(), skipInConstructor, newDeclarationIndex
|
||||
);
|
||||
result.setFunctionalArgument(getFunctionalArgument());
|
||||
result.setSynthetic(synthetic);
|
||||
|
||||
@@ -340,7 +340,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
if (capturedParamIndex >= 0) {
|
||||
val capturedParamInfoInLambda = activeLambda!!.capturedVars[capturedParamIndex]
|
||||
info = invocationParamBuilder.addCapturedParam(capturedParamInfoInLambda, capturedParamInfoInLambda.fieldName, false)
|
||||
info.setRemapValue(remappedValue)
|
||||
info.remapValue = remappedValue
|
||||
} else {
|
||||
info = invocationParamBuilder.addNextValueParameter(jvmType, false, remappedValue, parameterIndex)
|
||||
if (kind == ValueKind.NON_INLINEABLE_CALLED_IN_SUSPEND) {
|
||||
@@ -363,7 +363,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
): Function0<Unit>? {
|
||||
val index = IntArray(infos.size) { i ->
|
||||
if (!infos[i].isSkippedOrRemapped) {
|
||||
codegen.frameMap.enterTemp(infos[i].getType())
|
||||
codegen.frameMap.enterTemp(infos[i].type)
|
||||
} else -1
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
local.store(StackValue.onStack(type), codegen.v)
|
||||
}
|
||||
if (info is CapturedParamInfo) {
|
||||
info.setRemapValue(local)
|
||||
info.remapValue = local
|
||||
info.isSynthetic = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ class LocalVarRemapper(private val params: Parameters, private val additionalShi
|
||||
val shift = params.getDeclarationSlot(info)
|
||||
if (!info.isSkippedOrRemapped) {
|
||||
remapValues[shift] = StackValue.local(realSize, AsmTypes.OBJECT_TYPE)
|
||||
realSize += info.getType().size
|
||||
realSize += info.type.size
|
||||
} else {
|
||||
remapValues[shift] = if (info.isRemapped) info.remapValue else null
|
||||
if (CapturedParamInfo.isSynthetic(info)) {
|
||||
realSize += info.getType().size
|
||||
realSize += info.type.size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,81 +14,33 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.inline;
|
||||
package org.jetbrains.kotlin.codegen.inline
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.StackValue;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
public class ParameterInfo {
|
||||
private final int index;
|
||||
public final int declarationIndex;
|
||||
public final Type type;
|
||||
//for skipped parameter: e.g. inlined lambda
|
||||
public final boolean isSkipped;
|
||||
open class ParameterInfo(
|
||||
val type: Type,
|
||||
val isSkipped: Boolean, //for skipped parameter: e.g. inlined lambda
|
||||
val index: Int,
|
||||
var remapValue: StackValue?, //in case when parameter could be extracted from outer context (e.g. from local var)
|
||||
val declarationIndex: Int = -1
|
||||
) {
|
||||
|
||||
private boolean isCaptured;
|
||||
private FunctionalArgument functionalArgument;
|
||||
//in case when parameter could be extracted from outer context (e.g. from local var)
|
||||
private StackValue remapValue;
|
||||
var isCaptured: Boolean = false
|
||||
var functionalArgument: FunctionalArgument? = null
|
||||
|
||||
public ParameterInfo(@NotNull Type type, boolean skipped, int index, int remapValue, int declarationIndex) {
|
||||
this(type, skipped, index, remapValue == -1 ? null : StackValue.local(remapValue, type), declarationIndex);
|
||||
}
|
||||
val isSkippedOrRemapped: Boolean
|
||||
get() = isSkipped || isRemapped
|
||||
|
||||
public ParameterInfo(@NotNull Type type, boolean skipped, int index, @Nullable StackValue remapValue, int declarationIndex) {
|
||||
this.type = type;
|
||||
this.isSkipped = skipped;
|
||||
this.remapValue = remapValue;
|
||||
this.index = index;
|
||||
this.declarationIndex = declarationIndex;
|
||||
}
|
||||
val isRemapped: Boolean
|
||||
get() = remapValue != null
|
||||
|
||||
public boolean isSkippedOrRemapped() {
|
||||
return isSkipped || isRemapped();
|
||||
}
|
||||
|
||||
public boolean isRemapped() {
|
||||
return remapValue != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StackValue getRemapValue() {
|
||||
return remapValue;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FunctionalArgument getFunctionalArgument() {
|
||||
return functionalArgument;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ParameterInfo setFunctionalArgument(@Nullable FunctionalArgument functionalArgument) {
|
||||
this.functionalArgument = functionalArgument;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ParameterInfo setRemapValue(@Nullable StackValue remapValue) {
|
||||
this.remapValue = remapValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCaptured() {
|
||||
return isCaptured;
|
||||
}
|
||||
|
||||
public void setCaptured(boolean isCaptured) {
|
||||
this.isCaptured = isCaptured;
|
||||
}
|
||||
constructor(type: Type, skipped: Boolean, index: Int, remapValue: Int, declarationIndex: Int) : this(
|
||||
type,
|
||||
skipped,
|
||||
index,
|
||||
if (remapValue == -1) null else StackValue.local(remapValue, type),
|
||||
declarationIndex
|
||||
)
|
||||
}
|
||||
|
||||
@@ -70,5 +70,5 @@ class Parameters(val parameters: List<ParameterInfo>) : Iterable<ParameterInfo>
|
||||
}
|
||||
|
||||
val capturedTypes: List<Type>
|
||||
get() = captured.map(CapturedParamInfo::getType)
|
||||
get() = captured.map(CapturedParamInfo::type)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class ParametersBuilder private constructor() {
|
||||
|
||||
private fun <T : ParameterInfo> addParameter(info: T): T {
|
||||
params.add(info)
|
||||
nextParameterOffset += info.getType().size
|
||||
nextParameterOffset += info.type.size
|
||||
if (info !is CapturedParamInfo) {
|
||||
nextValueParameterIndex++
|
||||
}
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ class RegeneratedLambdaFieldRemapper(
|
||||
if (field.isSkipped && field.functionalArgument is LambdaInfo)
|
||||
Type.getObjectType(parent!!.parent!!.newLambdaInternalName)
|
||||
else
|
||||
field.getType(),
|
||||
field.type,
|
||||
Type.getObjectType(newLambdaInternalName), /*TODO owner type*/
|
||||
field.newFieldName, false,
|
||||
prefix ?: StackValue.LOCAL_0
|
||||
|
||||
Reference in New Issue
Block a user