AsmTypeConstants introduced
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.asm4.Type;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class AsmTypeConstants {
|
||||
public static final Type OBJECT_TYPE = Type.getType(Object.class);
|
||||
public static final Type JAVA_NUMBER_TYPE = Type.getType(Number.class);
|
||||
public static final Type JAVA_STRING_BUILDER_TYPE = Type.getType(StringBuilder.class);
|
||||
public static final Type JAVA_STRING_TYPE = Type.getType(String.class);
|
||||
public static final Type JAVA_THROWABLE_TYPE = Type.getType(Throwable.class);
|
||||
public static final Type JAVA_CLASS_TYPE = Type.getType(Class.class);
|
||||
public static final Type JAVA_BOOLEAN_TYPE = Type.getType(Boolean.class);
|
||||
public static final Type JAVA_ARRAY_GENERIC_TYPE = Type.getType(Object[].class);
|
||||
public static final Type JAVA_CHAR_SEQUENCE_TYPE = Type.getType(CharSequence.class);
|
||||
public static final Type JAVA_COMPARABLE_TYPE = Type.getType(Comparable.class);
|
||||
public static final Type JAVA_ENUM_TYPE = Type.getType(Enum.class);
|
||||
public static final Type JAVA_ANNOTATION_TYPE = Type.getType(Annotation.class);
|
||||
public static final Type JAVA_ITERATOR_TYPE = Type.getType(Iterator.class);
|
||||
public static final Type JAVA_ITERABLE_TYPE = Type.getType(Iterable.class);
|
||||
|
||||
public static final Type JET_NOTHING_TYPE = Type.getObjectType("jet/Nothing");
|
||||
public static final Type JET_TUPLE0_TYPE = Type.getObjectType("jet/Tuple0");
|
||||
public static final Type JET_FUNCTION0_TYPE = Type.getObjectType("jet/Function0");
|
||||
public static final Type JET_FUNCTION1_TYPE = Type.getObjectType("jet/Function1");
|
||||
public static final Type JET_ITERATOR_TYPE = Type.getObjectType("jet/Iterator");
|
||||
public static final Type JET_INT_RANGE_TYPE = Type.getObjectType("jet/IntRange");
|
||||
public static final Type JET_SHARED_VAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Object");
|
||||
public static final Type JET_SHARED_INT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Int");
|
||||
public static final Type JET_SHARED_DOUBLE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Double");
|
||||
public static final Type JET_SHARED_FLOAT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Float");
|
||||
public static final Type JET_SHARED_BYTE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Byte");
|
||||
public static final Type JET_SHARED_SHORT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Short");
|
||||
public static final Type JET_SHARED_CHAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Char");
|
||||
public static final Type JET_SHARED_LONG_TYPE = Type.getObjectType("jet/runtime/SharedVar$Long");
|
||||
public static final Type JET_SHARED_BOOLEAN_TYPE = Type.getObjectType("jet/runtime/SharedVar$Boolean");
|
||||
|
||||
private AsmTypeConstants() {
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.classNameForAnonymousClass;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.isLocalNamedFun;
|
||||
@@ -192,24 +193,24 @@ public class ClosureCodegen {
|
||||
final ReceiverDescriptor receiver = funDescriptor.getReceiverParameter();
|
||||
int count = 1;
|
||||
if (receiver.exists()) {
|
||||
StackValue.local(count, JetTypeMapper.OBJECT_TYPE).put(JetTypeMapper.OBJECT_TYPE, iv);
|
||||
StackValue.onStack(JetTypeMapper.OBJECT_TYPE)
|
||||
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
StackValue.onStack(OBJECT_TYPE)
|
||||
.upcast(typeMapper.mapType(receiver.getType(), MapTypeMode.VALUE), iv);
|
||||
count++;
|
||||
}
|
||||
|
||||
final List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
|
||||
for (ValueParameterDescriptor param : params) {
|
||||
StackValue.local(count, JetTypeMapper.OBJECT_TYPE).put(JetTypeMapper.OBJECT_TYPE, iv);
|
||||
StackValue.onStack(JetTypeMapper.OBJECT_TYPE)
|
||||
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
StackValue.onStack(OBJECT_TYPE)
|
||||
.upcast(typeMapper.mapType(param.getType(), MapTypeMode.VALUE), iv);
|
||||
count++;
|
||||
}
|
||||
|
||||
iv.invokevirtual(className, "invoke", delegate.getDescriptor());
|
||||
StackValue.onStack(delegate.getReturnType()).put(JetTypeMapper.OBJECT_TYPE, iv);
|
||||
StackValue.onStack(delegate.getReturnType()).put(OBJECT_TYPE, iv);
|
||||
|
||||
iv.areturn(JetTypeMapper.OBJECT_TYPE);
|
||||
iv.areturn(OBJECT_TYPE);
|
||||
|
||||
FunctionCodegen.endVisit(mv, "bridge", fun);
|
||||
}
|
||||
@@ -240,7 +241,7 @@ public class ClosureCodegen {
|
||||
|
||||
int k = 1;
|
||||
for (int i = 0; i != argTypes.length; ++i) {
|
||||
StackValue.local(0, JetTypeMapper.OBJECT_TYPE).put(JetTypeMapper.OBJECT_TYPE, iv);
|
||||
StackValue.local(0, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
final Pair<String, Type> nameAndType = args.get(i);
|
||||
final Type type = nameAndType.second;
|
||||
StackValue.local(k, type).put(type, iv);
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -161,14 +162,14 @@ public class CodegenUtil {
|
||||
|
||||
for (int i = 0; i < paramCount; ++i) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
|
||||
signatureWriter.writeAsmType(JetTypeMapper.OBJECT_TYPE, true);
|
||||
signatureWriter.writeAsmType(OBJECT_TYPE, true);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
signatureWriter.writeParametersEnd();
|
||||
|
||||
signatureWriter.writeReturnType();
|
||||
signatureWriter.writeAsmType(JetTypeMapper.OBJECT_TYPE, true);
|
||||
signatureWriter.writeAsmType(OBJECT_TYPE, true);
|
||||
signatureWriter.writeReturnTypeEnd();
|
||||
|
||||
return signatureWriter.makeJvmMethodSignature("invoke");
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
@@ -34,13 +36,13 @@ public class ConstructorFrameMap extends FrameMap {
|
||||
private int myOuterThisIndex = -1;
|
||||
|
||||
public ConstructorFrameMap(CallableMethod callableMethod, @Nullable ConstructorDescriptor descriptor) {
|
||||
enterTemp(JetTypeMapper.OBJECT_TYPE); // this
|
||||
enterTemp(OBJECT_TYPE); // this
|
||||
|
||||
final List<JvmMethodParameterSignature> parameterTypes = callableMethod.getSignature().getKotlinParameterTypes();
|
||||
if (parameterTypes != null) {
|
||||
for (JvmMethodParameterSignature parameterType : parameterTypes) {
|
||||
if (parameterType.getKind() == JvmMethodParameterKind.OUTER) {
|
||||
myOuterThisIndex = enterTemp(JetTypeMapper.OBJECT_TYPE); // this0
|
||||
myOuterThisIndex = enterTemp(OBJECT_TYPE); // this0
|
||||
}
|
||||
else if (parameterType.getKind() != JvmMethodParameterKind.VALUE) {
|
||||
enterTemp(parameterType.getAsmType());
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.*;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.*;
|
||||
@@ -304,7 +305,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
if (isEmptyExpression(thenExpression)) {
|
||||
if (isEmptyExpression(elseExpression)) {
|
||||
if (!asmType.equals(JetTypeMapper.JET_TUPLE0_TYPE)) {
|
||||
if (!asmType.equals(JET_TUPLE0_TYPE)) {
|
||||
throw new CompilationException("Completely empty 'if' is expected to have Unit type", null, expression);
|
||||
}
|
||||
StackValue.putTuple0Instance(v);
|
||||
@@ -2060,7 +2061,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
v.dup();
|
||||
ValueArgument argument = arguments.get(i);
|
||||
if (argument.getSpreadElement() != null) {
|
||||
gen(argument.getArgumentExpression(), JetTypeMapper.OBJECT_TYPE);
|
||||
gen(argument.getArgumentExpression(), OBJECT_TYPE);
|
||||
v.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V");
|
||||
}
|
||||
else {
|
||||
@@ -2569,7 +2570,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
Type leftType = expressionType(left);
|
||||
Type rightType = expressionType(right);
|
||||
|
||||
if (leftType.equals(JetTypeMapper.JAVA_STRING_TYPE) && rightType.equals(JAVA_STRING_TYPE)) {
|
||||
if (leftType.equals(JAVA_STRING_TYPE) && rightType.equals(JAVA_STRING_TYPE)) {
|
||||
invokeAppend(left);
|
||||
invokeAppend(right);
|
||||
return;
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.isLocalFun;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescriptorToDeclaration;
|
||||
@@ -249,8 +250,8 @@ public class FunctionCodegen {
|
||||
else if (kind instanceof OwnerKind.DelegateKind) {
|
||||
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
dk.getDelegate().put(JetTypeMapper.OBJECT_TYPE, iv);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
dk.getDelegate().put(OBJECT_TYPE, iv);
|
||||
for (int i = 0; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
iv.load(i + 1, argType);
|
||||
@@ -498,7 +499,7 @@ public class FunctionCodegen {
|
||||
FrameMap frameMap = owner.prepareFrame(state.getInjector().getJetTypeMapper());
|
||||
|
||||
if (kind instanceof OwnerKind.StaticDelegateKind) {
|
||||
frameMap.leaveTemp(JetTypeMapper.OBJECT_TYPE);
|
||||
frameMap.leaveTemp(OBJECT_TYPE);
|
||||
}
|
||||
|
||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, jvmSignature.getReturnType(), owner, state);
|
||||
@@ -646,15 +647,15 @@ public class FunctionCodegen {
|
||||
Type[] argTypes = overridden.getArgumentTypes();
|
||||
Type[] originalArgTypes = jvmSignature.getArgumentTypes();
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
iv.load(reg, argType);
|
||||
if (argType.getSort() == Type.OBJECT) {
|
||||
StackValue.onStack(JetTypeMapper.OBJECT_TYPE).put(originalArgTypes[i], iv);
|
||||
StackValue.onStack(OBJECT_TYPE).put(originalArgTypes[i], iv);
|
||||
}
|
||||
else if (argType.getSort() == Type.ARRAY) {
|
||||
StackValue.onStack(JetTypeMapper.JAVA_ARRAY_GENERIC_TYPE).put(originalArgTypes[i], iv);
|
||||
StackValue.onStack(JAVA_ARRAY_GENERIC_TYPE).put(originalArgTypes[i], iv);
|
||||
}
|
||||
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
@@ -699,22 +700,22 @@ public class FunctionCodegen {
|
||||
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
iv.load(reg, argType);
|
||||
if (argType.getSort() == Type.OBJECT) {
|
||||
StackValue.onStack(JetTypeMapper.OBJECT_TYPE).put(method.getArgumentTypes()[i], iv);
|
||||
StackValue.onStack(OBJECT_TYPE).put(method.getArgumentTypes()[i], iv);
|
||||
}
|
||||
else if (argType.getSort() == Type.ARRAY) {
|
||||
StackValue.onStack(JetTypeMapper.JAVA_ARRAY_GENERIC_TYPE).put(method.getArgumentTypes()[i], iv);
|
||||
StackValue.onStack(JAVA_ARRAY_GENERIC_TYPE).put(method.getArgumentTypes()[i], iv);
|
||||
}
|
||||
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
reg += argType.getSize();
|
||||
}
|
||||
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
field.put(field.type, iv);
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) overriddenDescriptor.getContainingDeclaration();
|
||||
String internalName =
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.OBJECT_TYPE;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.eclosingClassDescriptor;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.enumEntryNeedSubclass;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescriptorToDeclaration;
|
||||
@@ -407,7 +407,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
for (int i = 1, reg = 1; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
iv.load(reg, argType);
|
||||
@@ -444,7 +444,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
if (original.getVisibility() == Visibilities.PRIVATE) {
|
||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), original.getName().getName(),
|
||||
originalMethod.getReturnType().getDescriptor());
|
||||
@@ -479,7 +479,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
Type[] argTypes = method.getArgumentTypes();
|
||||
for (int i = 1, reg = 1; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
@@ -642,7 +642,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
final String internalName = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName();
|
||||
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
|
||||
if (captureReceiver != null) {
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
final Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), MapTypeMode.IMPL);
|
||||
iv.load(1, asmType);
|
||||
iv.putfield(internalName, RECEIVER$0, asmType.getDescriptor());
|
||||
@@ -655,7 +655,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (sharedVarType == null) {
|
||||
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getType(), MapTypeMode.VALUE);
|
||||
}
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
iv.load(k, StackValue.refType(sharedVarType));
|
||||
k += StackValue.refType(sharedVarType).getSize();
|
||||
iv.putfield(internalName,
|
||||
@@ -705,7 +705,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
assert superType != null;
|
||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||
if (typeMapper.hasThis0(superClassDescriptor)) {
|
||||
iv.load(1, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(1, OBJECT_TYPE);
|
||||
parameterTypes.add(typeMapper.mapType(
|
||||
eclosingClassDescriptor(typeMapper.getBindingContext(), descriptor).getDefaultType(), MapTypeMode.VALUE));
|
||||
}
|
||||
@@ -718,7 +718,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void genSimpleSuperCall(InstructionAdapter iv) {
|
||||
iv.load(0, Type.getType("L" + superClass + ";"));
|
||||
if (descriptor.getKind() == ClassKind.ENUM_CLASS || descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
iv.load(1, JetTypeMapper.JAVA_STRING_TYPE);
|
||||
iv.load(1, AsmTypeConstants.JAVA_STRING_TYPE);
|
||||
iv.load(2, Type.INT_TYPE);
|
||||
iv.invokespecial(superClass, "<init>", "(Ljava/lang/String;I)V");
|
||||
}
|
||||
@@ -952,7 +952,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type[] argTypes = function.getArgumentTypes();
|
||||
List<Type> originalArgTypes = jvmSignature.getValueParameterTypes();
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
||||
Type argType = argTypes[i];
|
||||
iv.load(reg, argType);
|
||||
|
||||
@@ -54,30 +54,6 @@ import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDec
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class JetTypeMapper {
|
||||
public static final Type OBJECT_TYPE = Type.getType(Object.class);
|
||||
public static final Type JAVA_NUMBER_TYPE = Type.getType(Number.class);
|
||||
public static final Type JAVA_STRING_BUILDER_TYPE = Type.getType(StringBuilder.class);
|
||||
public static final Type JAVA_STRING_TYPE = Type.getType(String.class);
|
||||
public static final Type JAVA_THROWABLE_TYPE = Type.getType(Throwable.class);
|
||||
public static final Type JAVA_CLASS_TYPE = Type.getType(Class.class);
|
||||
public static final Type JAVA_BOOLEAN_TYPE = Type.getType(Boolean.class);
|
||||
public static final Type JAVA_ARRAY_GENERIC_TYPE = Type.getType(Object[].class);
|
||||
|
||||
public static final Type JET_NOTHING_TYPE = Type.getObjectType("jet/Nothing");
|
||||
public static final Type JET_TUPLE0_TYPE = Type.getObjectType("jet/Tuple0");
|
||||
public static final Type JET_FUNCTION0_TYPE = Type.getObjectType("jet/Function0");
|
||||
public static final Type JET_FUNCTION1_TYPE = Type.getObjectType("jet/Function1");
|
||||
public static final Type JET_ITERATOR_TYPE = Type.getObjectType("jet/Iterator");
|
||||
public static final Type JET_INT_RANGE_TYPE = Type.getObjectType("jet/IntRange");
|
||||
public static final Type JET_SHARED_VAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Object");
|
||||
public static final Type JET_SHARED_INT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Int");
|
||||
public static final Type JET_SHARED_DOUBLE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Double");
|
||||
public static final Type JET_SHARED_FLOAT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Float");
|
||||
public static final Type JET_SHARED_BYTE_TYPE = Type.getObjectType("jet/runtime/SharedVar$Byte");
|
||||
public static final Type JET_SHARED_SHORT_TYPE = Type.getObjectType("jet/runtime/SharedVar$Short");
|
||||
public static final Type JET_SHARED_CHAR_TYPE = Type.getObjectType("jet/runtime/SharedVar$Char");
|
||||
public static final Type JET_SHARED_LONG_TYPE = Type.getObjectType("jet/runtime/SharedVar$Long");
|
||||
public static final Type JET_SHARED_BOOLEAN_TYPE = Type.getObjectType("jet/runtime/SharedVar$Boolean");
|
||||
|
||||
private BindingContext bindingContext;
|
||||
private boolean mapBuiltinsToJava;
|
||||
@@ -256,7 +232,7 @@ public class JetTypeMapper {
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeNothing(true);
|
||||
}
|
||||
return OBJECT_TYPE;
|
||||
return AsmTypeConstants.OBJECT_TYPE;
|
||||
}
|
||||
return mapType(jetType, signatureVisitor, MapTypeMode.VALUE);
|
||||
}
|
||||
@@ -351,7 +327,7 @@ public class JetTypeMapper {
|
||||
r = Type.getType("[" + boxType(mapType(memberType, kind)).getDescriptor());
|
||||
}
|
||||
else {
|
||||
r = JAVA_ARRAY_GENERIC_TYPE;
|
||||
r = AsmTypeConstants.JAVA_ARRAY_GENERIC_TYPE;
|
||||
}
|
||||
checkValidType(r);
|
||||
return r;
|
||||
|
||||
@@ -33,11 +33,11 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
||||
import org.jetbrains.jet.lang.types.ref.ClassName;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
@@ -64,18 +64,18 @@ public class KotlinToJavaTypesMap {
|
||||
private void init() {
|
||||
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
|
||||
|
||||
register(JetStandardClasses.getAny(), Object.class);
|
||||
register(standardLibrary.getNumber(), Number.class);
|
||||
register(standardLibrary.getString(), String.class);
|
||||
register(standardLibrary.getThrowable(), Throwable.class);
|
||||
register(standardLibrary.getCharSequence(), CharSequence.class);
|
||||
register(standardLibrary.getComparable(), Comparable.class);
|
||||
register(standardLibrary.getEnum(), Enum.class);
|
||||
register(standardLibrary.getAnnotation(), Annotation.class);
|
||||
register(standardLibrary.getIterable(), Iterable.class);
|
||||
register(standardLibrary.getIterator(), Iterator.class);
|
||||
register(standardLibrary.getMutableIterable(), Iterable.class);
|
||||
register(standardLibrary.getMutableIterator(), Iterator.class);
|
||||
register(JetStandardClasses.getAny(), OBJECT_TYPE);
|
||||
register(standardLibrary.getNumber(), JAVA_NUMBER_TYPE);
|
||||
register(standardLibrary.getString(), JAVA_STRING_TYPE);
|
||||
register(standardLibrary.getThrowable(), JAVA_THROWABLE_TYPE);
|
||||
register(standardLibrary.getCharSequence(), JAVA_CHAR_SEQUENCE_TYPE);
|
||||
register(standardLibrary.getComparable(), JAVA_COMPARABLE_TYPE);
|
||||
register(standardLibrary.getEnum(), JAVA_ENUM_TYPE);
|
||||
register(standardLibrary.getAnnotation(), JAVA_ANNOTATION_TYPE);
|
||||
register(standardLibrary.getIterable(), JAVA_ITERABLE_TYPE);
|
||||
register(standardLibrary.getMutableIterable(), JAVA_ITERABLE_TYPE);
|
||||
register(standardLibrary.getIterator(), JAVA_ITERATOR_TYPE);
|
||||
register(standardLibrary.getMutableIterator(), JAVA_ITERATOR_TYPE);
|
||||
}
|
||||
|
||||
private void initPrimitives() {
|
||||
@@ -105,10 +105,6 @@ public class KotlinToJavaTypesMap {
|
||||
return asmTypes.get(className);
|
||||
}
|
||||
|
||||
private void register(@NotNull ClassDescriptor kotlinDescriptor, @NotNull Class<?> javaClass) {
|
||||
register(kotlinDescriptor, Type.getType(javaClass));
|
||||
}
|
||||
|
||||
private void register(@NotNull ClassDescriptor kotlinDescriptor, @NotNull Type javaType) {
|
||||
FqNameUnsafe fqName = DescriptorUtils.getFQName(kotlinDescriptor);
|
||||
ClassName className = new ClassName(fqName.toSafe(), kotlinDescriptor.getDefaultType().getArguments().size());
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
import java.util.BitSet;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenUtil.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||
|
||||
@@ -217,7 +218,7 @@ public class PropertyCodegen {
|
||||
else {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
if (kind != OwnerKind.NAMESPACE) {
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
}
|
||||
final Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||
|
||||
@@ -227,7 +228,7 @@ public class PropertyCodegen {
|
||||
|
||||
if (kind instanceof OwnerKind.DelegateKind) {
|
||||
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
|
||||
dk.getDelegate().put(JetTypeMapper.OBJECT_TYPE, iv);
|
||||
dk.getDelegate().put(OBJECT_TYPE, iv);
|
||||
iv.invokeinterface(dk.getOwnerClass(), getterName, descriptor);
|
||||
}
|
||||
else {
|
||||
@@ -321,7 +322,7 @@ public class PropertyCodegen {
|
||||
final Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||
int paramCode = 0;
|
||||
if (kind != OwnerKind.NAMESPACE) {
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
paramCode = 1;
|
||||
}
|
||||
|
||||
@@ -331,8 +332,8 @@ public class PropertyCodegen {
|
||||
|
||||
if (kind instanceof OwnerKind.DelegateKind) {
|
||||
OwnerKind.DelegateKind dk = (OwnerKind.DelegateKind) kind;
|
||||
iv.load(0, JetTypeMapper.OBJECT_TYPE);
|
||||
dk.getDelegate().put(JetTypeMapper.OBJECT_TYPE, iv);
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
dk.getDelegate().put(OBJECT_TYPE, iv);
|
||||
|
||||
iv.load(paramCode, type);
|
||||
iv.invokeinterface(dk.getOwnerClass(), setterName(propertyDescriptor.getName()), descriptor);
|
||||
|
||||
@@ -38,7 +38,7 @@ import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.OBJECT_TYPE;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.OBJECT_TYPE;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.OBJECT_TYPE;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -267,7 +267,7 @@ public abstract class StackValue {
|
||||
v.iconst(0);
|
||||
}
|
||||
}
|
||||
else if (toType.equals(JetTypeMapper.JET_TUPLE0_TYPE) && !fromType.equals(JetTypeMapper.JET_TUPLE0_TYPE)) {
|
||||
else if (toType.equals(JET_TUPLE0_TYPE) && !fromType.equals(JET_TUPLE0_TYPE)) {
|
||||
pop(fromType, v);
|
||||
putTuple0Instance(v);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ public abstract class StackValue {
|
||||
v.checkcast(JvmPrimitiveType.CHAR.getWrapper().getAsmType());
|
||||
}
|
||||
else {
|
||||
v.checkcast(JetTypeMapper.JAVA_NUMBER_TYPE);
|
||||
v.checkcast(JAVA_NUMBER_TYPE);
|
||||
}
|
||||
}
|
||||
unbox(toType, v);
|
||||
@@ -477,11 +477,11 @@ public abstract class StackValue {
|
||||
if (type == Type.VOID_TYPE) {
|
||||
return;
|
||||
}
|
||||
if (type.equals(JetTypeMapper.JET_TUPLE0_TYPE)) {
|
||||
if (type.equals(JET_TUPLE0_TYPE)) {
|
||||
putTuple0Instance(v);
|
||||
return;
|
||||
}
|
||||
if (type != Type.BOOLEAN_TYPE && !type.equals(OBJECT_TYPE) && !type.equals(JetTypeMapper.JAVA_BOOLEAN_TYPE)) {
|
||||
if (type != Type.BOOLEAN_TYPE && !type.equals(OBJECT_TYPE) && !type.equals(JAVA_BOOLEAN_TYPE)) {
|
||||
throw new UnsupportedOperationException("don't know how to put a compare as a non-boolean type " + type);
|
||||
}
|
||||
putAsBoolean(v);
|
||||
@@ -570,7 +570,7 @@ public abstract class StackValue {
|
||||
myOperand.put(type, v); // the operand will remove itself from the stack if needed
|
||||
return;
|
||||
}
|
||||
if (type != Type.BOOLEAN_TYPE && !type.equals(OBJECT_TYPE) && !type.equals(JetTypeMapper.JAVA_BOOLEAN_TYPE)) {
|
||||
if (type != Type.BOOLEAN_TYPE && !type.equals(OBJECT_TYPE) && !type.equals(JAVA_BOOLEAN_TYPE)) {
|
||||
throw new UnsupportedOperationException("don't know how to put a compare as a non-boolean type");
|
||||
}
|
||||
putAsBoolean(v);
|
||||
@@ -1048,31 +1048,31 @@ public abstract class StackValue {
|
||||
switch (type.getSort()) {
|
||||
case Type.OBJECT:
|
||||
case Type.ARRAY:
|
||||
return JetTypeMapper.JET_SHARED_VAR_TYPE;
|
||||
return JET_SHARED_VAR_TYPE;
|
||||
|
||||
case Type.BYTE:
|
||||
return JetTypeMapper.JET_SHARED_BYTE_TYPE;
|
||||
return JET_SHARED_BYTE_TYPE;
|
||||
|
||||
case Type.SHORT:
|
||||
return JetTypeMapper.JET_SHARED_SHORT_TYPE;
|
||||
return JET_SHARED_SHORT_TYPE;
|
||||
|
||||
case Type.CHAR:
|
||||
return JetTypeMapper.JET_SHARED_CHAR_TYPE;
|
||||
return JET_SHARED_CHAR_TYPE;
|
||||
|
||||
case Type.INT:
|
||||
return JetTypeMapper.JET_SHARED_INT_TYPE;
|
||||
return JET_SHARED_INT_TYPE;
|
||||
|
||||
case Type.LONG:
|
||||
return JetTypeMapper.JET_SHARED_LONG_TYPE;
|
||||
return JET_SHARED_LONG_TYPE;
|
||||
|
||||
case Type.BOOLEAN:
|
||||
return JetTypeMapper.JET_SHARED_BOOLEAN_TYPE;
|
||||
return JET_SHARED_BOOLEAN_TYPE;
|
||||
|
||||
case Type.FLOAT:
|
||||
return JetTypeMapper.JET_SHARED_FLOAT_TYPE;
|
||||
return JET_SHARED_FLOAT_TYPE;
|
||||
|
||||
case Type.DOUBLE:
|
||||
return JetTypeMapper.JET_SHARED_DOUBLE_TYPE;
|
||||
return JET_SHARED_DOUBLE_TYPE;
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.OBJECT_TYPE;
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.CLASS_FOR_FUNCTION;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.FQN;
|
||||
|
||||
@@ -374,7 +374,7 @@ public abstract class CodegenContext {
|
||||
@Override
|
||||
public StackValue lookupInContext(DeclarationDescriptor d, @Nullable StackValue result, GenerationState state, boolean ignoreNoOuter) {
|
||||
if (getContextDescriptor() == d) {
|
||||
return StackValue.local(0, JetTypeMapper.OBJECT_TYPE);
|
||||
return StackValue.local(0, AsmTypeConstants.OBJECT_TYPE);
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,7 +39,7 @@ public class ArrayGet implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
Type type = JetTypeMapper.correctElementType(receiver.type);
|
||||
|
||||
codegen.gen(arguments.get(0), Type.INT_TYPE);
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,9 +36,9 @@ public class ArrayIndices implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.arraylength();
|
||||
v.invokestatic("jet/IntRange", "count", "(I)Ljet/IntRange;");
|
||||
return StackValue.onStack(JetTypeMapper.JET_INT_RANGE_TYPE);
|
||||
return StackValue.onStack(AsmTypeConstants.JET_INT_RANGE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
@@ -50,7 +47,7 @@ public class ArrayIterator implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
JetCallExpression call = (JetCallExpression) element;
|
||||
FunctionDescriptor funDescriptor = (FunctionDescriptor) codegen.getBindingContext()
|
||||
.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
|
||||
@@ -58,7 +55,7 @@ public class ArrayIterator implements IntrinsicMethod {
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
|
||||
if (containingDeclaration.equals(JetStandardLibrary.getInstance().getArray())) {
|
||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljava/util/Iterator;");
|
||||
return StackValue.onStack(JetTypeMapper.JET_ITERATOR_TYPE);
|
||||
return StackValue.onStack(AsmTypeConstants.JET_ITERATOR_TYPE);
|
||||
}
|
||||
else {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,7 +39,7 @@ public class ArraySet implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
Type type = JetTypeMapper.correctElementType(receiver.type);
|
||||
|
||||
codegen.gen(arguments.get(0), Type.INT_TYPE);
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,7 +39,7 @@ public class ArraySize implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.arraylength();
|
||||
|
||||
return StackValue.onStack(Type.INT_TYPE);
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -48,7 +45,7 @@ public class Concat implements IntrinsicMethod {
|
||||
codegen.invokeAppend(arguments.get(1));
|
||||
}
|
||||
else { // LHS.plus(RHS)
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
codegen.generateStringBuilderConstructor();
|
||||
v.swap(); // StringBuilder LHS
|
||||
codegen.invokeAppendMethod(expectedType); // StringBuilder(LHS)
|
||||
@@ -56,7 +53,7 @@ public class Concat implements IntrinsicMethod {
|
||||
}
|
||||
|
||||
v.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;");
|
||||
StackValue.onStack(JetTypeMapper.JAVA_STRING_TYPE).put(expectedType, v);
|
||||
StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE).put(expectedType, v);
|
||||
return StackValue.onStack(expectedType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,9 +37,9 @@ public class EnumName implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.invokevirtual("java/lang/Enum", "name", "()Ljava/lang/String;");
|
||||
StackValue.onStack(JetTypeMapper.JAVA_STRING_TYPE).put(expectedType, v);
|
||||
StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE).put(expectedType, v);
|
||||
return StackValue.onStack(expectedType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,7 +37,7 @@ public class EnumOrdinal implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.invokevirtual("java/lang/Enum", "ordinal", "()I");
|
||||
StackValue.onStack(Type.INT_TYPE).put(expectedType, v);
|
||||
return StackValue.onStack(expectedType);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class EnumValueOf implements IntrinsicMethod {
|
||||
Type type = state.getInjector().getJetTypeMapper().mapType(
|
||||
returnType, MapTypeMode.VALUE);
|
||||
assert arguments != null;
|
||||
codegen.gen(arguments.get(0), JetTypeMapper.JAVA_STRING_TYPE);
|
||||
codegen.gen(arguments.get(0), AsmTypeConstants.JAVA_STRING_TYPE);
|
||||
v.invokestatic(type.getInternalName(), "valueOf", "(Ljava/lang/String;)" + type.getDescriptor());
|
||||
StackValue.onStack(type).put(expectedType, v);
|
||||
return StackValue.onStack(expectedType);
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -50,7 +47,7 @@ public class Equals implements IntrinsicMethod {
|
||||
boolean leftNullable = true;
|
||||
JetExpression rightExpr;
|
||||
if (element instanceof JetCallExpression) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
JetCallExpression jetCallExpression = (JetCallExpression) element;
|
||||
JetExpression calleeExpression = jetCallExpression.getCalleeExpression();
|
||||
if (calleeExpression != null) {
|
||||
@@ -66,16 +63,16 @@ public class Equals implements IntrinsicMethod {
|
||||
JetType leftType = codegen.getBindingContext().get(BindingContext.EXPRESSION_TYPE, leftExpr);
|
||||
assert leftType != null;
|
||||
leftNullable = leftType.isNullable();
|
||||
codegen.gen(leftExpr).put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
codegen.gen(leftExpr).put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
rightExpr = arguments.get(1);
|
||||
}
|
||||
|
||||
JetType rightType = codegen.getBindingContext().get(BindingContext.EXPRESSION_TYPE, rightExpr);
|
||||
codegen.gen(rightExpr).put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
codegen.gen(rightExpr).put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
|
||||
assert rightType != null;
|
||||
return codegen
|
||||
.generateEqualsForExpressionsOnStack(JetTokens.EQEQ, JetTypeMapper.OBJECT_TYPE, JetTypeMapper.OBJECT_TYPE, leftNullable,
|
||||
.generateEqualsForExpressionsOnStack(JetTokens.EQEQ, AsmTypeConstants.OBJECT_TYPE, AsmTypeConstants.OBJECT_TYPE, leftNullable,
|
||||
rightType.isNullable());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.Opcodes;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -44,7 +41,7 @@ public class HashCode implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "hashCode", "()I");
|
||||
return StackValue.onStack(Type.INT_TYPE);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
@@ -31,6 +28,8 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmTypeConstants.*;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
@@ -46,15 +45,15 @@ public class IdentityEquals implements IntrinsicMethod {
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
if (element instanceof JetCallExpression) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
codegen.gen(arguments.get(0)).put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(OBJECT_TYPE, v);
|
||||
codegen.gen(arguments.get(0)).put(OBJECT_TYPE, v);
|
||||
}
|
||||
else {
|
||||
assert element instanceof JetBinaryExpression;
|
||||
JetBinaryExpression e = (JetBinaryExpression) element;
|
||||
codegen.gen(e.getLeft()).put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
codegen.gen(e.getRight()).put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
codegen.gen(e.getLeft()).put(OBJECT_TYPE, v);
|
||||
codegen.gen(e.getRight()).put(OBJECT_TYPE, v);
|
||||
}
|
||||
return StackValue.cmp(JetTokens.EQEQEQ, JetTypeMapper.OBJECT_TYPE);
|
||||
return StackValue.cmp(JetTokens.EQEQEQ, OBJECT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -70,7 +67,7 @@ public class IteratorNext implements IntrinsicMethod {
|
||||
else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.invokevirtual("jet/" + name + "Iterator", "next" + name, "()" + expectedType.getDescriptor());
|
||||
return StackValue.onStack(expectedType);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@ public class JavaClassFunction implements IntrinsicMethod {
|
||||
else {
|
||||
v.aconst(type);
|
||||
}
|
||||
return StackValue.onStack(JetTypeMapper.JAVA_CLASS_TYPE);
|
||||
return StackValue.onStack(AsmTypeConstants.JAVA_CLASS_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
|
||||
@@ -53,6 +50,6 @@ public class JavaClassProperty implements IntrinsicMethod {
|
||||
else {
|
||||
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;");
|
||||
}
|
||||
return StackValue.onStack(JetTypeMapper.JAVA_CLASS_TYPE);
|
||||
return StackValue.onStack(AsmTypeConstants.JAVA_CLASS_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -43,7 +40,7 @@ public class StringGetChar implements IntrinsicMethod {
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
if (receiver != null) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
}
|
||||
if (arguments != null) {
|
||||
codegen.gen(arguments.get(0)).put(Type.INT_TYPE, v);
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,7 +39,7 @@ public class StringLength implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.invokeinterface("java/lang/CharSequence", "length", "()I");
|
||||
return StackValue.onStack(Type.INT_TYPE);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -43,14 +40,14 @@ public class StringPlus implements IntrinsicMethod {
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
if (receiver == null || receiver == StackValue.none()) {
|
||||
codegen.gen(arguments.get(0)).put(JetTypeMapper.JAVA_STRING_TYPE, v);
|
||||
codegen.gen(arguments.get(1)).put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
codegen.gen(arguments.get(0)).put(AsmTypeConstants.JAVA_STRING_TYPE, v);
|
||||
codegen.gen(arguments.get(1)).put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
}
|
||||
else {
|
||||
receiver.put(JetTypeMapper.JAVA_STRING_TYPE, v);
|
||||
codegen.gen(arguments.get(0)).put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.JAVA_STRING_TYPE, v);
|
||||
codegen.gen(arguments.get(0)).put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
}
|
||||
v.invokestatic("jet/runtime/Intrinsics", "stringPlus", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
|
||||
return StackValue.onStack(JetTypeMapper.JAVA_STRING_TYPE);
|
||||
return StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
@@ -42,9 +39,9 @@ public class StupidSync implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
codegen.pushMethodArguments((JetCallExpression) element, Arrays.asList(JetTypeMapper.OBJECT_TYPE, JetTypeMapper.JET_FUNCTION0_TYPE));
|
||||
codegen.pushMethodArguments((JetCallExpression) element, Arrays.asList(AsmTypeConstants.OBJECT_TYPE, AsmTypeConstants.JET_FUNCTION0_TYPE));
|
||||
v.invokestatic("jet/runtime/Intrinsics", "stupidSync", "(Ljava/lang/Object;Ljet/Function0;)Ljava/lang/Object;");
|
||||
StackValue.onStack(JetTypeMapper.OBJECT_TYPE).put(expectedType, v);
|
||||
StackValue.onStack(AsmTypeConstants.OBJECT_TYPE).put(expectedType, v);
|
||||
return StackValue.onStack(expectedType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,8 +39,8 @@ public class ToString implements IntrinsicMethod {
|
||||
StackValue receiver,
|
||||
@NotNull GenerationState state
|
||||
) {
|
||||
receiver.put(JetTypeMapper.OBJECT_TYPE, v);
|
||||
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
|
||||
v.invokestatic("java/lang/String", "valueOf", "(Ljava/lang/Object;)Ljava/lang/String;");
|
||||
return StackValue.onStack(JetTypeMapper.JAVA_STRING_TYPE);
|
||||
return StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.asm4.commons.Method;
|
||||
import org.jetbrains.asm4.signature.SignatureVisitor;
|
||||
import org.jetbrains.asm4.signature.SignatureWriter;
|
||||
import org.jetbrains.asm4.util.CheckSignatureAdapter;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.AsmTypeConstants;
|
||||
import org.jetbrains.jet.lang.resolve.java.JetSignatureUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
@@ -196,7 +196,7 @@ public class BothSignatureWriter {
|
||||
jetSignatureWriter.visitClassType("jet/Nothing", nullable, false);
|
||||
jetSignatureWriter.visitEnd();
|
||||
if (nullable) {
|
||||
writeAsmType0(JetTypeMapper.OBJECT_TYPE);
|
||||
writeAsmType0(AsmTypeConstants.OBJECT_TYPE);
|
||||
}
|
||||
else {
|
||||
writeAsmType0(Type.VOID_TYPE);
|
||||
|
||||
Reference in New Issue
Block a user