MCPcopy Create free account
hub / github.com/BaseXdb/basex / Closure

Class Closure

basex-core/src/main/java/org/basex/query/func/Closure.java:34–533  ·  view source on GitHub ↗

Inline function. @author BaseX Team, BSD License @author Leo Woerteler

Source from the content-addressed store, hash-verified

32 * @author Leo Woerteler
33 */
34public final class Closure extends Single implements Scope, XQFunctionExpr {
35 /** Function name, {@code null} if not specified. */
36 private final QNm name;
37 /** Parameters. */
38 private final Var[] params;
39 /** Value type, {@code null} if not specified. */
40 private final SeqType declType;
41 /** Annotations. */
42 private AnnList anns;
43 /** Updating flag. */
44 private boolean updating;
45
46 /** Map with requested function properties. */
47 private final EnumMap<Flag, Boolean> map = new EnumMap<>(Flag.class);
48 /** Compilation flag. */
49 private boolean compiled;
50 /** Indicates if code is currently being compiled or evaluated. */
51 private boolean dontEnter;
52
53 /** Local variables in the scope of this function. */
54 private final VarScope vs;
55 /** Non-local variable bindings. */
56 private final Map<Var, Expr> global;
57
58 /**
59 * Constructor.
60 * @param info input info (can be {@code null})
61 * @param expr function body
62 * @param params parameters
63 * @param anns annotations
64 * @param vs scope
65 * @param global bindings for non-local variables
66 */
67 public Closure(final InputInfo info, final Expr expr, final Params params, final AnnList anns,
68 final VarScope vs, final Map<Var, Expr> global) {
69 this(info, expr, params.vars(), anns, vs, global, params.seqType(), null);
70 }
71
72 /**
73 * Package-private constructor allowing a name.
74 * @param info input info (can be {@code null})
75 * @param expr function expression
76 * @param params parameters
77 * @param anns annotations
78 * @param vs variable scope
79 * @param global bindings for non-local variables (can be {@code null})
80 * @param declType declared type (can be {@code null})
81 * @param name function name (can be {@code null})
82 */
83 Closure(final InputInfo info, final Expr expr, final Var[] params, final AnnList anns,
84 final VarScope vs, final Map<Var, Expr> global, final SeqType declType, final QNm name) {
85 super(info, expr, Types.FUNCTION_O);
86 this.params = params;
87 this.anns = anns;
88 this.vs = vs;
89 this.global = global == null ? new HashMap<>() : new HashMap<>(global);
90 this.declType = declType == null || declType.eq(Types.ITEM_ZM) ? null : declType;
91 this.name = name;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected