Class StringImplementor

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

public class StringImplementor extends Object
  • Constructor Details

    • StringImplementor

      public StringImplementor()
  • Method Details

    • buildString

      public static void buildString(org.objectweb.asm.MethodVisitor methodVisitor, int itemCount)
      Constructs a string from the top itemCount on the stack. Basically generate the following code:
           StringBuilder builder = new StringBuilder();
           builder.insert(0, TOS);
           builder.insert(0, TOS1);
           ...
           builder.insert(0, TOS(itemCount - 1));
           TOS' = PythonString.valueOf(builder.toString())
       
      Parameters:
      itemCount - The number of items to put into collection from the stack
    • formatValue

      public static void formatValue(org.objectweb.asm.MethodVisitor methodVisitor, PythonBytecodeInstruction instruction)
      TOS1 is a value and TOS is an optional format string (either PythonNone or PythonString). Depending on instruction.arg, does one of several things to TOS1 before formatting it (as specified by StringOpDescriptor.FORMAT_VALUE: arg & 3 == 0: Do nothing arg & 3 == 1: Call str() on value before formatting it arg & 3 == 2: Call repr() on value before formatting it arg & 3 == 3: Call ascii() on value before formatting it if arg & 4 == 0, TOS is the value to format, so push PythonNone before calling format if arg & 4 == 4, TOS is a format string, use it in the call
    • print

      public static void print(FunctionMetadata functionMetadata, StackMetadata stackMetadata)
      TOS is an PythonLikeObject to be printed. Pop TOS off the stack and print it.