Class VarScope

java.lang.Object
org.basex.query.var.VarScope

public final class VarScope extends Object
The scope of variables, either the query, a user-defined or an inline function.
Author:
BaseX Team 2005-21, BSD License, Leo Woerteler
  • Field Details

  • Constructor Details

    • VarScope

      public VarScope(StaticContext sc)
      Constructor for a top-level module.
      Parameters:
      sc - static context
  • Method Details

    • add

      public Var add(Var var)
      Adds a variable to this scope.
      Parameters:
      var - variable to be added
      Returns:
      the variable (for convenience)
    • addNew

      public Var addNew(QNm name, SeqType st, boolean param, QueryContext qc, InputInfo ii)
      Creates a new local variable in this scope.
      Parameters:
      name - variable name
      st - type of the variable (can be null)
      param - function parameter flag
      qc - query context
      ii - input info
      Returns:
      the variable
    • enter

      public int enter(QueryContext qc)
      Enters this scope.
      Parameters:
      qc - query context
      Returns:
      old frame pointer
    • exit

      public static void exit(int fp, QueryContext qc)
      Exits this scope.
      Parameters:
      fp - frame pointer
      qc - query context
    • cleanUp

      public void cleanUp(Scope scope)
      Deletes all unused variables from this scope and assigns stack slots.
      Parameters:
      scope - the scope
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • stackSize

      public int stackSize()
      Stack-frame size needed for this scope.
      Returns:
      stack-frame size
    • copy

      public void copy(CompileContext cc, IntObjMap<Var> vm)
      Returns a copy of this variable scope.
      Parameters:
      cc - compilation context
      vm - variable mapping