Minor, add nullability annotations, toString(), remove unused methods

This commit is contained in:
Alexander Udalov
2014-07-10 05:59:46 +04:00
parent 05baebfc27
commit c0d9bfe89f
4 changed files with 48 additions and 42 deletions
@@ -16,11 +16,12 @@
package org.jetbrains.jet.codegen.context;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.org.objectweb.asm.Type;
public final class EnclosedValueDescriptor {
private final String fieldName;
@@ -28,37 +29,51 @@ public final class EnclosedValueDescriptor {
private final StackValue innerValue;
private final Type type;
public EnclosedValueDescriptor(String fieldName, DeclarationDescriptor descriptor, StackValue innerValue, Type type) {
public EnclosedValueDescriptor(
@NotNull String fieldName,
@Nullable DeclarationDescriptor descriptor,
@Nullable StackValue innerValue,
@NotNull Type type
) {
this.fieldName = fieldName;
this.descriptor = descriptor;
this.innerValue = innerValue;
this.type = type;
}
@NotNull
public String getFieldName() {
return fieldName;
}
@Nullable
public DeclarationDescriptor getDescriptor() {
return descriptor;
}
@Nullable
public StackValue getInnerValue() {
return innerValue;
}
@NotNull
public Type getType() {
return type;
}
public StackValue getOuterValue(ExpressionCodegen expressionCodegen) {
GenerationState state = expressionCodegen.getState();
@NotNull
public StackValue getOuterValue(@NotNull ExpressionCodegen codegen) {
for (LocalLookup.LocalLookupCase aCase : LocalLookup.LocalLookupCase.values()) {
if (aCase.isCase(descriptor)) {
return aCase.outerValue(this, expressionCodegen);
return aCase.outerValue(this, codegen);
}
}
throw new IllegalStateException();
throw new IllegalStateException("Can't get outer value in " + codegen + " for " + this);
}
public String getFieldName() {
return fieldName;
@Override
public String toString() {
return fieldName + " " + type + " -> " + descriptor;
}
}
@@ -16,9 +16,9 @@
package org.jetbrains.jet.codegen.context;
import org.jetbrains.jet.codegen.JvmCodegenUtil;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.JvmCodegenUtil;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.codegen.binding.MutableClosure;
import org.jetbrains.jet.codegen.state.GenerationState;
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.org.objectweb.asm.Type;
import static org.jetbrains.jet.codegen.AsmUtil.CAPTURED_RECEIVER_FIELD;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
@@ -132,8 +133,9 @@ public interface LocalLookup {
return innerValue;
}
@NotNull
@Override
public StackValue outerValue(EnclosedValueDescriptor d, ExpressionCodegen expressionCodegen) {
public StackValue outerValue(@NotNull EnclosedValueDescriptor d, @NotNull ExpressionCodegen codegen) {
CallableDescriptor descriptor = (CallableDescriptor) d.getDescriptor();
return StackValue.local(descriptor.getExpectedThisObject() != null ? 1 : 0, d.getType());
}
@@ -149,8 +151,9 @@ public interface LocalLookup {
Type classType
);
public StackValue outerValue(EnclosedValueDescriptor d, ExpressionCodegen expressionCodegen) {
int idx = expressionCodegen.lookupLocalIndex(d.getDescriptor());
@NotNull
public StackValue outerValue(@NotNull EnclosedValueDescriptor d, @NotNull ExpressionCodegen codegen) {
int idx = codegen.lookupLocalIndex(d.getDescriptor());
assert idx != -1;
return StackValue.local(idx, d.getType());
@@ -18,47 +18,35 @@ package org.jetbrains.jet.codegen.inline;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.jet.codegen.context.EnclosedValueDescriptor;
public class CapturedParamDesc {
private final CapturedParamOwner containingLambda;
private final String fieldName;
private final Type type;
public CapturedParamDesc(@NotNull CapturedParamOwner containingLambda, @NotNull EnclosedValueDescriptor descriptor) {
this.containingLambda = containingLambda;
this.type = descriptor.getType();
this.fieldName = descriptor.getFieldName();
}
public CapturedParamDesc(@NotNull CapturedParamOwner containingLambda, @NotNull String fieldName, @NotNull Type type) {
this.containingLambda = containingLambda;
this.fieldName = fieldName;
this.type = type;
}
public CapturedParamOwner getContainingLambda() {
return containingLambda;
}
public String getFieldName() {
return fieldName;
}
public Type getType() {
return type;
}
public static CapturedParamDesc createDesc(@NotNull CapturedParamOwner containingLambdaInfo, @NotNull String fieldName, @NotNull Type type) {
return new CapturedParamDesc(containingLambdaInfo, fieldName, type);
}
@NotNull
public String getContainingLambdaName() {
return containingLambda.getType().getInternalName();
}
@NotNull
public String getFieldName() {
return fieldName;
}
@NotNull
public Type getType() {
return type;
}
@NotNull
public static CapturedParamDesc createDesc(@NotNull CapturedParamOwner containingLambdaInfo, @NotNull String fieldName, @NotNull Type type) {
return new CapturedParamDesc(containingLambdaInfo, fieldName, type);
}
}
@@ -73,6 +73,6 @@ public class CapturedParamInfo extends ParameterInfo {
@NotNull
public String getContainingLambdaName() {
return desc.getContainingLambda().getType().getInternalName();
return desc.getContainingLambdaName();
}
}