Add StackValue.put(InstructionAdapter) for convenience
This commit is contained in:
@@ -420,8 +420,7 @@ public class ConstructorCodegen {
|
||||
// Super constructor requires OUTER parameter, but our OUTER instance may be different from what is expected by the super
|
||||
// constructor. We need to traverse our outer classes from the bottom up, to find the needed class. See innerExtendsOuter.kt
|
||||
ClassDescriptor outerForSuper = (ClassDescriptor) superConstructor.getContainingDeclaration().getContainingDeclaration();
|
||||
StackValue outer = codegen.generateThisOrOuter(outerForSuper, true, true);
|
||||
outer.put(outer.type, codegen.v);
|
||||
codegen.generateThisOrOuter(outerForSuper, true, true).put(codegen.v);
|
||||
superIndex++;
|
||||
}
|
||||
else if (kind == JvmMethodParameterKind.SUPER_CALL_PARAM || kind == JvmMethodParameterKind.ENUM_NAME_OR_ORDINAL) {
|
||||
|
||||
@@ -1556,7 +1556,7 @@ public class FunctionCodegen {
|
||||
iv.load(2, returnType);
|
||||
}
|
||||
else {
|
||||
StackValue.constant(typeSafeBarrierDescription.getDefaultValue(), returnType).put(returnType, iv);
|
||||
StackValue.constant(typeSafeBarrierDescription.getDefaultValue(), returnType).put(iv);
|
||||
}
|
||||
iv.areturn(returnType);
|
||||
|
||||
@@ -1619,7 +1619,7 @@ public class FunctionCodegen {
|
||||
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
field.put(field.type, iv);
|
||||
field.put(iv);
|
||||
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
||||
StackValue.local(reg, argTypes[i]).put(originalArgTypes[i], iv);
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
|
||||
@@ -913,7 +913,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (state.getClassBuilderMode().generateBodies && info.defaultValue == null) {
|
||||
ExpressionCodegen codegen = createOrGetClInitCodegen();
|
||||
int companionObjectIndex = putCompanionObjectInLocalVar(codegen);
|
||||
StackValue.local(companionObjectIndex, OBJECT_TYPE).put(OBJECT_TYPE, codegen.v);
|
||||
StackValue.local(companionObjectIndex, OBJECT_TYPE).put(codegen.v);
|
||||
copyFieldFromCompanionObject(property);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -49,8 +49,7 @@ class JvmStaticInCompanionObjectGenerator(
|
||||
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
|
||||
val iv = codegen.v
|
||||
val classDescriptor = descriptor.containingDeclaration as ClassDescriptor
|
||||
val singletonValue = StackValue.singleton(classDescriptor, typeMapper)
|
||||
singletonValue.put(singletonValue.type, iv)
|
||||
StackValue.singleton(classDescriptor, typeMapper).put(iv)
|
||||
var index = 0
|
||||
val asmMethod = signature.asmMethod
|
||||
for (paramType in asmMethod.argumentTypes) {
|
||||
|
||||
@@ -103,14 +103,18 @@ public abstract class StackValue {
|
||||
put(type, kotlinType, v);
|
||||
}
|
||||
|
||||
public void put(@NotNull Type type, @Nullable KotlinType kotlinType, @NotNull InstructionAdapter v) {
|
||||
put(type, kotlinType, v, false);
|
||||
public void put(@NotNull InstructionAdapter v) {
|
||||
put(type, null, v, false);
|
||||
}
|
||||
|
||||
public void put(@NotNull Type type, @NotNull InstructionAdapter v) {
|
||||
put(type, null, v, false);
|
||||
}
|
||||
|
||||
public void put(@NotNull Type type, @Nullable KotlinType kotlinType, @NotNull InstructionAdapter v) {
|
||||
put(type, kotlinType, v, false);
|
||||
}
|
||||
|
||||
public void put(@NotNull Type type, @Nullable KotlinType kotlinType, @NotNull InstructionAdapter v, boolean skipReceiver) {
|
||||
if (!skipReceiver) {
|
||||
putReceiver(v, true);
|
||||
|
||||
@@ -22,10 +22,9 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
class ArraySize : IntrinsicPropertyGetter() {
|
||||
override fun generate(
|
||||
resolvedCall: ResolvedCall<*>?, codegen: ExpressionCodegen, returnType: Type, receiver: StackValue
|
||||
) = StackValue.operation(returnType) {
|
||||
receiver.put(receiver.type, it)
|
||||
it.arraylength()
|
||||
}
|
||||
override fun generate(resolvedCall: ResolvedCall<*>?, codegen: ExpressionCodegen, returnType: Type, receiver: StackValue) =
|
||||
StackValue.operation(returnType) { iv ->
|
||||
receiver.put(iv)
|
||||
iv.arraylength()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.isInlineClassType
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.UNIT_TYPE
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.getType
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
@@ -53,7 +52,7 @@ object JavaClassProperty : IntrinsicPropertyGetter() {
|
||||
when {
|
||||
type == Type.VOID_TYPE -> {
|
||||
receiver.put(Type.VOID_TYPE, v)
|
||||
StackValue.unit().put(UNIT_TYPE, v)
|
||||
StackValue.unit().put(v)
|
||||
invokeVirtualGetClassMethod()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user