Package org.basex.query.util.parse
Class LocalVars
java.lang.Object
org.basex.query.util.parse.LocalVars
Organizes local variables.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates and registers a new local variable in the current scope.voidcloseScope(int marker) Closes the sub-scope and marks all contained variables as inaccessible.intOpens a new sub-scope inside the current one.Pops one variable context from the stack.voidpushContext(HashMap<Var, Expr> global) Pushes a new variable context onto the stack.Resolves the referenced variable as a local or static variable and returns a reference to it.resolveLocal(QNm name, InputInfo ii) Tries to resolve a local variable reference.
-
Constructor Details
-
LocalVars
Constructor.- Parameters:
parser- query parser
-
-
Method Details
-
add
Creates and registers a new local variable in the current scope.- Parameters:
var- variable to be added (can benull)- Returns:
- variable
-
resolveLocal
Tries to resolve a local variable reference.- Parameters:
name- variable nameii- input info- Returns:
- variable reference or
null
-
resolve
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 nameii- input info- Returns:
- referenced variable
- Throws:
QueryException- if the variable isn't defined
-
pushContext
Pushes a new variable context onto the stack.- Parameters:
global- mapping for non-local variables
-
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 tocloseScope(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
-