Class EnvVar

java.lang.Object
org.jfuncmachine.compiler.classgen.EnvVar

public class EnvVar extends Object
Associates a name and type with the index of a local variable. In Java instructions, local variables are referred to by a simple index number. The parameters to the method have the lowest index numbers.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    The index of the variable
    final String
    The name of the variable
    The type of the variable
  • Constructor Summary

    Constructors
    Constructor
    Description
    EnvVar(String name, Type type, int index)
    Creates a new EnvVar with a name, type, and index value
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    void
    Generates an instruction to get this variable
    void
    Generates an instruction to set this variable
    static int
    Returns the opcode used to get variables of a particular type
    int
     
    static int
    Returns the opcode used to set variables of a particular type

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      public final String name
      The name of the variable
    • type

      public Type type
      The type of the variable
    • index

      public final int index
      The index of the variable
  • Constructor Details

    • EnvVar

      public EnvVar(String name, Type type, int index)
      Creates a new EnvVar with a name, type, and index value
      Parameters:
      name - The name of the variable
      type - The type of the variable
      index - The index of the variable
  • Method Details

    • generateSet

      public void generateSet(ClassGenerator generator)
      Generates an instruction to set this variable
      Parameters:
      generator - The class generator currently generating the class
    • setOpcode

      public static int setOpcode(Type t)
      Returns the opcode used to set variables of a particular type
      Parameters:
      t - The type of variable to return the opcode for
      Returns:
      The opcode used to store variables of the given type
    • generateGet

      public void generateGet(ClassGenerator generator)
      Generates an instruction to get this variable
      Parameters:
      generator - The class generator currently generating the class
    • getOpcode

      public static int getOpcode(Type t)
      Returns the opcode used to get variables of a particular type
      Parameters:
      t - The type of variable to return the opcode for
      Returns:
      The opcode used to fetch variables of the given type
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object