Class JvmOpcodes

java.lang.Object
org.ek9lang.compiler.backend.jvm.support.JvmOpcodes

public final class JvmOpcodes extends Object
Shared JVM opcode selection for the bytecode generators: primitive/reference local-variable load/store opcodes and optimal integer-constant loading. Single-sources the per-type opcode switches and the ICONST/BIPUSH/SIPUSH/LDC ladder that were duplicated across several generators.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    isPrimitive(String typeName)
    Whether typeName is an EK9/Java primitive type (uses the I/L/F/D-family opcodes rather than the reference A-family).
    static int
    The JVM local-variable LOAD opcode for type (ALOAD for object/reference types and null).
    static void
    pushIntConstant(org.objectweb.asm.MethodVisitor mv, int value)
    Push an int constant onto the operand stack using the most compact instruction: ICONST_M1..ICONST_5 for -1..5, BIPUSH for a byte, SIPUSH for a short, otherwise LDC.
    static int
    The JVM local-variable STORE opcode for type (ASTORE for object/reference types).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isPrimitive

      public static boolean isPrimitive(String typeName)
      Whether typeName is an EK9/Java primitive type (uses the I/L/F/D-family opcodes rather than the reference A-family).
    • loadOpcode

      public static int loadOpcode(String type)
      The JVM local-variable LOAD opcode for type (ALOAD for object/reference types and null).
    • storeOpcode

      public static int storeOpcode(String type)
      The JVM local-variable STORE opcode for type (ASTORE for object/reference types).
    • pushIntConstant

      public static void pushIntConstant(org.objectweb.asm.MethodVisitor mv, int value)
      Push an int constant onto the operand stack using the most compact instruction: ICONST_M1..ICONST_5 for -1..5, BIPUSH for a byte, SIPUSH for a short, otherwise LDC.