JetTypeMapper api cleanup
- mapType got JetTypeMapperMode.VALUE as default parameter - mapType(ClassifierDescriptor) introduced - mapType(VariableDescriptor) introduced
This commit is contained in:
@@ -24,7 +24,6 @@ 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;
|
||||
@@ -103,7 +102,7 @@ public abstract class AnnotationCodegen {
|
||||
return;
|
||||
}
|
||||
|
||||
String internalName = typeMapper.mapType(type, JetTypeMapperMode.VALUE).getDescriptor();
|
||||
String internalName = typeMapper.mapType(type).getDescriptor();
|
||||
AnnotationVisitor annotationVisitor = visitAnnotation(internalName, rp == RetentionPolicy.RUNTIME);
|
||||
|
||||
getAnnotation(resolvedCall, annotationVisitor);
|
||||
@@ -156,8 +155,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(), JetTypeMapperMode.VALUE).getDescriptor(),
|
||||
descriptor.getName().getName());
|
||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +180,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(), JetTypeMapperMode.VALUE));
|
||||
.mapType(call.getResultingDescriptor().getReturnType().getArguments().get(0).getType()));
|
||||
return;
|
||||
}
|
||||
else if (IntrinsicMethods.KOTLIN_ARRAYS_ARRAY.equals(value)) {
|
||||
@@ -197,7 +195,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(), JetTypeMapperMode.VALUE).getDescriptor());
|
||||
.mapType(descriptor.getContainingDeclaration()).getDescriptor());
|
||||
getAnnotation(call, visitor);
|
||||
visitor.visitEnd();
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,6 @@ 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.*;
|
||||
@@ -109,7 +108,7 @@ public abstract class ClassBodyCodegen extends GenerationStateAware {
|
||||
}
|
||||
}
|
||||
else {
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor);
|
||||
v.newMethod(p, ACC_PUBLIC | ACC_ABSTRACT, p.getName(), "()" + type.getDescriptor(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,15 +190,14 @@ 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(), JetTypeMapperMode.VALUE), iv);
|
||||
.upcast(typeMapper.mapType(receiver.getType()), iv);
|
||||
count++;
|
||||
}
|
||||
|
||||
final List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
|
||||
for (ValueParameterDescriptor param : params) {
|
||||
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
StackValue.onStack(OBJECT_TYPE)
|
||||
.upcast(typeMapper.mapType(param.getType(), JetTypeMapperMode.VALUE), iv);
|
||||
StackValue.onStack(OBJECT_TYPE).upcast(typeMapper.mapType(param.getType()), iv);
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -258,13 +257,12 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
) {
|
||||
final ClassDescriptor captureThis = closure.getCaptureThis();
|
||||
if (captureThis != null) {
|
||||
final Type type = typeMapper.mapType(captureThis.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
final Type type = typeMapper.mapType(captureThis);
|
||||
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(), JetTypeMapperMode.VALUE)));
|
||||
args.add(new Pair<String, Type>(RECEIVER$0, typeMapper.mapType(captureReceiver)));
|
||||
}
|
||||
|
||||
for (DeclarationDescriptor descriptor : closure.getCaptureVariables().keySet()) {
|
||||
@@ -273,7 +271,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
|
||||
final Type type = sharedVarType != null
|
||||
? sharedVarType
|
||||
: typeMapper.mapType(((VariableDescriptor) descriptor).getType(), JetTypeMapperMode.VALUE);
|
||||
: typeMapper.mapType((VariableDescriptor) descriptor);
|
||||
args.add(new Pair<String, Type>("$" + descriptor.getName().getName(), type));
|
||||
}
|
||||
else if (isLocalNamedFun(state.getBindingContext(), descriptor)) {
|
||||
|
||||
@@ -31,7 +31,6 @@ 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.JetClassObject;
|
||||
@@ -216,13 +215,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(), JetTypeMapperMode.VALUE).getDescriptor(), null,
|
||||
v.newField(null, access, THIS$0, typeMapper.mapType(captureThis).getDescriptor(), null,
|
||||
null);
|
||||
}
|
||||
|
||||
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
|
||||
if (captureReceiver != null) {
|
||||
v.newField(null, access, RECEIVER$0, typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.VALUE).getDescriptor(),
|
||||
v.newField(null, access, RECEIVER$0, typeMapper.mapType(captureReceiver).getDescriptor(),
|
||||
null, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
@NotNull
|
||||
private Type asmType(@NotNull JetType type) {
|
||||
return typeMapper.mapType(type, JetTypeMapperMode.VALUE);
|
||||
return typeMapper.mapType(type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1118,7 +1118,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(), JetTypeMapperMode.VALUE);
|
||||
sharedVarType = typeMapper.mapType((VariableDescriptor) entry.getKey());
|
||||
}
|
||||
entry.getValue().getOuterValue(this).put(sharedVarType, v);
|
||||
//}
|
||||
@@ -1400,7 +1400,7 @@ 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(), JetTypeMapperMode.VALUE);
|
||||
final Type type = typeMapper.mapType(descriptor1);
|
||||
return StackValue.field(type,
|
||||
JvmClassName.byType(typeMapper.mapType(((ClassDescriptor) descriptor).getDefaultType(),
|
||||
JetTypeMapperMode.IMPL)),
|
||||
@@ -1450,7 +1450,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, false);
|
||||
script.put(script.type, v);
|
||||
Type fieldType = typeMapper.mapType(valueParameterDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
Type fieldType = typeMapper.mapType(valueParameterDescriptor);
|
||||
return StackValue.field(fieldType, scriptClassName, valueParameterDescriptor.getName().getIdentifier(), false);
|
||||
}
|
||||
|
||||
@@ -1462,7 +1462,7 @@ 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(), JetTypeMapperMode.VALUE);
|
||||
Type type = typeMapper.mapType(containing);
|
||||
return StackValue.field(type, JvmClassName.byType(type), variableDescriptor.getName().getName(), true);
|
||||
}
|
||||
else {
|
||||
@@ -1753,7 +1753,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
JetType type = resolvedCall.getCandidateDescriptor().getReturnType();
|
||||
assert type != null;
|
||||
Type callType = typeMapper.mapType(type, JetTypeMapperMode.VALUE);
|
||||
Type callType = typeMapper.mapType(type);
|
||||
|
||||
Type exprType = asmTypeOrVoid(type);
|
||||
StackValue stackValue = intrinsic.generate(this, v, callType, call.getCallElement(), args, receiver, state);
|
||||
@@ -1975,7 +1975,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert !isSuper;
|
||||
|
||||
if (context.hasThisDescriptor() && context.getThisDescriptor().equals(calleeContainingClass)) {
|
||||
return StackValue.local(0, typeMapper.mapType(calleeContainingClass.getDefaultType(), JetTypeMapperMode.VALUE));
|
||||
return StackValue.local(0, typeMapper.mapType(calleeContainingClass));
|
||||
}
|
||||
else {
|
||||
return StackValue.singleton(calleeContainingClass, typeMapper);
|
||||
@@ -2915,7 +2915,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, JetTypeMapperMode.VALUE);
|
||||
type = typeMapper.mapType(expressionType);
|
||||
if (type.getSort() == Type.ARRAY) {
|
||||
generateNewArray(expression, expressionType);
|
||||
}
|
||||
@@ -2987,7 +2987,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType())));
|
||||
}
|
||||
else {
|
||||
Type type = typeMapper.mapType(arrayType, JetTypeMapperMode.VALUE);
|
||||
Type type = typeMapper.mapType(arrayType);
|
||||
gen(args.get(0), Type.INT_TYPE);
|
||||
v.newarray(correctElementType(type));
|
||||
}
|
||||
|
||||
@@ -268,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(), JetTypeMapperMode.VALUE);
|
||||
Type localVarType = state.getTypeMapper().mapType(parameter);
|
||||
int index = frameMap.getIndex(parameter);
|
||||
mv.visitTypeInsn(NEW, sharedVarType.getInternalName());
|
||||
mv.visitInsn(DUP);
|
||||
@@ -302,26 +302,25 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
int k = 0;
|
||||
|
||||
if (expectedThisObject.exists()) {
|
||||
Type type = state.getTypeMapper().mapType(expectedThisObject.getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(expectedThisObject.getType());
|
||||
// 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(), JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(context.getThisDescriptor());
|
||||
mv.visitLocalVariable("this", type.getDescriptor(), null, methodBegin, methodEnd, k++);
|
||||
}
|
||||
|
||||
if (receiverParameter.exists()) {
|
||||
Type type = state.getTypeMapper().mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(receiverParameter.getType());
|
||||
// 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(), JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(parameter);
|
||||
// TODO: specify signature
|
||||
|
||||
Label divideLabel = mapLabelsToDivideLocalVarVisibilityForSharedVar.get(parameter.getName());
|
||||
@@ -515,7 +514,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
|
||||
Type receiverType;
|
||||
if (hasReceiver) {
|
||||
receiverType = state.getTypeMapper().mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
receiverType = state.getTypeMapper().mapType(receiverParameter.getType());
|
||||
var += receiverType.getSize();
|
||||
}
|
||||
else {
|
||||
@@ -667,7 +666,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
iv.invokevirtual(state.getTypeMapper().mapType(
|
||||
((ClassDescriptor) owner.getContextDescriptor()).getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(),
|
||||
(ClassDescriptor) owner.getContextDescriptor()).getInternalName(),
|
||||
jvmSignature.getName(), jvmSignature.getDescriptor());
|
||||
if (isPrimitive(jvmSignature.getReturnType()) && !isPrimitive(overridden.getReturnType())) {
|
||||
StackValue.valueOf(iv, jvmSignature.getReturnType());
|
||||
@@ -722,7 +721,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) overriddenDescriptor.getContainingDeclaration();
|
||||
String internalName =
|
||||
state.getTypeMapper().mapType(classDescriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName();
|
||||
state.getTypeMapper().mapType(classDescriptor).getInternalName();
|
||||
if (classDescriptor.getKind() == ClassKind.TRAIT) {
|
||||
iv.invokeinterface(internalName, method.getName(), method.getDescriptor());
|
||||
}
|
||||
|
||||
@@ -317,11 +317,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, JetTypeMapperMode.VALUE).getInternalName();
|
||||
superClass = typeMapper.mapType(superClassType).getInternalName();
|
||||
}
|
||||
if (descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
superClassType = descriptor.getTypeConstructor().getSupertypes().iterator().next();
|
||||
superClass = typeMapper.mapType(superClassType, JetTypeMapperMode.VALUE).getInternalName();
|
||||
superClass = typeMapper.mapType(superClassType).getInternalName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -410,7 +410,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
MethodVisitor mv =
|
||||
v.newMethod(myClass, ACC_PUBLIC | ACC_STATIC, "values", "()" + type.getDescriptor(), null, null);
|
||||
mv.visitCode();
|
||||
mv.visitFieldInsn(GETSTATIC, typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(),
|
||||
mv.visitFieldInsn(GETSTATIC, typeMapper.mapType(descriptor).getInternalName(),
|
||||
VALUES,
|
||||
type.getDescriptor());
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, type.getInternalName(), "clone", "()Ljava/lang/Object;");
|
||||
@@ -572,7 +572,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
private void generateFieldForObjectInstance() {
|
||||
if (isNonLiteralObject(myClass)) {
|
||||
Type type = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
Type type = typeMapper.mapType(descriptor);
|
||||
v.newField(myClass, ACC_PUBLIC | ACC_STATIC | ACC_FINAL, "$instance", type.getDescriptor(), null, null);
|
||||
|
||||
staticInitializerChunks.add(new CodeChunk() {
|
||||
@@ -583,7 +583,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
v.dup();
|
||||
v.invokespecial(name, "<init>", "()V");
|
||||
v.putstatic(name, "$instance",
|
||||
typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getDescriptor());
|
||||
typeMapper.mapType(descriptor).getDescriptor());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -594,7 +594,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(), JetTypeMapperMode.VALUE).getInternalName());
|
||||
Type type = Type.getObjectType(typeMapper.mapType(descriptor1).getInternalName());
|
||||
v.newField(classObject, ACC_PUBLIC | ACC_STATIC, "$classobj", type.getDescriptor(), null, null);
|
||||
|
||||
staticInitializerChunks.add(new CodeChunk() {
|
||||
@@ -607,7 +607,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
v.anew(classObjectType);
|
||||
v.dup();
|
||||
v.invokespecial(name, "<init>", "()V");
|
||||
v.putstatic(typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(), "$classobj",
|
||||
v.putstatic(typeMapper.mapType(descriptor).getInternalName(), "$classobj",
|
||||
classObjectType.getDescriptor());
|
||||
}
|
||||
});
|
||||
@@ -697,7 +697,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
if (hasThis0) {
|
||||
final Type type = typeMapper
|
||||
.mapType(enclosingClassDescriptor(bindingContext, descriptor).getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
.mapType(enclosingClassDescriptor(bindingContext, descriptor));
|
||||
String interfaceDesc = type.getDescriptor();
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getOuterThisIndex(), type);
|
||||
@@ -706,7 +706,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
if (closure != null) {
|
||||
int k = hasThis0 ? 2 : 1;
|
||||
final String internalName = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName();
|
||||
final String internalName = typeMapper.mapType(descriptor).getInternalName();
|
||||
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
|
||||
if (captureReceiver != null) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
@@ -720,7 +720,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(), JetTypeMapperMode.VALUE);
|
||||
sharedVarType = typeMapper.mapType((VariableDescriptor) varDescr);
|
||||
}
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
iv.load(k, StackValue.refType(sharedVarType));
|
||||
@@ -747,7 +747,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(), JetTypeMapperMode.VALUE);
|
||||
Type type = typeMapper.mapType(descriptor);
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getIndex(descriptor), type);
|
||||
iv.putfield(classname.getInternalName(), descriptor.getName().getName(), type.getDescriptor());
|
||||
@@ -774,11 +774,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
if (CodegenBinding.hasThis0(bindingContext, superClassDescriptor)) {
|
||||
iv.load(1, OBJECT_TYPE);
|
||||
parameterTypes.add(typeMapper.mapType(
|
||||
enclosingClassDescriptor(bindingContext, descriptor).getDefaultType(), JetTypeMapperMode.VALUE));
|
||||
enclosingClassDescriptor(bindingContext, descriptor)));
|
||||
}
|
||||
Method superCallMethod = new Method("<init>", Type.VOID_TYPE, parameterTypes.toArray(new Type[parameterTypes.size()]));
|
||||
//noinspection ConstantConditions
|
||||
iv.invokespecial(typeMapper.mapType(superClassDescriptor.getDefaultType(), JetTypeMapperMode.VALUE).getInternalName(), "<init>",
|
||||
iv.invokespecial(typeMapper.mapType(superClassDescriptor).getInternalName(), "<init>",
|
||||
superCallMethod.getDescriptor());
|
||||
}
|
||||
|
||||
@@ -866,7 +866,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
!propertyDescriptor.isVar() &&
|
||||
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
|
||||
// final property with backing field
|
||||
field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE), classname,
|
||||
field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classname,
|
||||
propertyDescriptor.getName().getName(), false);
|
||||
}
|
||||
else {
|
||||
@@ -874,7 +874,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
codegen.genToJVMStack(expression);
|
||||
|
||||
String delegateField = "$delegate_" + n;
|
||||
Type fieldType = typeMapper.mapType(superClassDescriptor.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
Type fieldType = typeMapper.mapType(superClassDescriptor.getDefaultType());
|
||||
String fieldDesc = fieldType.getDescriptor();
|
||||
|
||||
v.newField(specifier, ACC_PRIVATE|ACC_FINAL|ACC_SYNTHETIC, delegateField, fieldDesc, /*TODO*/null, null);
|
||||
@@ -1258,7 +1258,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
final JetType jetType = propertyDescriptor.getType();
|
||||
if (compileTimeValue != null) {
|
||||
Object value = compileTimeValue.getValue();
|
||||
Type type = typeMapper.mapType(jetType, JetTypeMapperMode.VALUE);
|
||||
Type type = typeMapper.mapType(jetType);
|
||||
if (skipDefaultValue(propertyDescriptor, value, type)) continue;
|
||||
}
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
@@ -1269,7 +1269,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, JetTypeMapperMode.VALUE);
|
||||
Type propType = typeMapper.mapType(jetType);
|
||||
StackValue.property(propertyDescriptor.getName().getName(), owner, owner,
|
||||
propType, false, false, false, null, null, 0).store(propType, iv);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ 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.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;
|
||||
@@ -112,7 +111,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
||||
modifiers |= ACC_VOLATILE;
|
||||
}
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(propertyDescriptor);
|
||||
FieldVisitor fieldVisitor = v.newField(p, modifiers, propertyDescriptor.getName().getName(), type.getDescriptor(), null, value);
|
||||
AnnotationCodegen.forField(fieldVisitor, state.getTypeMapper()).genAnnotations(propertyDescriptor);
|
||||
}
|
||||
@@ -220,7 +219,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
if (kind != OwnerKind.NAMESPACE) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
}
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor);
|
||||
|
||||
if ((kind instanceof OwnerKind.DelegateKind) != (propertyDescriptor.getKind() == FunctionDescriptor.Kind.DELEGATION)) {
|
||||
throw new IllegalStateException("mismatching kind in " + propertyDescriptor);
|
||||
@@ -318,7 +317,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
||||
}
|
||||
else {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor.getType(), JetTypeMapperMode.VALUE);
|
||||
final Type type = state.getTypeMapper().mapType(propertyDescriptor);
|
||||
int paramCode = 0;
|
||||
if (kind != OwnerKind.NAMESPACE) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
|
||||
@@ -29,7 +29,6 @@ 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;
|
||||
@@ -115,7 +114,7 @@ public class ScriptCodegen extends GenerationStateAware {
|
||||
@NotNull List<ScriptDescriptor> importedScripts
|
||||
) {
|
||||
|
||||
Type blockType = typeMapper.mapType(scriptDescriptor.getReturnType(), JetTypeMapperMode.VALUE);
|
||||
Type blockType = typeMapper.mapType(scriptDescriptor.getReturnType());
|
||||
|
||||
classBuilder.newField(null, ACC_PUBLIC | ACC_FINAL, ScriptNameUtil.LAST_EXPRESSION_VALUE_FIELD_NAME,
|
||||
blockType.getDescriptor(), null, null);
|
||||
@@ -173,7 +172,7 @@ public class ScriptCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor parameter : scriptDescriptor.getValueParameters()) {
|
||||
Type parameterType = typeMapper.mapType(parameter.getType(), JetTypeMapperMode.VALUE);
|
||||
Type parameterType = typeMapper.mapType(parameter.getType());
|
||||
instructionAdapter.load(0, className.getAsmType());
|
||||
instructionAdapter.load(offset, parameterType);
|
||||
offset += parameterType.getSize();
|
||||
@@ -202,7 +201,7 @@ public class ScriptCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor parameter : script.getValueParameters()) {
|
||||
Type parameterType = typeMapper.mapType(parameter.getType(), JetTypeMapperMode.VALUE);
|
||||
Type parameterType = typeMapper.mapType(parameter);
|
||||
int access = ACC_PUBLIC | ACC_FINAL;
|
||||
classBuilder.newField(null, access, parameter.getName().getIdentifier(), parameterType.getDescriptor(), null, null);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
|
||||
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.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
@@ -357,7 +356,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
public static StackValue singleton(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) {
|
||||
final Type type = typeMapper.mapType(classDescriptor.getDefaultType(), JetTypeMapperMode.VALUE);
|
||||
final Type type = typeMapper.mapType(classDescriptor.getDefaultType());
|
||||
|
||||
final ClassKind kind = classDescriptor.getKind();
|
||||
if (kind == ClassKind.CLASS_OBJECT || kind == ClassKind.OBJECT) {
|
||||
@@ -727,7 +726,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(), JetTypeMapperMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
|
||||
int sz = type.getSize();
|
||||
frame.enterTemp(type);
|
||||
lastIndex += sz;
|
||||
@@ -749,7 +748,7 @@ public abstract class StackValue {
|
||||
ReceiverDescriptor receiverParameter = resolvedGetCall.getReceiverArgument();
|
||||
int receiverIndex = -1;
|
||||
if (receiverParameter.exists()) {
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType());
|
||||
int sz = type.getSize();
|
||||
frame.enterTemp(type);
|
||||
lastIndex += sz;
|
||||
@@ -773,7 +772,7 @@ public abstract class StackValue {
|
||||
if (thisIndex != -1) {
|
||||
if (receiverIndex != -1) {
|
||||
realReceiverIndex = receiverIndex;
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType());
|
||||
}
|
||||
else {
|
||||
realReceiverIndex = thisIndex;
|
||||
@@ -782,7 +781,7 @@ public abstract class StackValue {
|
||||
}
|
||||
else {
|
||||
if (receiverIndex != -1) {
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType());
|
||||
realReceiverIndex = receiverIndex;
|
||||
}
|
||||
else {
|
||||
@@ -807,7 +806,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(), JetTypeMapperMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
|
||||
int sz = type.getSize();
|
||||
v.load(index - sz, type);
|
||||
index -= sz;
|
||||
@@ -819,7 +818,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
if (receiverIndex != -1) {
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType());
|
||||
v.load(receiverIndex - type.getSize(), type);
|
||||
}
|
||||
|
||||
@@ -835,7 +834,7 @@ public abstract class StackValue {
|
||||
|
||||
index = firstParamIndex;
|
||||
for (int i = 0; i != valueParameters.size(); ++i) {
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = codegen.typeMapper.mapType(valueParameters.get(i).getType());
|
||||
int sz = type.getSize();
|
||||
v.load(index - sz, type);
|
||||
index -= sz;
|
||||
@@ -864,7 +863,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor valueParameter : valueParameters) {
|
||||
if (codegen.typeMapper.mapType(valueParameter.getType(), JetTypeMapperMode.VALUE).getSize() != 1) {
|
||||
if (codegen.typeMapper.mapType(valueParameter.getType()).getSize() != 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -875,7 +874,7 @@ public abstract class StackValue {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType(), JetTypeMapperMode.VALUE)
|
||||
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType())
|
||||
.getSize() != 1) {
|
||||
return false;
|
||||
}
|
||||
@@ -1267,10 +1266,10 @@ public abstract class StackValue {
|
||||
}
|
||||
else {
|
||||
if (receiverArgument.exists()) {
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType());
|
||||
}
|
||||
else {
|
||||
return codegen.typeMapper.mapType(descriptor.getExpectedThisObject().getType(), JetTypeMapperMode.VALUE);
|
||||
return codegen.typeMapper.mapType(descriptor.getExpectedThisObject().getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1280,7 +1279,7 @@ public abstract class StackValue {
|
||||
return callableMethod.getReceiverClass();
|
||||
}
|
||||
else {
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1302,7 +1301,7 @@ public abstract class StackValue {
|
||||
}
|
||||
else {
|
||||
codegen.generateFromResolvedCall(thisObject, codegen.typeMapper
|
||||
.mapType(descriptor.getExpectedThisObject().getType(), JetTypeMapperMode.VALUE));
|
||||
.mapType(descriptor.getExpectedThisObject().getType()));
|
||||
}
|
||||
genReceiver(v, receiverArgument, type, descriptor.getReceiverParameter(), 1);
|
||||
}
|
||||
@@ -1323,7 +1322,7 @@ public abstract class StackValue {
|
||||
) {
|
||||
if (receiver == StackValue.none()) {
|
||||
if (receiverParameter != null) {
|
||||
Type receiverType = codegen.typeMapper.mapType(receiverParameter.getType(), JetTypeMapperMode.VALUE);
|
||||
Type receiverType = codegen.typeMapper.mapType(receiverParameter.getType());
|
||||
codegen.generateFromResolvedCall(receiverArgument, receiverType);
|
||||
StackValue.onStack(receiverType).put(type, v);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ 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;
|
||||
|
||||
@@ -196,7 +195,7 @@ public abstract class CodegenContext {
|
||||
|
||||
CallableDescriptor receiverDescriptor = getCallableDescriptorWithReceiver();
|
||||
if (receiverDescriptor != null) {
|
||||
Type type = mapper.mapType(receiverDescriptor.getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = mapper.mapType(receiverDescriptor.getReceiverParameter().getType());
|
||||
frameMap.enterTemp(type); // Next slot for receiver
|
||||
}
|
||||
|
||||
@@ -243,7 +242,7 @@ public abstract class CodegenContext {
|
||||
public StackValue getReceiverExpression(JetTypeMapper typeMapper) {
|
||||
assert getCallableDescriptorWithReceiver() != null;
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
Type asmType = typeMapper.mapType(getCallableDescriptorWithReceiver().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
Type asmType = typeMapper.mapType(getCallableDescriptorWithReceiver().getReceiverParameter().getType());
|
||||
return hasThisDescriptor() ? StackValue.local(1, asmType) : StackValue.local(0, asmType);
|
||||
}
|
||||
|
||||
@@ -262,7 +261,7 @@ public abstract class CodegenContext {
|
||||
final ClassDescriptor enclosingClass = getEnclosingClass();
|
||||
outerExpression = enclosingClass != null
|
||||
? StackValue
|
||||
.field(typeMapper.mapType(enclosingClass.getDefaultType(), JetTypeMapperMode.VALUE), CodegenBinding.getJvmClassName(
|
||||
.field(typeMapper.mapType(enclosingClass), CodegenBinding.getJvmClassName(
|
||||
typeMapper.getBindingTrace(), classDescriptor), CodegenUtil.THIS$0,
|
||||
false)
|
||||
: null;
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
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;
|
||||
@@ -58,7 +57,7 @@ public interface LocalLookup {
|
||||
if (!idx) return null;
|
||||
|
||||
final Type sharedVarType = state.getTypeMapper().getSharedVarType(vd);
|
||||
Type localType = state.getTypeMapper().mapType(vd.getType(), JetTypeMapperMode.VALUE);
|
||||
Type localType = state.getTypeMapper().mapType(vd);
|
||||
final Type type = sharedVarType != null ? sharedVarType : localType;
|
||||
|
||||
final String fieldName = "$" + vd.getName();
|
||||
@@ -122,7 +121,7 @@ public interface LocalLookup {
|
||||
if (closure.getEnclosingReceiverDescriptor() != d) return null;
|
||||
|
||||
final JetType receiverType = ((CallableDescriptor) d).getReceiverParameter().getType();
|
||||
Type type = state.getTypeMapper().mapType(receiverType, JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(receiverType);
|
||||
StackValue innerValue = StackValue.field(type, className, CodegenUtil.RECEIVER$0, false);
|
||||
closure.setCaptureReceiver();
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.jet.codegen.AsmTypeConstants;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
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;
|
||||
@@ -51,8 +50,7 @@ public class EnumValueOf implements IntrinsicMethod {
|
||||
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
||||
JetType returnType = resultingDescriptor.getReturnType();
|
||||
assert returnType != null;
|
||||
Type type = state.getTypeMapper().mapType(
|
||||
returnType, JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(returnType);
|
||||
assert arguments != null;
|
||||
codegen.gen(arguments.get(0), AsmTypeConstants.JAVA_STRING_TYPE);
|
||||
v.invokestatic(type.getInternalName(), "valueOf", "(Ljava/lang/String;)" + type.getDescriptor());
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
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,8 +49,7 @@ public class EnumValues implements IntrinsicMethod {
|
||||
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
||||
JetType returnType = resultingDescriptor.getReturnType();
|
||||
assert returnType != null;
|
||||
Type type = state.getTypeMapper().mapType(
|
||||
returnType, JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(returnType);
|
||||
v.invokestatic(type.getElementType().getInternalName(), "values", "()" + type);
|
||||
StackValue.onStack(type).put(expectedType, v);
|
||||
return StackValue.onStack(expectedType);
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.jet.codegen.AsmTypeConstants;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
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;
|
||||
@@ -52,8 +51,7 @@ public class JavaClassFunction implements IntrinsicMethod {
|
||||
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
|
||||
JetType returnType = resultingDescriptor.getReturnType();
|
||||
assert returnType != null;
|
||||
Type type = state.getTypeMapper().mapType(
|
||||
returnType.getArguments().get(0).getType(), JetTypeMapperMode.VALUE);
|
||||
Type type = state.getTypeMapper().mapType(returnType.getArguments().get(0).getType());
|
||||
JvmPrimitiveType primitiveType = JvmPrimitiveType.getByAsmType(type);
|
||||
if (primitiveType != null) {
|
||||
v.getstatic(primitiveType.getWrapper().getAsmType().getInternalName(), "TYPE", "Ljava/lang/Class;");
|
||||
|
||||
@@ -200,6 +200,21 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return mapType(jetType, null, kind);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(@NotNull final JetType jetType) {
|
||||
return mapType(jetType, null, JetTypeMapperMode.VALUE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(@NotNull final VariableDescriptor variableDescriptor) {
|
||||
return mapType(variableDescriptor.getType(), null, JetTypeMapperMode.VALUE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(@NotNull final ClassifierDescriptor classifierDescriptor) {
|
||||
return mapType(classifierDescriptor.getDefaultType());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type mapType(JetType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode kind) {
|
||||
Type known = null;
|
||||
@@ -422,7 +437,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(), JetTypeMapperMode.VALUE));
|
||||
thisClass = JvmClassName.byType(mapType(receiver.getDefaultType()));
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("unknown function parent");
|
||||
@@ -431,7 +446,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
Type receiverParameterType;
|
||||
if (functionDescriptor.getReceiverParameter().exists()) {
|
||||
receiverParameterType = mapType(functionDescriptor.getOriginal().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
receiverParameterType = mapType(functionDescriptor.getOriginal().getReceiverParameter().getType());
|
||||
}
|
||||
else {
|
||||
receiverParameterType = null;
|
||||
@@ -480,10 +495,10 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
ClassDescriptor containingDeclaration = (ClassDescriptor) f.getContainingDeclaration();
|
||||
JetType jetType = CodegenUtil.getSuperClass(containingDeclaration);
|
||||
Type type = mapType(jetType, JetTypeMapperMode.VALUE);
|
||||
Type type = mapType(jetType);
|
||||
if (type.getInternalName().equals("java/lang/Object")) {
|
||||
jetType = containingDeclaration.getDefaultType();
|
||||
type = mapType(jetType, JetTypeMapperMode.VALUE);
|
||||
type = mapType(jetType);
|
||||
}
|
||||
|
||||
signatureVisitor.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
@@ -743,7 +758,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(), JetTypeMapperMode.VALUE);
|
||||
sharedVarType = mapType(((VariableDescriptor) entry.getKey()).getType());
|
||||
}
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.SHARED_VAR);
|
||||
signatureWriter.writeAsmType(sharedVarType, false);
|
||||
@@ -839,7 +854,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
public Type getSharedVarType(DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof PropertyDescriptor) {
|
||||
return StackValue
|
||||
.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType(), JetTypeMapperMode.VALUE));
|
||||
.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType()));
|
||||
}
|
||||
else if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||
PsiElement psiElement = descriptorToDeclaration(bindingContext, descriptor);
|
||||
@@ -847,11 +862,11 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
return StackValue
|
||||
.sharedTypeForType(mapType(((FunctionDescriptor) descriptor).getReceiverParameter().getType(), JetTypeMapperMode.VALUE));
|
||||
.sharedTypeForType(mapType(((FunctionDescriptor) descriptor).getReceiverParameter().getType()));
|
||||
}
|
||||
else if (descriptor instanceof VariableDescriptor && isVarCapturedInClosure(bindingContext, descriptor)) {
|
||||
JetType outType = ((VariableDescriptor) descriptor).getType();
|
||||
return StackValue.sharedTypeForType(mapType(outType, JetTypeMapperMode.VALUE));
|
||||
return StackValue.sharedTypeForType(mapType(outType));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -865,7 +880,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
JvmClassName owner = getInternalClassName(fd);
|
||||
Type receiverParameterType;
|
||||
if (fd.getReceiverParameter().exists()) {
|
||||
receiverParameterType = mapType(fd.getOriginal().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
receiverParameterType = mapType(fd.getOriginal().getReceiverParameter().getType());
|
||||
}
|
||||
else {
|
||||
receiverParameterType = null;
|
||||
|
||||
Reference in New Issue
Block a user