Class CompileContext

java.lang.Object
org.basex.query.CompileContext

public final class CompileContext extends Object
Compilation context.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Details

    • MAX_PREEVAL

      public static final int MAX_PREEVAL
      Limit for the size of sequences that are pre-evaluated.
      See Also:
    • qc

      public final QueryContext qc
      Query context.
  • Constructor Details

    • CompileContext

      public CompileContext(QueryContext qc)
      Constructor.
      Parameters:
      qc - query context
  • Method Details

    • info

      public void info(String string, Object... ext)
      Adds some compilation info.
      Parameters:
      string - evaluation info
      ext - text text extensions
    • pushScope

      public void pushScope(VarScope vs)
      Pushes a new variable scope to the stack.
      Parameters:
      vs - variable scope
    • removeScope

      public VarScope removeScope()
      Removes and returns the current variable scope.
      Returns:
      the removed element
    • removeScope

      public void removeScope(Scope scope)
      Prepares the variable scope for being compiled. This method should be run after compiling a scope.
      Parameters:
      scope - scope
    • pushFocus

      public void pushFocus(Expr expr)
      Pushes the current query focus onto the stack and, if possible, assigns a new dummy item.
      Parameters:
      expr - focus expression (can be null)
    • updateFocus

      public void updateFocus(Expr expr)
      Assigns a new dummy item to the query focus.
      Parameters:
      expr - focus expression
    • get

      public Expr get(Expr expr, QuerySupplier<Expr> func) throws QueryException
      Evaluates a function in the given focus.
      Parameters:
      expr - focus expression (can be null)
      func - function to evaluate
      Returns:
      resulting expression
      Throws:
      QueryException - query exception
    • ok

      public boolean ok(Expr expr, QuerySupplier<Boolean> func) throws QueryException
      Evaluates a function in the given focus.
      Parameters:
      expr - focus expression (can be null)
      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

      public VarScope vs()
      Returns the current variable scope.
      Returns:
      variable scope
    • sc

      public StaticContext sc()
      Returns the current static context.
      Returns:
      static context
    • copy

      public Var copy(Var var, IntObjMap<Var> vm)
      Creates a new copy of the given variable in this scope.
      Parameters:
      var - variable to copy (can be null)
      vm - variable mapping (can be null)
      Returns:
      new variable, or null if the supplied variable is null
    • preEval

      public Expr preEval(Expr expr) throws QueryException
      Pre-evaluates the specified expression.
      Parameters:
      expr - expression
      Returns:
      optimized expression
      Throws:
      QueryException - query exception
    • emptySeq

      public Expr emptySeq(Expr expr)
      Replaces the specified expression with an empty sequence.
      Parameters:
      expr - original expression
      Returns:
      optimized expression
    • simplify

      public Expr simplify(Expr expr, Expr result)
      Replaces an expression with a simplified one. As the simplified expression may have a different type, no type refinement is performed.
      Parameters:
      expr - original expression
      result - resulting expression
      Returns:
      optimized expression
    • replaceWith

      public Expr replaceWith(Expr expr, Expr result)
      Replaces an expression with the specified one.
      Parameters:
      expr - original expression
      result - resulting expression
      Returns:
      optimized expression
    • error

      public StandardFunc error(QueryException qe, Expr expr)
      Creates an error function instance.
      Parameters:
      qe - exception to be raised
      expr - expression that caused the error message
      Returns:
      function
    • function

      public Expr function(AFunction function, InputInfo ii, Expr... exprs) throws QueryException
      Creates and returns an optimized instance of the specified function.
      Parameters:
      function - function
      ii - input info
      exprs - expressions
      Returns:
      function
      Throws:
      QueryException - query exception
    • merge

      public Expr merge(Expr cond, Expr rtrn, InputInfo ii) throws QueryException
      Creates a list expression from a condition and a return expression.
      Parameters:
      cond - condition (an optional result will be swallowed)
      rtrn - return expression
      ii - input info
      Returns:
      function
      Throws:
      QueryException - query exception
    • replicate

      public Expr replicate(Expr expr, Expr count, InputInfo ii) throws QueryException
      Replicates an expression.
      Parameters:
      expr - expression
      count - count expression
      ii - input info
      Returns:
      function
      Throws:
      QueryException - query exception