Class LocalVars

java.lang.Object
org.basex.query.util.parse.LocalVars

public final class LocalVars extends Object
Organizes local variables.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • LocalVars

      public LocalVars(QueryParser parser)
      Constructor.
      Parameters:
      parser - query parser
  • Method Details

    • add

      public Var add(Var var)
      Creates and registers a new local variable in the current scope.
      Parameters:
      var - variable to be added (can be null)
      Returns:
      variable
    • resolveLocal

      public VarRef resolveLocal(QNm name, InputInfo ii)
      Tries to resolve a local variable reference.
      Parameters:
      name - variable name
      ii - input info
      Returns:
      variable reference or null
    • resolve

      public ParseExpr resolve(QNm name, InputInfo ii) throws QueryException
      Resolves the referenced variable as a local or static variable and returns a reference to it. IF the variable is not declared, the specified error is thrown.
      Parameters:
      name - variable name
      ii - input info
      Returns:
      referenced variable
      Throws:
      QueryException - if the variable isn't defined
    • pushContext

      public void pushContext(HashMap<Var,Expr> global)
      Pushes a new variable context onto the stack.
      Parameters:
      global - mapping for non-local variables
    • popContext

      public VarScope popContext()
      Pops one variable context from the stack.
      Returns:
      the removed context's variable scope
    • openScope

      public int openScope()
      Opens a new sub-scope inside the current one. The returned marker has to be supplied to the corresponding call to closeScope(int) in order to mark the variables as inaccessible.
      Returns:
      marker for the current bindings
    • closeScope

      public void closeScope(int marker)
      Closes the sub-scope and marks all contained variables as inaccessible.
      Parameters:
      marker - marker for the start of the sub-scope