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:
10: /** Coerces an item sequence to a node sequence.
11: * Uses the Nodes class to do the actual work. */
12:
13: public class CoerceNodes extends Procedure1 implements Inlineable {
14: public static final CoerceNodes coerceNodes = new CoerceNodes();
15:
16: public Object apply1(Object values) {
17: Nodes nodes = new Nodes();
18: Values.writeValues(values, nodes);
19: return nodes;
20: }
21:
22: public void compile(ApplyExp exp, Compilation comp, Target target) {
23: Expression[] args = exp.getArgs();
24: if (args.length != 1)
25: ApplyExp.compile(exp, comp, target);
26: else
27: ConsumerTarget.compileUsingConsumer(args[0], comp, target,
28: makeNodesMethod, null);
29: }
30:
31: public Type getReturnType(Expression[] args) {
32: return typeNodes;
33: }
34:
35: public static final ClassType typeNodes = ClassType
36: .make("gnu.kawa.xml.Nodes");
37: public static final Method makeNodesMethod = typeNodes
38: .getDeclaredMethod("<init>", 0);
39:
40: }
|