Fix lots of deprecation warnings on ASM code

In the vast majority of cases it's known that we're calling a class method and
not an interface method
This commit is contained in:
Alexander Udalov
2014-07-26 01:05:03 +04:00
parent 99025de748
commit c69303fd1d
21 changed files with 129 additions and 124 deletions
@@ -345,7 +345,7 @@ public class AsmUtil {
iv.anew(Type.getObjectType(exception)); iv.anew(Type.getObjectType(exception));
iv.dup(); iv.dup();
iv.aconst(message); iv.aconst(message);
iv.invokespecial(exception, "<init>", "(Ljava/lang/String;)V"); iv.invokespecial(exception, "<init>", "(Ljava/lang/String;)V", false);
iv.athrow(); iv.athrow();
} }
@@ -395,18 +395,18 @@ public class AsmUtil {
public static void genStringBuilderConstructor(InstructionAdapter v) { public static void genStringBuilderConstructor(InstructionAdapter v) {
v.visitTypeInsn(NEW, "java/lang/StringBuilder"); v.visitTypeInsn(NEW, "java/lang/StringBuilder");
v.dup(); v.dup();
v.invokespecial("java/lang/StringBuilder", "<init>", "()V"); v.invokespecial("java/lang/StringBuilder", "<init>", "()V", false);
} }
public static void genInvokeAppendMethod(InstructionAdapter v, Type type) { public static void genInvokeAppendMethod(InstructionAdapter v, Type type) {
type = stringBuilderAppendType(type); type = stringBuilderAppendType(type);
v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;"); v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;", false);
} }
public static StackValue genToString(InstructionAdapter v, StackValue receiver, Type receiverType) { public static StackValue genToString(InstructionAdapter v, StackValue receiver, Type receiverType) {
Type type = stringValueOfType(receiverType); Type type = stringValueOfType(receiverType);
receiver.put(type, v); receiver.put(type, v);
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;"); v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false);
return StackValue.onStack(JAVA_STRING_TYPE); return StackValue.onStack(JAVA_STRING_TYPE);
} }
@@ -414,24 +414,24 @@ public class AsmUtil {
if (type.getSort() == Type.ARRAY) { if (type.getSort() == Type.ARRAY) {
Type elementType = correctElementType(type); Type elementType = correctElementType(type);
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) { if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
iv.invokestatic("java/util/Arrays", "hashCode", "([Ljava/lang/Object;)I"); iv.invokestatic("java/util/Arrays", "hashCode", "([Ljava/lang/Object;)I", false);
} }
else { else {
iv.invokestatic("java/util/Arrays", "hashCode", "(" + type.getDescriptor() + ")I"); iv.invokestatic("java/util/Arrays", "hashCode", "(" + type.getDescriptor() + ")I", false);
} }
} }
else if (type.getSort() == Type.OBJECT) { else if (type.getSort() == Type.OBJECT) {
iv.invokevirtual("java/lang/Object", "hashCode", "()I"); iv.invokevirtual("java/lang/Object", "hashCode", "()I", false);
} }
else if (type.getSort() == Type.LONG) { else if (type.getSort() == Type.LONG) {
genLongHashCode(mv, iv); genLongHashCode(mv, iv);
} }
else if (type.getSort() == Type.DOUBLE) { else if (type.getSort() == Type.DOUBLE) {
iv.invokestatic("java/lang/Double", "doubleToLongBits", "(D)J"); iv.invokestatic("java/lang/Double", "doubleToLongBits", "(D)J", false);
genLongHashCode(mv, iv); genLongHashCode(mv, iv);
} }
else if (type.getSort() == Type.FLOAT) { else if (type.getSort() == Type.FLOAT) {
iv.invokestatic("java/lang/Float", "floatToIntBits", "(F)I"); iv.invokestatic("java/lang/Float", "floatToIntBits", "(F)I", false);
} }
else if (type.getSort() == Type.BOOLEAN) { else if (type.getSort() == Type.BOOLEAN) {
Label end = new Label(); Label end = new Label();
@@ -473,7 +473,7 @@ public class AsmUtil {
return StackValue.cmp(opToken, leftType); return StackValue.cmp(opToken, leftType);
} }
else { else {
v.invokestatic("kotlin/jvm/internal/Intrinsics", "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z"); v.invokestatic("kotlin/jvm/internal/Intrinsics", "areEqual", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
if (opToken == JetTokens.EXCLEQ || opToken == JetTokens.EXCLEQEQEQ) { if (opToken == JetTokens.EXCLEQ || opToken == JetTokens.EXCLEQEQEQ) {
genInvertBoolean(v); genInvertBoolean(v);
@@ -549,7 +549,8 @@ public class AsmUtil {
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) { if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
v.load(index, asmType); v.load(index, asmType);
v.visitLdcInsn(parameter.getName().asString()); v.visitLdcInsn(parameter.getName().asString());
v.invokestatic("kotlin/jvm/internal/Intrinsics", "checkParameterIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V"); v.invokestatic("kotlin/jvm/internal/Intrinsics", "checkParameterIsNotNull",
"(Ljava/lang/Object;Ljava/lang/String;)V", false);
} }
} }
} }
@@ -591,7 +592,8 @@ public class AsmUtil {
v.dup(); v.dup();
v.visitLdcInsn(descriptor.getContainingDeclaration().getName().asString()); v.visitLdcInsn(descriptor.getContainingDeclaration().getName().asString());
v.visitLdcInsn(descriptor.getName().asString()); v.visitLdcInsn(descriptor.getName().asString());
v.invokestatic("kotlin/jvm/internal/Intrinsics", assertMethodToCall, "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V"); v.invokestatic("kotlin/jvm/internal/Intrinsics", assertMethodToCall,
"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V", false);
} }
} }
@@ -18,16 +18,16 @@ package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.commons.Method; import org.jetbrains.org.objectweb.asm.commons.Method;
import org.jetbrains.org.objectweb.asm.util.Printer; import org.jetbrains.org.objectweb.asm.util.Printer;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -137,13 +137,14 @@ public class CallableMethod implements Callable {
String desc = method.getDescriptor().replace(")", "I)"); String desc = method.getDescriptor().replace(")", "I)");
if ("<init>".equals(method.getName())) { if ("<init>".equals(method.getName())) {
v.visitMethodInsn(INVOKESPECIAL, defaultImplOwner.getInternalName(), "<init>", desc); v.visitMethodInsn(INVOKESPECIAL, defaultImplOwner.getInternalName(), "<init>", desc, false);
} }
else { else {
if (getInvokeOpcode() != INVOKESTATIC) { if (getInvokeOpcode() != INVOKESTATIC) {
desc = desc.replace("(", "(" + defaultImplParam.getDescriptor()); desc = desc.replace("(", "(" + defaultImplParam.getDescriptor());
} }
v.visitMethodInsn(INVOKESTATIC, defaultImplOwner.getInternalName(), method.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, desc); v.visitMethodInsn(INVOKESTATIC, defaultImplOwner.getInternalName(),
method.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, desc, false);
} }
} }
@@ -45,10 +45,10 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import static org.jetbrains.jet.codegen.AsmUtil.*; import static org.jetbrains.jet.codegen.AsmUtil.*;
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.OtherOrigin;
import static org.jetbrains.jet.codegen.JvmCodegenUtil.isConst; import static org.jetbrains.jet.codegen.JvmCodegenUtil.isConst;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*; import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass; import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.OtherOrigin;
import static org.jetbrains.org.objectweb.asm.Opcodes.*; import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public class ClosureCodegen extends ParentCodegenAware { public class ClosureCodegen extends ParentCodegenAware {
@@ -194,7 +194,7 @@ public class ClosureCodegen extends ParentCodegenAware {
v.dup(); v.dup();
codegen.pushClosureOnStack(closure, false, codegen.defaultCallGenerator); codegen.pushClosureOnStack(closure, false, codegen.defaultCallGenerator);
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor()); v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
} }
return StackValue.onStack(asmType); return StackValue.onStack(asmType);
} }
@@ -210,7 +210,7 @@ public class ClosureCodegen extends ParentCodegenAware {
mv.visitCode(); mv.visitCode();
iv.anew(asmType); iv.anew(asmType);
iv.dup(); iv.dup();
iv.invokespecial(asmType.getInternalName(), "<init>", "()V"); iv.invokespecial(asmType.getInternalName(), "<init>", "()V", false);
iv.putstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()); iv.putstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor());
mv.visitInsn(RETURN); mv.visitInsn(RETURN);
FunctionCodegen.endVisit(mv, "<clinit>", fun); FunctionCodegen.endVisit(mv, "<clinit>", fun);
@@ -243,7 +243,7 @@ public class ClosureCodegen extends ParentCodegenAware {
count++; count++;
} }
iv.invokevirtual(asmType.getInternalName(), delegate.getName(), delegate.getDescriptor()); iv.invokevirtual(asmType.getInternalName(), delegate.getName(), delegate.getDescriptor(), false);
StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), iv); StackValue.onStack(delegate.getReturnType()).put(bridge.getReturnType(), iv);
iv.areturn(bridge.getReturnType()); iv.areturn(bridge.getReturnType());
@@ -270,7 +270,7 @@ public class ClosureCodegen extends ParentCodegenAware {
} }
iv.load(0, superClassAsmType); iv.load(0, superClassAsmType);
iv.invokespecial(superClassAsmType.getInternalName(), "<init>", "()V"); iv.invokespecial(superClassAsmType.getInternalName(), "<init>", "()V", false);
iv.visitInsn(RETURN); iv.visitInsn(RETURN);
@@ -667,7 +667,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
// The result is stored to local variable // The result is stored to local variable
protected void generateRangeOrProgressionProperty(Type loopRangeType, String getterName, Type elementType, int varToStore) { protected void generateRangeOrProgressionProperty(Type loopRangeType, String getterName, Type elementType, int varToStore) {
Type boxedType = boxType(elementType); Type boxedType = boxType(elementType);
v.invokevirtual(loopRangeType.getInternalName(), getterName, "()" + boxedType.getDescriptor()); v.invokevirtual(loopRangeType.getInternalName(), getterName, "()" + boxedType.getDescriptor(), false);
StackValue.coerce(boxedType, elementType, v); StackValue.coerce(boxedType, elementType, v);
v.store(varToStore, elementType); v.store(varToStore, elementType);
} }
@@ -1028,7 +1028,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Type methodParamType = asmElementType.getSort() == Type.LONG ? Type.LONG_TYPE : Type.INT_TYPE; Type methodParamType = asmElementType.getSort() == Type.LONG ? Type.LONG_TYPE : Type.INT_TYPE;
v.invokestatic("kotlin/internal/InternalPackage", "getProgressionFinalElement", v.invokestatic("kotlin/internal/InternalPackage", "getProgressionFinalElement",
Type.getMethodDescriptor(methodParamType, methodParamType, methodParamType, methodParamType)); Type.getMethodDescriptor(methodParamType, methodParamType, methodParamType, methodParamType), false);
finalVar = createLoopTempVariable(asmElementType); finalVar = createLoopTempVariable(asmElementType);
v.store(finalVar, asmElementType); v.store(finalVar, asmElementType);
@@ -1266,7 +1266,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
genInvokeAppendMethod(v, JAVA_STRING_TYPE); genInvokeAppendMethod(v, JAVA_STRING_TYPE);
} }
} }
v.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;"); v.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false);
return StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE); return StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE);
} }
} }
@@ -1364,7 +1364,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
argumentGenerator.generate(valueArguments); argumentGenerator.generate(valueArguments);
} }
v.invokespecial(type.getInternalName(), "<init>", constructor.getAsmMethod().getDescriptor()); v.invokespecial(type.getInternalName(), "<init>", constructor.getAsmMethod().getDescriptor(), false);
return StackValue.onStack(type); return StackValue.onStack(type);
} }
@@ -1480,7 +1480,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (sharedVarType != null) { if (sharedVarType != null) {
v.anew(sharedVarType); v.anew(sharedVarType);
v.dup(); v.dup();
v.invokespecial(sharedVarType.getInternalName(), "<init>", "()V"); v.invokespecial(sharedVarType.getInternalName(), "<init>", "()V", false);
v.store(index, OBJECT_TYPE); v.store(index, OBJECT_TYPE);
} }
@@ -1750,7 +1750,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (descriptor instanceof TypeParameterDescriptor) { if (descriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor; TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
v.invokevirtual("jet/TypeInfo", "getClassObject", "()Ljava/lang/Object;"); v.invokevirtual("jet/TypeInfo", "getClassObject", "()Ljava/lang/Object;", false);
JetType type = typeParameterDescriptor.getClassObjectType(); JetType type = typeParameterDescriptor.getClassObjectType();
assert type != null; assert type != null;
v.checkcast(asmType(type)); v.checkcast(asmType(type));
@@ -2032,7 +2032,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.goTo(afterAll); v.goTo(afterAll);
v.mark(ifNonNull); v.mark(ifNonNull);
v.invokespecial(asmType.getInternalName(), "<init>", Type.getMethodDescriptor(Type.VOID_TYPE, functionType)); v.invokespecial(asmType.getInternalName(), "<init>", Type.getMethodDescriptor(Type.VOID_TYPE, functionType), false);
v.mark(afterAll); v.mark(afterAll);
return StackValue.onStack(asmType); return StackValue.onStack(asmType);
@@ -2380,24 +2380,24 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
String owner = "kotlin/jvm/internal/SpreadBuilder"; String owner = "kotlin/jvm/internal/SpreadBuilder";
v.anew(Type.getObjectType(owner)); v.anew(Type.getObjectType(owner));
v.dup(); v.dup();
v.invokespecial(owner, "<init>", "()V"); v.invokespecial(owner, "<init>", "()V", false);
for (int i = 0; i != size; ++i) { for (int i = 0; i != size; ++i) {
v.dup(); v.dup();
ValueArgument argument = arguments.get(i); ValueArgument argument = arguments.get(i);
if (argument.getSpreadElement() != null) { if (argument.getSpreadElement() != null) {
gen(argument.getArgumentExpression(), OBJECT_TYPE); gen(argument.getArgumentExpression(), OBJECT_TYPE);
v.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V"); v.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V", false);
} }
else { else {
gen(argument.getArgumentExpression(), elementType); gen(argument.getArgumentExpression(), elementType);
v.invokevirtual(owner, "add", "(Ljava/lang/Object;)Z"); v.invokevirtual(owner, "add", "(Ljava/lang/Object;)Z", false);
v.pop(); v.pop();
} }
} }
v.dup(); v.dup();
v.invokevirtual(owner, "size", "()I"); v.invokevirtual(owner, "size", "()I", false);
v.newarray(elementType); v.newarray(elementType);
v.invokevirtual(owner, "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;"); v.invokevirtual(owner, "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", false);
v.checkcast(type); v.checkcast(type);
} }
} }
@@ -3080,7 +3080,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.dup(); v.dup();
Label ok = new Label(); Label ok = new Label();
v.ifnonnull(ok); v.ifnonnull(ok);
v.invokestatic("kotlin/jvm/internal/Intrinsics", "throwNpe", "()V"); v.invokestatic("kotlin/jvm/internal/Intrinsics", "throwNpe", "()V", false);
v.mark(ok); v.mark(ok);
return StackValue.onStack(base.type); return StackValue.onStack(base.type);
} }
@@ -3354,7 +3354,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.dup2(); v.dup2();
v.load(indexIndex, Type.INT_TYPE); v.load(indexIndex, Type.INT_TYPE);
v.invokestatic("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;"); v.invokestatic("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false);
v.invokeinterface(FUNCTION1_TYPE.getInternalName(), "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;"); v.invokeinterface(FUNCTION1_TYPE.getInternalName(), "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;");
v.load(indexIndex, Type.INT_TYPE); v.load(indexIndex, Type.INT_TYPE);
v.iinc(indexIndex, 1); v.iinc(indexIndex, 1);
@@ -3841,10 +3841,10 @@ The "returned" value of try expression with no finally is either the last expres
v.dup(); v.dup();
if (message != null) { if (message != null) {
v.visitLdcInsn(message); v.visitLdcInsn(message);
v.invokespecial(className, "<init>", "(Ljava/lang/String;)V"); v.invokespecial(className, "<init>", "(Ljava/lang/String;)V", false);
} }
else { else {
v.invokespecial(className, "<init>", "()V"); v.invokespecial(className, "<init>", "()V", false);
} }
v.athrow(); v.athrow();
} }
@@ -382,7 +382,7 @@ public class FunctionCodegen extends ParentCodegenAware {
iv.load(k, argType); iv.load(k, argType);
k += argType.getSize(); k += argType.getSize();
} }
iv.invokestatic(context.getDelegateToClassType().getInternalName(), asmMethod.getName(), asmMethod.getDescriptor()); iv.invokestatic(context.getDelegateToClassType().getInternalName(), asmMethod.getName(), asmMethod.getDescriptor(), false);
iv.areturn(asmMethod.getReturnType()); iv.areturn(asmMethod.getReturnType());
} }
@@ -531,7 +531,7 @@ public class FunctionCodegen extends ParentCodegenAware {
} }
v.iconst(mask); v.iconst(mask);
String desc = method.getAsmMethod().getDescriptor().replace(")", "I)"); String desc = method.getAsmMethod().getDescriptor().replace(")", "I)");
v.invokespecial(methodOwner.getInternalName(), "<init>", desc); v.invokespecial(methodOwner.getInternalName(), "<init>", desc, false);
v.areturn(Type.VOID_TYPE); v.areturn(Type.VOID_TYPE);
endVisit(mv, "default constructor for " + methodOwner.getInternalName(), null); endVisit(mv, "default constructor for " + methodOwner.getInternalName(), null);
} }
@@ -517,7 +517,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
mv.visitCode(); mv.visitCode();
iv.load(0, classAsmType); iv.load(0, classAsmType);
iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray", "(Ljava/util/Collection;)[Ljava/lang/Object;"); iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray", "(Ljava/util/Collection;)[Ljava/lang/Object;", false);
iv.areturn(Type.getObjectType("[Ljava/lang/Object;")); iv.areturn(Type.getObjectType("[Ljava/lang/Object;"));
FunctionCodegen.endVisit(mv, "toArray", myClass); FunctionCodegen.endVisit(mv, "toArray", myClass);
@@ -534,7 +534,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.load(0, classAsmType); iv.load(0, classAsmType);
iv.load(1, Type.getObjectType("[Ljava/lang/Object;")); iv.load(1, Type.getObjectType("[Ljava/lang/Object;"));
iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray", "(Ljava/util/Collection;[Ljava/lang/Object;)[Ljava/lang/Object;"); iv.invokestatic("kotlin/jvm/internal/CollectionToArray", "toArray",
"(Ljava/util/Collection;[Ljava/lang/Object;)[Ljava/lang/Object;", false);
iv.areturn(Type.getObjectType("[Ljava/lang/Object;")); iv.areturn(Type.getObjectType("[Ljava/lang/Object;"));
FunctionCodegen.endVisit(mv, "toArray", myClass); FunctionCodegen.endVisit(mv, "toArray", myClass);
@@ -673,10 +674,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (asmType.getSort() == Type.ARRAY) { if (asmType.getSort() == Type.ARRAY) {
Type elementType = correctElementType(asmType); Type elementType = correctElementType(asmType);
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) { if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
iv.invokestatic("java/util/Arrays", "equals", "([Ljava/lang/Object;[Ljava/lang/Object;)Z"); iv.invokestatic("java/util/Arrays", "equals", "([Ljava/lang/Object;[Ljava/lang/Object;)Z", false);
} }
else { else {
iv.invokestatic("java/util/Arrays", "equals", "([" + elementType.getDescriptor() + "[" + elementType.getDescriptor() + ")Z"); iv.invokestatic("java/util/Arrays", "equals",
"([" + elementType.getDescriptor() + "[" + elementType.getDescriptor() + ")Z", false);
} }
} }
else { else {
@@ -770,7 +772,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
first = false; first = false;
} }
else { else {
iv.aconst(", " + propertyDescriptor.getName().asString()+"="); iv.aconst(", " + propertyDescriptor.getName().asString() + "=");
} }
genInvokeAppendMethod(iv, JAVA_STRING_TYPE); genInvokeAppendMethod(iv, JAVA_STRING_TYPE);
@@ -779,12 +781,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (type.getSort() == Type.ARRAY) { if (type.getSort() == Type.ARRAY) {
Type elementType = correctElementType(type); Type elementType = correctElementType(type);
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) { if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
iv.invokestatic("java/util/Arrays", "toString", "([Ljava/lang/Object;)Ljava/lang/String;"); iv.invokestatic("java/util/Arrays", "toString", "([Ljava/lang/Object;)Ljava/lang/String;", false);
type = JAVA_STRING_TYPE; type = JAVA_STRING_TYPE;
} }
else { else {
if (elementType.getSort() != Type.CHAR) { if (elementType.getSort() != Type.CHAR) {
iv.invokestatic("java/util/Arrays", "toString", "(" + type.getDescriptor() + ")Ljava/lang/String;"); iv.invokestatic("java/util/Arrays", "toString", "(" + type.getDescriptor() + ")Ljava/lang/String;", false);
type = JAVA_STRING_TYPE; type = JAVA_STRING_TYPE;
} }
} }
@@ -795,7 +797,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.aconst(")"); iv.aconst(")");
genInvokeAppendMethod(iv, JAVA_STRING_TYPE); genInvokeAppendMethod(iv, JAVA_STRING_TYPE);
iv.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;"); iv.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false);
iv.areturn(JAVA_STRING_TYPE); iv.areturn(JAVA_STRING_TYPE);
FunctionCodegen.endVisit(mv, "toString", myClass); FunctionCodegen.endVisit(mv, "toString", myClass);
@@ -812,7 +814,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
else { else {
//noinspection ConstantConditions //noinspection ConstantConditions
Method method = typeMapper.mapSignature(propertyDescriptor.getGetter()).getAsmMethod(); Method method = typeMapper.mapSignature(propertyDescriptor.getGetter()).getAsmMethod();
iv.invokevirtual(classAsmType.getInternalName(), method.getName(), method.getDescriptor()); iv.invokevirtual(classAsmType.getInternalName(), method.getName(), method.getDescriptor(), false);
return method.getReturnType(); return method.getReturnType();
} }
} }
@@ -833,7 +835,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (!componentType.equals(Type.VOID_TYPE)) { if (!componentType.equals(Type.VOID_TYPE)) {
iv.load(0, classAsmType); iv.load(0, classAsmType);
String desc = "()" + componentType.getDescriptor(); String desc = "()" + componentType.getDescriptor();
iv.invokevirtual(classAsmType.getInternalName(), PropertyCodegen.getterName(parameter.getName()), desc); iv.invokevirtual(classAsmType.getInternalName(), PropertyCodegen.getterName(parameter.getName()), desc, false);
} }
iv.areturn(componentType); iv.areturn(componentType);
} }
@@ -884,7 +886,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
} }
Method constructorAsmMethod = typeMapper.mapSignature(constructor).getAsmMethod(); Method constructorAsmMethod = typeMapper.mapSignature(constructor).getAsmMethod();
iv.invokespecial(thisDescriptorType.getInternalName(), "<init>", constructorAsmMethod.getDescriptor()); iv.invokespecial(thisDescriptorType.getInternalName(), "<init>", constructorAsmMethod.getDescriptor(), false);
iv.areturn(thisDescriptorType); iv.areturn(thisDescriptorType);
} }
@@ -1260,10 +1262,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (descriptor.getKind() == ClassKind.ENUM_CLASS || descriptor.getKind() == ClassKind.ENUM_ENTRY) { if (descriptor.getKind() == ClassKind.ENUM_CLASS || descriptor.getKind() == ClassKind.ENUM_ENTRY) {
iv.load(1, JAVA_STRING_TYPE); iv.load(1, JAVA_STRING_TYPE);
iv.load(2, Type.INT_TYPE); iv.load(2, Type.INT_TYPE);
iv.invokespecial(superClassAsmType.getInternalName(), "<init>", "(Ljava/lang/String;I)V"); iv.invokespecial(superClassAsmType.getInternalName(), "<init>", "(Ljava/lang/String;I)V", false);
} }
else { else {
iv.invokespecial(superClassAsmType.getInternalName(), "<init>", "()V"); iv.invokespecial(superClassAsmType.getInternalName(), "<init>", "()V", false);
} }
} }
@@ -1529,7 +1531,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.invokespecial("java/lang/Object", "clone", "()Ljava/lang/Object;", false); iv.invokespecial("java/lang/Object", "clone", "()Ljava/lang/Object;", false);
} }
else { else {
iv.invokestatic(traitImplType.getInternalName(), traitMethod.getName(), traitMethod.getDescriptor()); iv.invokestatic(traitImplType.getInternalName(), traitMethod.getName(), traitMethod.getDescriptor(), false);
} }
Type returnType = signature.getReturnType(); Type returnType = signature.getReturnType();
@@ -1706,7 +1708,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
codegen.invokeMethodWithArguments(method, resolvedCall, StackValue.none()); codegen.invokeMethodWithArguments(method, resolvedCall, StackValue.none());
} }
else { else {
iv.invokespecial(implClass.getInternalName(), "<init>", "(Ljava/lang/String;I)V"); iv.invokespecial(implClass.getInternalName(), "<init>", "(Ljava/lang/String;I)V", false);
} }
iv.dup(); iv.dup();
@@ -366,7 +366,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
iv.anew(PROPERTY_METADATA_IMPL_TYPE); iv.anew(PROPERTY_METADATA_IMPL_TYPE);
iv.dup(); iv.dup();
iv.visitLdcInsn(property.getName().asString()); iv.visitLdcInsn(property.getName().asString());
iv.invokespecial(PROPERTY_METADATA_IMPL_TYPE.getInternalName(), "<init>", "(Ljava/lang/String;)V"); iv.invokespecial(PROPERTY_METADATA_IMPL_TYPE.getInternalName(), "<init>", "(Ljava/lang/String;)V", false);
iv.astore(PROPERTY_METADATA_IMPL_TYPE); iv.astore(PROPERTY_METADATA_IMPL_TYPE);
} }
@@ -122,7 +122,7 @@ public class SamWrapperCodegen {
// super constructor // super constructor
iv.load(0, OBJECT_TYPE); iv.load(0, OBJECT_TYPE);
iv.invokespecial(OBJECT_TYPE.getInternalName(), "<init>", "()V"); iv.invokespecial(OBJECT_TYPE.getInternalName(), "<init>", "()V", false);
// save parameter to field // save parameter to field
iv.load(0, OBJECT_TYPE); iv.load(0, OBJECT_TYPE);
@@ -142,7 +142,7 @@ public class ScriptCodegen extends MemberCodegen<JetScript> {
assert classType != null; assert classType != null;
instructionAdapter.load(0, classType); instructionAdapter.load(0, classType);
instructionAdapter.invokespecial("java/lang/Object", "<init>", "()V"); instructionAdapter.invokespecial("java/lang/Object", "<init>", "()V", false);
instructionAdapter.load(0, classType); instructionAdapter.load(0, classType);
@@ -162,57 +162,57 @@ public abstract class StackValue {
private static void box(Type type, Type toType, InstructionAdapter v) { private static void box(Type type, Type toType, InstructionAdapter v) {
if (type == Type.BYTE_TYPE || toType.getInternalName().equals(NULLABLE_BYTE_TYPE_NAME) && type == Type.INT_TYPE) { if (type == Type.BYTE_TYPE || toType.getInternalName().equals(NULLABLE_BYTE_TYPE_NAME) && type == Type.INT_TYPE) {
v.cast(type, Type.BYTE_TYPE); v.cast(type, Type.BYTE_TYPE);
v.invokestatic(NULLABLE_BYTE_TYPE_NAME, "valueOf", "(B)L" + NULLABLE_BYTE_TYPE_NAME + ";"); v.invokestatic(NULLABLE_BYTE_TYPE_NAME, "valueOf", "(B)L" + NULLABLE_BYTE_TYPE_NAME + ";", false);
} }
else if (type == Type.SHORT_TYPE || toType.getInternalName().equals(NULLABLE_SHORT_TYPE_NAME) && type == Type.INT_TYPE) { else if (type == Type.SHORT_TYPE || toType.getInternalName().equals(NULLABLE_SHORT_TYPE_NAME) && type == Type.INT_TYPE) {
v.cast(type, Type.SHORT_TYPE); v.cast(type, Type.SHORT_TYPE);
v.invokestatic(NULLABLE_SHORT_TYPE_NAME, "valueOf", "(S)L" + NULLABLE_SHORT_TYPE_NAME + ";"); v.invokestatic(NULLABLE_SHORT_TYPE_NAME, "valueOf", "(S)L" + NULLABLE_SHORT_TYPE_NAME + ";", false);
} }
else if (type == Type.LONG_TYPE || toType.getInternalName().equals(NULLABLE_LONG_TYPE_NAME) && type == Type.INT_TYPE) { else if (type == Type.LONG_TYPE || toType.getInternalName().equals(NULLABLE_LONG_TYPE_NAME) && type == Type.INT_TYPE) {
v.cast(type, Type.LONG_TYPE); v.cast(type, Type.LONG_TYPE);
v.invokestatic(NULLABLE_LONG_TYPE_NAME, "valueOf", "(J)L" + NULLABLE_LONG_TYPE_NAME +";"); v.invokestatic(NULLABLE_LONG_TYPE_NAME, "valueOf", "(J)L" + NULLABLE_LONG_TYPE_NAME + ";", false);
} }
else if (type == Type.INT_TYPE) { else if (type == Type.INT_TYPE) {
v.invokestatic("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;"); v.invokestatic("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false);
} }
else if (type == Type.BOOLEAN_TYPE) { else if (type == Type.BOOLEAN_TYPE) {
v.invokestatic("java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;"); v.invokestatic("java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false);
} }
else if (type == Type.CHAR_TYPE) { else if (type == Type.CHAR_TYPE) {
v.invokestatic("java/lang/Character", "valueOf", "(C)Ljava/lang/Character;"); v.invokestatic("java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false);
} }
else if (type == Type.FLOAT_TYPE) { else if (type == Type.FLOAT_TYPE) {
v.invokestatic("java/lang/Float", "valueOf", "(F)Ljava/lang/Float;"); v.invokestatic("java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false);
} }
else if (type == Type.DOUBLE_TYPE) { else if (type == Type.DOUBLE_TYPE) {
v.invokestatic("java/lang/Double", "valueOf", "(D)Ljava/lang/Double;"); v.invokestatic("java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
} }
} }
private static void unbox(Type type, InstructionAdapter v) { private static void unbox(Type type, InstructionAdapter v) {
if (type == Type.INT_TYPE) { if (type == Type.INT_TYPE) {
v.invokevirtual("java/lang/Number", "intValue", "()I"); v.invokevirtual("java/lang/Number", "intValue", "()I", false);
} }
else if (type == Type.BOOLEAN_TYPE) { else if (type == Type.BOOLEAN_TYPE) {
v.invokevirtual("java/lang/Boolean", "booleanValue", "()Z"); v.invokevirtual("java/lang/Boolean", "booleanValue", "()Z", false);
} }
else if (type == Type.CHAR_TYPE) { else if (type == Type.CHAR_TYPE) {
v.invokevirtual("java/lang/Character", "charValue", "()C"); v.invokevirtual("java/lang/Character", "charValue", "()C", false);
} }
else if (type == Type.SHORT_TYPE) { else if (type == Type.SHORT_TYPE) {
v.invokevirtual("java/lang/Number", "shortValue", "()S"); v.invokevirtual("java/lang/Number", "shortValue", "()S", false);
} }
else if (type == Type.LONG_TYPE) { else if (type == Type.LONG_TYPE) {
v.invokevirtual("java/lang/Number", "longValue", "()J"); v.invokevirtual("java/lang/Number", "longValue", "()J", false);
} }
else if (type == Type.BYTE_TYPE) { else if (type == Type.BYTE_TYPE) {
v.invokevirtual("java/lang/Number", "byteValue", "()B"); v.invokevirtual("java/lang/Number", "byteValue", "()B", false);
} }
else if (type == Type.FLOAT_TYPE) { else if (type == Type.FLOAT_TYPE) {
v.invokevirtual("java/lang/Number", "floatValue", "()F"); v.invokevirtual("java/lang/Number", "floatValue", "()F", false);
} }
else if (type == Type.DOUBLE_TYPE) { else if (type == Type.DOUBLE_TYPE) {
v.invokevirtual("java/lang/Number", "doubleValue", "()D"); v.invokevirtual("java/lang/Number", "doubleValue", "()D", false);
} }
} }
@@ -852,9 +852,8 @@ public abstract class StackValue {
coerceTo(type, v); coerceTo(type, v);
} }
else { else {
Method method = getter.getAsmMethod(); getter.invokeWithoutAssertions(v);
v.visitMethodInsn(getter.getInvokeOpcode(), getter.getOwner().getInternalName(), method.getName(), method.getDescriptor()); coerce(getter.getAsmMethod().getReturnType(), type, v);
coerce(method.getReturnType(), type, v);
} }
} }
@@ -866,8 +865,7 @@ public abstract class StackValue {
v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, methodOwner.getInternalName(), fieldName, this.type.getDescriptor()); v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, methodOwner.getInternalName(), fieldName, this.type.getDescriptor());
} }
else { else {
Method method = setter.getAsmMethod(); setter.invokeWithoutAssertions(v);
v.visitMethodInsn(setter.getInvokeOpcode(), setter.getOwner().getInternalName(), method.getName(), method.getDescriptor());
} }
} }
@@ -18,16 +18,16 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
import static org.jetbrains.org.objectweb.asm.Type.INT_TYPE;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.INT_RANGE_TYPE; import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.INT_RANGE_TYPE;
import static org.jetbrains.org.objectweb.asm.Type.INT_TYPE;
public class ArrayIndices extends IntrinsicMethod { public class ArrayIndices extends IntrinsicMethod {
@NotNull @NotNull
@@ -42,7 +42,7 @@ public class ArrayIndices extends IntrinsicMethod {
) { ) {
receiver.put(receiver.type, v); receiver.put(receiver.type, v);
v.arraylength(); v.arraylength();
v.invokestatic("kotlin/jvm/internal/Intrinsics", "arrayIndices", Type.getMethodDescriptor(INT_RANGE_TYPE, INT_TYPE)); v.invokestatic("kotlin/jvm/internal/Intrinsics", "arrayIndices", Type.getMethodDescriptor(INT_RANGE_TYPE, INT_TYPE), false);
return INT_RANGE_TYPE; return INT_RANGE_TYPE;
} }
} }
@@ -18,8 +18,6 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
@@ -32,6 +30,8 @@ import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lang.types.lang.PrimitiveType; import org.jetbrains.jet.lang.types.lang.PrimitiveType;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -59,7 +59,7 @@ public class ArrayIterator extends IntrinsicMethod {
assert funDescriptor != null; assert funDescriptor != null;
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal(); ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
if (containingDeclaration.equals(KotlinBuiltIns.getInstance().getArray())) { if (containingDeclaration.equals(KotlinBuiltIns.getInstance().getArray())) {
v.invokestatic("kotlin/jvm/internal/InternalPackage", "iterator", "([Ljava/lang/Object;)Ljava/util/Iterator;"); v.invokestatic("kotlin/jvm/internal/InternalPackage", "iterator", "([Ljava/lang/Object;)Ljava/util/Iterator;", false);
return getType(Iterator.class); return getType(Iterator.class);
} }
@@ -70,7 +70,7 @@ public class ArrayIterator extends IntrinsicMethod {
FqName fqName = new FqName(BUILT_INS_PACKAGE_FQ_NAME + "." + primitiveType.getTypeName() + "Iterator"); FqName fqName = new FqName(BUILT_INS_PACKAGE_FQ_NAME + "." + primitiveType.getTypeName() + "Iterator");
String iteratorDesc = asmDescByFqNameWithoutInnerClasses(fqName); String iteratorDesc = asmDescByFqNameWithoutInnerClasses(fqName);
String methodSignature = "([" + asmTypeForPrimitive(jvmPrimitiveType) + ")" + iteratorDesc; String methodSignature = "([" + asmTypeForPrimitive(jvmPrimitiveType) + ")" + iteratorDesc;
v.invokestatic("kotlin/jvm/internal/InternalPackage", "iterator", methodSignature); v.invokestatic("kotlin/jvm/internal/InternalPackage", "iterator", methodSignature, false);
return Type.getType(iteratorDesc); return Type.getType(iteratorDesc);
} }
} }
@@ -19,11 +19,11 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -58,16 +58,16 @@ public class CompareTo extends IntrinsicMethod {
codegen.gen(argument, type); codegen.gen(argument, type);
if (type == Type.INT_TYPE) { if (type == Type.INT_TYPE) {
v.invokestatic("kotlin/jvm/internal/Intrinsics", "compare", "(II)I"); v.invokestatic("kotlin/jvm/internal/Intrinsics", "compare", "(II)I", false);
} }
else if (type == Type.LONG_TYPE) { else if (type == Type.LONG_TYPE) {
v.invokestatic("kotlin/jvm/internal/Intrinsics", "compare", "(JJ)I"); v.invokestatic("kotlin/jvm/internal/Intrinsics", "compare", "(JJ)I", false);
} }
else if (type == Type.FLOAT_TYPE) { else if (type == Type.FLOAT_TYPE) {
v.invokestatic("java/lang/Float", "compare", "(FF)I"); v.invokestatic("java/lang/Float", "compare", "(FF)I", false);
} }
else if (type == Type.DOUBLE_TYPE) { else if (type == Type.DOUBLE_TYPE) {
v.invokestatic("java/lang/Double", "compare", "(DD)I"); v.invokestatic("java/lang/Double", "compare", "(DD)I", false);
} }
else { else {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@@ -18,12 +18,12 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants; import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -42,20 +42,22 @@ public class Concat extends IntrinsicMethod {
List<JetExpression> arguments, List<JetExpression> arguments,
StackValue receiver StackValue receiver
) { ) {
if (receiver == null || receiver == StackValue.none()) { // LHS + RHS if (receiver == null || receiver == StackValue.none()) {
// LHS + RHS
genStringBuilderConstructor(v); genStringBuilderConstructor(v);
codegen.invokeAppend(arguments.get(0)); // StringBuilder(LHS) codegen.invokeAppend(arguments.get(0));
codegen.invokeAppend(arguments.get(1)); codegen.invokeAppend(arguments.get(1));
} }
else { // LHS.plus(RHS) else {
// LHS.plus(RHS)
receiver.put(AsmTypeConstants.OBJECT_TYPE, v); receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
genStringBuilderConstructor(v); genStringBuilderConstructor(v);
v.swap(); // StringBuilder LHS v.swap();
genInvokeAppendMethod(v, returnType); // StringBuilder(LHS) genInvokeAppendMethod(v, returnType);
codegen.invokeAppend(arguments.get(0)); codegen.invokeAppend(arguments.get(0));
} }
v.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;"); v.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false);
return JAVA_STRING_TYPE; return JAVA_STRING_TYPE;
} }
} }
@@ -19,11 +19,11 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -42,7 +42,7 @@ public class EnumValueOf extends IntrinsicMethod {
) { ) {
assert arguments != null; assert arguments != null;
codegen.gen(arguments.get(0), JAVA_STRING_TYPE); codegen.gen(arguments.get(0), JAVA_STRING_TYPE);
v.invokestatic(returnType.getInternalName(), "valueOf", "(Ljava/lang/String;)" + returnType.getDescriptor()); v.invokestatic(returnType.getInternalName(), "valueOf", "(Ljava/lang/String;)" + returnType.getDescriptor(), false);
return returnType; return returnType;
} }
} }
@@ -19,11 +19,11 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -38,7 +38,7 @@ public class EnumValues extends IntrinsicMethod {
@Nullable List<JetExpression> arguments, @Nullable List<JetExpression> arguments,
StackValue receiver StackValue receiver
) { ) {
v.invokestatic(returnType.getElementType().getInternalName(), "values", "()" + returnType); v.invokestatic(returnType.getElementType().getInternalName(), "values", "()" + returnType, false);
return returnType; return returnType;
} }
} }
@@ -18,12 +18,12 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants; import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -69,7 +69,7 @@ public class IteratorNext extends IntrinsicMethod {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
receiver.put(AsmTypeConstants.OBJECT_TYPE, v); receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
v.invokevirtual(BUILT_INS_PACKAGE_FQ_NAME + "/" + name + "Iterator", "next" + name, "()" + returnType.getDescriptor()); v.invokevirtual(BUILT_INS_PACKAGE_FQ_NAME + "/" + name + "Iterator", "next" + name, "()" + returnType.getDescriptor(), false);
return returnType; return returnType;
} }
} }
@@ -19,11 +19,11 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -48,7 +48,7 @@ public class JavaClassProperty extends IntrinsicMethod {
} }
else { else {
receiver.put(type, v); receiver.put(type, v);
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;"); v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;", false);
} }
return getType(Class.class); return getType(Class.class);
@@ -18,12 +18,12 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetBinaryExpression; import org.jetbrains.jet.lang.psi.JetBinaryExpression;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -58,7 +58,7 @@ public class RangeTo extends IntrinsicMethod {
codegen.gen(expression.getRight(), type); codegen.gen(expression.getRight(), type);
} }
v.invokespecial(returnType.getInternalName(), "<init>", Type.getMethodDescriptor(Type.VOID_TYPE, type, type)); v.invokespecial(returnType.getInternalName(), "<init>", Type.getMethodDescriptor(Type.VOID_TYPE, type, type), false);
return returnType; return returnType;
} }
@@ -18,11 +18,11 @@ package org.jetbrains.jet.codegen.intrinsics;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.ExpressionCodegen; import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue; import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List; import java.util.List;
@@ -48,7 +48,7 @@ public class StringPlus extends IntrinsicMethod {
receiver.put(JAVA_STRING_TYPE, v); receiver.put(JAVA_STRING_TYPE, v);
codegen.gen(arguments.get(0)).put(OBJECT_TYPE, v); codegen.gen(arguments.get(0)).put(OBJECT_TYPE, v);
} }
v.invokestatic("kotlin/jvm/internal/Intrinsics", "stringPlus", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;"); v.invokestatic("kotlin/jvm/internal/Intrinsics", "stringPlus", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;", false);
return JAVA_STRING_TYPE; return JAVA_STRING_TYPE;
} }
} }
@@ -16,11 +16,11 @@
package org.jetbrains.jet.preloading.instrumentation; package org.jetbrains.jet.preloading.instrumentation;
import org.jetbrains.jet.preloading.instrumentation.annotations.*;
import org.jetbrains.org.objectweb.asm.*; import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.util.Textifier; import org.jetbrains.org.objectweb.asm.util.Textifier;
import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor; import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor;
import org.jetbrains.jet.preloading.instrumentation.annotations.*;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@@ -580,7 +580,7 @@ public class InterceptionInstrumenter {
private static void box(InstructionAdapter ia, Type from, Class<?> boxedClass) { private static void box(InstructionAdapter ia, Type from, Class<?> boxedClass) {
Type boxedType = Type.getType(boxedClass); Type boxedType = Type.getType(boxedClass);
ia.invokestatic(boxedType.getInternalName(), "valueOf", "(" + from.getDescriptor() + ")" + boxedType.getDescriptor()); ia.invokestatic(boxedType.getInternalName(), "valueOf", "(" + from.getDescriptor() + ")" + boxedType.getDescriptor(), false);
} }
public void dump(PrintStream out) { public void dump(PrintStream out) {