Pass state and property descriptor to StackValue.Property
This commit is contained in:
@@ -1613,9 +1613,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ownerParam = callableMethod.getDefaultImplParam();
|
||||
}
|
||||
|
||||
return StackValue
|
||||
.property(propertyDescriptor.getName().getName(), owner, ownerParam, asmType(propertyDescriptor.getType()), isStatic,
|
||||
isInterface, isSuper, getter, setter, invokeOpcode);
|
||||
return StackValue.property(propertyDescriptor, owner, ownerParam, asmType(propertyDescriptor.getType()),
|
||||
isStatic, isInterface, isSuper, getter, setter, invokeOpcode, state);
|
||||
}
|
||||
|
||||
private static boolean isOverrideForTrait(CallableMemberDescriptor propertyDescriptor) {
|
||||
|
||||
@@ -962,7 +962,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
curParam++;
|
||||
}
|
||||
|
||||
generateInitializers(codegen, iv, myClass.getDeclarations(), bindingContext, typeMapper);
|
||||
generateInitializers(codegen, iv, myClass.getDeclarations(), bindingContext, state);
|
||||
|
||||
mv.visitInsn(RETURN);
|
||||
FunctionCodegen.endVisit(mv, "constructor", myClass);
|
||||
@@ -1451,8 +1451,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
public static void generateInitializers(
|
||||
@NotNull ExpressionCodegen codegen, @NotNull InstructionAdapter iv, @NotNull List<JetDeclaration> declarations,
|
||||
@NotNull BindingContext bindingContext, @NotNull JetTypeMapper typeMapper
|
||||
@NotNull BindingContext bindingContext, @NotNull GenerationState state
|
||||
) {
|
||||
JetTypeMapper typeMapper = state.getTypeMapper();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
if (declaration instanceof JetProperty) {
|
||||
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(BindingContext.VARIABLE, declaration);
|
||||
@@ -1476,8 +1477,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
// @todo write directly to the field. Fix test excloset.jet::test6
|
||||
JvmClassName owner = typeMapper.getOwner(propertyDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
Type propType = typeMapper.mapType(jetType);
|
||||
StackValue.property(propertyDescriptor.getName().getName(), owner, owner,
|
||||
propType, false, false, false, null, null, 0).store(propType, iv);
|
||||
StackValue.property(propertyDescriptor, owner, owner,
|
||||
propType, false, false, false, null, null, 0, state).store(propType, iv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class ScriptCodegen extends MemberCodegen {
|
||||
instructionAdapter,
|
||||
scriptDeclaration.getDeclarations(),
|
||||
bindingContext,
|
||||
typeMapper);
|
||||
state);
|
||||
|
||||
int offset = 1;
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
public static Property property(
|
||||
String name,
|
||||
PropertyDescriptor descriptor,
|
||||
JvmClassName methodOwner,
|
||||
JvmClassName methodOwnerParam,
|
||||
Type type,
|
||||
@@ -161,9 +161,11 @@ public abstract class StackValue {
|
||||
boolean isSuper,
|
||||
@Nullable Method getter,
|
||||
@Nullable Method setter,
|
||||
int invokeOpcode
|
||||
int invokeOpcode,
|
||||
GenerationState state
|
||||
) {
|
||||
return new Property(name, methodOwner, methodOwnerParam, getter, setter, isStatic, isInterface, isSuper, type, invokeOpcode);
|
||||
return new Property(descriptor, methodOwner, methodOwnerParam, getter, setter, isStatic, isInterface, isSuper, type, invokeOpcode,
|
||||
state);
|
||||
}
|
||||
|
||||
public static StackValue expression(Type type, JetExpression expression, ExpressionCodegen generator) {
|
||||
@@ -929,8 +931,6 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
static class Property extends StackValue {
|
||||
@NotNull
|
||||
private final String name;
|
||||
@Nullable
|
||||
private final Method getter;
|
||||
@Nullable
|
||||
@@ -943,21 +943,27 @@ public abstract class StackValue {
|
||||
private final boolean isInterface;
|
||||
private final boolean isSuper;
|
||||
private final int invokeOpcode;
|
||||
@NotNull
|
||||
private final PropertyDescriptor descriptor;
|
||||
@NotNull
|
||||
private final GenerationState state;
|
||||
|
||||
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
|
||||
@NotNull PropertyDescriptor descriptor, @NotNull JvmClassName methodOwner, @NotNull JvmClassName methodOwnerParam,
|
||||
@Nullable Method getter, @Nullable Method setter, boolean isStatic, boolean isInterface, boolean isSuper,
|
||||
@NotNull Type type, int invokeOpcode, @NotNull GenerationState state
|
||||
) {
|
||||
super(type);
|
||||
this.name = name;
|
||||
this.methodOwner = methodOwner;
|
||||
this.methodOwnerParam = methodOwnerParam;
|
||||
this.getter = getter;
|
||||
this.setter = setter;
|
||||
isStatic = aStatic;
|
||||
this.isStatic = isStatic;
|
||||
this.isInterface = isInterface;
|
||||
this.isSuper = isSuper;
|
||||
this.invokeOpcode = invokeOpcode;
|
||||
this.descriptor = descriptor;
|
||||
this.state = state;
|
||||
if (invokeOpcode == 0) {
|
||||
if (setter != null || getter != null) {
|
||||
throw new IllegalArgumentException();
|
||||
@@ -974,7 +980,7 @@ public abstract class StackValue {
|
||||
}
|
||||
else {
|
||||
if (getter == null) {
|
||||
v.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, methodOwner.getInternalName(), name,
|
||||
v.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, methodOwner.getInternalName(), descriptor.getName().getName(),
|
||||
this.type.getDescriptor());
|
||||
}
|
||||
else {
|
||||
@@ -993,7 +999,7 @@ public abstract class StackValue {
|
||||
setter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
||||
}
|
||||
else if (setter == null) {
|
||||
v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, methodOwner.getInternalName(), name,
|
||||
v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, methodOwner.getInternalName(), descriptor.getName().getName(),
|
||||
this.type.getDescriptor());
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user