Class StaticFunc

All Implemented Interfaces:
XQFunction, XQFunctionExpr, Scope

public final class StaticFunc extends StaticDecl implements XQFunction
A static user-defined function.
Author:
BaseX Team 2005-21, BSD License, Leo Woerteler
  • Field Details

    • params

      public final Var[] params
      Formal parameters.
  • Method Details

    • comp

      public void comp(CompileContext cc)
      Description copied from interface: Scope
      Compiles the expression contained in this scope.
      Specified by:
      comp in interface Scope
      Parameters:
      cc - compilation context
    • optimize

      public void optimize(CompileContext cc)
      Optimize the static function.
      Parameters:
      cc - compilation context
    • arity

      public int arity()
      Description copied from interface: XQFunctionExpr
      Number of arguments this function takes.
      Specified by:
      arity in interface XQFunctionExpr
      Returns:
      function arity
    • funcName

      public QNm funcName()
      Description copied from interface: XQFunctionExpr
      Name of this function, null means anonymous function.
      Specified by:
      funcName in interface XQFunctionExpr
      Returns:
      name or null
    • paramName

      public QNm paramName(int pos)
      Description copied from interface: XQFunctionExpr
      Name of the parameter at the given position.
      Specified by:
      paramName in interface XQFunctionExpr
      Parameters:
      pos - position of the parameter
      Returns:
      name of the parameter
    • funcType

      public FuncType funcType()
      Description copied from interface: XQFunctionExpr
      Type of this function.
      Specified by:
      funcType in interface XQFunctionExpr
      Returns:
      this function's type
    • stackFrameSize

      public int stackFrameSize()
      Description copied from interface: XQFunction
      Size of this function's stack frame.
      Specified by:
      stackFrameSize in interface XQFunction
      Returns:
      stack frame size
    • annotations

      public AnnList annotations()
      Description copied from interface: XQFunctionExpr
      Annotations of this function.
      Specified by:
      annotations in interface XQFunctionExpr
      Returns:
      this function's annotations
    • invokeInternal

      public Value invokeInternal(QueryContext qc, InputInfo ii, Value[] args) throws QueryException
      Description copied from interface: XQFunction
      Internally invokes this function with the given arguments.
      Specified by:
      invokeInternal in interface XQFunction
      Parameters:
      qc - query context
      ii - input info
      args - arguments
      Returns:
      resulting value
      Throws:
      QueryException - query exception
    • vacuousBody

      public boolean vacuousBody()
      Description copied from interface: XQFunctionExpr
      Checks if this function returns vacuous results (see Expr.vacuous()).
      Specified by:
      vacuousBody in interface XQFunctionExpr
      Returns:
      result of check
    • visit

      public boolean visit(ASTVisitor visitor)
      Description copied from interface: Scope
      Traverses this scope with the given ASTVisitor.
      Specified by:
      visit in interface Scope
      Parameters:
      visitor - visitor
      Returns:
      continue flag
    • id

      public byte[] id()
      Description copied from class: StaticDecl
      Returns a unique identifier for this declaration.
      Specified by:
      id in class StaticDecl
      Returns:
      a byte sequence that uniquely identifies this declaration
    • inline

      public Expr inline(Expr[] exprs, CompileContext cc) throws QueryException
      Description copied from interface: XQFunctionExpr
      Tries to inline this function with the given arguments.
      Specified by:
      inline in interface XQFunctionExpr
      Parameters:
      exprs - arguments
      cc - compilation context
      Returns:
      the expression to inline if successful, null otherwise
      Throws:
      QueryException - query exception
    • inline

      public static boolean inline(CompileContext cc, AnnList anns, Expr expr)
      Checks if inlining conditions are given.
      Parameters:
      cc - compilation context
      anns - annotations
      expr - expression
      Returns:
      result of check
    • description

      public String description()
      Description copied from class: ExprInfo
      Returns a string description of the expression. This method is only called by error messages. Contrary to the ExprInfo.toString() method, arguments are not included in the output.
      Overrides:
      description in class ExprInfo
      Returns:
      result of check
    • plan

      public void plan(QueryPlan plan)
      Description copied from class: ExprInfo
      Creates a query plan.
      Specified by:
      plan in class ExprInfo
      Parameters:
      plan - expression plan
    • plan

      public void plan(QueryString qs)
      Description copied from class: ExprInfo
      Creates a query string.
      Specified by:
      plan in class ExprInfo
      Parameters:
      qs - query string builder