isInline method moved from SimpleFunctionDescriptor to InlineStrategy
This commit is contained in:
@@ -32,9 +32,7 @@ import org.jetbrains.asm4.MethodVisitor;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||
import org.jetbrains.asm4.commons.Method;
|
||||
import org.jetbrains.asm4.tree.MethodNode;
|
||||
import org.jetbrains.jet.codegen.asm.InlineCodegen;
|
||||
import org.jetbrains.jet.codegen.asm.InlineCodegenUtil;
|
||||
import org.jetbrains.jet.codegen.asm.Inliner;
|
||||
import org.jetbrains.jet.codegen.asm.NameGenerator;
|
||||
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
@@ -2125,9 +2123,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
) {
|
||||
boolean disable = false;
|
||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||
boolean isInline = descriptor instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) descriptor).isInline();
|
||||
Inliner inliner = !isInline ? Inliner.NOT_INLINE
|
||||
: new InlineCodegen(this, true, state, disable, (SimpleFunctionDescriptor) unwrapFakeOverride((CallableMemberDescriptor)descriptor.getOriginal()));
|
||||
boolean isInline = call != null && descriptor instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) descriptor).getInlineStrategy().isInline();
|
||||
Inliner inliner = !isInline ? Inliner.NOT_INLINE :
|
||||
new InlineCodegen(this, true, state, disable, (SimpleFunctionDescriptor) unwrapFakeOverride(
|
||||
(CallableMemberDescriptor) descriptor.getOriginal()), call);
|
||||
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
resolvedCall = ((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall();
|
||||
|
||||
@@ -91,7 +91,7 @@ public class MethodContext extends CodegenContext<CallableMemberDescriptor> {
|
||||
public boolean isInlineFunction() {
|
||||
DeclarationDescriptor descriptor = getContextDescriptor();
|
||||
if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||
return ((SimpleFunctionDescriptor) descriptor).isInline();
|
||||
return ((SimpleFunctionDescriptor) descriptor).getInlineStrategy().isInline();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.resolve.extension.InlineAnalyzerExtension;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
@@ -60,7 +59,7 @@ public class FunctionAnalyzerExtension {
|
||||
private static List<AnalyzerExtension> getExtensions(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
List<AnalyzerExtension> list = new ArrayList<AnalyzerExtension>();
|
||||
if (functionDescriptor instanceof SimpleFunctionDescriptor &&
|
||||
((SimpleFunctionDescriptor) functionDescriptor).isInline()) {
|
||||
((SimpleFunctionDescriptor) functionDescriptor).getInlineStrategy().isInline()) {
|
||||
list.add(InlineAnalyzerExtension.INSTANCE);
|
||||
}
|
||||
return list;
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class CallResolverExtensionProvider {
|
||||
private static void appendExtensionsFor(DeclarationDescriptor declarationDescriptor, List<CallResolverExtension> extensions) {
|
||||
if (declarationDescriptor instanceof SimpleFunctionDescriptor) {
|
||||
SimpleFunctionDescriptor descriptor = (SimpleFunctionDescriptor) declarationDescriptor;
|
||||
if (descriptor.isInline()) {
|
||||
if (descriptor.getInlineStrategy().isInline()) {
|
||||
extensions.add(new InlineCallResolverExtension(descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ public class InlineCallResolverExtension implements CallResolverExtension {
|
||||
private final boolean isEffectivelyPublicApiFunction;
|
||||
|
||||
public InlineCallResolverExtension(@NotNull SimpleFunctionDescriptor descriptor) {
|
||||
assert descriptor.isInline() : "This extension should be created only for inline functions but not " + descriptor;
|
||||
assert descriptor.getInlineStrategy().isInline() : "This extension should be created only for inline functions but not " + descriptor;
|
||||
this.descriptor = descriptor;
|
||||
this.isEffectivelyPublicApiFunction = isEffectivelyPublicApi(descriptor);
|
||||
|
||||
@@ -232,7 +232,7 @@ public class InlineCallResolverExtension implements CallResolverExtension {
|
||||
|
||||
return isInvoke ||
|
||||
//or inline extension
|
||||
((SimpleFunctionDescriptor) descriptor).isInline();
|
||||
((SimpleFunctionDescriptor) descriptor).getInlineStrategy().isInline();
|
||||
}
|
||||
|
||||
private void checkVisibility(@NotNull CallableDescriptor declarationDescriptor, @NotNull JetElement expression, @NotNull BasicCallResolutionContext context){
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class InlineAnalyzerExtension implements FunctionAnalyzerExtension.Analyz
|
||||
public void process(
|
||||
@NotNull final FunctionDescriptor descriptor, @NotNull JetNamedFunction function, @NotNull final BindingTrace trace
|
||||
) {
|
||||
assert descriptor instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) descriptor).isInline() :
|
||||
assert descriptor instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) descriptor).getInlineStrategy().isInline() :
|
||||
"This method should be invoced on inline function: " + descriptor;
|
||||
|
||||
checkDefaults(descriptor, function, trace);
|
||||
|
||||
+1
-1
@@ -159,7 +159,7 @@ public class ExpressionTypingUtils {
|
||||
}
|
||||
|
||||
CallableDescriptor callable = call.getResultingDescriptor();
|
||||
if (callable instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) callable).isInline()) {
|
||||
if (callable instanceof SimpleFunctionDescriptor && ((SimpleFunctionDescriptor) callable).getInlineStrategy().isInline()) {
|
||||
DeclarationDescriptor scopeContainerParent = scopeContainer.getContainingDeclaration();
|
||||
assert scopeContainerParent != null : "parent is null for " + scopeContainer;
|
||||
return scopeContainerParent == variableParent || isCapturedInInline(context, scopeContainerParent, variableParent);
|
||||
|
||||
+3
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.types.lang.InlineStrategy;
|
||||
|
||||
/**
|
||||
* Simple functions are the ones with 'fun' keyword and function literals
|
||||
@@ -31,5 +32,6 @@ public interface SimpleFunctionDescriptor extends FunctionDescriptor {
|
||||
@Override
|
||||
SimpleFunctionDescriptor getOriginal();
|
||||
|
||||
boolean isInline();
|
||||
@NotNull
|
||||
InlineStrategy getInlineStrategy();
|
||||
}
|
||||
|
||||
+1
-5
@@ -102,12 +102,8 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return getInlineStrategy() != InlineStrategy.NOT_INLINE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public InlineStrategy getInlineStrategy() {
|
||||
return inlineStrategy;
|
||||
}
|
||||
|
||||
@@ -20,4 +20,8 @@ public enum InlineStrategy {
|
||||
AS_FUNCTION,
|
||||
IN_PLACE,
|
||||
NOT_INLINE;
|
||||
|
||||
public boolean isInline() {
|
||||
return this != NOT_INLINE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user