Package org.basex.query.func
Class FuncLit
- java.lang.Object
-
- org.basex.query.expr.ExprInfo
-
- org.basex.query.expr.Expr
-
- org.basex.query.expr.ParseExpr
-
- org.basex.query.expr.Single
-
- org.basex.query.func.FuncLit
-
- All Implemented Interfaces:
XQFunctionExpr
,Scope
public final class FuncLit extends Single implements Scope, XQFunctionExpr
A named function literal.- Author:
- BaseX Team 2005-24, BSD License, Leo Woerteler
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(ASTVisitor visitor)
Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties.AnnList
annotations()
Annotations of this function.int
arity()
Number of arguments this function takes.Expr
compile(CompileContext cc)
Compiles and optimizes the expression, assigns types and cardinalities.boolean
compiled()
Checks if this scope has already been compiled.Expr
copy(CompileContext cc, IntObjMap<Var> vm)
Copies an expression.String
description()
Returns a string description of the expression.boolean
equals(Object obj)
This function is e.g. called by:If.optimize(CompileContext)
,Switch.optimize(CompileContext)
,Typeswitch.optimize(CompileContext)
, in order to discard identical expressions.QNm
funcName()
Name of this function,null
means anonymous function.Expr
inline(Expr[] exprs, CompileContext cc)
Tries to inline this function with the given arguments.FuncItem
item(QueryContext qc, InputInfo ii)
Evaluates the expression and returns the resulting item, orEmpty.VALUE
if the expression yields an empty sequence.Expr
optimize(CompileContext cc)
Optimizes an already compiled expression without recompiling its sub-expressions.QNm
paramName(int pos)
Name of the parameter at the given position.void
toString(QueryString qs)
Creates a query string.boolean
vacuousBody()
Checks if this function returns vacuous results (seeExpr.vacuous()
).boolean
visit(ASTVisitor visitor)
Traverses this scope with the givenASTVisitor
.-
Methods inherited from class org.basex.query.expr.Single
arg, args, checkUp, count, exprSize, has, inline, inlineable, toXml
-
Methods inherited from class org.basex.query.expr.ParseExpr
adoptType, atomValue, checkAllUp, checkNoneUp, checkNoUp, checkType, checkType, checkUp, copyType, ctxValue, data, info, iter, refineType, sc, seqType, size, test, toArray, toArray, toAtomItem, toBin, toBin, toBinOrNull, toBoolean, toBoolean, toBooleanOrFalse, toBytes, toBytes, toDouble, toDouble, toElem, toElem, toEnum, toFloat, toFunction, toLong, toLong, toLong, toMap, toMap, toNode, toNode, toNodeOrNull, toNumber, toNumber, toNumberOrNull, toQNm, toQNmOrNull, toRecord, toString, toString, toStringOrNull, toToken, toToken, toTokenOrNull, toZeroToken, value
-
Methods inherited from class org.basex.query.expr.Expr
atomItem, atomIter, ddo, funcType, hasFreeVars, indexAccessible, info, isSimple, markTailCalls, mergeEbv, optimizePos, simplify, simplifyFor, typeCheck, uses, vacuous, visitAll
-
Methods inherited from class org.basex.query.expr.ExprInfo
toErrorString, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.basex.query.func.XQFunctionExpr
funcType
-
-
-
-
Method Detail
-
arity
public int arity()
Description copied from interface:XQFunctionExpr
Number of arguments this function takes.- Specified by:
arity
in interfaceXQFunctionExpr
- Returns:
- function arity
-
funcName
public QNm funcName()
Description copied from interface:XQFunctionExpr
Name of this function,null
means anonymous function.- Specified by:
funcName
in interfaceXQFunctionExpr
- 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 interfaceXQFunctionExpr
- Parameters:
pos
- position of the parameter- Returns:
- name of the parameter
-
annotations
public AnnList annotations()
Description copied from interface:XQFunctionExpr
Annotations of this function.- Specified by:
annotations
in interfaceXQFunctionExpr
- Returns:
- this function's annotations
-
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 interfaceXQFunctionExpr
- Parameters:
exprs
- argumentscc
- compilation context- Returns:
- the expression to inline if successful,
null
otherwise - Throws:
QueryException
- query exception
-
vacuousBody
public boolean vacuousBody()
Description copied from interface:XQFunctionExpr
Checks if this function returns vacuous results (seeExpr.vacuous()
).- Specified by:
vacuousBody
in interfaceXQFunctionExpr
- Returns:
- result of check
-
compile
public Expr compile(CompileContext cc) throws QueryException
Description copied from class:Expr
Compiles and optimizes the expression, assigns types and cardinalities.- Specified by:
compile
in interfaceScope
- Overrides:
compile
in classSingle
- Parameters:
cc
- compilation context- Returns:
- optimized expression
- Throws:
QueryException
- query exception
-
optimize
public Expr optimize(CompileContext cc) throws QueryException
Description copied from class:Expr
Optimizes an already compiled expression without recompiling its sub-expressions.- Overrides:
optimize
in classSingle
- Parameters:
cc
- compilation context- Returns:
- optimized expression
- Throws:
QueryException
- query exception
-
compiled
public boolean compiled()
Description copied from interface:Scope
Checks if this scope has already been compiled.
-
item
public FuncItem item(QueryContext qc, InputInfo ii)
Description copied from class:Expr
Evaluates the expression and returns the resulting item, orEmpty.VALUE
if the expression yields an empty sequence. If this method is not implemented,Expr.value(QueryContext)
must be implemented instead.- Overrides:
item
in classParseExpr
- Parameters:
qc
- query contextii
- input info (can benull
); required for thoseValue
instances that have no input info)- Returns:
- item or
Empty.VALUE
-
copy
public Expr copy(CompileContext cc, IntObjMap<Var> vm)
Description copied from class:Expr
Copies an expression. Used for inlining functions, or for copying static queries. It is utilized byVarRef.inline(org.basex.query.InlineContext)
,FuncItem.inline(org.basex.query.expr.Expr[], org.basex.query.CompileContext)
,Closure.inline(org.basex.query.InlineContext)
andStaticFunc.inline(org.basex.query.expr.Expr[], org.basex.query.CompileContext)
.- Specified by:
copy
in classExpr
- Parameters:
cc
- compilation contextvm
- mapping from old variable IDs to new variable copies. Required byClosure.copy(org.basex.query.CompileContext, org.basex.util.hash.IntObjMap<org.basex.query.var.Var>)
andVarRef.copy(org.basex.query.CompileContext, org.basex.util.hash.IntObjMap<org.basex.query.var.Var>)
- Returns:
- copied expression
-
visit
public boolean visit(ASTVisitor visitor)
Description copied from interface:Scope
Traverses this scope with the givenASTVisitor
.
-
accept
public boolean accept(ASTVisitor visitor)
Description copied from class:Expr
Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties.
-
equals
public boolean equals(Object obj)
Description copied from class:Single
This function is e.g. called by:Must be overwritten by implementing class.If.optimize(CompileContext)
,Switch.optimize(CompileContext)
,Typeswitch.optimize(CompileContext)
, in order to discard identical expressions.CmpR.mergeEbv(Expr, boolean, CompileContext)
orCmpSR.mergeEbv(Expr, boolean, CompileContext)
, in order to merge expressions with identical input.CmpG.optimize(CompileContext)
orCmpV.optimize(CompileContext)
, in order to pre-evaluate equality tests.CmpG.optimize(CompileContext)
, in order to compare the start and end value.PathCache
, in order to find identical root values at runtime.
-
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 theExprInfo.toString()
method, arguments are not included in the output.- Overrides:
description
in classExprInfo
- Returns:
- result of check
-
toString
public void toString(QueryString qs)
Description copied from class:ExprInfo
Creates a query string.
-
-