1 30 package com.genimen.djeneric.tools.scriptengine.core.nodes; 31 32 import java.util.HashMap ; 33 import java.util.Iterator ; 34 35 import com.genimen.djeneric.tools.scriptengine.core.DjScriptParserEngine; 36 import com.genimen.djeneric.tools.scriptengine.core.SimpleNode; 37 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptCompileTimeScope; 38 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptExecutionException; 39 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptExecutionTimeScope; 40 import com.genimen.djeneric.tools.scriptengine.core.util.Variable; 41 42 public class ConstructorNode extends SimpleNode 43 { 44 45 public ConstructorNode(int i) 46 { 47 super(i); 48 } 49 50 public ConstructorNode(DjScriptParserEngine p, int i) 51 { 52 super(p, i); 53 } 54 55 public String getName() 56 { 57 return "constructor"; 58 } 59 60 public String getNodeTitle() 61 { 62 return "Constructor"; 63 } 64 65 public String toString() 66 { 67 return getName(); 68 } 69 70 public void execute(DjScriptExecutionTimeScope ctxt) throws DjScriptExecutionException 71 { 72 BodyNode body = (BodyNode) getChild(BodyNode.class); 73 74 body.executeButKeepStack(ctxt); 76 } 77 78 public void declareGlobals(DjScriptCompileTimeScope ctxt) throws DjScriptExecutionException 79 { 80 HashMap vars = new HashMap (); 81 collectVariables(ctxt, vars, -1); 82 Iterator it = vars.keySet().iterator(); 83 while (it.hasNext()) 84 { 85 String key = it.next().toString(); 86 ctxt.pushVariable(new Variable(key, null, (String ) vars.get(key))); 87 } 88 } 89 90 } | Popular Tags |