MapTypeMode renamed to JetTypeMapperMode and moved to state package
This commit is contained in:
@@ -24,6 +24,7 @@ import org.jetbrains.asm4.FieldVisitor;
|
||||
import org.jetbrains.asm4.MethodVisitor;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
@@ -102,7 +103,7 @@ public abstract class AnnotationCodegen {
|
||||
return;
|
||||
}
|
||||
|
||||
String internalName = typeMapper.mapType(type, MapTypeMode.VALUE).getDescriptor();
|
||||
String internalName = typeMapper.mapType(type, JetTypeMapperMode.VALUE).getDescriptor();
|
||||
AnnotationVisitor annotationVisitor = visitAnnotation(internalName, rp == RetentionPolicy.RUNTIME);
|
||||
|
||||
getAnnotation(resolvedCall, annotationVisitor);
|
||||
@@ -155,7 +156,7 @@ public abstract class AnnotationCodegen {
|
||||
if (call != null) {
|
||||
if (call.getResultingDescriptor() instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor descriptor = (PropertyDescriptor) call.getResultingDescriptor();
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(),
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), JetTypeMapperMode.VALUE).getDescriptor(),
|
||||
descriptor.getName().getName());
|
||||
return;
|
||||
}
|
||||
@@ -181,7 +182,7 @@ public abstract class AnnotationCodegen {
|
||||
if (IntrinsicMethods.KOTLIN_JAVA_CLASS_FUNCTION.equals(value)) {
|
||||
//noinspection ConstantConditions
|
||||
annotationVisitor.visit(keyName, typeMapper
|
||||
.mapType(call.getResultingDescriptor().getReturnType().getArguments().get(0).getType(), MapTypeMode.VALUE));
|
||||
.mapType(call.getResultingDescriptor().getReturnType().getArguments().get(0).getType(), JetTypeMapperMode.VALUE));
|
||||
return;
|
||||
}
|
||||
else if (IntrinsicMethods.KOTLIN_ARRAYS_ARRAY.equals(value)) {
|
||||
@@ -196,7 +197,7 @@ public abstract class AnnotationCodegen {
|
||||
else if (call.getResultingDescriptor() instanceof ConstructorDescriptor) {
|
||||
ConstructorDescriptor descriptor = (ConstructorDescriptor) call.getResultingDescriptor();
|
||||
AnnotationVisitor visitor = annotationVisitor.visitAnnotation(keyName, typeMapper
|
||||
.mapType(descriptor.getContainingDeclaration().getDefaultType(), MapTypeMode.VALUE).getDescriptor());
|
||||
.mapType(descriptor.getContainingDeclaration().getDefaultType(), JetTypeMapperMode.VALUE).getDescriptor());
|
||||
getAnnotation(call, visitor);
|
||||
visitor.visitEnd();
|
||||
return;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.GenerationStateAware;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -108,7 +109,7 @@ public abstract class ClassBodyCodegen extends GenerationStateAware {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
v.newMethod(p, ACC_PUBLIC | ACC_ABSTRACT, p.getName(), "()" + type.getDescriptor(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.codegen;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.GenerationStateAware;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
@@ -112,7 +113,7 @@ public final class ClassFileFactory extends GenerationStateAware {
|
||||
|
||||
public ClassBuilder forClassImplementation(ClassDescriptor aClass) {
|
||||
return newVisitor(
|
||||
state.getTypeMapper().mapType(aClass.getDefaultType(), MapTypeMode.IMPL).getInternalName() + ".class");
|
||||
state.getTypeMapper().mapType(aClass.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName() + ".class");
|
||||
}
|
||||
|
||||
public ClassBuilder forNamespacepart(String name) {
|
||||
@@ -121,6 +122,6 @@ public final class ClassFileFactory extends GenerationStateAware {
|
||||
|
||||
public ClassBuilder forTraitImplementation(ClassDescriptor aClass, GenerationState state) {
|
||||
return newVisitor(
|
||||
state.getTypeMapper().mapType(aClass.getDefaultType(), MapTypeMode.TRAIT_IMPL).getInternalName() + ".class");
|
||||
state.getTypeMapper().mapType(aClass.getDefaultType(), JetTypeMapperMode.TRAIT_IMPL).getInternalName() + ".class");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Label;
|
||||
import org.jetbrains.asm4.MethodVisitor;
|
||||
import org.jetbrains.asm4.Type;
|
||||
@@ -35,7 +34,7 @@ import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.GenerationStateAware;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
@@ -191,7 +190,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
if (receiver.exists()) {
|
||||
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
StackValue.onStack(OBJECT_TYPE)
|
||||
.upcast(typeMapper.mapType(receiver.getType(), MapTypeMode.VALUE), iv);
|
||||
.upcast(typeMapper.mapType(receiver.getType(), JetTypeMapperMode.VALUE), iv);
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -199,7 +198,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
for (ValueParameterDescriptor param : params) {
|
||||
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
StackValue.onStack(OBJECT_TYPE)
|
||||
.upcast(typeMapper.mapType(param.getType(), MapTypeMode.VALUE), iv);
|
||||
.upcast(typeMapper.mapType(param.getType(), JetTypeMapperMode.VALUE), iv);
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -259,13 +258,13 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
) {
|
||||
final ClassDescriptor captureThis = closure.getCaptureThis();
|
||||
if (captureThis != null) {
|
||||
final Type type = typeMapper.mapType(captureThis.getDefaultType(), MapTypeMode.VALUE);
|
||||
final Type type = typeMapper.mapType(captureThis.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
args.add(new Pair<String, Type>(THIS$0, type));
|
||||
}
|
||||
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
|
||||
if (captureReceiver != null) {
|
||||
args.add(new Pair<String, Type>(RECEIVER$0,
|
||||
typeMapper.mapType(captureReceiver.getDefaultType(), MapTypeMode.VALUE)));
|
||||
typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.VALUE)));
|
||||
}
|
||||
|
||||
for (DeclarationDescriptor descriptor : closure.getCaptureVariables().keySet()) {
|
||||
@@ -274,7 +273,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
|
||||
final Type type = sharedVarType != null
|
||||
? sharedVarType
|
||||
: typeMapper.mapType(((VariableDescriptor) descriptor).getType(), MapTypeMode.VALUE);
|
||||
: typeMapper.mapType(((VariableDescriptor) descriptor).getType(), JetTypeMapperMode.VALUE);
|
||||
args.add(new Pair<String, Type>("$" + descriptor.getName().getName(), type));
|
||||
}
|
||||
else if (isLocalNamedFun(state.getBindingContext(), descriptor)) {
|
||||
@@ -302,7 +301,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
private void appendType(SignatureWriter signatureWriter, JetType type, char variance) {
|
||||
signatureWriter.visitTypeArgument(variance);
|
||||
|
||||
final Type rawRetType = typeMapper.mapType(type, MapTypeMode.TYPE_PARAMETER);
|
||||
final Type rawRetType = typeMapper.mapType(type, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
signatureWriter.visitClassType(rawRetType.getInternalName());
|
||||
signatureWriter.visitEnd();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -225,13 +226,13 @@ public class CodegenUtil {
|
||||
final ClassifierDescriptor captureThis = closure.getCaptureThis();
|
||||
final int access = ACC_PUBLIC | ACC_SYNTHETIC | ACC_FINAL;
|
||||
if (captureThis != null) {
|
||||
v.newField(null, access, THIS$0, typeMapper.mapType(captureThis.getDefaultType(), MapTypeMode.VALUE).getDescriptor(), null,
|
||||
v.newField(null, access, THIS$0, typeMapper.mapType(captureThis.getDefaultType(), JetTypeMapperMode.VALUE).getDescriptor(), null,
|
||||
null);
|
||||
}
|
||||
|
||||
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
|
||||
if (captureReceiver != null) {
|
||||
v.newField(null, access, RECEIVER$0, typeMapper.mapType(captureReceiver.getDefaultType(), MapTypeMode.VALUE).getDescriptor(),
|
||||
v.newField(null, access, RECEIVER$0, typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.VALUE).getDescriptor(),
|
||||
null, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
|
||||
import org.jetbrains.jet.codegen.signature.JvmPropertyAccessorSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -287,7 +288,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
@NotNull
|
||||
private Type asmType(@NotNull JetType type) {
|
||||
return typeMapper.mapType(type, MapTypeMode.VALUE);
|
||||
return typeMapper.mapType(type, JetTypeMapperMode.VALUE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1111,7 +1112,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
|
||||
if (captureReceiver != null) {
|
||||
final Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), MapTypeMode.IMPL);
|
||||
final Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.IMPL);
|
||||
v.load(context.isStatic() ? 0 : 1, asmType);
|
||||
}
|
||||
}
|
||||
@@ -1120,7 +1121,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
//if (entry.getKey() instanceof VariableDescriptor && !(entry.getKey() instanceof PropertyDescriptor)) {
|
||||
Type sharedVarType = typeMapper.getSharedVarType(entry.getKey());
|
||||
if (sharedVarType == null) {
|
||||
sharedVarType = typeMapper.mapType(((VariableDescriptor) entry.getKey()).getType(), MapTypeMode.VALUE);
|
||||
sharedVarType = typeMapper.mapType(((VariableDescriptor) entry.getKey()).getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
entry.getValue().getOuterValue(this).put(sharedVarType, v);
|
||||
//}
|
||||
@@ -1403,10 +1404,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (declaration instanceof JetClass) {
|
||||
final ClassDescriptor descriptor1 = ((ClassDescriptor) descriptor).getClassObjectDescriptor();
|
||||
assert descriptor1 != null;
|
||||
final Type type = typeMapper.mapType(descriptor1.getDefaultType(), MapTypeMode.VALUE);
|
||||
final Type type = typeMapper.mapType(descriptor1.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
return StackValue.field(type,
|
||||
JvmClassName.byType(typeMapper.mapType(((ClassDescriptor) descriptor).getDefaultType(),
|
||||
MapTypeMode.IMPL)),
|
||||
JetTypeMapperMode.IMPL)),
|
||||
"$classobj",
|
||||
true);
|
||||
}
|
||||
@@ -1453,7 +1454,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
final ClassDescriptor scriptClass = bindingContext.get(CLASS_FOR_FUNCTION, scriptDescriptor);
|
||||
final StackValue script = StackValue.thisOrOuter(this, scriptClass);
|
||||
script.put(script.type, v);
|
||||
Type fieldType = typeMapper.mapType(valueParameterDescriptor.getType(), MapTypeMode.VALUE);
|
||||
Type fieldType = typeMapper.mapType(valueParameterDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
return StackValue.field(fieldType, scriptClassName, valueParameterDescriptor.getName().getIdentifier(), false);
|
||||
}
|
||||
|
||||
@@ -1465,12 +1466,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (isEnumEntry) {
|
||||
ClassDescriptor containing = (ClassDescriptor) variableDescriptor.getContainingDeclaration().getContainingDeclaration();
|
||||
assert containing != null;
|
||||
Type type = typeMapper.mapType(containing.getDefaultType(), MapTypeMode.VALUE);
|
||||
Type type = typeMapper.mapType(containing.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().getName(), true).put(type, v);
|
||||
return StackValue.onStack(type);
|
||||
}
|
||||
else {
|
||||
Type type = typeMapper.mapType(objectClassDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||
Type type = typeMapper.mapType(objectClassDescriptor.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
return StackValue.field(type, JvmClassName.byType(type), "$instance", true);
|
||||
}
|
||||
}
|
||||
@@ -1602,7 +1603,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
invokeOpcode = callableMethod.getInvokeOpcode();
|
||||
owner = isFakeOverride && !overridesTrait && !isInterface(initialDescriptor.getContainingDeclaration())
|
||||
? JvmClassName.byType(typeMapper.mapType(
|
||||
((ClassDescriptor) initialDescriptor.getContainingDeclaration()).getDefaultType(), MapTypeMode.IMPL))
|
||||
((ClassDescriptor) initialDescriptor.getContainingDeclaration()).getDefaultType(), JetTypeMapperMode.IMPL))
|
||||
: callableMethod.getOwner();
|
||||
ownerParam = callableMethod.getDefaultImplParam();
|
||||
}
|
||||
@@ -1748,7 +1749,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
JetType type = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||
assert type != null;
|
||||
Type callType = typeMapper.mapType(type, MapTypeMode.VALUE);
|
||||
Type callType = typeMapper.mapType(type, JetTypeMapperMode.VALUE);
|
||||
|
||||
Type exprType = asmTypeOrVoid(type);
|
||||
StackValue stackValue = intrinsic.generate(this, v, callType, call.getCallElement(), args, receiver, state);
|
||||
@@ -1867,7 +1868,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ClassDescriptor classReceiverDeclarationDescriptor = classReceiver.getDeclarationDescriptor();
|
||||
if (DescriptorUtils.isClassObject(classReceiverDeclarationDescriptor)) {
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) classReceiverDeclarationDescriptor.getContainingDeclaration();
|
||||
Type classObjType = typeMapper.mapType(containingDeclaration.getDefaultType(), MapTypeMode.IMPL);
|
||||
Type classObjType = typeMapper.mapType(containingDeclaration.getDefaultType(), JetTypeMapperMode.IMPL);
|
||||
if (context.getContextDescriptor() instanceof ConstructorDescriptor &&
|
||||
classReceiverDeclarationDescriptor.getDefaultType()
|
||||
.equals(((ConstructorDescriptor) context.getContextDescriptor()).getReturnType())) {
|
||||
@@ -2905,7 +2906,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
//noinspection ConstantConditions
|
||||
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
assert expressionType != null;
|
||||
type = typeMapper.mapType(expressionType, MapTypeMode.VALUE);
|
||||
type = typeMapper.mapType(expressionType, JetTypeMapperMode.VALUE);
|
||||
if (type.getSort() == Type.ARRAY) {
|
||||
generateNewArray(expression, expressionType);
|
||||
}
|
||||
@@ -2973,7 +2974,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType())));
|
||||
}
|
||||
else {
|
||||
Type type = typeMapper.mapType(arrayType, MapTypeMode.VALUE);
|
||||
Type type = typeMapper.mapType(arrayType, JetTypeMapperMode.VALUE);
|
||||
gen(args.get(0), Type.INT_TYPE);
|
||||
v.newarray(correctElementType(type));
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.jet.codegen.signature.kotlin.JetMethodAnnotationWriter;
|
||||
import org.jetbrains.jet.codegen.signature.kotlin.JetValueParameterAnnotationWriter;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.GenerationStateAware;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -267,7 +268,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
for (ValueParameterDescriptor parameter : paramDescrs) {
|
||||
Type sharedVarType = state.getTypeMapper().getSharedVarType(parameter);
|
||||
if (sharedVarType != null) {
|
||||
Type localVarType = state.getTypeMapper().mapType(parameter.getType(), MapTypeMode.VALUE);
|
||||
Type localVarType = state.getTypeMapper().mapType(parameter.getType(), JetTypeMapperMode.VALUE);
|
||||
int index = frameMap.getIndex(parameter);
|
||||
mv.visitTypeInsn(NEW, sharedVarType.getInternalName());
|
||||
mv.visitInsn(DUP);
|
||||
@@ -301,26 +302,26 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
int k = 0;
|
||||
|
||||
if (expectedThisObject.exists()) {
|
||||
Type type = state.getTypeMapper().mapType(expectedThisObject.getType(), MapTypeMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(expectedThisObject.getType(), JetTypeMapperMode.VALUE);
|
||||
// TODO: specify signature
|
||||
mv.visitLocalVariable("this", type.getDescriptor(), null, methodBegin, methodEnd, k++);
|
||||
}
|
||||
else if (fun instanceof JetFunctionLiteralExpression ||
|
||||
isLocalFun(bindingContext, functionDescriptor)) {
|
||||
Type type = state.getTypeMapper().mapType(
|
||||
context.getThisDescriptor().getDefaultType(), MapTypeMode.VALUE);
|
||||
context.getThisDescriptor().getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
mv.visitLocalVariable("this", type.getDescriptor(), null, methodBegin, methodEnd, k++);
|
||||
}
|
||||
|
||||
if (receiverParameter.exists()) {
|
||||
Type type = state.getTypeMapper().mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
// TODO: specify signature
|
||||
mv.visitLocalVariable("this$receiver", type.getDescriptor(), null, methodBegin, methodEnd, k);
|
||||
k += type.getSize();
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor parameter : paramDescrs) {
|
||||
Type type = state.getTypeMapper().mapType(parameter.getType(), MapTypeMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(parameter.getType(), JetTypeMapperMode.VALUE);
|
||||
// TODO: specify signature
|
||||
|
||||
Label divideLabel = mapLabelsToDivideLocalVarVisibilityForSharedVar.get(parameter.getName());
|
||||
@@ -461,7 +462,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
else {
|
||||
ownerInternalName = JvmClassName.byType(state.getTypeMapper()
|
||||
.mapType(((ClassDescriptor) contextClass).getDefaultType(),
|
||||
MapTypeMode.IMPL));
|
||||
JetTypeMapperMode.IMPL));
|
||||
}
|
||||
|
||||
String descriptor = jvmSignature.getDescriptor().replace(")", "I)");
|
||||
@@ -514,7 +515,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
|
||||
Type receiverType;
|
||||
if (hasReceiver) {
|
||||
receiverType = state.getTypeMapper().mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||
receiverType = state.getTypeMapper().mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
var += receiverType.getSize();
|
||||
}
|
||||
else {
|
||||
@@ -666,7 +667,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
iv.invokevirtual(state.getTypeMapper().mapType(
|
||||
((ClassDescriptor) owner.getContextDescriptor()).getDefaultType(), MapTypeMode.VALUE).getInternalName(),
|
||||
((ClassDescriptor) owner.getContextDescriptor()).getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(),
|
||||
jvmSignature.getName(), jvmSignature.getDescriptor());
|
||||
if (isPrimitive(jvmSignature.getReturnType()) && !isPrimitive(overridden.getReturnType())) {
|
||||
StackValue.valueOf(iv, jvmSignature.getReturnType());
|
||||
@@ -722,7 +723,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
field.put(field.type, iv);
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) overriddenDescriptor.getContainingDeclaration();
|
||||
String internalName =
|
||||
state.getTypeMapper().mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName();
|
||||
state.getTypeMapper().mapType(classDescriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName();
|
||||
if (classDescriptor.getKind() == ClassKind.TRAIT) {
|
||||
iv.invokeinterface(internalName, method.getName(), method.getDescriptor());
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jetbrains.jet.codegen.signature.kotlin.JetMethodAnnotationWriter;
|
||||
import org.jetbrains.jet.codegen.signature.kotlin.JetValueParameterAnnotationWriter;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -166,7 +167,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void writeInnerOuterClasses() {
|
||||
ClassDescriptor container = getContainingClassDescriptor(descriptor);
|
||||
if (container != null) {
|
||||
v.visitOuterClass(typeMapper.mapType(container.getDefaultType(), MapTypeMode.IMPL).getInternalName(), null, null);
|
||||
v.visitOuterClass(typeMapper.mapType(container.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName(), null, null);
|
||||
}
|
||||
|
||||
for (DeclarationDescriptor declarationDescriptor : descriptor.getUnsubstitutedInnerClassesScope().getAllDescriptors()) {
|
||||
@@ -186,14 +187,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
// TODO: cache internal names
|
||||
String outerClassInernalName = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String innerClassInternalName = typeMapper.mapType(innerClass.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String outerClassInernalName = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
String innerClassInternalName = typeMapper.mapType(innerClass.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
v.visitInnerClass(innerClassInternalName, outerClassInernalName, innerClass.getName().getName(), innerClassAccess);
|
||||
}
|
||||
|
||||
if (descriptor.getClassObjectDescriptor() != null) {
|
||||
int innerClassAccess = ACC_PUBLIC | ACC_FINAL | ACC_STATIC;
|
||||
String outerClassInernalName = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String outerClassInernalName = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
v.visitInnerClass(outerClassInernalName + JvmAbi.CLASS_OBJECT_SUFFIX, outerClassInernalName, JvmAbi.CLASS_OBJECT_CLASS_NAME,
|
||||
innerClassAccess);
|
||||
}
|
||||
@@ -245,7 +246,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
signatureVisitor.writeClassEnd();
|
||||
}
|
||||
else {
|
||||
typeMapper.mapType(superClassType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||
typeMapper.mapType(superClassType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
}
|
||||
signatureVisitor.writeSuperclassEnd();
|
||||
}
|
||||
@@ -260,7 +261,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||
if (isInterface(superClassDescriptor)) {
|
||||
signatureVisitor.writeInterface();
|
||||
Type jvmName = typeMapper.mapType(superType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||
Type jvmName = typeMapper.mapType(superType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
signatureVisitor.writeInterfaceEnd();
|
||||
superInterfacesLinkedHashSet.add(jvmName.getInternalName());
|
||||
}
|
||||
@@ -279,7 +280,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (kind != OwnerKind.IMPLEMENTATION) {
|
||||
throw new IllegalStateException("must not call this method with kind " + kind);
|
||||
}
|
||||
return typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
return typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
}
|
||||
|
||||
protected void getSuperClass() {
|
||||
@@ -304,7 +305,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
assert superClassDescriptor != null;
|
||||
if (!isInterface(superClassDescriptor)) {
|
||||
superClassType = superType;
|
||||
superClass = typeMapper.mapType(superClassDescriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
superClass = typeMapper.mapType(superClassDescriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
superCall = specifier;
|
||||
}
|
||||
}
|
||||
@@ -313,11 +314,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (superClassType == null) {
|
||||
if (descriptor.getKind() == ClassKind.ENUM_CLASS) {
|
||||
superClassType = JetStandardLibrary.getInstance().getEnumType(descriptor.getDefaultType());
|
||||
superClass = typeMapper.mapType(superClassType, MapTypeMode.VALUE).getInternalName();
|
||||
superClass = typeMapper.mapType(superClassType, JetTypeMapperMode.VALUE).getInternalName();
|
||||
}
|
||||
if (descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
superClassType = descriptor.getTypeConstructor().getSupertypes().iterator().next();
|
||||
superClass = typeMapper.mapType(superClassType, MapTypeMode.VALUE).getInternalName();
|
||||
superClass = typeMapper.mapType(superClassType, JetTypeMapperMode.VALUE).getInternalName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,12 +354,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (myEnumConstants.size() > 0) {
|
||||
{
|
||||
Type type =
|
||||
typeMapper.mapType(JetStandardLibrary.getInstance().getArrayType(descriptor.getDefaultType()), MapTypeMode.IMPL);
|
||||
typeMapper.mapType(JetStandardLibrary.getInstance().getArrayType(descriptor.getDefaultType()), JetTypeMapperMode.IMPL);
|
||||
|
||||
MethodVisitor mv =
|
||||
v.newMethod(myClass, ACC_PUBLIC | ACC_STATIC, "values", "()" + type.getDescriptor(), null, null);
|
||||
mv.visitCode();
|
||||
mv.visitFieldInsn(GETSTATIC, typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName(), VALUES,
|
||||
mv.visitFieldInsn(GETSTATIC, typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(), VALUES,
|
||||
type.getDescriptor());
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, type.getInternalName(), "clone", "()Ljava/lang/Object;");
|
||||
mv.visitTypeInsn(CHECKCAST, type.getInternalName());
|
||||
@@ -366,7 +367,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
FunctionCodegen.endVisit(mv, "values()", myClass);
|
||||
}
|
||||
{
|
||||
Type type = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL);
|
||||
Type type = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL);
|
||||
|
||||
MethodVisitor mv =
|
||||
v.newMethod(myClass, ACC_PUBLIC | ACC_STATIC, "valueOf", "(Ljava/lang/String;)" + type.getDescriptor(), null, null);
|
||||
@@ -508,7 +509,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
private void generateFieldForObjectInstance() {
|
||||
if (isNonLiteralObject(myClass)) {
|
||||
Type type = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||
Type type = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
v.newField(myClass, ACC_PUBLIC | ACC_STATIC | ACC_FINAL, "$instance", type.getDescriptor(), null, null);
|
||||
|
||||
staticInitializerChunks.add(new CodeChunk() {
|
||||
@@ -518,7 +519,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
v.anew(Type.getObjectType(name));
|
||||
v.dup();
|
||||
v.invokespecial(name, "<init>", "()V");
|
||||
v.putstatic(name, "$instance", typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE).getDescriptor());
|
||||
v.putstatic(name, "$instance", typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getDescriptor());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -529,7 +530,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (classObject != null) {
|
||||
final ClassDescriptor descriptor1 = bindingContext.get(BindingContext.CLASS, classObject.getObjectDeclaration());
|
||||
assert descriptor1 != null;
|
||||
Type type = Type.getObjectType(typeMapper.mapType(descriptor1.getDefaultType(), MapTypeMode.VALUE).getInternalName());
|
||||
Type type = Type.getObjectType(typeMapper.mapType(descriptor1.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName());
|
||||
v.newField(classObject, ACC_PUBLIC | ACC_STATIC, "$classobj", type.getDescriptor(), null, null);
|
||||
|
||||
staticInitializerChunks.add(new CodeChunk() {
|
||||
@@ -537,12 +538,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
public void generate(InstructionAdapter v) {
|
||||
final ClassDescriptor descriptor1 = bindingContext.get(BindingContext.CLASS, classObject.getObjectDeclaration());
|
||||
assert descriptor1 != null;
|
||||
String name = typeMapper.mapType(descriptor1.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String name = typeMapper.mapType(descriptor1.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
final Type classObjectType = Type.getObjectType(name);
|
||||
v.anew(classObjectType);
|
||||
v.dup();
|
||||
v.invokespecial(name, "<init>", "()V");
|
||||
v.putstatic(typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName(), "$classobj",
|
||||
v.putstatic(typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(), "$classobj",
|
||||
classObjectType.getDescriptor());
|
||||
}
|
||||
});
|
||||
@@ -615,7 +616,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
final InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, constructorContext, state);
|
||||
|
||||
Type classType = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL);
|
||||
Type classType = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL);
|
||||
JvmClassName classname = JvmClassName.byType(classType);
|
||||
|
||||
if (superCall == null) {
|
||||
@@ -630,7 +631,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
if (hasThis0) {
|
||||
final Type type = typeMapper
|
||||
.mapType(eclosingClassDescriptor(bindingContext, descriptor).getDefaultType(), MapTypeMode.VALUE);
|
||||
.mapType(eclosingClassDescriptor(bindingContext, descriptor).getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
String interfaceDesc = type.getDescriptor();
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getOuterThisIndex(), type);
|
||||
@@ -639,11 +640,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
if (closure != null) {
|
||||
int k = hasThis0 ? 2 : 1;
|
||||
final String internalName = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName();
|
||||
final String internalName = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName();
|
||||
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
|
||||
if (captureReceiver != null) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
final Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), MapTypeMode.IMPL);
|
||||
final Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.IMPL);
|
||||
iv.load(1, asmType);
|
||||
iv.putfield(internalName, RECEIVER$0, asmType.getDescriptor());
|
||||
k += asmType.getSize();
|
||||
@@ -653,7 +654,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (varDescr instanceof VariableDescriptor && !(varDescr instanceof PropertyDescriptor)) {
|
||||
Type sharedVarType = typeMapper.getSharedVarType(varDescr);
|
||||
if (sharedVarType == null) {
|
||||
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getType(), MapTypeMode.VALUE);
|
||||
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
iv.load(k, StackValue.refType(sharedVarType));
|
||||
@@ -680,7 +681,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
for (JetParameter parameter : constructorParameters) {
|
||||
if (parameter.getValOrVarNode() != null) {
|
||||
VariableDescriptor descriptor = paramDescrs.get(curParam);
|
||||
Type type = typeMapper.mapType(descriptor.getType(), MapTypeMode.VALUE);
|
||||
Type type = typeMapper.mapType(descriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getIndex(descriptor), type);
|
||||
iv.putfield(classname.getInternalName(), descriptor.getName().getName(), type.getDescriptor());
|
||||
@@ -707,11 +708,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (CodegenBinding.hasThis0(bindingContext, superClassDescriptor)) {
|
||||
iv.load(1, OBJECT_TYPE);
|
||||
parameterTypes.add(typeMapper.mapType(
|
||||
eclosingClassDescriptor(bindingContext, descriptor).getDefaultType(), MapTypeMode.VALUE));
|
||||
eclosingClassDescriptor(bindingContext, descriptor).getDefaultType(), JetTypeMapperMode.VALUE));
|
||||
}
|
||||
Method superCallMethod = new Method("<init>", Type.VOID_TYPE, parameterTypes.toArray(new Type[parameterTypes.size()]));
|
||||
//noinspection ConstantConditions
|
||||
iv.invokespecial(typeMapper.mapType(superClassDescriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName(), "<init>",
|
||||
iv.invokespecial(typeMapper.mapType(superClassDescriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(), "<init>",
|
||||
superCallMethod.getDescriptor());
|
||||
}
|
||||
|
||||
@@ -773,7 +774,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||
assert superClassDescriptor != null;
|
||||
String delegateField = "$delegate_" + n;
|
||||
Type fieldType = typeMapper.mapType(superClassDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||
Type fieldType = typeMapper.mapType(superClassDescriptor.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
String fieldDesc = fieldType.getDescriptor();
|
||||
v.newField(specifier, ACC_PRIVATE, delegateField, fieldDesc, /*TODO*/null, null);
|
||||
StackValue field = StackValue.field(fieldType, classname, delegateField, false);
|
||||
@@ -784,7 +785,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
delegateField, false),
|
||||
typeMapper.mapType(superClassDescriptor
|
||||
.getDefaultType(),
|
||||
MapTypeMode.IMPL)
|
||||
JetTypeMapperMode.IMPL)
|
||||
.getInternalName()),
|
||||
state);
|
||||
generateDelegates(superClassDescriptor, delegateContext, field);
|
||||
@@ -961,15 +962,15 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
JetType jetType = CodegenUtil.getSuperClass(declaration);
|
||||
Type type = typeMapper.mapType(jetType, MapTypeMode.IMPL);
|
||||
Type type = typeMapper.mapType(jetType, JetTypeMapperMode.IMPL);
|
||||
if (type.getInternalName().equals("java/lang/Object")) {
|
||||
jetType = declaration.getDefaultType();
|
||||
type = typeMapper.mapType(jetType, MapTypeMode.IMPL);
|
||||
type = typeMapper.mapType(jetType, JetTypeMapperMode.IMPL);
|
||||
}
|
||||
|
||||
String fdescriptor = functionOriginal.getDescriptor().replace("(", "(" + type.getDescriptor());
|
||||
Type type1 =
|
||||
typeMapper.mapType(((ClassDescriptor) fun.getContainingDeclaration()).getDefaultType(), MapTypeMode.TRAIT_IMPL);
|
||||
typeMapper.mapType(((ClassDescriptor) fun.getContainingDeclaration()).getDefaultType(), JetTypeMapperMode.TRAIT_IMPL);
|
||||
iv.invokestatic(type1.getInternalName(), function.getName(), fdescriptor);
|
||||
if (function.getReturnType().getSort() == Type.OBJECT &&
|
||||
!function.getReturnType().equals(functionOriginal.getReturnType())) {
|
||||
@@ -1050,7 +1051,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
else if (declaration instanceof JetEnumEntry && !((JetEnumEntry) declaration).hasPrimaryConstructor()) {
|
||||
String name = declaration.getName();
|
||||
final String desc = "L" + typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName() + ";";
|
||||
final String desc = "L" + typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName() + ";";
|
||||
v.newField(declaration, ACC_PUBLIC | ACC_ENUM | ACC_STATIC | ACC_FINAL, name, desc, null, null);
|
||||
if (myEnumConstants.isEmpty()) {
|
||||
staticInitializerChunks.add(new CodeChunk() {
|
||||
@@ -1073,11 +1074,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
ExpressionCodegen codegen = new ExpressionCodegen(iv, new FrameMap(), Type.VOID_TYPE, context, state);
|
||||
int ordinal = -1;
|
||||
JetType myType = descriptor.getDefaultType();
|
||||
Type myAsmType = typeMapper.mapType(myType, MapTypeMode.IMPL);
|
||||
Type myAsmType = typeMapper.mapType(myType, JetTypeMapperMode.IMPL);
|
||||
|
||||
assert myEnumConstants.size() > 0;
|
||||
JetType arrayType = JetStandardLibrary.getInstance().getArrayType(myType);
|
||||
Type arrayAsmType = typeMapper.mapType(arrayType, MapTypeMode.IMPL);
|
||||
Type arrayAsmType = typeMapper.mapType(arrayType, JetTypeMapperMode.IMPL);
|
||||
v.newField(myClass, ACC_PRIVATE | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, "$VALUES", arrayAsmType.getDescriptor(), null, null);
|
||||
|
||||
iv.iconst(myEnumConstants.size());
|
||||
@@ -1092,7 +1093,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
ClassDescriptor classDescriptor = bindingContext.get(BindingContext.CLASS, enumConstant);
|
||||
assert classDescriptor != null;
|
||||
String implClass = typeMapper.mapType(classDescriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String implClass = typeMapper.mapType(classDescriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
|
||||
final List<JetDelegationSpecifier> delegationSpecifiers = enumConstant.getDelegationSpecifiers();
|
||||
if (delegationSpecifiers.size() > 1) {
|
||||
@@ -1147,7 +1148,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
final JetType jetType = propertyDescriptor.getType();
|
||||
if (compileTimeValue != null) {
|
||||
Object value = compileTimeValue.getValue();
|
||||
Type type = typeMapper.mapType(jetType, MapTypeMode.VALUE);
|
||||
Type type = typeMapper.mapType(jetType, JetTypeMapperMode.VALUE);
|
||||
if (skipDefaultValue(propertyDescriptor, value, type)) continue;
|
||||
}
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
@@ -1158,7 +1159,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
codegen.gen(initializer, type);
|
||||
// @todo write directly to the field. Fix test excloset.jet::test6
|
||||
JvmClassName owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
Type propType = typeMapper.mapType(jetType, MapTypeMode.VALUE);
|
||||
Type propType = typeMapper.mapType(jetType, JetTypeMapperMode.VALUE);
|
||||
StackValue.property(propertyDescriptor.getName().getName(), owner, owner,
|
||||
propType, false, false, false, null, null, 0).store(propType, iv);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.signature.JvmPropertyAccessorSignature;
|
||||
import org.jetbrains.jet.codegen.signature.kotlin.JetMethodAnnotationWriter;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.GenerationStateAware;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -111,7 +111,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
||||
modifiers |= ACC_VOLATILE;
|
||||
}
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
FieldVisitor fieldVisitor = v.newField(p, modifiers, propertyDescriptor.getName().getName(), type.getDescriptor(), null, value);
|
||||
AnnotationCodegen.forField(fieldVisitor, state.getTypeMapper()).genAnnotations(propertyDescriptor);
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
if (kind != OwnerKind.NAMESPACE) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
}
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
|
||||
if ((kind instanceof OwnerKind.DelegateKind) != (propertyDescriptor.getKind() == FunctionDescriptor.Kind.DELEGATION)) {
|
||||
throw new IllegalStateException("mismatching kind in " + propertyDescriptor);
|
||||
@@ -320,7 +320,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
}
|
||||
else {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
int paramCode = 0;
|
||||
if (kind != OwnerKind.NAMESPACE) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.GenerationStateAware;
|
||||
import org.jetbrains.jet.codegen.state.GenerationStrategy;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
@@ -114,7 +115,7 @@ public class ScriptCodegen extends GenerationStateAware {
|
||||
@NotNull List<ScriptDescriptor> importedScripts
|
||||
) {
|
||||
|
||||
Type blockType = typeMapper.mapType(scriptDescriptor.getReturnType(), MapTypeMode.VALUE);
|
||||
Type blockType = typeMapper.mapType(scriptDescriptor.getReturnType(), JetTypeMapperMode.VALUE);
|
||||
|
||||
classBuilder.newField(null, ACC_PUBLIC | ACC_FINAL, ScriptNameUtil.LAST_EXPRESSION_VALUE_FIELD_NAME,
|
||||
blockType.getDescriptor(), null, null);
|
||||
@@ -172,7 +173,7 @@ public class ScriptCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor parameter : scriptDescriptor.getValueParameters()) {
|
||||
Type parameterType = typeMapper.mapType(parameter.getType(), MapTypeMode.VALUE);
|
||||
Type parameterType = typeMapper.mapType(parameter.getType(), JetTypeMapperMode.VALUE);
|
||||
instructionAdapter.load(0, className.getAsmType());
|
||||
instructionAdapter.load(offset, parameterType);
|
||||
offset += parameterType.getSize();
|
||||
@@ -201,7 +202,7 @@ public class ScriptCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor parameter : script.getValueParameters()) {
|
||||
Type parameterType = typeMapper.mapType(parameter.getType(), MapTypeMode.VALUE);
|
||||
Type parameterType = typeMapper.mapType(parameter.getType(), JetTypeMapperMode.VALUE);
|
||||
int access = ACC_PUBLIC | ACC_FINAL;
|
||||
classBuilder.newField(null, access, parameter.getName().getIdentifier(), parameterType.getDescriptor(), null, null);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.asm4.commons.Method;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
@@ -707,7 +708,7 @@ public abstract class StackValue {
|
||||
List<ValueParameterDescriptor> valueParameters = resolvedGetCall.getResultingDescriptor().getValueParameters();
|
||||
int firstParamIndex = -1;
|
||||
for (int i = valueParameters.size() - 1; i >= 0; --i) {
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType(), MapTypeMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType(), JetTypeMapperMode.VALUE);
|
||||
int sz = type.getSize();
|
||||
frame.enterTemp(type);
|
||||
lastIndex += sz;
|
||||
@@ -729,7 +730,7 @@ public abstract class StackValue {
|
||||
ReceiverDescriptor receiverParameter = resolvedGetCall.getReceiverArgument();
|
||||
int receiverIndex = -1;
|
||||
if (receiverParameter.exists()) {
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
int sz = type.getSize();
|
||||
frame.enterTemp(type);
|
||||
lastIndex += sz;
|
||||
@@ -753,7 +754,7 @@ public abstract class StackValue {
|
||||
if (thisIndex != -1) {
|
||||
if (receiverIndex != -1) {
|
||||
realReceiverIndex = receiverIndex;
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
else {
|
||||
realReceiverIndex = thisIndex;
|
||||
@@ -762,7 +763,7 @@ public abstract class StackValue {
|
||||
}
|
||||
else {
|
||||
if (receiverIndex != -1) {
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
realReceiverIndex = receiverIndex;
|
||||
}
|
||||
else {
|
||||
@@ -787,7 +788,7 @@ public abstract class StackValue {
|
||||
|
||||
int index = firstParamIndex;
|
||||
for (int i = 0; i != valueParameters.size(); ++i) {
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType(), MapTypeMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType(), JetTypeMapperMode.VALUE);
|
||||
int sz = type.getSize();
|
||||
v.load(index - sz, type);
|
||||
index -= sz;
|
||||
@@ -799,7 +800,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
if (receiverIndex != -1) {
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
v.load(receiverIndex - type.getSize(), type);
|
||||
}
|
||||
|
||||
@@ -815,7 +816,7 @@ public abstract class StackValue {
|
||||
|
||||
index = firstParamIndex;
|
||||
for (int i = 0; i != valueParameters.size(); ++i) {
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType(), MapTypeMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType(), JetTypeMapperMode.VALUE);
|
||||
int sz = type.getSize();
|
||||
v.load(index - sz, type);
|
||||
index -= sz;
|
||||
@@ -844,7 +845,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor valueParameter : valueParameters) {
|
||||
if (codegen.typeMapper.mapType(valueParameter.getType(), MapTypeMode.VALUE).getSize() != 1) {
|
||||
if (codegen.typeMapper.mapType(valueParameter.getType(), JetTypeMapperMode.VALUE).getSize() != 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -855,7 +856,7 @@ public abstract class StackValue {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType(), MapTypeMode.VALUE)
|
||||
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType(), JetTypeMapperMode.VALUE)
|
||||
.getSize() != 1) {
|
||||
return false;
|
||||
}
|
||||
@@ -1245,10 +1246,10 @@ public abstract class StackValue {
|
||||
}
|
||||
else {
|
||||
if (receiverArgument.exists()) {
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
else {
|
||||
return codegen.typeMapper.mapType(descriptor.getExpectedThisObject().getType(), MapTypeMode.VALUE);
|
||||
return codegen.typeMapper.mapType(descriptor.getExpectedThisObject().getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1258,7 +1259,7 @@ public abstract class StackValue {
|
||||
return callableMethod.getReceiverClass();
|
||||
}
|
||||
else {
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1280,7 +1281,7 @@ public abstract class StackValue {
|
||||
}
|
||||
else {
|
||||
codegen.generateFromResolvedCall(thisObject, codegen.typeMapper
|
||||
.mapType(descriptor.getExpectedThisObject().getType(), MapTypeMode.VALUE));
|
||||
.mapType(descriptor.getExpectedThisObject().getType(), JetTypeMapperMode.VALUE));
|
||||
}
|
||||
genReceiver(v, receiverArgument, type, descriptor.getReceiverParameter(), 1);
|
||||
}
|
||||
@@ -1301,7 +1302,7 @@ public abstract class StackValue {
|
||||
) {
|
||||
if (receiver == StackValue.none()) {
|
||||
if (receiverParameter != null) {
|
||||
Type receiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||
Type receiverType = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
codegen.generateFromResolvedCall(receiverArgument, receiverType);
|
||||
StackValue.onStack(receiverType).put(type, v);
|
||||
}
|
||||
|
||||
@@ -18,14 +18,8 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
|
||||
@@ -47,6 +41,6 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private String jvmName() {
|
||||
return typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.TRAIT_IMPL).getInternalName();
|
||||
return typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.TRAIT_IMPL).getInternalName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
|
||||
@@ -184,7 +185,7 @@ public abstract class CodegenContext {
|
||||
|
||||
CallableDescriptor receiverDescriptor = getReceiverDescriptor();
|
||||
if (receiverDescriptor != null) {
|
||||
Type type = mapper.mapType(receiverDescriptor.getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||
Type type = mapper.mapType(receiverDescriptor.getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
frameMap.enterTemp(type); // Next slot for receiver
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ public abstract class CodegenContext {
|
||||
|
||||
public StackValue getReceiverExpression(JetTypeMapper typeMapper) {
|
||||
assert getReceiverDescriptor() != null;
|
||||
Type asmType = typeMapper.mapType(getReceiverDescriptor().getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||
Type asmType = typeMapper.mapType(getReceiverDescriptor().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
return hasThisDescriptor() ? StackValue.local(1, asmType) : StackValue.local(0, asmType);
|
||||
}
|
||||
|
||||
@@ -249,7 +250,7 @@ public abstract class CodegenContext {
|
||||
final ClassDescriptor enclosingClass = getEnclosingClass();
|
||||
outerExpression = enclosingClass != null
|
||||
? StackValue
|
||||
.field(typeMapper.mapType(enclosingClass.getDefaultType(), MapTypeMode.VALUE), CodegenBinding.getJvmClassName(
|
||||
.field(typeMapper.mapType(enclosingClass.getDefaultType(), JetTypeMapperMode.VALUE), CodegenBinding.getJvmClassName(
|
||||
typeMapper.getBindingTrace(), classDescriptor), CodegenUtil.THIS$0,
|
||||
false)
|
||||
: null;
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
@@ -55,7 +56,7 @@ public interface LocalLookup {
|
||||
if (!idx) return null;
|
||||
|
||||
final Type sharedVarType = state.getTypeMapper().getSharedVarType(vd);
|
||||
Type localType = state.getTypeMapper().mapType(vd.getType(), MapTypeMode.VALUE);
|
||||
Type localType = state.getTypeMapper().mapType(vd.getType(), JetTypeMapperMode.VALUE);
|
||||
final Type type = sharedVarType != null ? sharedVarType : localType;
|
||||
|
||||
final String fieldName = "$" + vd.getName();
|
||||
@@ -119,7 +120,7 @@ public interface LocalLookup {
|
||||
if (closure.getEnclosingReceiverDescriptor() != d) return null;
|
||||
|
||||
final JetType receiverType = ((CallableDescriptor) d).getReceiverParameter().getType();
|
||||
Type type = state.getTypeMapper().mapType(receiverType, MapTypeMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(receiverType, JetTypeMapperMode.VALUE);
|
||||
StackValue innerValue = StackValue.field(type, className, CodegenUtil.RECEIVER$0, false);
|
||||
closure.setCaptureReceiver();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
@@ -49,7 +50,7 @@ public class EnumValueOf implements IntrinsicMethod {
|
||||
JetType returnType = resultingDescriptor.getReturnType();
|
||||
assert returnType != null;
|
||||
Type type = state.getTypeMapper().mapType(
|
||||
returnType, MapTypeMode.VALUE);
|
||||
returnType, JetTypeMapperMode.VALUE);
|
||||
assert arguments != null;
|
||||
codegen.gen(arguments.get(0), AsmTypeConstants.JAVA_STRING_TYPE);
|
||||
v.invokestatic(type.getInternalName(), "valueOf", "(Ljava/lang/String;)" + type.getDescriptor());
|
||||
|
||||
@@ -22,8 +22,8 @@ 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.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.MapTypeMode;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
@@ -51,7 +51,7 @@ public class EnumValues implements IntrinsicMethod {
|
||||
JetType returnType = resultingDescriptor.getReturnType();
|
||||
assert returnType != null;
|
||||
Type type = state.getTypeMapper().mapType(
|
||||
returnType, MapTypeMode.VALUE);
|
||||
returnType, JetTypeMapperMode.VALUE);
|
||||
v.invokestatic(type.getElementType().getInternalName(), "values", "()" + type);
|
||||
StackValue.onStack(type).put(expectedType, v);
|
||||
return StackValue.onStack(expectedType);
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
@@ -50,7 +51,7 @@ public class JavaClassFunction implements IntrinsicMethod {
|
||||
JetType returnType = resultingDescriptor.getReturnType();
|
||||
assert returnType != null;
|
||||
Type type = state.getTypeMapper().mapType(
|
||||
returnType.getArguments().get(0).getType(), MapTypeMode.VALUE);
|
||||
returnType.getArguments().get(0).getType(), JetTypeMapperMode.VALUE);
|
||||
JvmPrimitiveType primitiveType = JvmPrimitiveType.getByAsmType(type);
|
||||
if (primitiveType != null) {
|
||||
v.getstatic(primitiveType.getWrapper().getAsmType().getInternalName(), "TYPE", "Ljava/lang/Class;");
|
||||
|
||||
@@ -65,7 +65,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
@NotNull
|
||||
public JvmClassName getOwner(DeclarationDescriptor descriptor, OwnerKind kind) {
|
||||
MapTypeMode mapTypeMode = ownerKindToMapTypeMode(kind);
|
||||
JetTypeMapperMode mapTypeMode = ownerKindToMapTypeMode(kind);
|
||||
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||
@@ -74,11 +74,11 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
else if (containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||
if (kind instanceof OwnerKind.DelegateKind) {
|
||||
mapTypeMode = MapTypeMode.IMPL;
|
||||
mapTypeMode = JetTypeMapperMode.IMPL;
|
||||
}
|
||||
else {
|
||||
if (classDescriptor.getKind() == ClassKind.OBJECT) {
|
||||
mapTypeMode = MapTypeMode.IMPL;
|
||||
mapTypeMode = JetTypeMapperMode.IMPL;
|
||||
}
|
||||
}
|
||||
Type asmType = mapType(classDescriptor.getDefaultType(), mapTypeMode);
|
||||
@@ -95,12 +95,12 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
}
|
||||
|
||||
private static MapTypeMode ownerKindToMapTypeMode(OwnerKind kind) {
|
||||
private static JetTypeMapperMode ownerKindToMapTypeMode(OwnerKind kind) {
|
||||
if (kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.NAMESPACE || kind instanceof OwnerKind.StaticDelegateKind) {
|
||||
return MapTypeMode.IMPL;
|
||||
return JetTypeMapperMode.IMPL;
|
||||
}
|
||||
else if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
return MapTypeMode.TRAIT_IMPL;
|
||||
return JetTypeMapperMode.TRAIT_IMPL;
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("must not call this method with kind = " + kind);
|
||||
@@ -188,16 +188,16 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
return AsmTypeConstants.OBJECT_TYPE;
|
||||
}
|
||||
return mapType(jetType, signatureVisitor, MapTypeMode.VALUE);
|
||||
return mapType(jetType, signatureVisitor, JetTypeMapperMode.VALUE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(@NotNull final JetType jetType, @NotNull MapTypeMode kind) {
|
||||
public Type mapType(@NotNull final JetType jetType, @NotNull JetTypeMapperMode kind) {
|
||||
return mapType(jetType, null, kind);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(JetType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull MapTypeMode kind) {
|
||||
public Type mapType(JetType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode kind) {
|
||||
Type known = null;
|
||||
ClassifierDescriptor classifier = jetType.getConstructor().getDeclarationDescriptor();
|
||||
|
||||
@@ -208,16 +208,16 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
|
||||
if (known != null) {
|
||||
if (kind == MapTypeMode.VALUE) {
|
||||
if (kind == JetTypeMapperMode.VALUE) {
|
||||
return mapKnownAsmType(jetType, known, signatureVisitor);
|
||||
}
|
||||
else if (kind == MapTypeMode.TYPE_PARAMETER) {
|
||||
else if (kind == JetTypeMapperMode.TYPE_PARAMETER) {
|
||||
return mapKnownAsmType(jetType, boxType(known), signatureVisitor);
|
||||
}
|
||||
else if (kind == MapTypeMode.TRAIT_IMPL) {
|
||||
else if (kind == JetTypeMapperMode.TRAIT_IMPL) {
|
||||
throw new IllegalStateException("TRAIT_IMPL is not possible for " + jetType);
|
||||
}
|
||||
else if (kind == MapTypeMode.IMPL) {
|
||||
else if (kind == JetTypeMapperMode.IMPL) {
|
||||
//noinspection ConstantConditions
|
||||
if (mapBuiltinsToJava) {
|
||||
// TODO: enable and fix tests
|
||||
@@ -262,7 +262,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
if (signatureVisitor != null) {
|
||||
signatureVisitor.writeArrayType(jetType.isNullable());
|
||||
mapType(memberType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||
mapType(memberType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
signatureVisitor.writeArrayEnd();
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
JvmClassName name = getJvmClassName(bindingTrace, (ClassDescriptor) descriptor);
|
||||
Type asmType;
|
||||
if (kind == MapTypeMode.TRAIT_IMPL) {
|
||||
if (kind == JetTypeMapperMode.TRAIT_IMPL) {
|
||||
asmType = Type.getObjectType(name.getInternalName() + JvmAbi.TRAIT_IMPL_SUFFIX);
|
||||
}
|
||||
else {
|
||||
@@ -316,7 +316,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
for (TypeProjection proj : jetType.getArguments()) {
|
||||
// TODO: +-
|
||||
signatureVisitor.writeTypeArgument(proj.getProjectionKind());
|
||||
mapType(proj.getType(), signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||
mapType(proj.getType(), signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
signatureVisitor.writeTypeArgumentEnd();
|
||||
}
|
||||
signatureVisitor.writeClassEnd();
|
||||
@@ -374,7 +374,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
else if (functionDescriptor instanceof ConstructorDescriptor) {
|
||||
assert !superCall;
|
||||
ClassDescriptor containingClass = (ClassDescriptor) functionParent;
|
||||
owner = JvmClassName.byType(mapType(containingClass.getDefaultType(), MapTypeMode.IMPL));
|
||||
owner = JvmClassName.byType(mapType(containingClass.getDefaultType(), JetTypeMapperMode.IMPL));
|
||||
ownerForDefaultImpl = ownerForDefaultParam = owner;
|
||||
invokeOpcode = INVOKESPECIAL;
|
||||
thisClass = null;
|
||||
@@ -407,9 +407,9 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
// TODO: TYPE_PARAMETER is hack here
|
||||
|
||||
boolean isInterface = originalIsInterface && currentIsInterface;
|
||||
Type type = mapType(receiver.getDefaultType(), MapTypeMode.TYPE_PARAMETER);
|
||||
Type type = mapType(receiver.getDefaultType(), JetTypeMapperMode.TYPE_PARAMETER);
|
||||
owner = JvmClassName.byType(type);
|
||||
ownerForDefaultParam = JvmClassName.byType(mapType(declarationOwner.getDefaultType(), MapTypeMode.TYPE_PARAMETER));
|
||||
ownerForDefaultParam = JvmClassName.byType(mapType(declarationOwner.getDefaultType(), JetTypeMapperMode.TYPE_PARAMETER));
|
||||
ownerForDefaultImpl = JvmClassName.byInternalName(
|
||||
ownerForDefaultParam.getInternalName() + (originalIsInterface ? JvmAbi.TRAIT_IMPL_SUFFIX : ""));
|
||||
|
||||
@@ -420,7 +420,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
descriptor = mapSignature(functionDescriptor, false, OwnerKind.TRAIT_IMPL);
|
||||
owner = JvmClassName.byInternalName(owner.getInternalName() + JvmAbi.TRAIT_IMPL_SUFFIX);
|
||||
}
|
||||
thisClass = JvmClassName.byType(mapType(receiver.getDefaultType(), MapTypeMode.VALUE));
|
||||
thisClass = JvmClassName.byType(mapType(receiver.getDefaultType(), JetTypeMapperMode.VALUE));
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("unknown function parent");
|
||||
@@ -429,7 +429,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
Type receiverParameterType;
|
||||
if (functionDescriptor.getReceiverParameter().exists()) {
|
||||
receiverParameterType = mapType(functionDescriptor.getOriginal().getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||
receiverParameterType = mapType(functionDescriptor.getOriginal().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
else {
|
||||
receiverParameterType = null;
|
||||
@@ -475,17 +475,17 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
if (isAccessor(f)) {
|
||||
signatureVisitor.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
mapType(((ClassifierDescriptor) f.getContainingDeclaration()).getDefaultType(), signatureVisitor, MapTypeMode.VALUE);
|
||||
mapType(((ClassifierDescriptor) f.getContainingDeclaration()).getDefaultType(), signatureVisitor, JetTypeMapperMode.VALUE);
|
||||
signatureVisitor.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) f.getContainingDeclaration();
|
||||
JetType jetType = CodegenUtil.getSuperClass(containingDeclaration);
|
||||
Type type = mapType(jetType, MapTypeMode.VALUE);
|
||||
Type type = mapType(jetType, JetTypeMapperMode.VALUE);
|
||||
if (type.getInternalName().equals("java/lang/Object")) {
|
||||
jetType = containingDeclaration.getDefaultType();
|
||||
type = mapType(jetType, MapTypeMode.VALUE);
|
||||
type = mapType(jetType, JetTypeMapperMode.VALUE);
|
||||
}
|
||||
|
||||
signatureVisitor.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
@@ -495,13 +495,13 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
if (receiverType != null) {
|
||||
signatureVisitor.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||
mapType(receiverType, signatureVisitor, MapTypeMode.VALUE);
|
||||
mapType(receiverType, signatureVisitor, JetTypeMapperMode.VALUE);
|
||||
signatureVisitor.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor parameter : parameters) {
|
||||
signatureVisitor.writeParameterType(JvmMethodParameterKind.VALUE);
|
||||
mapType(parameter.getType(), signatureVisitor, MapTypeMode.VALUE);
|
||||
mapType(parameter.getType(), signatureVisitor, JetTypeMapperMode.VALUE);
|
||||
signatureVisitor.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
for (JetType jetType : typeParameterDescriptor.getUpperBounds()) {
|
||||
if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
||||
if (!isInterface(jetType)) {
|
||||
mapType(jetType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||
mapType(jetType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
break classBound;
|
||||
}
|
||||
}
|
||||
@@ -561,13 +561,13 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
|
||||
if (isInterface(jetType)) {
|
||||
signatureVisitor.writeInterfaceBound();
|
||||
mapType(jetType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||
mapType(jetType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
signatureVisitor.writeInterfaceBoundEnd();
|
||||
}
|
||||
}
|
||||
if (jetType.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
|
||||
signatureVisitor.writeInterfaceBound();
|
||||
mapType(jetType, signatureVisitor, MapTypeMode.TYPE_PARAMETER);
|
||||
mapType(jetType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
|
||||
signatureVisitor.writeInterfaceBoundEnd();
|
||||
}
|
||||
}
|
||||
@@ -586,19 +586,19 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
if (isAccessor(f)) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
mapType(((ClassifierDescriptor) f.getContainingDeclaration()).getDefaultType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(((ClassifierDescriptor) f.getContainingDeclaration()).getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
final List<ValueParameterDescriptor> parameters = f.getValueParameters();
|
||||
if (receiver.exists()) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||
mapType(receiver.getType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(receiver.getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
for (ValueParameterDescriptor parameter : parameters) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
|
||||
mapType(parameter.getType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(parameter.getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@@ -630,28 +630,28 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
@SuppressWarnings("ConstantConditions") ClassDescriptor containingDeclaration = (ClassDescriptor) parentDescriptor;
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
mapType(containingDeclaration.getDefaultType(), signatureWriter, MapTypeMode.IMPL);
|
||||
mapType(containingDeclaration.getDefaultType(), signatureWriter, JetTypeMapperMode.IMPL);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
else {
|
||||
if (descriptor instanceof AccessorForPropertyDescriptor) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
mapType(((ClassifierDescriptor) descriptor.getContainingDeclaration()).getDefaultType(), signatureWriter,
|
||||
MapTypeMode.VALUE);
|
||||
JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor.getReceiverParameter().exists()) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
signatureWriter.writeParametersEnd();
|
||||
|
||||
signatureWriter.writeReturnType();
|
||||
mapType(descriptor.getType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(descriptor.getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeReturnTypeEnd();
|
||||
|
||||
JvmMethodSignature jvmMethodSignature = signatureWriter.makeJvmMethodSignature(name);
|
||||
@@ -676,26 +676,26 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) descriptor.getContainingDeclaration();
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
mapType(containingDeclaration.getDefaultType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(containingDeclaration.getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
else {
|
||||
if (descriptor instanceof AccessorForPropertyDescriptor) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
mapType(((ClassifierDescriptor) descriptor.getContainingDeclaration()).getDefaultType(), signatureWriter,
|
||||
MapTypeMode.VALUE);
|
||||
JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor.getReceiverParameter().exists()) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
|
||||
mapType(outType, signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(outType, signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
|
||||
signatureWriter.writeParametersEnd();
|
||||
@@ -720,23 +720,23 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
final ClassDescriptor captureThis = closure != null ? closure.getCaptureThis() : null;
|
||||
if (captureThis != null) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.OUTER);
|
||||
mapType(captureThis.getDefaultType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(captureThis.getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
final ClassifierDescriptor captureReceiver = closure != null ? closure.getCaptureReceiver() : null;
|
||||
if (captureReceiver != null) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||
mapType(captureReceiver.getDefaultType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(captureReceiver.getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
if (containingDeclaration.getKind() == ClassKind.ENUM_CLASS || containingDeclaration.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.ENUM_NAME);
|
||||
mapType(JetStandardLibrary.getInstance().getStringType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(JetStandardLibrary.getInstance().getStringType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.ENUM_ORDINAL);
|
||||
mapType(JetStandardLibrary.getInstance().getIntType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(JetStandardLibrary.getInstance().getIntType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (entry.getKey() instanceof VariableDescriptor && !(entry.getKey() instanceof PropertyDescriptor)) {
|
||||
Type sharedVarType = getSharedVarType(entry.getKey());
|
||||
if (sharedVarType == null) {
|
||||
sharedVarType = mapType(((VariableDescriptor) entry.getKey()).getType(), MapTypeMode.VALUE);
|
||||
sharedVarType = mapType(((VariableDescriptor) entry.getKey()).getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.SHARED_VAR);
|
||||
signatureWriter.writeAsmType(sharedVarType, false);
|
||||
@@ -783,7 +783,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
for (ValueParameterDescriptor parameter : descriptor.getOriginal().getValueParameters()) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
|
||||
mapType(parameter.getType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(parameter.getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@@ -806,13 +806,13 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
|
||||
final ClassDescriptor descriptor = bindingContext.get(CLASS_FOR_FUNCTION, importedScript);
|
||||
assert descriptor != null;
|
||||
mapType(descriptor.getDefaultType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(descriptor.getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor valueParameter : script.getValueParameters()) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
|
||||
mapType(valueParameter.getType(), signatureWriter, MapTypeMode.VALUE);
|
||||
mapType(valueParameter.getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@@ -826,7 +826,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
public CallableMethod mapToCallableMethod(ConstructorDescriptor descriptor, CalculatedClosure closure) {
|
||||
final JvmMethodSignature method = mapConstructorSignature(descriptor, closure);
|
||||
JetType defaultType = descriptor.getContainingDeclaration().getDefaultType();
|
||||
Type mapped = mapType(defaultType, MapTypeMode.IMPL);
|
||||
Type mapped = mapType(defaultType, JetTypeMapperMode.IMPL);
|
||||
if (mapped.getSort() != Type.OBJECT) {
|
||||
throw new IllegalStateException("type must have been mapped to object: " + defaultType + ", actual: " + mapped);
|
||||
}
|
||||
@@ -843,7 +843,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
public Type getSharedVarType(DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof PropertyDescriptor) {
|
||||
return StackValue
|
||||
.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType(), MapTypeMode.VALUE));
|
||||
.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType(), JetTypeMapperMode.VALUE));
|
||||
}
|
||||
else if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||
PsiElement psiElement = descriptorToDeclaration(bindingContext, descriptor);
|
||||
@@ -851,11 +851,11 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
return StackValue
|
||||
.sharedTypeForType(mapType(((FunctionDescriptor) descriptor).getReceiverParameter().getType(), MapTypeMode.VALUE));
|
||||
.sharedTypeForType(mapType(((FunctionDescriptor) descriptor).getReceiverParameter().getType(), JetTypeMapperMode.VALUE));
|
||||
}
|
||||
else if (descriptor instanceof VariableDescriptor && isVarCapturedInClosure(bindingContext, descriptor)) {
|
||||
JetType outType = ((VariableDescriptor) descriptor).getType();
|
||||
return StackValue.sharedTypeForType(mapType(outType, MapTypeMode.VALUE));
|
||||
return StackValue.sharedTypeForType(mapType(outType, JetTypeMapperMode.VALUE));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -869,7 +869,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
JvmClassName owner = getInternalClassName(fd);
|
||||
Type receiverParameterType;
|
||||
if (fd.getReceiverParameter().exists()) {
|
||||
receiverParameterType = mapType(fd.getOriginal().getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||
receiverParameterType = mapType(fd.getOriginal().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
}
|
||||
else {
|
||||
receiverParameterType = null;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.state;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public enum JetTypeMapperMode {
|
||||
/**
|
||||
* foo.Bar is mapped to Lfoo/Bar;
|
||||
*/
|
||||
IMPL,
|
||||
/**
|
||||
* foo.Bar is mapped to Lfoo/Bar$TImpl;
|
||||
*/
|
||||
TRAIT_IMPL,
|
||||
/**
|
||||
* jet.Int is mapped to I
|
||||
*/
|
||||
VALUE,
|
||||
/**
|
||||
* jet.Int is mapped to Ljava/lang/Integer;
|
||||
*/
|
||||
TYPE_PARAMETER,
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
@@ -106,9 +107,9 @@ public class TestlibTest extends CodegenTestCase {
|
||||
DescriptorUtils.addSuperTypes(descriptor.getDefaultType(), allSuperTypes);
|
||||
|
||||
for(JetType type : allSuperTypes) {
|
||||
String internalName = typeMapper.mapType(type, MapTypeMode.IMPL).getInternalName();
|
||||
String internalName = typeMapper.mapType(type, JetTypeMapperMode.IMPL).getInternalName();
|
||||
if(internalName.equals("junit/framework/Test")) {
|
||||
String name = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
String name = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
|
||||
System.out.println(name);
|
||||
Class<TestCase> aClass = (Class<TestCase>) loader.loadClass(name.replace('/', '.'));
|
||||
if ((aClass.getModifiers() & Modifier.ABSTRACT) == 0
|
||||
|
||||
@@ -38,8 +38,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderMode;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.MapTypeMode;
|
||||
import org.jetbrains.jet.codegen.NamespaceCodegen;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
@@ -183,12 +183,12 @@ public class JetPositionManager implements PositionManager {
|
||||
if (classDescriptor == null) {
|
||||
return null;
|
||||
}
|
||||
MapTypeMode mode;
|
||||
JetTypeMapperMode mode;
|
||||
if (jetClass instanceof JetClass && ((JetClass) jetClass).isTrait()) {
|
||||
mode = MapTypeMode.TRAIT_IMPL;
|
||||
mode = JetTypeMapperMode.TRAIT_IMPL;
|
||||
}
|
||||
else {
|
||||
mode = MapTypeMode.IMPL;
|
||||
mode = JetTypeMapperMode.IMPL;
|
||||
}
|
||||
return typeMapper.mapType(classDescriptor.getDefaultType(), mode).getInternalName();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user