Class Local<T extends ACell>

Type Parameters:
T - Result type of Op
All Implemented Interfaces:
IValidated, IWriteable

public class Local<T extends ACell> extends AOp<T>
Op to look up a local value from the lexical environment
  • Method Details

    • create

      public static final <R extends ACell> Local<R> create(long position)
      Creates Local to look up a lexical value in the given position
      Parameters:
      position - Position in lexical value vector
      Returns:
      Special instance, or null if not found
    • execute

      public <R extends ACell> Context<T> execute(Context<R> context)
      Description copied from class: AOp
      Executes this op with the given context. Must preserve depth unless an exceptional is returned.
      Specified by:
      execute in class AOp<T extends ACell>
      Type Parameters:
      R - Type of Context
      Parameters:
      context - Initial Context
      Returns:
      The updated Context after executing this operation
    • opCode

      public byte opCode()
      Description copied from class: AOp
      Returns the opcode for this op
      Specified by:
      opCode in class AOp<T extends ACell>
      Returns:
      Opcode as a byte
    • encodeRaw

      public int encodeRaw(byte[] bs, int pos)
      Description copied from class: AOp
      Writes the raw data for this Op to the specified bytebuffer. Assumes Op tag and opcode already written.
      Specified by:
      encodeRaw in class AOp<T extends ACell>
      Parameters:
      bs - Byte array to write to
      pos - Position to write in byte array
      Returns:
      The updated position
    • read

      public static <R extends ACell> Local<R> read(ByteBuffer bb) throws BadFormatException
      Throws:
      BadFormatException
    • updateRefs

      public Local<T> updateRefs(IRefFunction func)
      Description copied from class: ACell
      Updates all Refs in this object using the given function. The function *must not* change the hash value of Refs, in order to ensure structural integrity of modified data structures. This is a building block for a very sneaky trick that enables use to do a lot of efficient operations on large trees of smart references. Must return the same object if no Refs are altered.
      Specified by:
      updateRefs in class AOp<T extends ACell>
      Parameters:
      func - Ref update function
      Returns:
      Cell with updated Refs
    • validateCell

      public void validateCell() throws InvalidDataException
      Description copied from class: ACell
      Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.
      Specified by:
      validateCell in class ACell
      Throws:
      InvalidDataException - If the Cell is invalid
    • getRefCount

      public int getRefCount()
      Description copied from class: ACell
      Gets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. Contained Refs may be either external or embedded.
      Specified by:
      getRefCount in class ACell
      Returns:
      The number of Refs in this Cell
    • print

      public boolean print(BlobBuilder bb, long limit)
      Description copied from class: AObject
      Prints this Object to a readable String Representation. SECURITY: Must halt and return false in O(1) time if limit of printing is exceeded otherwise DoS attacks may be possible.
      Specified by:
      print in class AObject
      Parameters:
      bb - BlobBuilder to append to
      limit - Limit of printing in string bytes
      Returns:
      True if fully printed within limit, false otherwise
    • toString

      public String toString()
      Description copied from class: ACell
      Returns the Java String representation of this Cell. The String representation is intended to be a easy-to-read textual representation of the Cell's data content.
      Overrides:
      toString in class ACell