Class LocalVariable


  • public final class LocalVariable
    extends Object
    A local variable.

    Local variables are used as identifiers for things that can be stored and loaded from the local variable slots associated with each method. By using LocalVariable intances, you are removed from the taudry task of book-keeping these slots.

    To use a local variable, create an intance and then use it in a code generator. The method will keep track of which local variables are in scope, and will handle all the nastiness for you. You can re-use the same local variable instance in different contexts, and it will be sanely allocated different or the same slots.

    The JVM stores some things in single words, and others in pairs of words. To hide this detail from you, local variables take a class that indicates the type of thing they will store. Please populate this sensibly.

    Author:
    Thomas Down, Matthew Pocock
    • Constructor Detail

      • LocalVariable

        public LocalVariable​(CodeClass clazz)
        Create a new local variable that will store values of a given type.
        Parameters:
        clazz - the type of the values stored in this variable
      • LocalVariable

        public LocalVariable​(CodeClass clazz,
                             String name)
        Create a new local variable with a type and a name.

        The name may appear in debug output from the generator, and possibly in stack-traces.

        Parameters:
        clazz - the type of the values stored in this variable
        name - the name of the variable