Interface Scope

All Known Subinterfaces:
SubScope

public interface Scope
A scope for local variable declarations, but not treated as a resource
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close this scope
    <T extends Types.BNonVoid>
    Local<T>
    decl(T type, String name)
    Declare a local variable in this scope
    sub()
    Open a child scope of this scope, usually for temporary declarations/allocations
  • Method Details

    • sub

      SubScope sub()
      Open a child scope of this scope, usually for temporary declarations/allocations

      The variables declared in this scope (see decl(BNonVoid, String)) are reserved only with the scope of the try-with-resources block that ought to be used to managed this resource. Local variables meant to be in scope for the method's full scope should just be declared in the root scope.

      Returns:
      the child scope
    • decl

      <T extends Types.BNonVoid> Local<T> decl(T type, String name)
      Declare a local variable in this scope

      This assigns the local the next available index, being careful to increment the index according to the category of the given type. When this scope is closed, that index is reset to what is was at the start of this scope.

      Type Parameters:
      T - the type of the variable
      Parameters:
      type - the type of the variable
      name - the name of the variable
      Returns:
      the handle to the variable
    • close

      void close()
      Close this scope

      This resets the index to what it was at the start of this scope. In general, there is no need for the user to call this on the root scope. This is automatically done by Misc.finish(Emitter).