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