01: /*
02: * ArrayNodeArgsCompiler.java
03: *
04: * Created on January 3, 2007, 6:51 PM
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package org.jruby.compiler;
11:
12: import org.jruby.ast.ArrayNode;
13: import org.jruby.ast.Node;
14:
15: /**
16: *
17: * @author headius
18: */
19: public class ArrayNodeArgsCompiler implements NodeCompiler {
20:
21: /** Creates a new instance of ArrayNodeArgsCompiler */
22: public ArrayNodeArgsCompiler() {
23: }
24:
25: public void compile(Node node, Compiler context) {
26: context.lineNumber(node.getPosition());
27:
28: ArrayNode arrayNode = (ArrayNode) node;
29:
30: ArrayCallback callback = new ArrayCallback() {
31: public void nextValue(Compiler context, Object sourceArray,
32: int index) {
33: Node node = (Node) ((Object[]) sourceArray)[index];
34: NodeCompilerFactory.getCompiler(node).compile(node,
35: context);
36: }
37: };
38:
39: context.createObjectArray(arrayNode.childNodes().toArray(),
40: callback);
41: // leave as a normal array
42: }
43:
44: }
|