ExpressionCOdegen.visitSimpleNameExpression simplification

This commit is contained in:
Mikhael Bogdanov
2013-04-18 12:55:31 +04:00
parent 1fd76845ad
commit a1d295638a
3 changed files with 64 additions and 29 deletions
@@ -1574,36 +1574,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
boolean isSuper = r instanceof JetSuperExpression;
propertyDescriptor = accessablePropertyDescriptor(propertyDescriptor);
StackValue.Property iValue =
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
if (!directToField && resolvedCall != null && !isSuper) {
receiver.put(propertyDescriptor.getReceiverParameter() != null || isStatic
? receiver.type
: iValue.methodOwner.getAsmType(), v);
}
else {
if (!isStatic) {
if (receiver == StackValue.none()) {
if (resolvedCall != null && resolvedCall.getThisObject() instanceof ExtensionReceiver) {
receiver = generateReceiver(((ExtensionReceiver) resolvedCall.getThisObject()).getDeclarationDescriptor());
}
else {
receiver = generateThisOrOuter((ClassDescriptor) propertyDescriptor.getContainingDeclaration(), false);
}
}
if (directToField) {
receiver = StackValue.receiverWithoutReceiverArgument(receiver);
}
JetType receiverType = bindingContext.get(BindingContext.EXPRESSION_TYPE, r);
receiver.put(receiverType != null && !isSuper ? asmType(receiverType) : OBJECT_TYPE, v);
if (receiverType != null) {
ClassDescriptor propReceiverDescriptor = (ClassDescriptor) propertyDescriptor.getContainingDeclaration();
if (!isInterface(propReceiverDescriptor) &&
isInterface(receiverType.getConstructor().getDeclarationDescriptor())) {
v.checkcast(asmType(propReceiverDescriptor.getDefaultType()));
}
}
}
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
if (directToField) {
receiver = StackValue.receiverWithoutReceiverArgument(receiver);
}
receiver.put(receiver.type, v);
return iValue;
}