UnionNodes.java 1010 B

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