Class DunderOperatorImplementor

java.lang.Object
ai.timefold.jpyinterpreter.implementors.DunderOperatorImplementor

public class DunderOperatorImplementor extends Object
Implementations of opcodes that delegate to dunder/magic methods.
  • Constructor Details

    • DunderOperatorImplementor

      public DunderOperatorImplementor()
  • Method Details

    • unaryOperator

      public static void unaryOperator(org.objectweb.asm.MethodVisitor methodVisitor, StackMetadata stackMetadata, PythonUnaryOperator operator)
    • unaryOperator

      public static void unaryOperator(org.objectweb.asm.MethodVisitor methodVisitor, PythonUnaryOperator operator)
      Performs a unary dunder operation on TOS. Generate codes that look like this:
          BiFunction[List, Map, Result] operand_method = TOS.$getType().$getAttributeOrError(operator.getDunderMethod());
          List args = new ArrayList(1);
          args.set(0) = TOS
          pop TOS
          TOS' = operand_method.apply(args, null)
       
    • binaryOperator

      public static void binaryOperator(org.objectweb.asm.MethodVisitor methodVisitor, StackMetadata stackMetadata, PythonBinaryOperator operator)
    • binaryOperator

      public static void binaryOperator(org.objectweb.asm.MethodVisitor methodVisitor, LocalVariableHelper localVariableHelper, PythonBinaryOperator operator)
      Performs a binary dunder operation on TOS and TOS1. Generate codes that look like this:
          BiFunction[List, Map, Result] operand_method = TOS1.$getType().$getAttributeOrError(operator.getDunderMethod());
          List args = new ArrayList(2);
          args.set(0) = TOS1
          args.set(1) = TOS
          pop TOS, TOS1
          TOS' = operand_method.apply(args, null)
       
    • binaryOperatorOnlyRight

      public static void binaryOperatorOnlyRight(org.objectweb.asm.MethodVisitor methodVisitor, LocalVariableHelper localVariableHelper, PythonBinaryOperator operator)
    • ternaryOperator

      public static void ternaryOperator(FunctionMetadata functionMetadata, StackMetadata stackMetadata, PythonTernaryOperator operator)
      Performs a ternary dunder operation on TOS, TOS1 and TOS2. Generate codes that look like this:
          BiFunction[List, Map, Result] operand_method = TOS2.$getType().$getAttributeOrError(operator.getDunderMethod());
          List args = new ArrayList(2);
          args.set(0) = TOS2
          args.set(1) = TOS1
          args.set(2) = TOS
          pop TOS, TOS1, TOS2
          TOS' = operand_method.apply(args, null)
       
    • compareValues

      public static void compareValues(org.objectweb.asm.MethodVisitor methodVisitor, StackMetadata stackMetadata, CompareOp op)
      Compares TOS and TOS1 via their dunder methods. CompareOp indicates the operation to perform.
    • getSlice

      public static void getSlice(FunctionMetadata functionMetadata, StackMetadata stackMetadata)
    • storeSlice

      public static void storeSlice(FunctionMetadata functionMetadata, StackMetadata stackMetadata)