Minor, add nullability annotations, toString(), remove unused methods
This commit is contained in:
+24
-9
@@ -16,11 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen.context;
|
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.ExpressionCodegen;
|
||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
public final class EnclosedValueDescriptor {
|
public final class EnclosedValueDescriptor {
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
@@ -28,37 +29,51 @@ public final class EnclosedValueDescriptor {
|
|||||||
private final StackValue innerValue;
|
private final StackValue innerValue;
|
||||||
private final Type type;
|
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.fieldName = fieldName;
|
||||||
this.descriptor = descriptor;
|
this.descriptor = descriptor;
|
||||||
this.innerValue = innerValue;
|
this.innerValue = innerValue;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getFieldName() {
|
||||||
|
return fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public DeclarationDescriptor getDescriptor() {
|
public DeclarationDescriptor getDescriptor() {
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public StackValue getInnerValue() {
|
public StackValue getInnerValue() {
|
||||||
return innerValue;
|
return innerValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StackValue getOuterValue(ExpressionCodegen expressionCodegen) {
|
@NotNull
|
||||||
GenerationState state = expressionCodegen.getState();
|
public StackValue getOuterValue(@NotNull ExpressionCodegen codegen) {
|
||||||
for (LocalLookup.LocalLookupCase aCase : LocalLookup.LocalLookupCase.values()) {
|
for (LocalLookup.LocalLookupCase aCase : LocalLookup.LocalLookupCase.values()) {
|
||||||
if (aCase.isCase(descriptor)) {
|
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() {
|
@Override
|
||||||
return fieldName;
|
public String toString() {
|
||||||
|
return fieldName + " " + type + " -> " + descriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen.context;
|
package org.jetbrains.jet.codegen.context;
|
||||||
|
|
||||||
import org.jetbrains.jet.codegen.JvmCodegenUtil;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
|
||||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||||
|
import org.jetbrains.jet.codegen.JvmCodegenUtil;
|
||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
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.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
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.AsmUtil.CAPTURED_RECEIVER_FIELD;
|
||||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||||
@@ -132,8 +133,9 @@ public interface LocalLookup {
|
|||||||
return innerValue;
|
return innerValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public StackValue outerValue(EnclosedValueDescriptor d, ExpressionCodegen expressionCodegen) {
|
public StackValue outerValue(@NotNull EnclosedValueDescriptor d, @NotNull ExpressionCodegen codegen) {
|
||||||
CallableDescriptor descriptor = (CallableDescriptor) d.getDescriptor();
|
CallableDescriptor descriptor = (CallableDescriptor) d.getDescriptor();
|
||||||
return StackValue.local(descriptor.getExpectedThisObject() != null ? 1 : 0, d.getType());
|
return StackValue.local(descriptor.getExpectedThisObject() != null ? 1 : 0, d.getType());
|
||||||
}
|
}
|
||||||
@@ -149,8 +151,9 @@ public interface LocalLookup {
|
|||||||
Type classType
|
Type classType
|
||||||
);
|
);
|
||||||
|
|
||||||
public StackValue outerValue(EnclosedValueDescriptor d, ExpressionCodegen expressionCodegen) {
|
@NotNull
|
||||||
int idx = expressionCodegen.lookupLocalIndex(d.getDescriptor());
|
public StackValue outerValue(@NotNull EnclosedValueDescriptor d, @NotNull ExpressionCodegen codegen) {
|
||||||
|
int idx = codegen.lookupLocalIndex(d.getDescriptor());
|
||||||
assert idx != -1;
|
assert idx != -1;
|
||||||
|
|
||||||
return StackValue.local(idx, d.getType());
|
return StackValue.local(idx, d.getType());
|
||||||
|
|||||||
@@ -18,47 +18,35 @@ package org.jetbrains.jet.codegen.inline;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
import org.jetbrains.jet.codegen.context.EnclosedValueDescriptor;
|
|
||||||
|
|
||||||
public class CapturedParamDesc {
|
public class CapturedParamDesc {
|
||||||
|
|
||||||
private final CapturedParamOwner containingLambda;
|
private final CapturedParamOwner containingLambda;
|
||||||
|
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
|
|
||||||
private final Type type;
|
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) {
|
public CapturedParamDesc(@NotNull CapturedParamOwner containingLambda, @NotNull String fieldName, @NotNull Type type) {
|
||||||
this.containingLambda = containingLambda;
|
this.containingLambda = containingLambda;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
this.type = type;
|
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
|
@NotNull
|
||||||
public String getContainingLambdaName() {
|
public String getContainingLambdaName() {
|
||||||
return containingLambda.getType().getInternalName();
|
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
|
@NotNull
|
||||||
public String getContainingLambdaName() {
|
public String getContainingLambdaName() {
|
||||||
return desc.getContainingLambda().getType().getInternalName();
|
return desc.getContainingLambdaName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user