Package org.basex.query
Class CompileContext
java.lang.Object
org.basex.query.CompileContext
Compilation context.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumCompile-time simplifications. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLimit for the size of sequences that are pre-evaluated.final QueryContextQuery context. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new copy of the given variable in this scope.Replaces the specified expression with an empty sequence.error(QueryException qe, Expr expr) Creates an error function instance.Creates and returns an optimized instance of the specified function.get(Expr expr, QuerySupplier<Expr> func) Evaluates a function in the given focus.voidAdds some compilation info.Creates a list expression from a condition and a return expression.booleanIndicates if the query focus is nested.booleanok(Expr expr, QuerySupplier<Boolean> func) Evaluates a function in the given focus.Pre-evaluates the specified expression.voidPushes the current query focus onto the stack and, if possible, assigns a new dummy item.voidPushes a new variable scope to the stack.voidRemoves the current query focus from the stack.Removes and returns the current variable scope.voidremoveScope(Scope scope) Prepares the variable scope for being compiled.replaceWith(Expr expr, Expr result) Replaces an expression with the specified one.Replicates an expression.sc()Returns the current static context.Replaces an expression with a simplified one.voidupdateFocus(Expr expr) Assigns a new dummy item to the query focus.vs()Returns the current variable scope.
-
Field Details
-
MAX_PREEVAL
public static final int MAX_PREEVALLimit for the size of sequences that are pre-evaluated.- See Also:
-
qc
Query context.
-
-
Constructor Details
-
CompileContext
Constructor.- Parameters:
qc- query context
-
-
Method Details
-
info
Adds some compilation info.- Parameters:
string- evaluation infoext- text text extensions
-
pushScope
Pushes a new variable scope to the stack.- Parameters:
vs- variable scope
-
removeScope
Removes and returns the current variable scope.- Returns:
- the removed element
-
removeScope
Prepares the variable scope for being compiled. This method should be run after compiling a scope.- Parameters:
scope- scope
-
pushFocus
Pushes the current query focus onto the stack and, if possible, assigns a new dummy item.- Parameters:
expr- focus expression (can benull)
-
updateFocus
Assigns a new dummy item to the query focus.- Parameters:
expr- focus expression
-
get
Evaluates a function in the given focus.- Parameters:
expr- focus expression (can benull)func- function to evaluate- Returns:
- resulting expression
- Throws:
QueryException- query exception
-
ok
Evaluates a function in the given focus.- Parameters:
expr- focus expression (can benull)func- function to evaluate- Returns:
- result of check
- Throws:
QueryException- query exception
-
removeFocus
public void removeFocus()Removes the current query focus from the stack. -
nestedFocus
public boolean nestedFocus()Indicates if the query focus is nested.- Returns:
- result of check
-
vs
Returns the current variable scope.- Returns:
- variable scope
-
sc
Returns the current static context.- Returns:
- static context
-
copy
Creates a new copy of the given variable in this scope.- Parameters:
var- variable to copy (can benull)vm- variable mapping (can benull)- Returns:
- new variable, or
nullif the supplied variable isnull
-
preEval
Pre-evaluates the specified expression.- Parameters:
expr- expression- Returns:
- optimized expression
- Throws:
QueryException- query exception
-
emptySeq
Replaces the specified expression with an empty sequence.- Parameters:
expr- original expression- Returns:
- optimized expression
-
simplify
Replaces an expression with a simplified one. As the simplified expression may have a different type, no type refinement is performed.- Parameters:
expr- original expressionresult- resulting expression- Returns:
- optimized expression
-
replaceWith
Replaces an expression with the specified one.- Parameters:
expr- original expressionresult- resulting expression- Returns:
- optimized expression
-
error
Creates an error function instance.- Parameters:
qe- exception to be raisedexpr- expression that caused the error message- Returns:
- function
-
function
Creates and returns an optimized instance of the specified function.- Parameters:
function- functionii- input infoexprs- expressions- Returns:
- function
- Throws:
QueryException- query exception
-
merge
Creates a list expression from a condition and a return expression.- Parameters:
cond- condition (an optional result will be swallowed)rtrn- return expressionii- input info- Returns:
- function
- Throws:
QueryException- query exception
-
replicate
Replicates an expression.- Parameters:
expr- expressioncount- count expressionii- input info- Returns:
- function
- Throws:
QueryException- query exception
-