ExCallable to Callable renaming
This commit is contained in:
@@ -35,7 +35,7 @@ public abstract class CallGenerator {
|
||||
|
||||
@Override
|
||||
public void genCallInner(
|
||||
@NotNull ExtendedCallable callableMethod,
|
||||
@NotNull Callable callableMethod,
|
||||
ResolvedCall<?> resolvedCall,
|
||||
boolean callDefault,
|
||||
@NotNull ExpressionCodegen codegen
|
||||
@@ -90,7 +90,7 @@ public abstract class CallGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
public void genCall(@NotNull ExtendedCallable callableMethod, @Nullable ResolvedCall<?> resolvedCall, boolean callDefault, @NotNull ExpressionCodegen codegen) {
|
||||
public void genCall(@NotNull Callable callableMethod, @Nullable ResolvedCall<?> resolvedCall, boolean callDefault, @NotNull ExpressionCodegen codegen) {
|
||||
if (resolvedCall != null) {
|
||||
JetExpression calleeExpression = resolvedCall.getCall().getCalleeExpression();
|
||||
if (calleeExpression != null) {
|
||||
@@ -101,7 +101,7 @@ public abstract class CallGenerator {
|
||||
genCallInner(callableMethod, resolvedCall, callDefault, codegen);
|
||||
}
|
||||
|
||||
public abstract void genCallInner(@NotNull ExtendedCallable callableMethod, @Nullable ResolvedCall<?> resolvedCall, boolean callDefault, @NotNull ExpressionCodegen codegen);
|
||||
public abstract void genCallInner(@NotNull Callable callableMethod, @Nullable ResolvedCall<?> resolvedCall, boolean callDefault, @NotNull ExpressionCodegen codegen);
|
||||
|
||||
public abstract void genCallWithoutAssertions(@NotNull CallableMethod callableMethod, @NotNull ExpressionCodegen codegen);
|
||||
|
||||
|
||||
@@ -16,10 +16,38 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
|
||||
public trait Callable {
|
||||
public fun getOwner(): Type
|
||||
|
||||
public fun invokeWithNotNullAssertion(v: InstructionAdapter, state: GenerationState, resolvedCall: ResolvedCall<*>)
|
||||
|
||||
public fun invokeWithoutAssertions(v: InstructionAdapter)
|
||||
|
||||
public fun getGenerateCalleeType(): Type?
|
||||
|
||||
public fun getValueParameterTypes(): List<Type>
|
||||
|
||||
public fun getArgumentTypes(): Array<Type>
|
||||
|
||||
public fun getReturnType(): Type
|
||||
|
||||
public fun isStaticCall(): Boolean
|
||||
|
||||
public fun getThisType(): Type?
|
||||
|
||||
public fun getReceiverClass(): Type?
|
||||
|
||||
public fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?)
|
||||
|
||||
public fun invokeMethodWithArguments(resolvedCall: ResolvedCall<*>, receiver: StackValue, returnType: Type, codegen: ExpressionCodegen): StackValue
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.jetbrains.org.objectweb.asm.util.Printer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CallableMethod(private val owner: Type, private val defaultImplOwner: Type?, private val defaultImplParam: Type?, private val signature: JvmMethodSignature, private val invokeOpcode: Int, private val thisClass: Type?, private val receiverParameterType: Type?, private val generateCalleeType: Type?) : ExtendedCallable {
|
||||
public class CallableMethod(private val owner: Type, private val defaultImplOwner: Type?, private val defaultImplParam: Type?, private val signature: JvmMethodSignature, private val invokeOpcode: Int, private val thisClass: Type?, private val receiverParameterType: Type?, private val generateCalleeType: Type?) : Callable {
|
||||
|
||||
override fun getOwner(): Type {
|
||||
return owner
|
||||
|
||||
@@ -2255,11 +2255,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
Callable callable = resolveToCallable(accessibleFunctionDescriptor, superCall, resolvedCall);
|
||||
Type returnType = typeMapper.mapReturnType(accessibleFunctionDescriptor);
|
||||
|
||||
return ((ExtendedCallable) callable).invokeMethodWithArguments(resolvedCall, receiver, returnType, this);
|
||||
return ((Callable) callable).invokeMethodWithArguments(resolvedCall, receiver, returnType, this);
|
||||
}
|
||||
|
||||
public void invokeMethodWithArguments(
|
||||
@NotNull ExtendedCallable callable,
|
||||
@NotNull Callable callable,
|
||||
@NotNull ResolvedCall resolvedCall,
|
||||
@NotNull StackValue receiver,
|
||||
@NotNull Type returnType
|
||||
@@ -2297,7 +2297,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull ResolvedCall resolvedCall) {
|
||||
IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd);
|
||||
if (intrinsic != null) {
|
||||
return !intrinsic.supportCallable() ? intrinsic : intrinsic.toCallable(fd, superCall, resolvedCall, this);
|
||||
return intrinsic.toCallable(fd, superCall, resolvedCall, this);
|
||||
}
|
||||
|
||||
return resolveToCallableMethod(fd, superCall, context);
|
||||
@@ -2309,7 +2309,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
public void invokeMethodWithArguments(
|
||||
@NotNull ExtendedCallable callableMethod,
|
||||
@NotNull Callable callableMethod,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull StackValue receiver
|
||||
) {
|
||||
@@ -2330,7 +2330,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
public void invokeMethodWithArguments(
|
||||
@NotNull ExtendedCallable callableMethod,
|
||||
@NotNull Callable callableMethod,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull StackValue receiver,
|
||||
@NotNull CallGenerator callGenerator,
|
||||
@@ -3282,7 +3282,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
boolean keepReturnValue = Boolean.TRUE.equals(bindingContext.get(VARIABLE_REASSIGNMENT, expression))
|
||||
|| !KotlinBuiltIns.getInstance().getUnitType().equals(descriptor.getReturnType());
|
||||
|
||||
callAugAssignMethod(expression, resolvedCall, (ExtendedCallable) callable, lhsType, keepReturnValue);
|
||||
callAugAssignMethod(expression, resolvedCall, (Callable) callable, lhsType, keepReturnValue);
|
||||
|
||||
return StackValue.none();
|
||||
}
|
||||
@@ -3290,7 +3290,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
private void callAugAssignMethod(
|
||||
@NotNull JetBinaryExpression expression,
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull ExtendedCallable callable,
|
||||
@NotNull Callable callable,
|
||||
@NotNull Type lhsType,
|
||||
boolean keepReturnValue
|
||||
) {
|
||||
@@ -3643,7 +3643,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
|
||||
Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall );
|
||||
ExtendedCallable callableMethod = resolveToCallableMethod(operationDescriptor, false, context);
|
||||
Callable callableMethod = resolveToCallableMethod(operationDescriptor, false, context);
|
||||
Type[] argumentTypes = callableMethod.getArgumentTypes();
|
||||
|
||||
StackValue collectionElementReceiver =
|
||||
@@ -3672,8 +3672,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = isGetter ? resolvedGetCall : resolvedSetCall;
|
||||
assert resolvedCall != null : "couldn't find resolved call: " + expression.getText();
|
||||
|
||||
if (callable instanceof ExtendedCallable) {
|
||||
ExtendedCallable callableMethod = (ExtendedCallable) callable;
|
||||
if (callable instanceof Callable) {
|
||||
Callable callableMethod = (Callable) callable;
|
||||
ArgumentGenerator argumentGenerator =
|
||||
new CallBasedArgumentGenerator(this, defaultCallGenerator,
|
||||
resolvedCall.getResultingDescriptor().getValueParameters(),
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtendedCallable extends Callable {
|
||||
@NotNull
|
||||
Type getOwner();
|
||||
|
||||
void invokeWithNotNullAssertion(
|
||||
@NotNull InstructionAdapter v,
|
||||
@NotNull GenerationState state,
|
||||
@NotNull ResolvedCall resolvedCall
|
||||
);
|
||||
|
||||
void invokeWithoutAssertions(@NotNull InstructionAdapter v);
|
||||
|
||||
@Nullable
|
||||
Type getGenerateCalleeType();
|
||||
|
||||
@NotNull
|
||||
List<Type> getValueParameterTypes();
|
||||
|
||||
Type[] getArgumentTypes();
|
||||
|
||||
@NotNull
|
||||
Type getReturnType();
|
||||
|
||||
boolean isStaticCall();
|
||||
|
||||
@Nullable
|
||||
Type getThisType();
|
||||
|
||||
@Nullable
|
||||
Type getReceiverClass();
|
||||
|
||||
void beforeParameterGeneration(@NotNull InstructionAdapter v, @Nullable StackValue value);
|
||||
|
||||
@NotNull
|
||||
StackValue invokeMethodWithArguments(
|
||||
@NotNull ResolvedCall resolvedCall,
|
||||
@NotNull StackValue receiver,
|
||||
@NotNull Type returnType,
|
||||
@NotNull ExpressionCodegen codegen
|
||||
);
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType;
|
||||
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethod;
|
||||
import org.jetbrains.kotlin.codegen.stackvalue.BranchedValue;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
|
||||
@@ -41,7 +40,6 @@ import org.jetbrains.org.objectweb.asm.Label;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
||||
@@ -430,7 +428,7 @@ public abstract class StackValue {
|
||||
ResolvedCall<?> resolvedCall,
|
||||
StackValue receiver,
|
||||
ExpressionCodegen codegen,
|
||||
@Nullable ExtendedCallable callableMethod
|
||||
@Nullable Callable callableMethod
|
||||
) {
|
||||
if (resolvedCall.getDispatchReceiver().exists() || resolvedCall.getExtensionReceiver().exists() || isLocalFunCall(callableMethod)) {
|
||||
boolean hasExtensionReceiver = resolvedCall.getExtensionReceiver().exists();
|
||||
@@ -449,7 +447,7 @@ public abstract class StackValue {
|
||||
@NotNull StackValue receiver,
|
||||
@NotNull ExpressionCodegen codegen,
|
||||
@NotNull ResolvedCall resolvedCall,
|
||||
@Nullable ExtendedCallable callableMethod,
|
||||
@Nullable Callable callableMethod,
|
||||
boolean isExtension
|
||||
) {
|
||||
ReceiverValue receiverValue = isExtension ? resolvedCall.getExtensionReceiver() : resolvedCall.getDispatchReceiver();
|
||||
@@ -483,7 +481,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
@Contract("null -> false")
|
||||
private static boolean isLocalFunCall(@Nullable ExtendedCallable callableMethod) {
|
||||
private static boolean isLocalFunCall(@Nullable Callable callableMethod) {
|
||||
return callableMethod != null && callableMethod.getGenerateCalleeType() != null;
|
||||
}
|
||||
|
||||
@@ -716,8 +714,8 @@ public abstract class StackValue {
|
||||
@NotNull Type type, @NotNull InstructionAdapter v
|
||||
) {
|
||||
ResolvedCall<?> call = isGetter ? resolvedGetCall : resolvedSetCall;
|
||||
if (callable instanceof ExtendedCallable) {
|
||||
StackValue newReceiver = StackValue.receiver(call, receiver, codegen, (ExtendedCallable) callable);
|
||||
if (callable instanceof Callable) {
|
||||
StackValue newReceiver = StackValue.receiver(call, receiver, codegen, (Callable) callable);
|
||||
newReceiver.put(newReceiver.type, v);
|
||||
argumentGenerator.generate(valueArguments);
|
||||
}
|
||||
@@ -860,8 +858,8 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
public static class CollectionElement extends StackValueWithSimpleReceiver {
|
||||
private final ExtendedCallable getter;
|
||||
private final ExtendedCallable setter;
|
||||
private final Callable getter;
|
||||
private final Callable setter;
|
||||
private final ExpressionCodegen codegen;
|
||||
private final GenerationState state;
|
||||
private final ResolvedCall<FunctionDescriptor> resolvedGetCall;
|
||||
@@ -884,9 +882,9 @@ public abstract class StackValue {
|
||||
this.setterDescriptor = resolvedSetCall == null ? null : resolvedSetCall.getResultingDescriptor();
|
||||
this.getterDescriptor = resolvedGetCall == null ? null : resolvedGetCall.getResultingDescriptor();
|
||||
this.setter =
|
||||
resolvedSetCall == null ? null : (ExtendedCallable) codegen.resolveToCallable(setterDescriptor, false, resolvedSetCall);
|
||||
resolvedSetCall == null ? null : (Callable) codegen.resolveToCallable(setterDescriptor, false, resolvedSetCall);
|
||||
this.getter =
|
||||
resolvedGetCall == null ? null : (ExtendedCallable) codegen.resolveToCallable(getterDescriptor, false, resolvedGetCall);
|
||||
resolvedGetCall == null ? null : (Callable) codegen.resolveToCallable(getterDescriptor, false, resolvedGetCall);
|
||||
this.codegen = codegen;
|
||||
}
|
||||
|
||||
@@ -1239,7 +1237,7 @@ public abstract class StackValue {
|
||||
value = StackValue.complexReceiver(value, true, false, true);
|
||||
value.put(this.type, v);
|
||||
|
||||
if (callable instanceof ExtendedCallable) {
|
||||
if (callable instanceof Callable) {
|
||||
value.store(codegen.invokeFunction(resolvedCall, StackValue.onStack(this.type)), v, true);
|
||||
}
|
||||
else {
|
||||
@@ -1269,7 +1267,7 @@ public abstract class StackValue {
|
||||
public static Type calcType(
|
||||
@NotNull ResolvedCall<?> resolvedCall,
|
||||
@NotNull JetTypeMapper typeMapper,
|
||||
@Nullable ExtendedCallable callableMethod
|
||||
@Nullable Callable callableMethod
|
||||
) {
|
||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ public class InlineCodegen extends CallGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genCallInner(@NotNull ExtendedCallable callableMethod, @Nullable ResolvedCall<?> resolvedCall, boolean callDefault, @NotNull ExpressionCodegen codegen) {
|
||||
public void genCallInner(@NotNull Callable callableMethod, @Nullable ResolvedCall<?> resolvedCall, boolean callDefault, @NotNull ExpressionCodegen codegen) {
|
||||
SMAPAndMethodNode nodeAndSmap = null;
|
||||
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,7 @@ import kotlin.Unit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod;
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable;
|
||||
import org.jetbrains.kotlin.codegen.Callable;
|
||||
import org.jetbrains.kotlin.codegen.StackValue;
|
||||
import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
@@ -56,7 +56,7 @@ public class ArrayGet extends LazyIntrinsicMethod {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ExtendedCallable toCallable(@NotNull CallableMethod method) {
|
||||
public Callable toCallable(@NotNull CallableMethod method) {
|
||||
return new MappedCallable(method, new ExtensionFunction1<MappedCallable, InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.asmDescByFqNameWithoutInnerClasses
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContext
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.getType
|
||||
@@ -71,7 +71,7 @@ public class ArrayIterator : IntrinsicMethod() {
|
||||
}
|
||||
|
||||
//TODO refactor
|
||||
override fun toCallable(state: GenerationState, fd: FunctionDescriptor, context: CodegenContext<*>, isSuper: Boolean): ExtendedCallable {
|
||||
override fun toCallable(state: GenerationState, fd: FunctionDescriptor, context: CodegenContext<*>, isSuper: Boolean): Callable {
|
||||
val callableMethod = state.getTypeMapper().mapToCallableMethod(fd, false, context)
|
||||
|
||||
val containingDeclaration = fd.getContainingDeclaration().getOriginal() as ClassDescriptor
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -43,7 +43,7 @@ public class ArraySet : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
val type = correctElementType(method.getThisType())
|
||||
return object: IntrinsicCallable(Type.VOID_TYPE, listOf(Type.INT_TYPE, type), method.getThisType(), method.getReceiverClass()) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ArraySize : LazyIntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
public override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
public override fun toCallable(method: CallableMethod): Callable {
|
||||
return UnaryIntrinsic(method, null, false) { adapter ->
|
||||
adapter.arraylength()
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes.*
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.numberFunctionOperandType
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContext
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -62,7 +62,7 @@ public class BinaryOp(private val opcode: Int) : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
val returnType = method.getReturnType()
|
||||
assert(method.getValueParameters().size() == 1)
|
||||
val operandType = numberFunctionOperandType(returnType)
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetElement
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
@@ -56,7 +56,7 @@ public class Clone : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod, isSuperCall: Boolean): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod, isSuperCall: Boolean): Callable {
|
||||
return UnaryIntrinsic(method, OBJECT_TYPE) {
|
||||
val opcodes: Int = if (isSuperCall) Opcodes.INVOKESPECIAL else Opcodes.INVOKEVIRTUAL
|
||||
it.visitMethodInsn(opcodes, "java/lang/Object", "clone", "()Ljava/lang/Object;", false)
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.comparisonOperandType
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
|
||||
public class CompareTo : IntrinsicMethod() {
|
||||
override fun generateImpl(codegen: ExpressionCodegen, v: InstructionAdapter, returnType: Type, element: PsiElement?, arguments: List<JetExpression>, receiver: StackValue): Type {
|
||||
@@ -74,7 +74,7 @@ public class CompareTo : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
val argumentType = comparisonOperandType(method.getThisType() ?: method.getReceiverClass(), method.getArgumentTypes().first())
|
||||
return IntrinsicCallable.binaryIntrinsic(method.getReturnType(), argumentType, argumentType, null) {
|
||||
genInvoke(argumentType, it)
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.genInvokeAppendMethod
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.genStringBuilderConstructor
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.JetBinaryExpression
|
||||
@@ -63,7 +63,7 @@ public class Concat : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val callable = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext())
|
||||
return object : MappedCallable(callable, {}) {
|
||||
override fun invokeMethodWithArguments(resolvedCall: ResolvedCall<*>, receiver: StackValue, returnType: Type, codegen: ExpressionCodegen): StackValue {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContext
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
@@ -52,7 +52,7 @@ public class CopyToArray : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
return object : IntrinsicCallable(getType(javaClass<Array<Any>>()), listOf(), null, Type.getType(javaClass<Collection<*>>())) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
v.dup()
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Equals : LazyIntrinsicMethod() {
|
||||
return genEqualsForExpressionsOnStack(JetTokens.EQEQ, leftExpr, codegen.genLazy(rightExpr, OBJECT_TYPE))
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return IntrinsicCallable.binaryIntrinsic(method.getReturnType(), OBJECT_TYPE, nullOrObject(method.getThisType()), nullOrObject(method.getReceiverClass())) {
|
||||
AsmUtil.genAreEqualCall(it)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
@@ -41,7 +41,7 @@ public class HashCode : LazyIntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return object: IntrinsicCallable(Type.INT_TYPE, emptyList(), nullOrObject(method.getThisType()), nullOrObject(method.getReceiverClass())) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "hashCode", "()I", false)
|
||||
|
||||
@@ -50,7 +50,7 @@ public class IdentityEquals : LazyIntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val callable = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext())
|
||||
return object : MappedCallable(callable) {
|
||||
override fun invokeMethodWithArguments(resolvedCall: ResolvedCall<*>, receiver: StackValue, returnType: Type, codegen: ExpressionCodegen): StackValue {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.genIncrement
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetPrefixExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
@@ -57,7 +57,7 @@ public class Increment(private val myDelta: Int) : LazyIntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val method = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext())
|
||||
return MappedCallable(method) {
|
||||
val jetExpression = resolvedCall.getCall().getCalleeExpression()
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
public abstract class IntrinsicCallable(val returnType1: Type,
|
||||
val valueParametersTypes: List<Type>,
|
||||
val thisType1: Type?,
|
||||
val receiverType1: Type?) : ExtendedCallable {
|
||||
val receiverType1: Type?) : Callable {
|
||||
|
||||
companion object {
|
||||
fun create(descriptor: FunctionDescriptor, context: CodegenContext<*>, state: GenerationState, lambda: IntrinsicCallable.(i: InstructionAdapter) -> Unit): IntrinsicCallable {
|
||||
@@ -79,7 +79,7 @@ public abstract class IntrinsicCallable(val returnType1: Type,
|
||||
|
||||
public abstract fun invokeIntrinsic(v: InstructionAdapter);
|
||||
|
||||
override fun getArgumentTypes(): Array<out Type>? {
|
||||
override fun getArgumentTypes(): Array<Type> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.numberFunctionOperandType;
|
||||
|
||||
public abstract class IntrinsicMethod implements Callable {
|
||||
public abstract class IntrinsicMethod {
|
||||
public StackValue generate(
|
||||
@NotNull final ExpressionCodegen codegen,
|
||||
@NotNull final Type returnType,
|
||||
@@ -70,29 +70,29 @@ public abstract class IntrinsicMethod implements Callable {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExtendedCallable toCallable(@NotNull FunctionDescriptor fd, boolean isSuper, @NotNull ResolvedCall resolvedCall, @NotNull ExpressionCodegen codegen) {
|
||||
public Callable toCallable(@NotNull FunctionDescriptor fd, boolean isSuper, @NotNull ResolvedCall resolvedCall, @NotNull ExpressionCodegen codegen) {
|
||||
return toCallable(codegen.getState(), fd, codegen.getContext(), isSuper, resolvedCall);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExtendedCallable toCallable(@NotNull GenerationState state, @NotNull FunctionDescriptor fd, @NotNull CodegenContext<?> context, boolean isSuper, @NotNull
|
||||
public Callable toCallable(@NotNull GenerationState state, @NotNull FunctionDescriptor fd, @NotNull CodegenContext<?> context, boolean isSuper, @NotNull
|
||||
ResolvedCall resolvedCall) {
|
||||
return toCallable(state, fd, context, isSuper);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExtendedCallable toCallable(@NotNull GenerationState state, @NotNull FunctionDescriptor fd, @NotNull CodegenContext<?> context, boolean isSuper) {
|
||||
public Callable toCallable(@NotNull GenerationState state, @NotNull FunctionDescriptor fd, @NotNull CodegenContext<?> context, boolean isSuper) {
|
||||
return toCallable(state.getTypeMapper().mapToCallableMethod(fd, false, context), isSuper);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExtendedCallable toCallable(@NotNull CallableMethod method, boolean isSuperCall) {
|
||||
public Callable toCallable(@NotNull CallableMethod method, boolean isSuperCall) {
|
||||
//assert !isSuper;
|
||||
return toCallable(method);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExtendedCallable toCallable(@NotNull CallableMethod method) {
|
||||
public Callable toCallable(@NotNull CallableMethod method) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -47,7 +47,7 @@ public class Inv : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
val type = numberFunctionOperandType(method.getReturnType())
|
||||
return UnaryIntrinsic(method, method.getReturnType(), newThisType = type) {
|
||||
if (getReturnType() == Type.LONG_TYPE) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
@@ -76,7 +76,7 @@ public class IteratorNext : IntrinsicMethod() {
|
||||
}
|
||||
|
||||
|
||||
override fun toCallable(state: GenerationState, fd: FunctionDescriptor, context: CodegenContext<*>, isSuper: Boolean): ExtendedCallable {
|
||||
override fun toCallable(state: GenerationState, fd: FunctionDescriptor, context: CodegenContext<*>, isSuper: Boolean): Callable {
|
||||
val type = state.getTypeMapper().mapReturnType(fd)
|
||||
return object: IntrinsicCallable(type, listOf(), AsmTypes.OBJECT_TYPE, null) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
@@ -46,7 +46,7 @@ public class JavaClassArray : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return MappedCallable(method) {
|
||||
//do nothing all generated as vararg
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.putJavaLangClassInstance
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.getType
|
||||
|
||||
@@ -52,7 +52,7 @@ public class JavaClassFunction : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val javaClass = resolvedCall.getResultingDescriptor().getReturnType()!!.getArguments().get(0).getType()
|
||||
return object: IntrinsicCallable(getType(javaClass<Class<Any>>()), listOf(), null, null) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.boxType
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.getType
|
||||
@@ -53,7 +53,7 @@ public class JavaClassProperty : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val classType = codegen.getState().getTypeMapper().mapType(resolvedCall.getCall().getDispatchReceiver().getType())
|
||||
return object : IntrinsicCallable(getType(javaClass<Class<Any>>()), listOf(), classType, null) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContext
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
@@ -65,7 +65,7 @@ public class MonitorInstruction private(private val opcode: Int) : IntrinsicMeth
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(state: GenerationState, fd: FunctionDescriptor, context: CodegenContext<*>, isSuper: Boolean, resolvedCall: ResolvedCall<*>): ExtendedCallable {
|
||||
override fun toCallable(state: GenerationState, fd: FunctionDescriptor, context: CodegenContext<*>, isSuper: Boolean, resolvedCall: ResolvedCall<*>): Callable {
|
||||
return object : IntrinsicCallable(Type.VOID_TYPE, listOf(OBJECT_TYPE), null, null) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
v.visitInsn(opcode)
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -33,7 +33,7 @@ public class NewArray : LazyIntrinsicMethod() {
|
||||
return codegen.generateNewArray(element as JetCallExpression)
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val jetType = resolvedCall.getResultingDescriptor().getReturnType()!!
|
||||
val type = codegen.getState().getTypeMapper().mapType(jetType)
|
||||
return object : IntrinsicCallable(type, listOf(Type.INT_TYPE), null, null) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetCallExpression
|
||||
@@ -44,7 +44,7 @@ public class Not : LazyIntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val callable = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext())
|
||||
return object : MappedCallable(callable, {}) {
|
||||
override fun invokeMethodWithArguments(resolvedCall: ResolvedCall<*>, receiver: StackValue, returnType: Type, codegen: ExpressionCodegen): StackValue {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -30,7 +30,7 @@ public class NumberCast : LazyIntrinsicMethod() {
|
||||
return StackValue.coercion(receiver, returnType)
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return UnaryIntrinsic(method) {
|
||||
StackValue.coerce(calcReceiverType()!!, getReturnType(), it)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetBinaryExpression
|
||||
@@ -99,7 +99,7 @@ public class RangeTo : IntrinsicMethod() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): ExtendedCallable {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val method = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext())
|
||||
val argType = nameToPrimitive(method.getReturnType().getInternalName().substringAfter("kotlin/").substringBefore("Range"))
|
||||
return object : IntrinsicCallable(method.getReturnType(), method.getValueParameterTypes().map { argType }, nullOr(method.getThisType(), argType), nullOr(method.getReceiverClass(), argType)) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContext
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
@@ -46,7 +46,7 @@ public class StringGetChar : LazyIntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return IntrinsicCallable.create(method) {
|
||||
it.invokevirtual("java/lang/String", "charAt", "(I)C", false)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
@@ -47,7 +47,7 @@ public class StringPlus : LazyIntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return IntrinsicCallable.create(method) {
|
||||
it.invokestatic("kotlin/jvm/internal/Intrinsics", "stringPlus", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;", false)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ToString : LazyIntrinsicMethod() {
|
||||
return genToString(receiver, receiver.type)
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
val type = AsmUtil.stringValueOfType(method.getThisType() ?: method.getReceiverClass())
|
||||
return UnaryIntrinsic(method, newThisType = type) {
|
||||
it.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false)
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.*
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
|
||||
public class UnaryMinus : LazyIntrinsicMethod() {
|
||||
@@ -46,7 +46,7 @@ public class UnaryMinus : LazyIntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return UnaryIntrinsic(method, numberFunctionOperandType(method.getReturnType()), needPrimitiveCheck = true) {
|
||||
it.neg(getReturnType())
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExtendedCallable
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
|
||||
public class UnaryPlus : LazyIntrinsicMethod() {
|
||||
override fun generateImpl(codegen: ExpressionCodegen, returnType: Type, element: PsiElement?, arguments: List<JetExpression>, receiver: StackValue): StackValue {
|
||||
@@ -39,7 +39,7 @@ public class UnaryPlus : LazyIntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): ExtendedCallable {
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
return UnaryIntrinsic(method, needPrimitiveCheck = true) {
|
||||
//nothing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user