1 9 10 package org.jruby.compiler; 11 12 import org.jruby.ast.ArrayNode; 13 import org.jruby.ast.Node; 14 15 19 public class ArrayNodeCompiler implements NodeCompiler { 20 21 22 public ArrayNodeCompiler() { 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, int index) { 32 Node node = (Node)((Object [])sourceArray)[index]; 33 NodeCompilerFactory.getCompiler(node).compile(node, context); 34 } 35 }; 36 37 context.createObjectArray(arrayNode.childNodes().toArray(), callback); 38 context.createNewArray(); 39 } 40 } 41 | Popular Tags |