Package ai.timefold.jpyinterpreter
Class PythonBytecodeToJavaBytecodeTranslator
java.lang.Object
ai.timefold.jpyinterpreter.PythonBytecodeToJavaBytecodeTranslator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic Pathstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateFields(org.objectweb.asm.ClassWriter classWriter) static <T> TcreateInstance(Class<T> functionClass, PythonInterpreter pythonInterpreter) static <T> TforceTranslatePythonBytecodeToGenerator(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType) static <T> Class<T>forceTranslatePythonBytecodeToGeneratorClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, Method methodWithoutGenerics, boolean isVirtual) Used for testing; force translate the python to a generator, even if it is not a generatorstatic MethodgetFunctionalInterfaceMethod(Class<?> interfaceClass) static PythonFunctionTypegetFunctionType(PythonCompiledFunction pythonCompiledFunction) static StackMetadatagetInitialStackMetadata(LocalVariableHelper localVariableHelper, MethodDescriptor method, boolean isVirtual) getOpcodeList(PythonCompiledFunction pythonCompiledFunction) static StringgetPythonBytecodeListing(PythonCompiledFunction pythonCompiledFunction) static voidprint(org.objectweb.asm.MethodVisitor methodVisitor) Used for debugging; prints TOSstatic voidprintStack(FunctionMetadata functionMetadata, StackMetadata stackMetadata) Used for debugging; prints the entire stackstatic <T> TtranslatePythonBytecode(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType) static <T> TtranslatePythonBytecode(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType, List<Class<?>> genericTypeArgumentList) static <T> Class<T>translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor) static <T> Class<T>translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, boolean isVirtual) static <T> Class<T>translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, Method methodWithoutGenerics, boolean isVirtual) static <T> Class<T>translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType) static <T> Class<T>translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType, List<Class<?>> genericTypeArgumentList) static <T> TtranslatePythonBytecodeToInstance(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor) static <T> TtranslatePythonBytecodeToInstance(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, boolean isVirtual) static <T> Class<T>translatePythonBytecodeToPythonWrapperClass(PythonCompiledFunction pythonCompiledFunction, OpaquePythonReference codeReference) static voidvisitGeneratedLineNumber(org.objectweb.asm.MethodVisitor methodVisitor) static voidwriteClassOutput(Map<String, byte[]> classNameToBytecode, String className, byte[] classByteCode) static voidwriteInstructionsForOpcodes(FunctionMetadata functionMetadata, List<StackMetadata> stackMetadataForOpcodeIndex, List<Opcode> opcodeList) static voidwriteInstructionsForOpcodes(FunctionMetadata functionMetadata, List<StackMetadata> stackMetadataForOpcodeIndex, List<Opcode> opcodeList, Consumer<PythonBytecodeInstruction> runAfterLabelAndBeforeArgumentors)
-
Field Details
-
USER_PACKAGE_BASE
- See Also:
-
GENERATED_PACKAGE_BASE
- See Also:
-
CONSTANTS_STATIC_FIELD_NAME
- See Also:
-
NAMES_STATIC_FIELD_NAME
- See Also:
-
VARIABLE_NAMES_STATIC_FIELD_NAME
- See Also:
-
GLOBALS_MAP_STATIC_FIELD_NAME
- See Also:
-
CLASS_CELL_STATIC_FIELD_NAME
- See Also:
-
ARGUMENT_SPEC_GETTER_STATIC_FIELD_NAME
- See Also:
-
PYTHON_WRAPPER_CODE_STATIC_FIELD_NAME
- See Also:
-
DEFAULT_POSITIONAL_ARGS_INSTANCE_FIELD_NAME
- See Also:
-
DEFAULT_KEYWORD_ARGS_INSTANCE_FIELD_NAME
- See Also:
-
ANNOTATION_DIRECTORY_INSTANCE_FIELD_NAME
- See Also:
-
CELLS_INSTANCE_FIELD_NAME
- See Also:
-
QUALIFIED_NAME_INSTANCE_FIELD_NAME
- See Also:
-
ARGUMENT_SPEC_INSTANCE_FIELD_NAME
- See Also:
-
INTERPRETER_INSTANCE_FIELD_NAME
- See Also:
-
PYTHON_WRAPPER_FUNCTION_INSTANCE_FIELD_NAME
- See Also:
-
classOutputRootPath
-
-
Constructor Details
-
PythonBytecodeToJavaBytecodeTranslator
public PythonBytecodeToJavaBytecodeTranslator()
-
-
Method Details
-
writeClassOutput
-
getFunctionalInterfaceMethod
-
createInstance
-
translatePythonBytecode
public static <T> T translatePythonBytecode(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType) -
translatePythonBytecode
public static <T> T translatePythonBytecode(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType, List<Class<?>> genericTypeArgumentList) -
forceTranslatePythonBytecodeToGenerator
public static <T> T forceTranslatePythonBytecodeToGenerator(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType) -
translatePythonBytecodeToClass
public static <T> Class<T> translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType) -
translatePythonBytecodeToClass
public static <T> Class<T> translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, Class<T> javaFunctionalInterfaceType, List<Class<?>> genericTypeArgumentList) -
translatePythonBytecodeToClass
public static <T> Class<T> translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor) -
translatePythonBytecodeToInstance
public static <T> T translatePythonBytecodeToInstance(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor) -
translatePythonBytecodeToInstance
public static <T> T translatePythonBytecodeToInstance(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, boolean isVirtual) -
translatePythonBytecodeToClass
public static <T> Class<T> translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, boolean isVirtual) -
translatePythonBytecodeToClass
public static <T> Class<T> translatePythonBytecodeToClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, Method methodWithoutGenerics, boolean isVirtual) -
translatePythonBytecodeToPythonWrapperClass
public static <T> Class<T> translatePythonBytecodeToPythonWrapperClass(PythonCompiledFunction pythonCompiledFunction, OpaquePythonReference codeReference) -
forceTranslatePythonBytecodeToGeneratorClass
public static <T> Class<T> forceTranslatePythonBytecodeToGeneratorClass(PythonCompiledFunction pythonCompiledFunction, MethodDescriptor methodDescriptor, Method methodWithoutGenerics, boolean isVirtual) Used for testing; force translate the python to a generator, even if it is not a generator -
createFields
public static void createFields(org.objectweb.asm.ClassWriter classWriter) -
getOpcodeList
-
getInitialStackMetadata
public static StackMetadata getInitialStackMetadata(LocalVariableHelper localVariableHelper, MethodDescriptor method, boolean isVirtual) -
getFunctionType
-
writeInstructionsForOpcodes
public static void writeInstructionsForOpcodes(FunctionMetadata functionMetadata, List<StackMetadata> stackMetadataForOpcodeIndex, List<Opcode> opcodeList) -
writeInstructionsForOpcodes
public static void writeInstructionsForOpcodes(FunctionMetadata functionMetadata, List<StackMetadata> stackMetadataForOpcodeIndex, List<Opcode> opcodeList, Consumer<PythonBytecodeInstruction> runAfterLabelAndBeforeArgumentors) -
print
public static void print(org.objectweb.asm.MethodVisitor methodVisitor) Used for debugging; prints TOS -
printStack
Used for debugging; prints the entire stack -
getPythonBytecodeListing
-
visitGeneratedLineNumber
public static void visitGeneratedLineNumber(org.objectweb.asm.MethodVisitor methodVisitor)
-