KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jruby > compiler > ArrayNodeArgsCompiler


1 /*
2  * ArrayNodeArgsCompiler.java
3  *
4  * Created on January 3, 2007, 6:51 PM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
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 JavaDoc context) {
26         context.lineNumber(node.getPosition());
27         
28         ArrayNode arrayNode = (ArrayNode)node;
29         
30         ArrayCallback callback = new ArrayCallback() {
31             public void nextValue(Compiler JavaDoc context, Object JavaDoc sourceArray, int index) {
32                 Node node = (Node)((Object JavaDoc[])sourceArray)[index];
33                 NodeCompilerFactory.getCompiler(node).compile(node, context);
34             }
35         };
36         
37         context.createObjectArray(arrayNode.childNodes().toArray(), callback);
38         // leave as a normal array
39
}
40     
41 }
42
Popular Tags