[Swift-commit] r3263 - trunk/src/org/griphyn/vdl/karajan/lib/swiftscript

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Thu Mar 18 13:21:11 CDT 2010


Author: wozniak
Date: 2010-03-18 13:21:11 -0500 (Thu, 18 Mar 2010)
New Revision: 3263

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
Log:
New tracef() %q specifier for arrays. 


Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2010-03-18 16:15:19 UTC (rev 3262)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2010-03-18 18:21:11 UTC (rev 3263)
@@ -2,6 +2,9 @@
 
 import java.io.IOException;
 
+import java.util.Collection;
+import java.util.List;
+import java.util.Stack;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -14,8 +17,10 @@
 import org.griphyn.vdl.karajan.lib.SwiftArg;
 import org.griphyn.vdl.karajan.lib.VDLFunction;
 import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.HandleOpenException;
 import org.griphyn.vdl.mapping.InvalidPathException;
 import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.ArrayDataNode;
 import org.griphyn.vdl.mapping.RootArrayDataNode;
 import org.griphyn.vdl.mapping.RootDataNode;
 import org.griphyn.vdl.type.NoSuchTypeException;
@@ -164,6 +169,31 @@
 	            throw new ExecutionException("tracef(): %i requires an int!");
 	        }
 	    }
+	    else if (c == 'q') {
+	        if (args[arg] instanceof ArrayDataNode) {
+	            ArrayDataNode node = (ArrayDataNode) args[arg];
+	            output.append("[");
+	            try {
+	                Stack stack = new Stack();
+                    Collection children = args[arg].getFields(Path.CHILDREN);
+                    for (Object o : children) 
+                        stack.push(o);
+                    while (!stack.empty()) {
+                        DSHandle child = (DSHandle) stack.pop();
+                        output.append(child);
+                        if (!stack.empty())
+                            output.append(",");
+                    }
+                }
+                catch (Exception e) {
+                    throw new ExecutionException("trace(%q): Could not get children of: " + args[arg]);
+                }
+                output.append("]");
+	        }
+	        else {
+	            throw new ExecutionException("tracef(): %q requires an array!");
+	        }
+	    }
 	    else if (c == 'k') {
 	        ;
 	    }




More information about the Swift-commit mailing list