Minor, fix/suppress warnings in codegen
This commit is contained in:
@@ -151,7 +151,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class FinallyBlockStackElement extends BlockStackElement {
|
static class FinallyBlockStackElement extends BlockStackElement {
|
||||||
List<Label> gaps = new ArrayList();
|
List<Label> gaps = new ArrayList<Label>();
|
||||||
|
|
||||||
final JetTryExpression expression;
|
final JetTryExpression expression;
|
||||||
|
|
||||||
@@ -178,21 +178,17 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
this.returnType = returnType;
|
this.returnType = returnType;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.methodVisitor = v;
|
this.methodVisitor = v;
|
||||||
this.v = createInstructionAdapter(methodVisitor);
|
this.v = new InstructionAdapter(methodVisitor) {
|
||||||
this.bindingContext = state.getBindingContext();
|
|
||||||
this.context = context;
|
|
||||||
this.statementVisitor = new CodegenStatementVisitor(this);
|
|
||||||
this.tailRecursionCodegen = new TailRecursionCodegen(context, this, this.v, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected InstructionAdapter createInstructionAdapter(MethodVisitor mv) {
|
|
||||||
return new InstructionAdapter(methodVisitor) {
|
|
||||||
@Override
|
@Override
|
||||||
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
||||||
super.visitLocalVariable(name, desc, signature, start, end, index);
|
super.visitLocalVariable(name, desc, signature, start, end, index);
|
||||||
localVariableNames.add(name);
|
localVariableNames.add(name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.bindingContext = state.getBindingContext();
|
||||||
|
this.context = context;
|
||||||
|
this.statementVisitor = new CodegenStatementVisitor(this);
|
||||||
|
this.tailRecursionCodegen = new TailRecursionCodegen(context, this, this.v, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenerationState getState() {
|
public GenerationState getState() {
|
||||||
@@ -1150,16 +1146,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitBreakExpression(@NotNull JetBreakExpression expression, StackValue receiver) {
|
public StackValue visitBreakExpression(@NotNull JetBreakExpression expression, StackValue receiver) {
|
||||||
return visitBreakOrContinueExpression(expression, receiver, true);
|
return generateBreakOrContinueExpression(expression, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitContinueExpression(@NotNull JetContinueExpression expression, StackValue receiver) {
|
public StackValue visitContinueExpression(@NotNull JetContinueExpression expression, StackValue receiver) {
|
||||||
return visitBreakOrContinueExpression(expression, receiver, false);
|
return generateBreakOrContinueExpression(expression, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private StackValue visitBreakOrContinueExpression(@NotNull JetLabelQualifiedExpression expression, StackValue receiver, boolean isBreak) {
|
private StackValue generateBreakOrContinueExpression(@NotNull JetLabelQualifiedExpression expression, boolean isBreak) {
|
||||||
assert expression instanceof JetContinueExpression || expression instanceof JetBreakExpression;
|
assert expression instanceof JetContinueExpression || expression instanceof JetBreakExpression;
|
||||||
|
|
||||||
if (!blockStackElements.isEmpty()) {
|
if (!blockStackElements.isEmpty()) {
|
||||||
@@ -1186,11 +1182,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
blockStackElements.pop();
|
blockStackElements.pop();
|
||||||
StackValue result = visitBreakOrContinueExpression(expression, receiver, isBreak);
|
StackValue result = generateBreakOrContinueExpression(expression, isBreak);
|
||||||
blockStackElements.push(stackElement);
|
blockStackElements.push(stackElement);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnsupportedOperationException("Target label for break/continue not found");
|
throw new UnsupportedOperationException("Target label for break/continue not found");
|
||||||
@@ -1812,6 +1806,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
int flags = AsmUtil.getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegatedProperty);
|
int flags = AsmUtil.getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegatedProperty);
|
||||||
skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || methodKind == MethodKind.SYNTHETIC_ACCESSOR || methodKind == MethodKind.INITIALIZER;
|
skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || methodKind == MethodKind.SYNTHETIC_ACCESSOR || methodKind == MethodKind.INITIALIZER;
|
||||||
if (!skipPropertyAccessors) {
|
if (!skipPropertyAccessors) {
|
||||||
|
//noinspection ConstantConditions
|
||||||
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor, true, delegateType);
|
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor, true, delegateType);
|
||||||
}
|
}
|
||||||
isStatic = true;
|
isStatic = true;
|
||||||
@@ -1869,6 +1864,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
|
//noinspection ConstantConditions
|
||||||
if (propertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) {
|
if (propertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) {
|
||||||
assert backingFieldContext instanceof FieldOwnerContext : "Actual context is " + backingFieldContext + " but should be instance of FieldOwnerContext" ;
|
assert backingFieldContext instanceof FieldOwnerContext : "Actual context is " + backingFieldContext + " but should be instance of FieldOwnerContext" ;
|
||||||
name = ((FieldOwnerContext) backingFieldContext).getFieldName(propertyDescriptor, isDelegatedProperty);
|
name = ((FieldOwnerContext) backingFieldContext).getFieldName(propertyDescriptor, isDelegatedProperty);
|
||||||
@@ -1947,6 +1943,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
v.anew(asmType);
|
v.anew(asmType);
|
||||||
v.dup();
|
v.dup();
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
Type functionType = typeMapper.mapType(samInterface.getFunctionTypeForSamInterface());
|
Type functionType = typeMapper.mapType(samInterface.getFunctionTypeForSamInterface());
|
||||||
expression.accept(visitor, StackValue.none()).put(functionType, v);
|
expression.accept(visitor, StackValue.none()).put(functionType, v);
|
||||||
|
|
||||||
@@ -2097,7 +2094,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCallAsFunctionObject(FunctionDescriptor fd) {
|
private static boolean isCallAsFunctionObject(FunctionDescriptor fd) {
|
||||||
if (fd instanceof ExpressionAsFunctionDescriptor) {
|
if (fd instanceof ExpressionAsFunctionDescriptor) {
|
||||||
JetExpression deparenthesize = JetPsiUtil.deparenthesize(((ExpressionAsFunctionDescriptor) fd).getExpression());
|
JetExpression deparenthesize = JetPsiUtil.deparenthesize(((ExpressionAsFunctionDescriptor) fd).getExpression());
|
||||||
return !(deparenthesize instanceof JetCallableReferenceExpression || deparenthesize instanceof JetFunctionLiteralExpression);
|
return !(deparenthesize instanceof JetCallableReferenceExpression || deparenthesize instanceof JetFunctionLiteralExpression);
|
||||||
@@ -2294,7 +2291,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private CodegenContext getNotNullParentContextForMethod(@NotNull CodegenContext cur) {
|
private static CodegenContext getNotNullParentContextForMethod(CodegenContext cur) {
|
||||||
if (cur instanceof MethodContext) {
|
if (cur instanceof MethodContext) {
|
||||||
cur = cur.getParentContext();
|
cur = cur.getParentContext();
|
||||||
}
|
}
|
||||||
@@ -3549,8 +3546,8 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
private List<Label> getCurrentCatchIntervals(
|
private static List<Label> getCurrentCatchIntervals(
|
||||||
@Nullable FinallyBlockStackElement finallyBlockStackElement,
|
@Nullable FinallyBlockStackElement finallyBlockStackElement,
|
||||||
@NotNull Label blockStart,
|
@NotNull Label blockStart,
|
||||||
@NotNull Label blockEnd
|
@NotNull Label blockEnd
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
ClassData data = new ClassData(createNameResolver(serializer.getNameTable()), classProto);
|
ClassData data = new ClassData(createNameResolver(serializer.getNameTable()), classProto);
|
||||||
|
|
||||||
AnnotationVisitor av = v.getVisitor().visitAnnotation(asmDescByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_CLASS), true);
|
AnnotationVisitor av = v.getVisitor().visitAnnotation(asmDescByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_CLASS), true);
|
||||||
|
//noinspection ConstantConditions
|
||||||
av.visit(JvmAnnotationNames.ABI_VERSION_FIELD_NAME, JvmAbi.VERSION);
|
av.visit(JvmAnnotationNames.ABI_VERSION_FIELD_NAME, JvmAbi.VERSION);
|
||||||
AnnotationVisitor array = av.visitArray(JvmAnnotationNames.DATA_FIELD_NAME);
|
AnnotationVisitor array = av.visitArray(JvmAnnotationNames.DATA_FIELD_NAME);
|
||||||
for (String string : BitEncoding.encodeBytes(data.toBytes())) {
|
for (String string : BitEncoding.encodeBytes(data.toBytes())) {
|
||||||
@@ -1068,7 +1069,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
private void generateClassObjectBackingFieldCopies() {
|
private void generateClassObjectBackingFieldCopies() {
|
||||||
if (classObjectPropertiesToCopy != null) {
|
if (classObjectPropertiesToCopy != null) {
|
||||||
for (PropertyAndDefaultValue propertyInfo : classObjectPropertiesToCopy) {
|
for (PropertyAndDefaultValue propertyInfo : classObjectPropertiesToCopy) {
|
||||||
PropertyDescriptor propertyDescriptor = propertyInfo.propertyDescriptor;
|
PropertyDescriptor propertyDescriptor = propertyInfo.descriptor;
|
||||||
|
|
||||||
FieldVisitor fv = v.newField(null, ACC_STATIC | ACC_FINAL | ACC_PUBLIC, context.getFieldName(propertyDescriptor),
|
FieldVisitor fv = v.newField(null, ACC_STATIC | ACC_FINAL | ACC_PUBLIC, context.getFieldName(propertyDescriptor),
|
||||||
typeMapper.mapType(propertyDescriptor).getDescriptor(), null, propertyInfo.defaultValue);
|
typeMapper.mapType(propertyDescriptor).getDescriptor(), null, propertyInfo.defaultValue);
|
||||||
@@ -1224,13 +1225,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
ImplementationBodyCodegen parentCodegen = getParentBodyCodegen(this);
|
ImplementationBodyCodegen parentCodegen = getParentBodyCodegen(this);
|
||||||
//generate object$
|
//generate object$
|
||||||
parentCodegen.genInitSingleton(descriptor, StackValue.singleton(descriptor, typeMapper));
|
parentCodegen.genInitSingleton(descriptor, StackValue.singleton(descriptor, typeMapper));
|
||||||
parentCodegen.generateInitializers(parentCodegen.createOrGetClInitCodegen(),
|
generateInitializers(parentCodegen.createOrGetClInitCodegen(), myClass.getDeclarations(), bindingContext, state);
|
||||||
myClass.getDeclarations(), bindingContext, state);
|
|
||||||
} else {
|
} else {
|
||||||
generateInitializers(codegen, myClass.getDeclarations(), bindingContext, state);
|
generateInitializers(codegen, myClass.getDeclarations(), bindingContext, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
iv.visitInsn(RETURN);
|
iv.visitInsn(RETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1435,7 +1434,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void generateDelegationToTraitImpl(final @NotNull FunctionDescriptor fun, @NotNull FunctionDescriptor inheritedFun) {
|
private void generateDelegationToTraitImpl(@NotNull FunctionDescriptor fun, @NotNull FunctionDescriptor inheritedFun) {
|
||||||
DeclarationDescriptor containingDeclaration = fun.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = fun.getContainingDeclaration();
|
||||||
if (!(containingDeclaration instanceof ClassDescriptor)) {
|
if (!(containingDeclaration instanceof ClassDescriptor)) {
|
||||||
return;
|
return;
|
||||||
@@ -1873,17 +1872,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
classObjectPropertiesToCopy.add(new PropertyAndDefaultValue(descriptor, defaultValue));
|
classObjectPropertiesToCopy.add(new PropertyAndDefaultValue(descriptor, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class PropertyAndDefaultValue {
|
private static class PropertyAndDefaultValue {
|
||||||
|
public final PropertyDescriptor descriptor;
|
||||||
|
public final Object defaultValue;
|
||||||
|
|
||||||
PropertyAndDefaultValue(PropertyDescriptor propertyDescriptor, Object defaultValue) {
|
public PropertyAndDefaultValue(PropertyDescriptor descriptor, Object defaultValue) {
|
||||||
this.propertyDescriptor = propertyDescriptor;
|
this.descriptor = descriptor;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyDescriptor propertyDescriptor;
|
|
||||||
|
|
||||||
private Object defaultValue;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -853,22 +853,18 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
|
|
||||||
JetDelegatorToSuperCall superCall = closure.getSuperCall();
|
JetDelegatorToSuperCall superCall = closure.getSuperCall();
|
||||||
if (superCall != null) {
|
if (superCall != null) {
|
||||||
DeclarationDescriptor superDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET,
|
DeclarationDescriptor superDescriptor = bindingContext
|
||||||
superCall
|
.get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression());
|
||||||
.getCalleeExpression()
|
|
||||||
.getConstructorReferenceExpression());
|
|
||||||
|
|
||||||
if(superDescriptor instanceof ConstructorDescriptor) {
|
if (superDescriptor instanceof ConstructorDescriptor) {
|
||||||
ConstructorDescriptor superConstructor = (ConstructorDescriptor) superDescriptor;
|
ConstructorDescriptor superConstructor = (ConstructorDescriptor) superDescriptor;
|
||||||
|
|
||||||
if (isObjectLiteral(bindingContext, descriptor.getContainingDeclaration())) {
|
if (isObjectLiteral(bindingContext, descriptor.getContainingDeclaration())) {
|
||||||
List<JvmMethodParameterSignature> types = mapConstructorSignature(superConstructor).getKotlinParameterTypes();
|
List<JvmMethodParameterSignature> types = mapConstructorSignature(superConstructor).getKotlinParameterTypes();
|
||||||
if (types != null) {
|
for (JvmMethodParameterSignature type : types) {
|
||||||
for (JvmMethodParameterSignature type : types) {
|
signatureWriter.writeParameterType(JvmMethodParameterKind.SUPER_CALL_PARAM);
|
||||||
signatureWriter.writeParameterType(JvmMethodParameterKind.SUPER_CALL_PARAM);
|
signatureWriter.writeAsmType(type.getAsmType());
|
||||||
signatureWriter.writeAsmType(type.getAsmType());
|
signatureWriter.writeParameterTypeEnd();
|
||||||
signatureWriter.writeParameterTypeEnd();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user