replace String with JvmClassName for readability
This commit is contained in:
@@ -199,7 +199,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
||||
ClassDescriptor function = state.getInjector().getJetTypeMapper().getClosureAnnotator().classDescriptorForFunctionDescriptor(funDescriptor, name);
|
||||
|
||||
final CodegenContexts.ClosureContext closureContext = context.intoClosure(
|
||||
funDescriptor, function, name.getInternalName(), this, state.getInjector().getJetTypeMapper());
|
||||
funDescriptor, function, name, this, state.getInjector().getJetTypeMapper());
|
||||
FunctionCodegen fc = new FunctionCodegen(closureContext, cv, state);
|
||||
JvmMethodSignature jvmMethodSignature = invokeSignature(funDescriptor);
|
||||
fc.generateMethod(body, jvmMethodSignature, false, null, funDescriptor);
|
||||
@@ -328,7 +328,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
||||
}
|
||||
i += type.getSize();
|
||||
|
||||
StackValue.field(type, name.getInternalName(), fieldName, false).store(iv);
|
||||
StackValue.field(type, name, fieldName, false).store(iv);
|
||||
}
|
||||
|
||||
iv.visitInsn(RETURN);
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.objectweb.asm.Type;
|
||||
@@ -129,7 +130,7 @@ public abstract class CodegenContext {
|
||||
return new CodegenContexts.ScriptContext(script, OwnerKind.IMPLEMENTATION, this, closure);
|
||||
}
|
||||
|
||||
public CodegenContexts.ClosureContext intoClosure(FunctionDescriptor funDescriptor, ClassDescriptor classDescriptor, String internalClassName, ClosureCodegen closureCodegen, JetTypeMapper typeMapper) {
|
||||
public CodegenContexts.ClosureContext intoClosure(FunctionDescriptor funDescriptor, ClassDescriptor classDescriptor, JvmClassName internalClassName, ClosureCodegen closureCodegen, JetTypeMapper typeMapper) {
|
||||
return new CodegenContexts.ClosureContext(funDescriptor, classDescriptor, this, closureCodegen, internalClassName, typeMapper);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyAccessorDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
@@ -145,7 +146,7 @@ public class CodegenContexts {
|
||||
|
||||
final Type type = enclosingClassType(typeMapper);
|
||||
outerExpression = type != null
|
||||
? StackValue.field(type, typeMapper.getFQName(contextType), "this$0", false)
|
||||
? StackValue.field(type, JvmClassName.byInternalName(typeMapper.getFQName(contextType)), "this$0", false)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ public class CodegenContexts {
|
||||
final Type type = enclosingClassType(typeMapper);
|
||||
Type owner = closure.state.getInjector().getJetTypeMapper().mapType(contextType.getDefaultType(), MapTypeMode.IMPL);
|
||||
outerExpression = type != null
|
||||
? StackValue.field(type, owner.getInternalName(), "this$0", false)
|
||||
? StackValue.field(type, JvmClassName.byType(owner), "this$0", false)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -190,7 +191,7 @@ public class CodegenContexts {
|
||||
public static class ClosureContext extends ReceiverContext {
|
||||
private ClassDescriptor classDescriptor;
|
||||
|
||||
public ClosureContext(FunctionDescriptor contextType, ClassDescriptor classDescriptor, CodegenContext parentContext, @NotNull ObjectOrClosureCodegen closureCodegen, String internalClassName, JetTypeMapper typeMapper) {
|
||||
public ClosureContext(FunctionDescriptor contextType, ClassDescriptor classDescriptor, CodegenContext parentContext, @NotNull ObjectOrClosureCodegen closureCodegen, JvmClassName internalClassName, JetTypeMapper typeMapper) {
|
||||
super(contextType, OwnerKind.IMPLEMENTATION, parentContext, closureCodegen);
|
||||
this.classDescriptor = classDescriptor;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
@@ -1010,7 +1011,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if(classDescriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
ClassDescriptor containing = (ClassDescriptor) classDescriptor.getContainingDeclaration().getContainingDeclaration();
|
||||
Type type = typeMapper.mapType(containing.getDefaultType(), MapTypeMode.VALUE);
|
||||
StackValue.field(type, type.getInternalName(), classDescriptor.getName().getName(), true).put(TYPE_OBJECT, v);
|
||||
StackValue.field(type, JvmClassName.byType(type), classDescriptor.getName().getName(), true).put(TYPE_OBJECT, v);
|
||||
|
||||
// todo: for now we don't generate classes for enum entries, so we need this hack
|
||||
type = typeMapper.mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||
@@ -1018,7 +1019,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
else {
|
||||
Type type = typeMapper.mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||
return StackValue.field(type, type.getInternalName(), "$instance", true);
|
||||
return StackValue.field(type, JvmClassName.byType(type), "$instance", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1043,7 +1044,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if(!directToField && resolvedCall != null && !isSuper) {
|
||||
receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic
|
||||
? receiver.type
|
||||
: Type.getObjectType(iValue.methodOwner), v);
|
||||
: iValue.methodOwner.getAsmType(), v);
|
||||
}
|
||||
else {
|
||||
if (!isStatic) {
|
||||
@@ -1083,9 +1084,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
assert descriptor1 != null;
|
||||
final Type type = typeMapper.mapType(descriptor1.getDefaultType(), MapTypeMode.VALUE);
|
||||
return StackValue.field(type,
|
||||
typeMapper.mapType(((ClassDescriptor) descriptor).getDefaultType(), MapTypeMode.IMPL).getInternalName(),
|
||||
"$classobj",
|
||||
true);
|
||||
JvmClassName.byType(typeMapper.mapType(((ClassDescriptor) descriptor).getDefaultType(), MapTypeMode.IMPL)),
|
||||
"$classobj",
|
||||
true);
|
||||
}
|
||||
else {
|
||||
// todo ?
|
||||
@@ -1115,7 +1116,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if(value instanceof StackValue.FieldForSharedVar) {
|
||||
StackValue.FieldForSharedVar fieldForSharedVar = (StackValue.FieldForSharedVar) value;
|
||||
Type sharedType = StackValue.sharedTypeForType(value.type);
|
||||
v.visitFieldInsn(Opcodes.GETFIELD, fieldForSharedVar.owner, fieldForSharedVar.name, sharedType.getDescriptor());
|
||||
v.visitFieldInsn(Opcodes.GETFIELD, fieldForSharedVar.owner.getInternalName(), fieldForSharedVar.name, sharedType.getDescriptor());
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -1129,7 +1130,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
DeclarationDescriptor containingDeclaration = functionDescriptor.getOriginal().getContainingDeclaration();
|
||||
boolean isStatic = containingDeclaration instanceof NamespaceDescriptor;
|
||||
functionDescriptor = functionDescriptor.getOriginal();
|
||||
String owner;
|
||||
JvmClassName owner;
|
||||
|
||||
IntrinsicMethod intrinsic = state.getInjector().getIntrinsics().getIntrinsic(functionDescriptor);
|
||||
if(intrinsic != null) {
|
||||
@@ -1148,7 +1149,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
isInterface = CodegenUtil.isInterface(containingDeclaration);
|
||||
}
|
||||
|
||||
v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL, owner, functionDescriptor.getName().getName(), typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor());
|
||||
int opcode = isStatic ? Opcodes.INVOKESTATIC : isInterface ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL;
|
||||
v.visitMethodInsn(opcode, owner.getInternalName(), functionDescriptor.getName().getName(),
|
||||
typeMapper.mapSignature(functionDescriptor.getName(),functionDescriptor).getAsmMethod().getDescriptor());
|
||||
StackValue.onStack(asmType(functionDescriptor.getReturnType())).coerce(type, v);
|
||||
}
|
||||
|
||||
@@ -1221,8 +1224,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
|
||||
int invokeOpcode;
|
||||
|
||||
String owner;
|
||||
String ownerParam;
|
||||
JvmClassName owner;
|
||||
JvmClassName ownerParam;
|
||||
boolean isInterface;
|
||||
if (isInsideClass || isStatic || propertyDescriptor.getGetter() == null) {
|
||||
owner = ownerParam = typeMapper.getOwner(propertyDescriptor, contextKind());
|
||||
@@ -1234,8 +1237,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
// TODO ugly
|
||||
CallableMethod callableMethod = typeMapper.mapToCallableMethod(propertyDescriptor.getGetter(), isSuper, contextKind());
|
||||
invokeOpcode = callableMethod.getInvokeOpcode();
|
||||
owner = callableMethod.getOwner();
|
||||
ownerParam = callableMethod.getDefaultImplParam();
|
||||
owner = JvmClassName.byInternalName(callableMethod.getOwner());
|
||||
ownerParam = JvmClassName.byInternalName(callableMethod.getDefaultImplParam());
|
||||
}
|
||||
|
||||
return StackValue.property(propertyDescriptor.getName().getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic, isInterface, isSuper, getter, setter, invokeOpcode);
|
||||
@@ -2715,8 +2718,8 @@ If finally block is present, its last expression is the value of try expression.
|
||||
expressionToMatch.dupReceiver(v);
|
||||
expressionToMatch.put(TYPE_OBJECT, v);
|
||||
v.dup();
|
||||
final String tupleClassName = "jet/Tuple" + entries.size();
|
||||
Type tupleType = Type.getObjectType(tupleClassName);
|
||||
final JvmClassName tupleClassName = JvmClassName.byInternalName("jet/Tuple" + entries.size());
|
||||
Type tupleType = tupleClassName.getAsmType();
|
||||
v.instanceOf(tupleType);
|
||||
Label lblCheck = new Label();
|
||||
v.ifne(lblCheck);
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -318,7 +319,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
reg += argType.getSize();
|
||||
}
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
|
||||
iv.areturn(method.getReturnType());
|
||||
FunctionCodegen.endVisit(iv, "accessor", null);
|
||||
@@ -344,9 +345,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||
if(original.getVisibility() == Visibilities.PRIVATE)
|
||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getReturnType().getDescriptor());
|
||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), original.getName().getName(), originalMethod.getReturnType().getDescriptor());
|
||||
else
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
|
||||
iv.areturn(method.getReturnType());
|
||||
FunctionCodegen.endVisit(iv, "accessor", null);
|
||||
@@ -377,9 +378,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
reg += argType.getSize();
|
||||
}
|
||||
if(original.getVisibility() == Visibilities.PRIVATE && original.getModality() == Modality.FINAL)
|
||||
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), original.getName().getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
||||
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), original.getName().getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
||||
else
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), originalMethod.getName(), originalMethod.getDescriptor());
|
||||
|
||||
iv.areturn(method.getReturnType());
|
||||
FunctionCodegen.endVisit(iv, "accessor", null);
|
||||
@@ -588,8 +589,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
// codegen.addTypeParameter(descriptor.getTypeConstructor().getParameters().get(slot), StackValue.local(frameMap.getFirstTypeParameter() + slot, JetTypeMapper.TYPE_TYPEINFO));
|
||||
// }
|
||||
|
||||
String classname = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||
final Type classType = Type.getType("L" + classname + ";");
|
||||
Type classType = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL);
|
||||
JvmClassName classname = JvmClassName.byType(classType);
|
||||
|
||||
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
|
||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||
@@ -657,7 +658,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
v.newField(myClass, ACC_FINAL, fieldName, interfaceDesc, null, null);
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getOuterThisIndex(), type);
|
||||
iv.putfield(classname, fieldName, interfaceDesc);
|
||||
iv.putfield(classname.getInternalName(), fieldName, interfaceDesc);
|
||||
}
|
||||
|
||||
if(closure != null) {
|
||||
@@ -693,7 +694,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type type = typeMapper.mapType(descriptor.getType(), MapTypeMode.VALUE);
|
||||
iv.load(0, classType);
|
||||
iv.load(frameMap.getIndex(descriptor), type);
|
||||
iv.putfield(classname, descriptor.getName().getName(), type.getDescriptor());
|
||||
iv.putfield(classname.getInternalName(), descriptor.getName().getName(), type.getDescriptor());
|
||||
}
|
||||
curParam++;
|
||||
}
|
||||
@@ -957,7 +958,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
type = JetTypeMapper.boxType(type);
|
||||
codegen.gen(initializer, type);
|
||||
// @todo write directly to the field. Fix test excloset.jet::test6
|
||||
String owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
JvmClassName owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
StackValue.property(propertyDescriptor.getName().getName(), owner, owner,
|
||||
typeMapper.mapType(propertyDescriptor.getType(), MapTypeMode.VALUE), false, false, false, null, null, 0).store(iv);
|
||||
}
|
||||
|
||||
@@ -142,13 +142,13 @@ public class JetTypeMapper {
|
||||
return Type.getType(internalName.substring(1));
|
||||
}
|
||||
|
||||
public String getOwner(DeclarationDescriptor descriptor, OwnerKind kind) {
|
||||
@NotNull
|
||||
public JvmClassName getOwner(DeclarationDescriptor descriptor, OwnerKind kind) {
|
||||
MapTypeMode mapTypeMode = ownerKindToMapTypeMode(kind);
|
||||
|
||||
String owner;
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||
owner = jvmClassNameForNamespace((NamespaceDescriptor) containingDeclaration).getInternalName();
|
||||
return jvmClassNameForNamespace((NamespaceDescriptor) containingDeclaration);
|
||||
}
|
||||
else if (containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||
@@ -164,12 +164,11 @@ public class JetTypeMapper {
|
||||
if (asmType.getSort() != Type.OBJECT) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
owner = asmType.getInternalName();
|
||||
return JvmClassName.byType(asmType);
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("don't know how to generate owner for parent " + containingDeclaration);
|
||||
}
|
||||
return owner;
|
||||
}
|
||||
|
||||
public static MapTypeMode ownerKindToMapTypeMode(OwnerKind kind) {
|
||||
|
||||
@@ -68,8 +68,8 @@ public class ObjectOrClosureCodegen {
|
||||
StackValue outerValue = StackValue.local(idx, type);
|
||||
final String fieldName = "$" + vd.getName();
|
||||
StackValue innerValue = sharedVarType != null
|
||||
? StackValue.fieldForSharedVar(localType, name.getInternalName(), fieldName)
|
||||
: StackValue.field(type, name.getInternalName(), fieldName, false);
|
||||
? StackValue.fieldForSharedVar(localType, name, fieldName)
|
||||
: StackValue.field(type, name, fieldName, false);
|
||||
|
||||
cv.newField(null, Opcodes.ACC_PUBLIC, fieldName, type.getDescriptor(), null, null);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ObjectOrClosureCodegen {
|
||||
|
||||
StackValue outerValue = StackValue.local(idx, localType);
|
||||
final String fieldName = "$" + vd.getName();
|
||||
StackValue innerValue = StackValue.field(localType, name.getInternalName(), fieldName, false);
|
||||
StackValue innerValue = StackValue.field(localType, name, fieldName, false);
|
||||
|
||||
cv.newField(null, Opcodes.ACC_PUBLIC, fieldName, localType.getDescriptor(), null, null);
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ObjectOrClosureCodegen {
|
||||
boolean isStatic = fcontext.getContextDescriptor().getContainingDeclaration() instanceof NamespaceDescriptor;
|
||||
StackValue outerValue = StackValue.local(isStatic ? 0 : 1, type);
|
||||
final String fieldName = "receiver$0";
|
||||
StackValue innerValue = StackValue.field(type, name.getInternalName(), fieldName, false);
|
||||
StackValue innerValue = StackValue.field(type, name, fieldName, false);
|
||||
|
||||
cv.newField(null, Opcodes.ACC_PUBLIC, fieldName, type.getDescriptor(), null, null);
|
||||
|
||||
|
||||
@@ -206,8 +206,10 @@ public class PropertyCodegen {
|
||||
iv.invokeinterface(dk.getOwnerClass(), getterName, descriptor);
|
||||
}
|
||||
else {
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.GETSTATIC : Opcodes.GETFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(),
|
||||
iv.visitFieldInsn(
|
||||
kind == OwnerKind.NAMESPACE ? Opcodes.GETSTATIC : Opcodes.GETFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind).getInternalName(),
|
||||
propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
}
|
||||
iv.areturn(type);
|
||||
@@ -297,7 +299,7 @@ public class PropertyCodegen {
|
||||
else {
|
||||
iv.load(paramCode, type);
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind), propertyDescriptor.getName().getName(),
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind).getInternalName(), propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -114,11 +115,11 @@ public abstract class StackValue {
|
||||
return new CollectionElement(type, getter, setter, codegen, state);
|
||||
}
|
||||
|
||||
public static StackValue field(Type type, String owner, String name, boolean isStatic) {
|
||||
public static StackValue field(Type type, JvmClassName owner, String name, boolean isStatic) {
|
||||
return new Field(type, owner, name, isStatic);
|
||||
}
|
||||
|
||||
public static Property property(String name, String methodOwner, String methodOwnerParam, Type type, boolean isStatic, boolean isInterface, boolean isSuper, Method getter, Method setter, int invokeOpcode) {
|
||||
public static Property property(String name, JvmClassName methodOwner, JvmClassName methodOwnerParam, Type type, boolean isStatic, boolean isInterface, boolean isSuper, Method getter, Method setter, int invokeOpcode) {
|
||||
return new Property(name, methodOwner, methodOwnerParam, getter, setter, isStatic, isInterface, isSuper, type, invokeOpcode);
|
||||
}
|
||||
|
||||
@@ -257,7 +258,7 @@ public abstract class StackValue {
|
||||
return None.INSTANCE;
|
||||
}
|
||||
|
||||
public static StackValue fieldForSharedVar(Type type, String name, String fieldName) {
|
||||
public static StackValue fieldForSharedVar(Type type, JvmClassName name, String fieldName) {
|
||||
return new FieldForSharedVar(type, name, fieldName);
|
||||
}
|
||||
|
||||
@@ -745,11 +746,11 @@ public abstract class StackValue {
|
||||
|
||||
|
||||
static class Field extends StackValue {
|
||||
final String owner;
|
||||
final JvmClassName owner;
|
||||
final String name;
|
||||
private final boolean isStatic;
|
||||
|
||||
public Field(Type type, String owner, String name, boolean isStatic) {
|
||||
public Field(Type type, JvmClassName owner, String name, boolean isStatic) {
|
||||
super(type);
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
@@ -758,7 +759,7 @@ public abstract class StackValue {
|
||||
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
v.visitFieldInsn(isStatic ? Opcodes.GETSTATIC : Opcodes.GETFIELD, owner, name, this.type.getDescriptor());
|
||||
v.visitFieldInsn(isStatic ? Opcodes.GETSTATIC : Opcodes.GETFIELD, owner.getInternalName(), name, this.type.getDescriptor());
|
||||
coerce(type, v);
|
||||
}
|
||||
|
||||
@@ -775,7 +776,7 @@ public abstract class StackValue {
|
||||
|
||||
@Override
|
||||
public void store(InstructionAdapter v) {
|
||||
v.visitFieldInsn(isStatic ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD, owner, name, this.type.getDescriptor());
|
||||
v.visitFieldInsn(isStatic ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD, owner.getInternalName(), name, this.type.getDescriptor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -787,15 +788,16 @@ public abstract class StackValue {
|
||||
@Nullable
|
||||
private final Method setter;
|
||||
@NotNull
|
||||
public final String methodOwner;
|
||||
public final JvmClassName methodOwner;
|
||||
@NotNull
|
||||
private final String methodOwnerParam;
|
||||
private final JvmClassName methodOwnerParam;
|
||||
private final boolean isStatic;
|
||||
private final boolean isInterface;
|
||||
private final boolean isSuper;
|
||||
private final int invokeOpcode;
|
||||
|
||||
public Property(@NotNull String name, @NotNull String methodOwner, @NotNull String methodOwnerParam, Method getter, Method setter, boolean aStatic, boolean isInterface, boolean isSuper, Type type, int invokeOpcode) {
|
||||
public Property(@NotNull String name, @NotNull JvmClassName methodOwner, @NotNull JvmClassName methodOwnerParam,
|
||||
Method getter, Method setter, boolean aStatic, boolean isInterface, boolean isSuper, Type type, int invokeOpcode) {
|
||||
super(type);
|
||||
this.name = name;
|
||||
this.methodOwner = methodOwner;
|
||||
@@ -816,14 +818,14 @@ public abstract class StackValue {
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
if(isSuper && isInterface) {
|
||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner, getter.getName(), getter.getDescriptor().replace("(", "(L" + methodOwnerParam + ";"));
|
||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), getter.getName(), getter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
||||
}
|
||||
else {
|
||||
if (getter == null) {
|
||||
v.visitFieldInsn(isStatic ? Opcodes.GETSTATIC : Opcodes.GETFIELD, methodOwner, name, this.type.getDescriptor());
|
||||
v.visitFieldInsn(isStatic ? Opcodes.GETSTATIC : Opcodes.GETFIELD, methodOwner.getInternalName(), name, this.type.getDescriptor());
|
||||
}
|
||||
else {
|
||||
v.visitMethodInsn(invokeOpcode, methodOwner, getter.getName(), getter.getDescriptor());
|
||||
v.visitMethodInsn(invokeOpcode, methodOwner.getInternalName(), getter.getName(), getter.getDescriptor());
|
||||
}
|
||||
}
|
||||
coerce(type, v);
|
||||
@@ -832,14 +834,14 @@ public abstract class StackValue {
|
||||
@Override
|
||||
public void store(InstructionAdapter v) {
|
||||
if(isSuper && isInterface) {
|
||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner, setter.getName(), setter.getDescriptor().replace("(", "(L" + methodOwnerParam + ";"));
|
||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), setter.getName(), setter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
||||
}
|
||||
else {
|
||||
if (setter == null) {
|
||||
v.visitFieldInsn(isStatic ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD, methodOwner, name, this.type.getDescriptor());
|
||||
v.visitFieldInsn(isStatic ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD, methodOwner.getInternalName(), name, this.type.getDescriptor());
|
||||
}
|
||||
else {
|
||||
v.visitMethodInsn(invokeOpcode, methodOwner, setter.getName(), setter.getDescriptor());
|
||||
v.visitMethodInsn(invokeOpcode, methodOwner.getInternalName(), setter.getName(), setter.getDescriptor());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -943,10 +945,10 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
static class FieldForSharedVar extends StackValue {
|
||||
final String owner;
|
||||
final JvmClassName owner;
|
||||
final String name;
|
||||
|
||||
public FieldForSharedVar(Type type, String owner, String name) {
|
||||
public FieldForSharedVar(Type type, JvmClassName owner, String name) {
|
||||
super(type);
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
|
||||
Reference in New Issue
Block a user