Class FunctionImplementor
java.lang.Object
ai.timefold.jpyinterpreter.implementors.FunctionImplementor
Implements opcodes related to functions
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcall(FunctionMetadata functionMetadata, StackMetadata stackMetadata, int argumentCount) Calls a function. argc is the number of positional arguments.static voidcallBinaryMethod(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, String methodName) static voidcallBinaryMethod(org.objectweb.asm.MethodVisitor methodVisitor, String methodName) static voidcallFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) Calls a function.static voidcallFunctionUnpack(FunctionMetadata functionMetadata, StackMetadata stackMetadata, PythonBytecodeInstruction instruction) Calls a function.static voidcallFunctionUnpackIterable(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor) static voidcallFunctionUnpackMapAndIterable(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor) static voidcallFunctionWithKeywords(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) Calls a function.static voidcallGenericFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, int argCount) static voidcallGenericFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) static voidcallGenericFunction(org.objectweb.asm.MethodVisitor methodVisitor, int argCount) static voidcallGenericFunctionWithKeywords(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) Calls a function.static voidcallMethod(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction, LocalVariableHelper localVariableHelper) Calls a method. argc is the number of positional arguments.static voidcreateFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, PythonBytecodeInstruction instruction) Creates a function.static PythonLikeFunctioncreateInstance(PythonLikeTuple defaultPositionalArgs, PythonLikeDict defaultKeywordArgs, PythonLikeDict annotationDict, PythonLikeTuple closure, PythonString functionName, PythonCode code, PythonInterpreter pythonInterpreter) static PythonLikeFunctioncreateInstance(PythonLikeTuple defaultPositionalArgs, PythonLikeDict defaultKeywordArgs, PythonLikeTuple annotationTuple, PythonLikeTuple closure, PythonString functionName, PythonCode code, PythonInterpreter pythonInterpreter) static <T> TcreateInstance(PythonLikeTuple defaultPositionalArgs, PythonLikeDict defaultKeywordArgs, PythonLikeTuple annotationTuple, PythonLikeTuple closure, PythonString functionName, Class<T> functionClass, PythonInterpreter pythonInterpreter) static voidloadMethod(FunctionMetadata functionMetadata, StackMetadata stackMetadata, int nameIndex) Loads a method named co_names[namei] from the TOS object.static voidsetCallKeywordNameTuple(FunctionMetadata functionMetadata, StackMetadata stackMetadata, int constantIndex)
-
Constructor Details
-
FunctionImplementor
public FunctionImplementor()
-
-
Method Details
-
callBinaryMethod
public static void callBinaryMethod(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, String methodName) -
callBinaryMethod
public static void callBinaryMethod(org.objectweb.asm.MethodVisitor methodVisitor, String methodName) -
loadMethod
public static void loadMethod(FunctionMetadata functionMetadata, StackMetadata stackMetadata, int nameIndex) Loads a method named co_names[namei] from the TOS object. TOS is popped. This bytecode distinguishes two cases: if TOS has a method with the correct name, the bytecode pushes the unbound method and TOS. TOS will be used as the first argument (self) by CALL_METHOD when calling the unbound method. Otherwise, NULL and the object return by the attribute lookup are pushed. -
setCallKeywordNameTuple
public static void setCallKeywordNameTuple(FunctionMetadata functionMetadata, StackMetadata stackMetadata, int constantIndex) -
call
public static void call(FunctionMetadata functionMetadata, StackMetadata stackMetadata, int argumentCount) Calls a function. argc is the number of positional arguments. Keyword arguments are stored in a local variable. Keyword arguments (if any) are at the top of the stack, followed by, positional arguments. Below them either self and an unbound method object or NULL and an arbitrary callable). All of them are popped and the return value is pushed. -
callMethod
public static void callMethod(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction, LocalVariableHelper localVariableHelper) Calls a method. argc is the number of positional arguments. Keyword arguments are not supported. This opcode is designed to be used with LOAD_METHOD. Positional arguments are on top of the stack. Below them, the two items described in LOAD_METHOD are on the stack (either self and an unbound method object or NULL and an arbitrary callable). All of them are popped and the return value is pushed. -
callFunction
public static void callFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) Calls a function. TOS...TOS[argc - 1] are the arguments to the function. TOS[argc] is the function to call. TOS...TOS[argc] are all popped and the result is pushed onto the stack. -
callGenericFunction
public static void callGenericFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) -
callGenericFunction
public static void callGenericFunction(org.objectweb.asm.MethodVisitor methodVisitor, int argCount) -
callGenericFunction
public static void callGenericFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, int argCount) -
callFunctionWithKeywords
public static void callFunctionWithKeywords(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) Calls a function. TOS is a tuple containing keyword names. TOS[1]...TOS[len(TOS)] are the keyword arguments to the function (TOS[1] is (TOS)[0], TOS[2] is (TOS)[1], ...). TOS[len(TOS) + 1]...TOS[argc + 1] are the positional arguments (rightmost first). TOS[argc + 2] is the function to call. TOS...TOS[argc + 2] are all popped and the result is pushed onto the stack. -
callGenericFunctionWithKeywords
public static void callGenericFunctionWithKeywords(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction) Calls a function. TOS is a tuple containing keyword names. TOS[1]...TOS[len(TOS)] are the keyword arguments to the function (TOS[1] is (TOS)[0], TOS[2] is (TOS)[1], ...). TOS[len(TOS) + 1]...TOS[argc + 1] are the positional arguments (rightmost first). TOS[argc + 2] is the function to call. TOS...TOS[argc + 2] are all popped and the result is pushed onto the stack. -
callFunctionUnpack
public static void callFunctionUnpack(FunctionMetadata functionMetadata, StackMetadata stackMetadata, PythonBytecodeInstruction instruction) Calls a function. If the lowest bit of instruction.arg is set, TOS is a mapping object containing keyword arguments, TOS[1] is an iterable containing positional arguments and TOS[2] is callable. Otherwise, TOS is an iterable containing positional arguments and TOS[1] is callable. -
callFunctionUnpackMapAndIterable
public static void callFunctionUnpackMapAndIterable(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor) -
callFunctionUnpackIterable
public static void callFunctionUnpackIterable(FunctionMetadata functionMetadata, StackMetadata stackMetadata, org.objectweb.asm.MethodVisitor methodVisitor) -
createFunction
public static void createFunction(FunctionMetadata functionMetadata, StackMetadata stackMetadata, PythonBytecodeInstruction instruction) Creates a function. The stack depends oninstruction.arg: - If (arg & 1) == 1, a tuple of default values for positional-only and positional-or-keyword parameters in positional order - If (arg & 2) == 2, a dictionary of keyword-only parameters’ default values - If (arg & 4) == 4, an annotation dictionary - If (arg & 8) == 8, a tuple containing cells for free variables The stack will contain the following items, in the given order: TOP [Mandatory] Function Name [Mandatory] Class of the PythonLikeFunction to create [Optional, flag = 0x8] A tuple containing the cells for free variables [Optional, flag = 0x4] A tuple containing key,value pairs for the annotation directory [Optional, flag = 0x2] A dictionary of keyword-only parameters’ default values [Optional, flag = 0x1] A tuple of default values for positional-only and positional-or-keyword parameters in positional order BOTTOM All arguments are popped. A new instance of Class is created with the arguments and pushed to the stack. -
createInstance
public static PythonLikeFunction createInstance(PythonLikeTuple defaultPositionalArgs, PythonLikeDict defaultKeywordArgs, PythonLikeDict annotationDict, PythonLikeTuple closure, PythonString functionName, PythonCode code, PythonInterpreter pythonInterpreter) -
createInstance
public static PythonLikeFunction createInstance(PythonLikeTuple defaultPositionalArgs, PythonLikeDict defaultKeywordArgs, PythonLikeTuple annotationTuple, PythonLikeTuple closure, PythonString functionName, PythonCode code, PythonInterpreter pythonInterpreter) -
createInstance
public static <T> T createInstance(PythonLikeTuple defaultPositionalArgs, PythonLikeDict defaultKeywordArgs, PythonLikeTuple annotationTuple, PythonLikeTuple closure, PythonString functionName, Class<T> functionClass, PythonInterpreter pythonInterpreter)
-