Minor, fix some warnings in codegen
This commit is contained in:
@@ -223,7 +223,7 @@ public class AsmUtil {
|
||||
}
|
||||
Integer defaultMapping = visibilityToAccessFlag.get(descriptor.getVisibility());
|
||||
if (defaultMapping == null) {
|
||||
throw new IllegalStateException(descriptor.getVisibility() + " is not a valid visibility in backend. Descriptor: " + descriptor);
|
||||
throw new IllegalStateException(descriptor.getVisibility() + " is not a valid visibility in backend: " + descriptor);
|
||||
}
|
||||
return defaultMapping;
|
||||
}
|
||||
@@ -263,8 +263,8 @@ public class AsmUtil {
|
||||
public static int getDeprecatedAccessFlag(@NotNull MemberDescriptor descriptor) {
|
||||
if (descriptor instanceof PropertyAccessorDescriptor) {
|
||||
return KotlinBuiltIns.getInstance().isDeprecated(descriptor)
|
||||
? ACC_DEPRECATED
|
||||
: getDeprecatedAccessFlag(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty());
|
||||
? ACC_DEPRECATED
|
||||
: getDeprecatedAccessFlag(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty());
|
||||
}
|
||||
else if (KotlinBuiltIns.getInstance().isDeprecated(descriptor)) {
|
||||
return ACC_DEPRECATED;
|
||||
@@ -518,14 +518,17 @@ public class AsmUtil {
|
||||
if (stackTop.getSize() == 1) {
|
||||
if (afterTop.getSize() == 1) {
|
||||
v.swap();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
v.dupX2();
|
||||
v.pop();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (afterTop.getSize() == 1) {
|
||||
v.dup2X1();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
v.dup2X2();
|
||||
}
|
||||
v.pop2();
|
||||
@@ -645,15 +648,19 @@ public class AsmUtil {
|
||||
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
|
||||
if (isDelegate || isExtensionProperty) {
|
||||
return ACC_PRIVATE;
|
||||
} else {
|
||||
return areBothAccessorDefault(propertyDescriptor) ? getVisibilityAccessFlag(descriptorForVisibility(propertyDescriptor)) : ACC_PRIVATE;
|
||||
}
|
||||
else {
|
||||
return areBothAccessorDefault(propertyDescriptor)
|
||||
? getVisibilityAccessFlag(descriptorForVisibility(propertyDescriptor))
|
||||
: ACC_PRIVATE;
|
||||
}
|
||||
}
|
||||
|
||||
private static MemberDescriptor descriptorForVisibility(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
if (!propertyDescriptor.isVar() ) {
|
||||
if (!propertyDescriptor.isVar()) {
|
||||
return propertyDescriptor;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return propertyDescriptor.getSetter() != null ? propertyDescriptor.getSetter() : propertyDescriptor;
|
||||
}
|
||||
}
|
||||
@@ -766,12 +773,17 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getOuterClassName(@NotNull ClassDescriptor classDescriptor, @NotNull DeclarationDescriptor originalDescriptor, @NotNull JetTypeMapper typeMapper) {
|
||||
private static String getOuterClassName(
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull DeclarationDescriptor originalDescriptor,
|
||||
@NotNull JetTypeMapper typeMapper
|
||||
) {
|
||||
DeclarationDescriptor container = classDescriptor.getContainingDeclaration();
|
||||
while (container != null) {
|
||||
if (container instanceof ClassDescriptor) {
|
||||
return typeMapper.mapClass((ClassDescriptor)container).getInternalName();
|
||||
} else if (CodegenBinding.isLocalFunOrLambda(container)) {
|
||||
return typeMapper.mapClass((ClassDescriptor) container).getInternalName();
|
||||
}
|
||||
else if (CodegenBinding.isLocalFunOrLambda(container)) {
|
||||
ClassDescriptor descriptor =
|
||||
CodegenBinding.anonymousClassForFunction(typeMapper.getBindingContext(), (FunctionDescriptor) container);
|
||||
return typeMapper.mapClass(descriptor).getInternalName();
|
||||
|
||||
@@ -1223,6 +1223,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
CompileTimeConstant<?> compileTimeValue = bindingContext.get(COMPILE_TIME_VALUE, expression);
|
||||
if (compileTimeValue instanceof IntegerValueTypeConstant) {
|
||||
JetType expectedType = bindingContext.get(EXPRESSION_TYPE, expression);
|
||||
assert expectedType != null : "Expression is not type checked: " + expression.getText();
|
||||
return EvaluatePackage.createCompileTimeConstantWithType((IntegerValueTypeConstant) compileTimeValue, expectedType);
|
||||
}
|
||||
return compileTimeValue;
|
||||
|
||||
@@ -626,9 +626,7 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
|
||||
CallGenerator generator = codegen.getOrCreateCallGenerator(functionDescriptor, function);
|
||||
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
|
||||
loadExplicitArgumentsOnStack(iv, OBJECT_TYPE, isStatic, signature, generator);
|
||||
loadExplicitArgumentsOnStack(OBJECT_TYPE, isStatic, signature, generator);
|
||||
|
||||
List<JvmMethodParameterSignature> mappedParameters = signature.getValueParameters();
|
||||
int capturedArgumentsCount = 0;
|
||||
@@ -637,6 +635,8 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
capturedArgumentsCount++;
|
||||
}
|
||||
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
|
||||
int maskIndex = 0;
|
||||
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
|
||||
for (int index = 0; index < valueParameters.size(); index++) {
|
||||
@@ -703,7 +703,6 @@ public class FunctionCodegen extends ParentCodegenAware {
|
||||
}
|
||||
|
||||
private static void loadExplicitArgumentsOnStack(
|
||||
@NotNull InstructionAdapter iv,
|
||||
@NotNull Type ownerType,
|
||||
boolean isStatic,
|
||||
@NotNull JvmMethodSignature signature,
|
||||
|
||||
@@ -27,10 +27,7 @@ import org.jetbrains.jet.backend.common.CodegenUtil;
|
||||
import org.jetbrains.jet.backend.common.DataClassMethodGenerator;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.codegen.bridges.BridgesPackage;
|
||||
import org.jetbrains.jet.codegen.context.ClassContext;
|
||||
import org.jetbrains.jet.codegen.context.ConstructorContext;
|
||||
import org.jetbrains.jet.codegen.context.FieldOwnerContext;
|
||||
import org.jetbrains.jet.codegen.context.MethodContext;
|
||||
import org.jetbrains.jet.codegen.context.*;
|
||||
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
@@ -77,9 +74,7 @@ import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorT
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.DelegationToTraitImpl;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.OtherOrigin;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.Synthetic;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.JvmDeclarationOrigin.NO_ORIGIN;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
@@ -93,7 +88,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
private List<PropertyAndDefaultValue> classObjectPropertiesToCopy;
|
||||
|
||||
private List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks;
|
||||
private final List<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>> additionalTasks =
|
||||
new ArrayList<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>>();
|
||||
|
||||
public ImplementationBodyCodegen(
|
||||
@NotNull JetClassOrObject aClass,
|
||||
@@ -104,7 +100,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
) {
|
||||
super(aClass, context, v, state, parentCodegen);
|
||||
this.classAsmType = typeMapper.mapClass(descriptor);
|
||||
additionalTasks = new ArrayList<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -969,7 +964,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
protected void generateSyntheticAccessors() {
|
||||
Map<DeclarationDescriptor, DeclarationDescriptor> accessors = context.getAccessors();
|
||||
Map<DeclarationDescriptor, DeclarationDescriptor> accessors = ((CodegenContext<?>) context).getAccessors();
|
||||
for (Map.Entry<DeclarationDescriptor, DeclarationDescriptor> entry : accessors.entrySet()) {
|
||||
generateSyntheticAccessor(entry);
|
||||
}
|
||||
@@ -1147,7 +1142,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
field.store(field.type, codegen.v);
|
||||
}
|
||||
|
||||
protected void genInitSingleton(ClassDescriptor fieldTypeDescriptor, StackValue.Field field) {
|
||||
private void genInitSingleton(ClassDescriptor fieldTypeDescriptor, StackValue.Field field) {
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
|
||||
Collection<ConstructorDescriptor> constructors = fieldTypeDescriptor.getConstructors();
|
||||
assert constructors.size() == 1 : "Class of singleton object must have only one constructor: " + constructors;
|
||||
@@ -1351,11 +1346,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PropertyDescriptor getDelegatePropertyIfAny(JetExpression expression) {
|
||||
return CodegenUtil.getDelegatePropertyIfAny(expression, descriptor, bindingContext);
|
||||
}
|
||||
|
||||
private void lookupConstructorExpressionsInClosureIfPresent(final ConstructorContext constructorContext) {
|
||||
JetVisitorVoid visitor = new JetVisitorVoid() {
|
||||
@Override
|
||||
|
||||
@@ -94,12 +94,12 @@ public class RemapVisitor extends InliningInstructionAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
public AnnotationVisitor visitAnnotation(@NotNull String desc, boolean visible) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
|
||||
public AnnotationVisitor visitParameterAnnotation(int parameter, @NotNull String desc, boolean visible) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -793,6 +793,7 @@ public class JetTypeMapper {
|
||||
type = sharedVarType;
|
||||
}
|
||||
else if (isLocalNamedFun(variableDescriptor)) {
|
||||
//noinspection CastConflictsWithInstanceof
|
||||
type = asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) variableDescriptor);
|
||||
}
|
||||
else {
|
||||
@@ -886,18 +887,16 @@ public class JetTypeMapper {
|
||||
}
|
||||
|
||||
public Type getSharedVarType(DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof PropertyDescriptor) {
|
||||
return StackValue.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType()));
|
||||
}
|
||||
else if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||
if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||
return asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
return StackValue.sharedTypeForType(mapType(((FunctionDescriptor) descriptor).getReceiverParameter().getType()));
|
||||
else if (descriptor instanceof PropertyDescriptor || descriptor instanceof FunctionDescriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = ((CallableDescriptor) descriptor).getReceiverParameter();
|
||||
assert receiverParameter != null : "Callable should have a receiver parameter: " + descriptor;
|
||||
return StackValue.sharedTypeForType(mapType(receiverParameter.getType()));
|
||||
}
|
||||
else if (descriptor instanceof VariableDescriptor && isVarCapturedInClosure(bindingContext, descriptor)) {
|
||||
JetType outType = ((VariableDescriptor) descriptor).getType();
|
||||
return StackValue.sharedTypeForType(mapType(outType));
|
||||
return StackValue.sharedTypeForType(mapType(((VariableDescriptor) descriptor).getType()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ public class AsmTypeConstants {
|
||||
public static final Type JAVA_THROWABLE_TYPE = getType(Throwable.class);
|
||||
|
||||
public static final Type UNIT_TYPE = Type.getObjectType(BUILT_INS_PACKAGE_FQ_NAME + "/Unit");
|
||||
public static final Type FUNCTION0_TYPE = Type.getObjectType(BUILT_INS_PACKAGE_FQ_NAME + "/Function0");
|
||||
public static final Type FUNCTION1_TYPE = Type.getObjectType(BUILT_INS_PACKAGE_FQ_NAME + "/Function1");
|
||||
public static final Type INT_RANGE_TYPE = Type.getObjectType(BUILT_INS_PACKAGE_FQ_NAME + "/IntRange");
|
||||
public static final Type PROPERTY_METADATA_TYPE = Type.getObjectType(BUILT_INS_PACKAGE_FQ_NAME + "/PropertyMetadata");
|
||||
|
||||
Reference in New Issue
Block a user