01: // Copyright (c) 2003 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.kawa.xml;
05:
06: import gnu.bytecode.*;
07: import gnu.mapping.*;
08: import gnu.expr.*;
09: import gnu.kawa.functions.AppendValues;
10:
11: /** Get the union of two node lists.
12: * Implements the XQuery '|' or 'union' operator.
13: */
14:
15: public class UnionNodes extends Procedure2 implements Inlineable {
16: public static final UnionNodes unionNodes = new UnionNodes();
17:
18: public Object apply2(Object vals1, Object vals2) {
19: SortedNodes nodes = new SortedNodes();
20: Values.writeValues(vals1, nodes);
21: Values.writeValues(vals2, nodes);
22: return nodes;
23: }
24:
25: public void compile(ApplyExp exp, Compilation comp, Target target) {
26: exp = new ApplyExp(AppendValues.appendValues, exp.getArgs());
27: ConsumerTarget.compileUsingConsumer(exp, comp, target,
28: SortNodes.makeSortedNodesMethod, null);
29: }
30:
31: public Type getReturnType(Expression[] args) {
32: return Compilation.typeObject;
33: }
34:
35: }
|