Minor, pull non-null getParentContext() to MethodContext

This commit is contained in:
Alexander Udalov
2014-04-24 19:41:27 +04:00
parent 5fe7bfdd83
commit 13728e1598
4 changed files with 10 additions and 28 deletions
@@ -1818,7 +1818,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
int flags = AsmUtil.getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegatedProperty);
skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || methodKind == MethodKind.SYNTHETIC_ACCESSOR || methodKind == MethodKind.INITIALIZER;
if (!skipPropertyAccessors) {
//noinspection ConstantConditions
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor, true, delegateType);
}
isStatic = true;
@@ -1872,7 +1871,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
String name;
//noinspection ConstantConditions
if (propertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) {
assert backingFieldContext instanceof FieldOwnerContext : "Actual context is " + backingFieldContext + " but should be instance of FieldOwnerContext" ;
name = ((FieldOwnerContext) backingFieldContext).getFieldName(propertyDescriptor, isDelegatedProperty);
@@ -47,30 +47,19 @@ import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.jetbrains.org.objectweb.asm.Opcodes.ACC_PROTECTED;
public abstract class CodegenContext<T extends DeclarationDescriptor> {
public static final CodegenContext STATIC = new RootContext();
@NotNull
private final T contextDescriptor;
@NotNull
private final OwnerKind contextKind;
@Nullable
private final CodegenContext parentContext;
private final ClassDescriptor thisDescriptor;
public final MutableClosure closure;
private final LocalLookup enclosingLocalLookup;
private Map<DeclarationDescriptor, DeclarationDescriptor> accessors;
private Map<DeclarationDescriptor, CodegenContext> childContexts;
private NullableLazyValue<StackValue> lazyOuterExpression;
private final LocalLookup enclosingLocalLookup;
public CodegenContext(
@NotNull T contextDescriptor,
@NotNull OwnerKind contextKind,
@@ -50,11 +50,4 @@ public class ConstructorContext extends MethodContext {
public String toString() {
return "Constructor: " + getContextDescriptor();
}
@NotNull
@Override
public CodegenContext getParentContext() {
//noinspection ConstantConditions
return super.getParentContext();
}
}
@@ -18,19 +18,17 @@ package org.jetbrains.jet.codegen.context;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.jet.codegen.OwnerKind;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.codegen.binding.MutableClosure;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
import org.jetbrains.org.objectweb.asm.Label;
public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
private Label methodStartLabel;
private final boolean isInliningLambda;
private Label methodStartLabel;
protected MethodContext(
@NotNull FunctionDescriptor contextDescriptor,
@@ -46,25 +44,29 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
this.isInliningLambda = isInliningLambda;
}
@NotNull
@Override
public CodegenContext getParentContext() {
//noinspection ConstantConditions
return super.getParentContext();
}
@Override
public StackValue lookupInContext(DeclarationDescriptor d, @Nullable StackValue result, GenerationState state, boolean ignoreNoOuter) {
if (getContextDescriptor() == d) {
return result != null ? result : StackValue.local(0, AsmTypeConstants.OBJECT_TYPE);
}
//noinspection ConstantConditions
return getParentContext().lookupInContext(d, result, state, ignoreNoOuter);
}
@Override
public boolean isStatic() {
//noinspection ConstantConditions
return getParentContext().isStatic();
}
@Override
public StackValue getOuterExpression(StackValue prefix, boolean ignoreNoOuter) {
//noinspection ConstantConditions
return getParentContext().getOuterExpression(prefix, false);
}