Invoke "remove unnecessary final" intention in compiler modules
This commit is contained in:
@@ -308,9 +308,9 @@ public abstract class AnnotationCodegen {
|
||||
}
|
||||
|
||||
private void genCompileTimeValue(
|
||||
@Nullable final String name,
|
||||
@Nullable String name,
|
||||
@NotNull ConstantValue<?> value,
|
||||
@NotNull final AnnotationVisitor annotationVisitor
|
||||
@NotNull AnnotationVisitor annotationVisitor
|
||||
) {
|
||||
AnnotationArgumentVisitor argumentVisitor = new AnnotationArgumentVisitor<Void, Void>() {
|
||||
@Override
|
||||
@@ -485,7 +485,7 @@ public abstract class AnnotationCodegen {
|
||||
abstract AnnotationVisitor visitAnnotation(String descr, boolean visible);
|
||||
|
||||
public static AnnotationCodegen forClass(
|
||||
final @NotNull ClassVisitor cv,
|
||||
@NotNull ClassVisitor cv,
|
||||
@NotNull InnerClassConsumer innerClassConsumer,
|
||||
@NotNull KotlinTypeMapper mapper
|
||||
) {
|
||||
@@ -499,7 +499,7 @@ public abstract class AnnotationCodegen {
|
||||
}
|
||||
|
||||
public static AnnotationCodegen forMethod(
|
||||
final @NotNull MethodVisitor mv,
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull InnerClassConsumer innerClassConsumer,
|
||||
@NotNull KotlinTypeMapper mapper
|
||||
) {
|
||||
@@ -513,7 +513,7 @@ public abstract class AnnotationCodegen {
|
||||
}
|
||||
|
||||
public static AnnotationCodegen forField(
|
||||
final @NotNull FieldVisitor fv,
|
||||
@NotNull FieldVisitor fv,
|
||||
@NotNull InnerClassConsumer innerClassConsumer,
|
||||
@NotNull KotlinTypeMapper mapper
|
||||
) {
|
||||
@@ -527,8 +527,8 @@ public abstract class AnnotationCodegen {
|
||||
}
|
||||
|
||||
public static AnnotationCodegen forParameter(
|
||||
final int parameter,
|
||||
final @NotNull MethodVisitor mv,
|
||||
int parameter,
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull InnerClassConsumer innerClassConsumer,
|
||||
@NotNull KotlinTypeMapper mapper
|
||||
) {
|
||||
@@ -542,7 +542,7 @@ public abstract class AnnotationCodegen {
|
||||
}
|
||||
|
||||
public static AnnotationCodegen forAnnotationDefaultValue(
|
||||
final @NotNull MethodVisitor mv,
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull InnerClassConsumer innerClassConsumer,
|
||||
@NotNull KotlinTypeMapper mapper
|
||||
) {
|
||||
|
||||
@@ -500,7 +500,7 @@ public class AsmUtil {
|
||||
v.invokevirtual("java/lang/StringBuilder", "append", "(" + type.getDescriptor() + ")Ljava/lang/StringBuilder;", false);
|
||||
}
|
||||
|
||||
public static StackValue genToString(final StackValue receiver, final Type receiverType) {
|
||||
public static StackValue genToString(StackValue receiver, Type receiverType) {
|
||||
return StackValue.operation(JAVA_STRING_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
@@ -563,12 +563,12 @@ public class AsmUtil {
|
||||
|
||||
@NotNull
|
||||
public static StackValue genEqualsForExpressionsOnStack(
|
||||
final @NotNull IElementType opToken,
|
||||
final @NotNull StackValue left,
|
||||
final @NotNull StackValue right
|
||||
@NotNull IElementType opToken,
|
||||
@NotNull StackValue left,
|
||||
@NotNull StackValue right
|
||||
) {
|
||||
final Type leftType = left.type;
|
||||
final Type rightType = right.type;
|
||||
Type leftType = left.type;
|
||||
Type rightType = right.type;
|
||||
if (isPrimitive(leftType) && leftType == rightType) {
|
||||
return StackValue.cmp(opToken, leftType, left, right);
|
||||
}
|
||||
@@ -686,8 +686,8 @@ public class AsmUtil {
|
||||
@NotNull
|
||||
public static StackValue genNotNullAssertions(
|
||||
@NotNull GenerationState state,
|
||||
@NotNull final StackValue stackValue,
|
||||
@Nullable final RuntimeAssertionInfo runtimeAssertionInfo
|
||||
@NotNull StackValue stackValue,
|
||||
@Nullable RuntimeAssertionInfo runtimeAssertionInfo
|
||||
) {
|
||||
if (state.isCallAssertionsDisabled()) return stackValue;
|
||||
if (runtimeAssertionInfo == null || !runtimeAssertionInfo.getNeedNotNullAssertion()) return stackValue;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ClassBuilderFactories {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ClassBuilderFactory binaries(final boolean generateSourceRetentionAnnotations) {
|
||||
public static ClassBuilderFactory binaries(boolean generateSourceRetentionAnnotations) {
|
||||
return new ClassBuilderFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
}
|
||||
|
||||
private void writeModuleMappings() {
|
||||
final JvmPackageTable.PackageTable.Builder builder = JvmPackageTable.PackageTable.newBuilder();
|
||||
JvmPackageTable.PackageTable.Builder builder = JvmPackageTable.PackageTable.newBuilder();
|
||||
String outputFilePath = getMappingFileName(state.getModuleName());
|
||||
|
||||
for (PackageParts part : ClassFileUtilsKt.addCompiledPartsAndSort(partsGroupedByPackage.values(), state)) {
|
||||
@@ -182,7 +182,7 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
}
|
||||
|
||||
private PackagePartRegistry buildNewPackagePartRegistry(@NotNull FqName packageFqName) {
|
||||
final String packageFqNameAsString = packageFqName.asString();
|
||||
String packageFqNameAsString = packageFqName.asString();
|
||||
return new PackagePartRegistry() {
|
||||
@Override
|
||||
public void addPart(@NotNull String partShortName, @Nullable String facadeShortName) {
|
||||
|
||||
@@ -236,10 +236,10 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
assert method != null : "No method for " + frontendFunDescriptor;
|
||||
v.getSerializationBindings().put(METHOD_FOR_FUNCTION, freeLambdaDescriptor, method);
|
||||
|
||||
final DescriptorSerializer serializer =
|
||||
DescriptorSerializer serializer =
|
||||
DescriptorSerializer.createForLambda(new JvmSerializerExtension(v.getSerializationBindings(), state));
|
||||
|
||||
final ProtoBuf.Function functionProto = serializer.functionProto(freeLambdaDescriptor).build();
|
||||
ProtoBuf.Function functionProto = serializer.functionProto(freeLambdaDescriptor).build();
|
||||
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0, new Function1<AnnotationVisitor, Unit>() {
|
||||
@Override
|
||||
@@ -281,7 +281,7 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public StackValue putInstanceOnStack(@NotNull final ExpressionCodegen codegen, @Nullable final StackValue functionReferenceReceiver) {
|
||||
public StackValue putInstanceOnStack(@NotNull ExpressionCodegen codegen, @Nullable StackValue functionReferenceReceiver) {
|
||||
return StackValue.operation(
|
||||
functionReferenceTarget != null ? K_FUNCTION : asmType,
|
||||
new Function1<InstructionAdapter, Unit>() {
|
||||
|
||||
@@ -480,12 +480,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return generateIfExpression(expression, false);
|
||||
}
|
||||
|
||||
/* package */ StackValue generateIfExpression(@NotNull final KtIfExpression expression, final boolean isStatement) {
|
||||
final Type asmType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
|
||||
final StackValue condition = gen(expression.getCondition());
|
||||
/* package */ StackValue generateIfExpression(@NotNull KtIfExpression expression, boolean isStatement) {
|
||||
Type asmType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
|
||||
StackValue condition = gen(expression.getCondition());
|
||||
|
||||
final KtExpression thenExpression = expression.getThen();
|
||||
final KtExpression elseExpression = expression.getElse();
|
||||
KtExpression thenExpression = expression.getThen();
|
||||
KtExpression elseExpression = expression.getElse();
|
||||
|
||||
if (isEmptyExpression(thenExpression)) {
|
||||
if (isEmptyExpression(elseExpression)) {
|
||||
@@ -522,7 +522,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitWhileExpression(@NotNull final KtWhileExpression expression, StackValue receiver) {
|
||||
public StackValue visitWhileExpression(@NotNull KtWhileExpression expression, StackValue receiver) {
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -553,7 +553,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitDoWhileExpression(@NotNull final KtDoWhileExpression expression, StackValue receiver) {
|
||||
public StackValue visitDoWhileExpression(@NotNull KtDoWhileExpression expression, StackValue receiver) {
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -611,7 +611,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitForExpression(@NotNull final KtForExpression forExpression, StackValue receiver) {
|
||||
public StackValue visitForExpression(@NotNull KtForExpression forExpression, StackValue receiver) {
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -765,7 +765,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
else {
|
||||
// E e = tmp<iterator>.next()
|
||||
final VariableDescriptor parameterDescriptor = bindingContext.get(VALUE_PARAMETER, loopParameter);
|
||||
VariableDescriptor parameterDescriptor = bindingContext.get(VALUE_PARAMETER, loopParameter);
|
||||
loopParameterType = asmType(parameterDescriptor.getType());
|
||||
loopParameterVar = myFrameMap.enter(parameterDescriptor, loopParameterType);
|
||||
scheduleLeaveVariable(new Runnable() {
|
||||
@@ -796,7 +796,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
private void generateDestructuringDeclaration(@NotNull KtDestructuringDeclaration destructuringDeclaration) {
|
||||
final Label destructuringStartLabel = new Label();
|
||||
Label destructuringStartLabel = new Label();
|
||||
|
||||
List<VariableDescriptor> componentDescriptors =
|
||||
CollectionsKt.map(
|
||||
@@ -809,9 +809,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
);
|
||||
|
||||
for (final VariableDescriptor componentDescriptor : CodegenUtilKt.filterOutDescriptorsWithSpecialNames(componentDescriptors)) {
|
||||
@SuppressWarnings("ConstantConditions") final Type componentAsmType = asmType(componentDescriptor.getReturnType());
|
||||
final int componentVarIndex = myFrameMap.enter(componentDescriptor, componentAsmType);
|
||||
for (VariableDescriptor componentDescriptor : CodegenUtilKt.filterOutDescriptorsWithSpecialNames(componentDescriptors)) {
|
||||
@SuppressWarnings("ConstantConditions") Type componentAsmType = asmType(componentDescriptor.getReturnType());
|
||||
int componentVarIndex = myFrameMap.enter(componentDescriptor, componentAsmType);
|
||||
scheduleLeaveVariable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -844,7 +844,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
leaveVariableTasks.add(runnable);
|
||||
}
|
||||
|
||||
protected int createLoopTempVariable(final Type type) {
|
||||
protected int createLoopTempVariable(Type type) {
|
||||
int varIndex = myFrameMap.enterTemp(type);
|
||||
scheduleLeaveVariable(new Runnable() {
|
||||
@Override
|
||||
@@ -1367,7 +1367,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
private StackValue generateBreakOrContinueExpression(
|
||||
@NotNull KtExpressionWithLabel expression,
|
||||
boolean isBreak,
|
||||
final @NotNull Label afterBreakContinueLabel
|
||||
@NotNull Label afterBreakContinueLabel
|
||||
) {
|
||||
assert expression instanceof KtContinueExpression || expression instanceof KtBreakExpression;
|
||||
|
||||
@@ -1389,7 +1389,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
if (labelElement == null ||
|
||||
loopBlockStackElement.targetLabel != null &&
|
||||
labelElement.getReferencedName().equals(loopBlockStackElement.targetLabel.getReferencedName())) {
|
||||
final Label label = isBreak ? loopBlockStackElement.breakLabel : loopBlockStackElement.continueLabel;
|
||||
Label label = isBreak ? loopBlockStackElement.breakLabel : loopBlockStackElement.continueLabel;
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -1412,11 +1412,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
private StackValue generateSingleBranchIf(
|
||||
final StackValue condition,
|
||||
final KtIfExpression ifExpression,
|
||||
final KtExpression expression,
|
||||
final boolean inverse,
|
||||
final boolean isStatement
|
||||
StackValue condition,
|
||||
KtIfExpression ifExpression,
|
||||
KtExpression expression,
|
||||
boolean inverse,
|
||||
boolean isStatement
|
||||
) {
|
||||
Type targetType = isStatement ? Type.VOID_TYPE : expressionType(ifExpression);
|
||||
return StackValue.operation(targetType, new Function1<InstructionAdapter, Unit>() {
|
||||
@@ -1476,7 +1476,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
@Nullable
|
||||
public static ConstantValue<?> getCompileTimeConstant(
|
||||
@NotNull KtExpression expression,
|
||||
@NotNull final BindingContext bindingContext,
|
||||
@NotNull BindingContext bindingContext,
|
||||
boolean takeUpConstValsAsConst,
|
||||
boolean shouldInlineConstVals
|
||||
) {
|
||||
@@ -1486,7 +1486,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
if (!shouldInlineConstVals && !takeUpConstValsAsConst && compileTimeValue.getUsesVariableAsConstant()) {
|
||||
final Ref<Boolean> containsNonInlinedVals = new Ref<Boolean>(false);
|
||||
Ref<Boolean> containsNonInlinedVals = new Ref<Boolean>(false);
|
||||
KtVisitor constantChecker = new KtVisitor() {
|
||||
@Override
|
||||
public Object visitSimpleNameExpression(@NotNull KtSimpleNameExpression expression, Object data) {
|
||||
@@ -1528,7 +1528,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
@Override
|
||||
public StackValue visitStringTemplateExpression(@NotNull KtStringTemplateExpression expression, StackValue receiver) {
|
||||
StringBuilder constantValue = new StringBuilder("");
|
||||
final KtStringTemplateEntry[] entries = expression.getEntries();
|
||||
KtStringTemplateEntry[] entries = expression.getEntries();
|
||||
|
||||
if (entries.length == 1 && entries[0] instanceof KtStringTemplateEntryWithExpression) {
|
||||
KtExpression expr = entries[0].getExpression();
|
||||
@@ -1666,9 +1666,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
@Override
|
||||
public StackValue visitObjectLiteralExpression(@NotNull KtObjectLiteralExpression expression, StackValue receiver) {
|
||||
final ObjectLiteralResult objectLiteralResult = generateObjectLiteral(expression);
|
||||
final ClassDescriptor classDescriptor = objectLiteralResult.classDescriptor;
|
||||
final Type type = typeMapper.mapType(classDescriptor);
|
||||
ObjectLiteralResult objectLiteralResult = generateObjectLiteral(expression);
|
||||
ClassDescriptor classDescriptor = objectLiteralResult.classDescriptor;
|
||||
Type type = typeMapper.mapType(classDescriptor);
|
||||
|
||||
return StackValue.operation(type, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
@@ -1824,11 +1824,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
@NotNull List<KtExpression> statements,
|
||||
boolean isStatement,
|
||||
@Nullable Label labelBeforeLastExpression,
|
||||
@Nullable final Label labelBlockEnd
|
||||
@Nullable Label labelBlockEnd
|
||||
) {
|
||||
final Label blockEnd = labelBlockEnd != null ? labelBlockEnd : new Label();
|
||||
Label blockEnd = labelBlockEnd != null ? labelBlockEnd : new Label();
|
||||
|
||||
final List<Function<StackValue, Void>> leaveTasks = Lists.newArrayList();
|
||||
List<Function<StackValue, Void>> leaveTasks = Lists.newArrayList();
|
||||
|
||||
@Nullable
|
||||
StackValue blockResult = null;
|
||||
@@ -1984,18 +1984,18 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
private void addLeaveTaskToRemoveLocalVariableFromFrameMap(
|
||||
@NotNull KtVariableDeclaration statement,
|
||||
final Label blockEnd,
|
||||
Label blockEnd,
|
||||
@NotNull List<Function<StackValue, Void>> leaveTasks
|
||||
) {
|
||||
final VariableDescriptor variableDescriptor = getVariableDescriptorNotNull(statement);
|
||||
VariableDescriptor variableDescriptor = getVariableDescriptorNotNull(statement);
|
||||
|
||||
// Do not modify local variables table for variables like _ in val (_, y) = pair
|
||||
// They always will have special name
|
||||
if (variableDescriptor.getName().isSpecial()) return;
|
||||
|
||||
final Type type = getVariableType(variableDescriptor);
|
||||
Type type = getVariableType(variableDescriptor);
|
||||
|
||||
final Label scopeStart = new Label();
|
||||
Label scopeStart = new Label();
|
||||
v.mark(scopeStart);
|
||||
|
||||
leaveTasks.add(new Function<StackValue, Void>() {
|
||||
@@ -2018,16 +2018,16 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
private void addLeaveTaskToRemoveNamedFunctionFromFrameMap(
|
||||
@NotNull final KtNamedFunction statement,
|
||||
final Label blockEnd,
|
||||
@NotNull KtNamedFunction statement,
|
||||
Label blockEnd,
|
||||
@NotNull List<Function<StackValue, Void>> leaveTasks
|
||||
) {
|
||||
final FunctionDescriptor functionDescriptor = (FunctionDescriptor) bindingContext.get(DECLARATION_TO_DESCRIPTOR, statement);
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) bindingContext.get(DECLARATION_TO_DESCRIPTOR, statement);
|
||||
assert functionDescriptor != null;
|
||||
|
||||
final Type type = asmTypeForAnonymousClass(bindingContext, functionDescriptor);
|
||||
Type type = asmTypeForAnonymousClass(bindingContext, functionDescriptor);
|
||||
|
||||
final Label scopeStart = new Label();
|
||||
Label scopeStart = new Label();
|
||||
v.mark(scopeStart);
|
||||
|
||||
leaveTasks.add(new Function<StackValue, Void>() {
|
||||
@@ -2159,7 +2159,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitReturnExpression(@NotNull final KtReturnExpression expression, final StackValue receiver) {
|
||||
public StackValue visitReturnExpression(@NotNull KtReturnExpression expression, StackValue receiver) {
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -2684,10 +2684,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
@Nullable
|
||||
private StackValue genSamInterfaceValue(
|
||||
@NotNull KtExpression probablyParenthesizedExpression,
|
||||
@NotNull final KtVisitor<StackValue, StackValue> visitor
|
||||
@NotNull KtVisitor<StackValue, StackValue> visitor
|
||||
) {
|
||||
final KtExpression expression = KtPsiUtil.deparenthesize(probablyParenthesizedExpression);
|
||||
final SamType samType = bindingContext.get(SAM_VALUE, probablyParenthesizedExpression);
|
||||
KtExpression expression = KtPsiUtil.deparenthesize(probablyParenthesizedExpression);
|
||||
SamType samType = bindingContext.get(SAM_VALUE, probablyParenthesizedExpression);
|
||||
if (samType == null || expression == null) return null;
|
||||
|
||||
if (expression instanceof KtLambdaExpression) {
|
||||
@@ -2698,7 +2698,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return genClosure((KtNamedFunction) expression, samType);
|
||||
}
|
||||
|
||||
final Type asmType =
|
||||
Type asmType =
|
||||
state.getSamWrapperClasses().getSamWrapperClass(samType, expression.getContainingKtFile(), this);
|
||||
|
||||
return StackValue.operation(asmType, new Function1<InstructionAdapter, Unit>() {
|
||||
@@ -3391,8 +3391,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
@NotNull KtElement element,
|
||||
@NotNull VariableDescriptor variableDescriptor,
|
||||
@NotNull VariableDescriptor target,
|
||||
@Nullable final Type receiverAsmType,
|
||||
@Nullable final StackValue receiverValue
|
||||
@Nullable Type receiverAsmType,
|
||||
@Nullable StackValue receiverValue
|
||||
) {
|
||||
ClassDescriptor classDescriptor = CodegenBinding.anonymousClassForCallable(bindingContext, variableDescriptor);
|
||||
|
||||
@@ -3420,9 +3420,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
@NotNull
|
||||
public StackValue generateClassLiteralReference(
|
||||
@NotNull final DoubleColonLHS lhs,
|
||||
@Nullable final KtExpression receiverExpression,
|
||||
final boolean wrapIntoKClass
|
||||
@NotNull DoubleColonLHS lhs,
|
||||
@Nullable KtExpression receiverExpression,
|
||||
boolean wrapIntoKClass
|
||||
) {
|
||||
return StackValue.operation(wrapIntoKClass ? K_CLASS_TYPE : JAVA_CLASS_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
@@ -3549,11 +3549,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
}
|
||||
|
||||
private StackValue generateIn(final StackValue leftValue, KtExpression rangeExpression, final KtSimpleNameExpression operationReference) {
|
||||
final KtExpression deparenthesized = KtPsiUtil.deparenthesize(rangeExpression);
|
||||
private StackValue generateIn(StackValue leftValue, KtExpression rangeExpression, KtSimpleNameExpression operationReference) {
|
||||
KtExpression deparenthesized = KtPsiUtil.deparenthesize(rangeExpression);
|
||||
|
||||
assert deparenthesized != null : "For with empty range expression";
|
||||
final boolean isInverted = operationReference.getReferencedNameElementType() == KtTokens.NOT_IN;
|
||||
boolean isInverted = operationReference.getReferencedNameElementType() == KtTokens.NOT_IN;
|
||||
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
@@ -3670,17 +3670,17 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
/*tries to use IEEE 754 arithmetic*/
|
||||
private StackValue genEqualsForExpressionsPreferIEEE754Arithmetic(
|
||||
@Nullable final KtExpression left,
|
||||
@Nullable final KtExpression right,
|
||||
@NotNull final IElementType opToken,
|
||||
@Nullable KtExpression left,
|
||||
@Nullable KtExpression right,
|
||||
@NotNull IElementType opToken,
|
||||
@NotNull Type leftType,
|
||||
@NotNull Type rightType,
|
||||
@Nullable final StackValue pregeneratedLeft
|
||||
@Nullable StackValue pregeneratedLeft
|
||||
) {
|
||||
assert (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) : "Optoken should be '==' or '!=', but: " + opToken;
|
||||
|
||||
final TypeAndNullability left754Type = calcTypeForIEEE754ArithmeticIfNeeded(left);
|
||||
final TypeAndNullability right754Type = calcTypeForIEEE754ArithmeticIfNeeded(right);
|
||||
TypeAndNullability left754Type = calcTypeForIEEE754ArithmeticIfNeeded(left);
|
||||
TypeAndNullability right754Type = calcTypeForIEEE754ArithmeticIfNeeded(right);
|
||||
if (left754Type != null && right754Type != null && left754Type.type.equals(right754Type.type)) {
|
||||
//check nullability cause there is some optimizations in codegen for non-nullable case
|
||||
if (left754Type.isNullable || right754Type.isNullable) {
|
||||
@@ -3849,17 +3849,16 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return StackValue.compareWithNull(gen(exp), (KtTokens.EQEQ == opToken || KtTokens.EQEQEQ == opToken) ? IFNONNULL : IFNULL);
|
||||
}
|
||||
|
||||
private StackValue generateElvis(@NotNull final KtBinaryExpression expression) {
|
||||
private StackValue generateElvis(@NotNull KtBinaryExpression expression) {
|
||||
KtExpression left = expression.getLeft();
|
||||
|
||||
final Type exprType = expressionType(expression);
|
||||
final Type leftType = expressionType(left);
|
||||
|
||||
final Label ifNull = new Label();
|
||||
Type exprType = expressionType(expression);
|
||||
Type leftType = expressionType(left);
|
||||
|
||||
Label ifNull = new Label();
|
||||
|
||||
assert left != null : "left expression in elvis should be not null: " + expression.getText();
|
||||
final StackValue value = generateExpressionWithNullFallback(left, ifNull);
|
||||
StackValue value = generateExpressionWithNullFallback(left, ifNull);
|
||||
|
||||
if (isPrimitive(leftType)) {
|
||||
return value;
|
||||
@@ -3918,7 +3917,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return CodegenUtilKt.calcTypeForIEEE754ArithmeticIfNeeded(expression, bindingContext, context.getFunctionDescriptor());
|
||||
}
|
||||
|
||||
private StackValue generateAssignmentExpression(final KtBinaryExpression expression) {
|
||||
private StackValue generateAssignmentExpression(KtBinaryExpression expression) {
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -3932,7 +3931,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
});
|
||||
}
|
||||
|
||||
private StackValue generateAugmentedAssignment(final KtBinaryExpression expression) {
|
||||
private StackValue generateAugmentedAssignment(KtBinaryExpression expression) {
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -4039,9 +4038,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitPostfixExpression(@NotNull final KtPostfixExpression expression, StackValue receiver) {
|
||||
public StackValue visitPostfixExpression(@NotNull KtPostfixExpression expression, StackValue receiver) {
|
||||
if (expression.getOperationReference().getReferencedNameElementType() == KtTokens.EXCLEXCL) {
|
||||
final StackValue base = genQualified(receiver, expression.getBaseExpression());
|
||||
StackValue base = genQualified(receiver, expression.getBaseExpression());
|
||||
if (isPrimitive(base.type)) {
|
||||
return base;
|
||||
} else {
|
||||
@@ -4062,19 +4061,19 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
DeclarationDescriptor originalOperation = bindingContext.get(REFERENCE_TARGET, expression.getOperationReference());
|
||||
String originalOperationName = originalOperation != null ? originalOperation.getName().asString() : null;
|
||||
final ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCallWithAssert(expression, bindingContext);
|
||||
ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCallWithAssert(expression, bindingContext);
|
||||
DeclarationDescriptor op = resolvedCall.getResultingDescriptor();
|
||||
if (!(op instanceof FunctionDescriptor) || originalOperation == null) {
|
||||
throw new UnsupportedOperationException("Don't know how to generate this postfix expression: " + originalOperationName + " " + op);
|
||||
}
|
||||
|
||||
|
||||
final Type asmResultType = expressionType(expression);
|
||||
final Type asmBaseType = expressionType(expression.getBaseExpression());
|
||||
Type asmResultType = expressionType(expression);
|
||||
Type asmBaseType = expressionType(expression.getBaseExpression());
|
||||
|
||||
DeclarationDescriptor cls = op.getContainingDeclaration();
|
||||
|
||||
final int increment;
|
||||
int increment;
|
||||
if (originalOperationName.equals("inc")) {
|
||||
increment = 1;
|
||||
}
|
||||
@@ -4085,7 +4084,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
throw new UnsupportedOperationException("Unsupported postfix operation: " + originalOperationName + " " + op);
|
||||
}
|
||||
|
||||
final boolean isPrimitiveNumberClassDescriptor = isPrimitiveNumberClassDescriptor(cls);
|
||||
boolean isPrimitiveNumberClassDescriptor = isPrimitiveNumberClassDescriptor(cls);
|
||||
if (isPrimitiveNumberClassDescriptor && AsmUtil.isPrimitive(asmBaseType)) {
|
||||
KtExpression operand = expression.getBaseExpression();
|
||||
// Optimization for j = i++, when j and i are Int without any smart cast: we just work with primitive int
|
||||
@@ -4255,7 +4254,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
@NotNull
|
||||
private Type generateProvideDelegateCallForLocalVariable(
|
||||
@NotNull StackValue initializer,
|
||||
final StackValue metadataValue,
|
||||
StackValue metadataValue,
|
||||
ResolvedCall<FunctionDescriptor> provideDelegateResolvedCall
|
||||
) {
|
||||
StackValue provideDelegateReceiver = StackValue.onStack(initializer.type);
|
||||
@@ -4340,7 +4339,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public StackValue generateConstructorCall(@NotNull final ResolvedCall<?> resolvedCall, @NotNull final Type objectType) {
|
||||
public StackValue generateConstructorCall(@NotNull ResolvedCall<?> resolvedCall, @NotNull Type objectType) {
|
||||
return StackValue.functionCall(objectType, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
@@ -4374,13 +4373,13 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
public StackValue generateNewArray(
|
||||
@NotNull KtCallExpression expression, @NotNull final KotlinType arrayType, @NotNull ResolvedCall<?> resolvedCall
|
||||
@NotNull KtCallExpression expression, @NotNull KotlinType arrayType, @NotNull ResolvedCall<?> resolvedCall
|
||||
) {
|
||||
List<KtValueArgument> args = expression.getValueArguments();
|
||||
assert args.size() == 1 || args.size() == 2 : "Unknown constructor called: " + args.size() + " arguments";
|
||||
|
||||
if (args.size() == 1) {
|
||||
final KtExpression sizeExpression = args.get(0).getArgumentExpression();
|
||||
KtExpression sizeExpression = args.get(0).getArgumentExpression();
|
||||
return StackValue.operation(typeMapper.mapType(arrayType), new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
@@ -4481,7 +4480,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackValue visitThrowExpression(@NotNull final KtThrowExpression expression, StackValue receiver) {
|
||||
public StackValue visitThrowExpression(@NotNull KtThrowExpression expression, StackValue receiver) {
|
||||
return StackValue.operation(Type.VOID_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
@@ -4510,13 +4509,13 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return generateTryExpression(expression, false);
|
||||
}
|
||||
|
||||
public StackValue generateTryExpression(final KtTryExpression expression, final boolean isStatement) {
|
||||
public StackValue generateTryExpression(KtTryExpression expression, boolean isStatement) {
|
||||
/*
|
||||
The "returned" value of try expression with no finally is either the last expression in the try block or the last expression in the catch block
|
||||
(or blocks).
|
||||
*/
|
||||
|
||||
final Type expectedAsmType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
|
||||
Type expectedAsmType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
|
||||
|
||||
return StackValue.operation(expectedAsmType, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
@@ -4662,12 +4661,12 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
@Override
|
||||
public StackValue visitBinaryWithTypeRHSExpression(@NotNull KtBinaryExpressionWithTypeRHS expression, StackValue receiver) {
|
||||
KtExpression left = expression.getLeft();
|
||||
final IElementType opToken = expression.getOperationReference().getReferencedNameElementType();
|
||||
IElementType opToken = expression.getOperationReference().getReferencedNameElementType();
|
||||
|
||||
final KotlinType rightType = bindingContext.get(TYPE, expression.getRight());
|
||||
KotlinType rightType = bindingContext.get(TYPE, expression.getRight());
|
||||
assert rightType != null;
|
||||
|
||||
final StackValue value = genQualified(receiver, left);
|
||||
StackValue value = genQualified(receiver, left);
|
||||
|
||||
return StackValue.operation(boxType(asmType(rightType)), new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
@@ -4732,7 +4731,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
return negated ? StackValue.not(value) : value;
|
||||
}
|
||||
|
||||
private StackValue generateIsCheck(final StackValue expressionToGen, final KotlinType kotlinType, final boolean leaveExpressionOnStack) {
|
||||
private StackValue generateIsCheck(StackValue expressionToGen, KotlinType kotlinType, boolean leaveExpressionOnStack) {
|
||||
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
@@ -4788,11 +4787,11 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
return generateWhenExpression(expression, false);
|
||||
}
|
||||
|
||||
public StackValue generateWhenExpression(final KtWhenExpression expression, final boolean isStatement) {
|
||||
final KtExpression expr = expression.getSubjectExpression();
|
||||
final Type subjectType = expressionType(expr);
|
||||
public StackValue generateWhenExpression(KtWhenExpression expression, boolean isStatement) {
|
||||
KtExpression expr = expression.getSubjectExpression();
|
||||
Type subjectType = expressionType(expr);
|
||||
|
||||
final Type resultType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
|
||||
Type resultType = isStatement ? Type.VOID_TYPE : expressionTypeForBranchingOperation(expression);
|
||||
|
||||
return StackValue.operation(resultType, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
|
||||
@@ -268,7 +268,7 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
private void generateDelegateForDefaultImpl(
|
||||
@NotNull final FunctionDescriptor functionDescriptor,
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@Nullable PsiElement element
|
||||
) {
|
||||
Method defaultImplMethod = typeMapper.mapAsmMethod(functionDescriptor, OwnerKind.DEFAULT_IMPLS);
|
||||
@@ -825,7 +825,7 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Function1<FunctionDescriptor, Method> getSignatureMapper(final @NotNull KotlinTypeMapper typeMapper) {
|
||||
private static Function1<FunctionDescriptor, Method> getSignatureMapper(@NotNull KotlinTypeMapper typeMapper) {
|
||||
return new Function1<FunctionDescriptor, Method>() {
|
||||
@Override
|
||||
public Method invoke(FunctionDescriptor descriptor) {
|
||||
@@ -847,7 +847,7 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final KotlinTypeMapper mapper) {
|
||||
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull KotlinTypeMapper mapper) {
|
||||
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.throws"));
|
||||
if (annotation == null) {
|
||||
annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.jvm.Throws"));
|
||||
@@ -1234,11 +1234,11 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
private void genDelegate(
|
||||
@NotNull final FunctionDescriptor delegateFunction,
|
||||
final FunctionDescriptor delegatedTo,
|
||||
@NotNull FunctionDescriptor delegateFunction,
|
||||
FunctionDescriptor delegatedTo,
|
||||
@NotNull JvmDeclarationOrigin declarationOrigin,
|
||||
final ClassDescriptor toClass,
|
||||
final StackValue field
|
||||
ClassDescriptor toClass,
|
||||
StackValue field
|
||||
) {
|
||||
generateMethod(
|
||||
declarationOrigin, delegateFunction,
|
||||
|
||||
+3
-3
@@ -78,10 +78,10 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
|
||||
*/
|
||||
|
||||
KtCallExpression fakeExpression = CodegenUtil.constructFakeFunctionCall(state.getProject(), referencedFunction);
|
||||
final List<? extends ValueArgument> fakeArguments = fakeExpression.getValueArguments();
|
||||
List<? extends ValueArgument> fakeArguments = fakeExpression.getValueArguments();
|
||||
|
||||
final ReceiverValue dispatchReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getDispatchReceiverParameter());
|
||||
final ReceiverValue extensionReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getExtensionReceiverParameter());
|
||||
ReceiverValue dispatchReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getDispatchReceiverParameter());
|
||||
ReceiverValue extensionReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getExtensionReceiverParameter());
|
||||
computeAndSaveArguments(fakeArguments, codegen);
|
||||
|
||||
ResolvedCall<CallableDescriptor> fakeResolvedCall = new DelegatingResolvedCall<CallableDescriptor>(resolvedCall) {
|
||||
|
||||
@@ -395,7 +395,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void generateToArray() {
|
||||
if (descriptor.getKind() == ClassKind.INTERFACE) return;
|
||||
|
||||
final KotlinBuiltIns builtIns = DescriptorUtilsKt.getBuiltIns(descriptor);
|
||||
KotlinBuiltIns builtIns = DescriptorUtilsKt.getBuiltIns(descriptor);
|
||||
if (!isSubclass(descriptor, builtIns.getCollection())) return;
|
||||
|
||||
if (CollectionsKt.any(DescriptorUtilsKt.getAllSuperclassesWithoutAny(descriptor), new Function1<ClassDescriptor, Boolean>() {
|
||||
@@ -637,7 +637,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateComponentFunction(@NotNull FunctionDescriptor function, @NotNull final ValueParameterDescriptor parameter) {
|
||||
public void generateComponentFunction(@NotNull FunctionDescriptor function, @NotNull ValueParameterDescriptor parameter) {
|
||||
PsiElement originalElement = DescriptorToSourceUtils.descriptorToDeclaration(parameter);
|
||||
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(originalElement, function), function, new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
@@ -665,10 +665,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
@Override
|
||||
public void generateCopyFunction(
|
||||
@NotNull final FunctionDescriptor function,
|
||||
@NotNull FunctionDescriptor function,
|
||||
@NotNull List<? extends KtParameter> constructorParameters
|
||||
) {
|
||||
final Type thisDescriptorType = typeMapper.mapType(descriptor);
|
||||
Type thisDescriptorType = typeMapper.mapType(descriptor);
|
||||
|
||||
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(myClass, function), function, new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
@@ -896,15 +896,15 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
StackValue.singleton(companionObject, typeMapper).store(instance, codegen.v, true);
|
||||
}
|
||||
|
||||
private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) {
|
||||
private void generatePrimaryConstructor(DelegationFieldsInfo delegationFieldsInfo) {
|
||||
if (isInterface(descriptor) || isAnnotationClass(descriptor)) return;
|
||||
|
||||
final ClassConstructorDescriptor constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor();
|
||||
ClassConstructorDescriptor constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor();
|
||||
if (constructorDescriptor == null) return;
|
||||
|
||||
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor);
|
||||
|
||||
final KtPrimaryConstructor primaryConstructor = myClass.getPrimaryConstructor();
|
||||
KtPrimaryConstructor primaryConstructor = myClass.getPrimaryConstructor();
|
||||
JvmDeclarationOrigin origin = JvmDeclarationOriginKt
|
||||
.OtherOrigin(primaryConstructor != null ? primaryConstructor : myClass.getPsiOrParent(), constructorDescriptor);
|
||||
functionCodegen.generateMethod(origin, constructorDescriptor, constructorContext,
|
||||
@@ -922,7 +922,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
new DefaultParameterValueSubstitutor(state).generatePrimaryConstructorOverloadsIfNeeded(constructorDescriptor, v, this, kind, myClass);
|
||||
}
|
||||
|
||||
private void generateSecondaryConstructor(@NotNull final ClassConstructorDescriptor constructorDescriptor) {
|
||||
private void generateSecondaryConstructor(@NotNull ClassConstructorDescriptor constructorDescriptor) {
|
||||
if (!canHaveDeclaredConstructors(descriptor)) return;
|
||||
|
||||
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor);
|
||||
@@ -994,7 +994,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
if (JvmAbi.isCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
||||
final ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
||||
ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||
@Override
|
||||
public ExpressionCodegen invoke() {
|
||||
@@ -1063,7 +1063,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateInitializers(@NotNull final ExpressionCodegen codegen) {
|
||||
private void generateInitializers(@NotNull ExpressionCodegen codegen) {
|
||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||
@Override
|
||||
public ExpressionCodegen invoke() {
|
||||
@@ -1306,7 +1306,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
CodegenUtilKt.reportTarget6InheritanceErrorIfNeeded(descriptor, myClass.getPsiOrParent(), restrictedInheritance, state);
|
||||
}
|
||||
|
||||
private void generateDelegationToDefaultImpl(@NotNull final FunctionDescriptor traitFun, @NotNull final FunctionDescriptor inheritedFun) {
|
||||
private void generateDelegationToDefaultImpl(@NotNull FunctionDescriptor traitFun, @NotNull FunctionDescriptor inheritedFun) {
|
||||
functionCodegen.generateMethod(
|
||||
JvmDeclarationOriginKt.DelegationToDefaultImpls(descriptorToDeclaration(traitFun), traitFun),
|
||||
inheritedFun,
|
||||
|
||||
@@ -691,8 +691,8 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
|
||||
private void generateSyntheticAccessor(@NotNull AccessorForCallableDescriptor<?> accessorForCallableDescriptor) {
|
||||
if (accessorForCallableDescriptor instanceof FunctionDescriptor) {
|
||||
final FunctionDescriptor accessor = (FunctionDescriptor) accessorForCallableDescriptor;
|
||||
final FunctionDescriptor original = (FunctionDescriptor) accessorForCallableDescriptor.getCalleeDescriptor();
|
||||
FunctionDescriptor accessor = (FunctionDescriptor) accessorForCallableDescriptor;
|
||||
FunctionDescriptor original = (FunctionDescriptor) accessorForCallableDescriptor.getCalleeDescriptor();
|
||||
functionCodegen.generateMethod(
|
||||
Synthetic(null, original), accessor,
|
||||
new FunctionGenerationStrategy.CodegenBased(state) {
|
||||
@@ -708,8 +708,8 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
);
|
||||
}
|
||||
else if (accessorForCallableDescriptor instanceof AccessorForPropertyDescriptor) {
|
||||
final AccessorForPropertyDescriptor accessor = (AccessorForPropertyDescriptor) accessorForCallableDescriptor;
|
||||
final PropertyDescriptor original = accessor.getCalleeDescriptor();
|
||||
AccessorForPropertyDescriptor accessor = (AccessorForPropertyDescriptor) accessorForCallableDescriptor;
|
||||
PropertyDescriptor original = accessor.getCalleeDescriptor();
|
||||
|
||||
class PropertyAccessorStrategy extends FunctionGenerationStrategy.CodegenBased {
|
||||
private final PropertyAccessorDescriptor callableDescriptor;
|
||||
@@ -815,10 +815,10 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
}
|
||||
|
||||
protected void generateKotlinClassMetadataAnnotation(@NotNull ClassDescriptor descriptor, boolean isScript) {
|
||||
final DescriptorSerializer serializer =
|
||||
DescriptorSerializer serializer =
|
||||
DescriptorSerializer.create(descriptor, new JvmSerializerExtension(v.getSerializationBindings(), state));
|
||||
|
||||
final ProtoBuf.Class classProto = serializer.classProto(descriptor).build();
|
||||
ProtoBuf.Class classProto = serializer.classProto(descriptor).build();
|
||||
|
||||
int flags = isScript ? JvmAnnotationNames.METADATA_SCRIPT_FLAG : 0;
|
||||
|
||||
|
||||
@@ -127,9 +127,9 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
|
||||
}
|
||||
}
|
||||
|
||||
final DescriptorSerializer serializer =
|
||||
DescriptorSerializer serializer =
|
||||
DescriptorSerializer.createTopLevel(new JvmSerializerExtension(v.getSerializationBindings(), state));
|
||||
final ProtoBuf.Package packageProto = serializer.packagePartProto(element.getPackageFqName(), members).build();
|
||||
ProtoBuf.Package packageProto = serializer.packagePartProto(element.getPackageFqName(), members).build();
|
||||
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.FILE_FACADE, 0, new Function1<AnnotationVisitor, Unit>() {
|
||||
@Override
|
||||
|
||||
@@ -537,7 +537,7 @@ public class PropertyCodegen {
|
||||
@NotNull ExpressionCodegen codegen,
|
||||
@NotNull KotlinTypeMapper typeMapper,
|
||||
@NotNull ResolvedCall<FunctionDescriptor> resolvedCall,
|
||||
final int indexInPropertyMetadataArray,
|
||||
int indexInPropertyMetadataArray,
|
||||
int propertyMetadataArgumentIndex
|
||||
) {
|
||||
StackValue.Property receiver = codegen.intermediateValueForProperty(propertyDescriptor, true, null, StackValue.LOCAL_0);
|
||||
@@ -551,14 +551,14 @@ public class PropertyCodegen {
|
||||
@NotNull ExpressionCodegen codegen,
|
||||
@NotNull KotlinTypeMapper typeMapper,
|
||||
@NotNull ResolvedCall<FunctionDescriptor> resolvedCall,
|
||||
final int indexInPropertyMetadataArray,
|
||||
int indexInPropertyMetadataArray,
|
||||
int propertyMetadataArgumentIndex,
|
||||
@Nullable StackValue receiver,
|
||||
@NotNull PropertyDescriptor propertyDescriptor
|
||||
) {
|
||||
final Type owner = JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor) ?
|
||||
codegen.getState().getTypeMapper().mapOwner(propertyDescriptor) :
|
||||
getDelegatedPropertyMetadataOwner(codegen, typeMapper);
|
||||
Type owner = JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor) ?
|
||||
codegen.getState().getTypeMapper().mapOwner(propertyDescriptor) :
|
||||
getDelegatedPropertyMetadataOwner(codegen, typeMapper);
|
||||
|
||||
codegen.tempVariables.put(
|
||||
resolvedCall.getCall().getValueArguments().get(propertyMetadataArgumentIndex).asElement(),
|
||||
|
||||
@@ -200,7 +200,7 @@ public class ScriptCodegen extends MemberCodegen<KtScript> {
|
||||
iv.putfield(classType.getInternalName(), context.getScriptFieldName(earlierScript), earlierClassType.getDescriptor());
|
||||
}
|
||||
|
||||
final ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, methodContext, state, this);
|
||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, methodContext, state, this);
|
||||
|
||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||
@Override
|
||||
|
||||
+6
-6
@@ -59,9 +59,9 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
||||
@Override
|
||||
@NotNull
|
||||
public InlineResult doTransform(@NotNull FieldRemapper parentRemapper) {
|
||||
final List<InnerClassNode> innerClassNodes = new ArrayList<InnerClassNode>();
|
||||
final ClassBuilder classBuilder = createRemappingClassBuilderViaFactory(inliningContext);
|
||||
final List<MethodNode> methodsToTransform = new ArrayList<MethodNode>();
|
||||
List<InnerClassNode> innerClassNodes = new ArrayList<InnerClassNode>();
|
||||
ClassBuilder classBuilder = createRemappingClassBuilderViaFactory(inliningContext);
|
||||
List<MethodNode> methodsToTransform = new ArrayList<MethodNode>();
|
||||
|
||||
createClassReader().accept(new ClassVisitor(InlineCodegenUtil.API, classBuilder.getVisitor()) {
|
||||
@Override
|
||||
@@ -273,7 +273,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
||||
NO_ORIGIN, constructor.access, "<init>", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY
|
||||
);
|
||||
|
||||
final Label newBodyStartLabel = new Label();
|
||||
Label newBodyStartLabel = new Label();
|
||||
constructorVisitor.visitLabel(newBodyStartLabel);
|
||||
//initialize captured fields
|
||||
List<NewJavaField> newFieldsWithSkipped = TransformationUtilsKt.getNewFieldsToGenerate(allCapturedBuilder.listCaptured());
|
||||
@@ -316,7 +316,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
||||
InlineCodegenUtil.removeFinallyMarkers(intermediateMethodNode);
|
||||
|
||||
AbstractInsnNode first = intermediateMethodNode.instructions.getFirst();
|
||||
final Label oldStartLabel = first instanceof LabelNode ? ((LabelNode) first).getLabel() : null;
|
||||
Label oldStartLabel = first instanceof LabelNode ? ((LabelNode) first).getLabel() : null;
|
||||
intermediateMethodNode.accept(new MethodBodyVisitor(capturedFieldInitializer) {
|
||||
@Override
|
||||
public void visitLocalVariable(
|
||||
@@ -344,7 +344,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static DeferredMethodVisitor newMethod(@NotNull final ClassBuilder builder, @NotNull final MethodNode original) {
|
||||
private static DeferredMethodVisitor newMethod(@NotNull ClassBuilder builder, @NotNull MethodNode original) {
|
||||
return new DeferredMethodVisitor(
|
||||
new MethodNode(
|
||||
original.access, original.name, original.desc, original.signature,
|
||||
|
||||
@@ -229,7 +229,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
|
||||
@NotNull
|
||||
static SMAPAndMethodNode createMethodNode(
|
||||
@NotNull final FunctionDescriptor functionDescriptor,
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@NotNull JvmMethodSignature jvmSignature,
|
||||
@NotNull ExpressionCodegen codegen,
|
||||
@NotNull CodegenContext context,
|
||||
@@ -259,14 +259,14 @@ public class InlineCodegen extends CallGenerator {
|
||||
);
|
||||
}
|
||||
|
||||
final GenerationState state = codegen.getState();
|
||||
final Method asmMethod =
|
||||
GenerationState state = codegen.getState();
|
||||
Method asmMethod =
|
||||
callDefault
|
||||
? state.getTypeMapper().mapDefaultMethod(functionDescriptor, context.getContextKind())
|
||||
: jvmSignature.getAsmMethod();
|
||||
|
||||
MethodId methodId = new MethodId(DescriptorUtils.getFqNameSafe(functionDescriptor.getContainingDeclaration()), asmMethod);
|
||||
final CallableMemberDescriptor directMember = getDirectMemberAndCallableFromObject(functionDescriptor);
|
||||
CallableMemberDescriptor directMember = getDirectMemberAndCallableFromObject(functionDescriptor);
|
||||
if (!isBuiltInArrayIntrinsic(functionDescriptor) && !(directMember instanceof DeserializedCallableMemberDescriptor)) {
|
||||
return doCreateMethodNodeFromSource(functionDescriptor, jvmSignature, codegen, context, callDefault, state, asmMethod);
|
||||
}
|
||||
@@ -310,7 +310,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
@Nullable
|
||||
private static SMAPAndMethodNode doCreateMethodNodeFromCompiled(
|
||||
@NotNull CallableMemberDescriptor callableDescriptor,
|
||||
@NotNull final GenerationState state,
|
||||
@NotNull GenerationState state,
|
||||
@NotNull Method asmMethod
|
||||
) {
|
||||
if (isBuiltInArrayIntrinsic(callableDescriptor)) {
|
||||
@@ -330,7 +330,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
KotlinTypeMapper.ContainingClassesInfo containingClasses =
|
||||
state.getTypeMapper().getContainingClassesForDeserializedCallable((DeserializedCallableMemberDescriptor) callableDescriptor);
|
||||
|
||||
final ClassId containerId = containingClasses.getImplClassId();
|
||||
ClassId containerId = containingClasses.getImplClassId();
|
||||
|
||||
byte[] bytes = InlineCacheKt.getOrPut(state.getInlineCache().getClassBytes(), containerId, new Function0<byte[]>() {
|
||||
@Override
|
||||
@@ -454,7 +454,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
result.getReifiedTypeParametersUsages().mergeAll(reificationResult);
|
||||
|
||||
CallableMemberDescriptor descriptor = getLabelOwnerDescriptor(codegen.getContext());
|
||||
final Set<String> labels = getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor);
|
||||
Set<String> labels = getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor);
|
||||
LabelOwner labelOwner = new LabelOwner() {
|
||||
@Override
|
||||
public boolean isMyLabel(@NotNull String name) {
|
||||
@@ -747,8 +747,8 @@ public class InlineCodegen extends CallGenerator {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Runnable recordParameterValueInLocalVal(boolean delayedWritingToLocals, @NotNull final ParameterInfo... infos) {
|
||||
final int[] index = new int[infos.length];
|
||||
private Runnable recordParameterValueInLocalVal(boolean delayedWritingToLocals, @NotNull ParameterInfo... infos) {
|
||||
int[] index = new int[infos.length];
|
||||
for (int i = 0; i < infos.length; i++) {
|
||||
ParameterInfo info = infos[i];
|
||||
if (!info.isSkippedOrRemapped()) {
|
||||
|
||||
@@ -91,14 +91,14 @@ public class InlineCodegenUtil {
|
||||
@Nullable
|
||||
public static SMAPAndMethodNode getMethodNode(
|
||||
byte[] classData,
|
||||
final String methodName,
|
||||
final String methodDescriptor,
|
||||
String methodName,
|
||||
String methodDescriptor,
|
||||
ClassId classId
|
||||
) {
|
||||
ClassReader cr = new ClassReader(classData);
|
||||
final MethodNode[] node = new MethodNode[1];
|
||||
final String[] debugInfo = new String[2];
|
||||
final int[] lines = new int[2];
|
||||
MethodNode[] node = new MethodNode[1];
|
||||
String[] debugInfo = new String[2];
|
||||
int[] lines = new int[2];
|
||||
lines[0] = Integer.MAX_VALUE;
|
||||
lines[1] = Integer.MIN_VALUE;
|
||||
//noinspection PointlessBitwiseExpression
|
||||
|
||||
+1
-1
@@ -429,7 +429,7 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
|
||||
// Utility methods
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private LabelWrapper getLabelWrapper(final Label label) {
|
||||
private LabelWrapper getLabelWrapper(Label label) {
|
||||
return ContainerUtil.getOrCreate(labelWrappersMap, label, new Factory<LabelWrapper>() {
|
||||
@Override
|
||||
public LabelWrapper create() {
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
|
||||
return needToRepeat;
|
||||
}
|
||||
|
||||
private static boolean isUnsafeToRemoveBoxingForConnectedValues(List<BasicValue> usedValues, final Type unboxedType) {
|
||||
private static boolean isUnsafeToRemoveBoxingForConnectedValues(List<BasicValue> usedValues, Type unboxedType) {
|
||||
return CollectionsKt.any(usedValues, new Function1<BasicValue, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(BasicValue input) {
|
||||
|
||||
@@ -464,7 +464,7 @@ public class KotlinTypeMapper {
|
||||
@NotNull
|
||||
public Type mapType(
|
||||
@NotNull KotlinType kotlinType,
|
||||
@Nullable final JvmSignatureWriter signatureVisitor,
|
||||
@Nullable JvmSignatureWriter signatureVisitor,
|
||||
@NotNull TypeMappingMode mode
|
||||
) {
|
||||
return TypeSignatureMappingKt.mapType(
|
||||
|
||||
Reference in New Issue
Block a user