[Swift-commit] cog r3428

swift at ci.uchicago.edu swift at ci.uchicago.edu
Sat Jul 14 01:10:05 CDT 2012


------------------------------------------------------------------------
r3428 | hategan | 2012-07-14 01:05:34 -0500 (Sat, 14 Jul 2012) | 1 line

fixed stack trace and made FlowNode.getTextualName public
------------------------------------------------------------------------
Index: modules/karajan/src/org/globus/cog/karajan/stack/LinkedStack.java
===================================================================
--- modules/karajan/src/org/globus/cog/karajan/stack/LinkedStack.java	(revision 3427)
+++ modules/karajan/src/org/globus/cog/karajan/stack/LinkedStack.java	(working copy)
@@ -274,7 +274,7 @@
 	public VariableStack copy() {
 		return new LinkedStack(this);
 	}
-
+	
 	public String toString() {
 		StringBuffer buf = new StringBuffer();
 		buf.append("Stack dump:\n");
@@ -364,9 +364,7 @@
 			if (caller != null) {
 				l.add(caller);
 			}
-			else {
-				crt = crt.prev;
-			}
+			crt = crt.prev;
 		}
 		return l;
 	}
Index: modules/karajan/src/org/globus/cog/karajan/stack/Trace.java
===================================================================
--- modules/karajan/src/org/globus/cog/karajan/stack/Trace.java	(revision 3427)
+++ modules/karajan/src/org/globus/cog/karajan/stack/Trace.java	(working copy)
@@ -9,6 +9,9 @@
  */
 package org.globus.cog.karajan.stack;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.globus.cog.karajan.workflow.nodes.FlowElement;
 import org.globus.cog.karajan.workflow.nodes.FlowNode;
 
@@ -16,31 +19,37 @@
 public class Trace {
 	public static final String ELEMENT = "#trace:element";
 	
+	public static List<Object> getAsList(VariableStack stack) {
+	    List<Object> l = new ArrayList<Object>();
+	    boolean first = true;
+        for (int li = stack.frameCount() - 1; li >= 0; li--) {
+            StackFrame frame = stack.getFrame(li);
+            Object caller = frame.getRegs().getCaller();
+            if (first) {
+                if (caller != null) {
+                    l.add(caller);
+                    first = false;
+                }
+            }
+            else {
+                if (frame.isDefined(ELEMENT)) {
+                    l.add(frame.getVar(ELEMENT));
+                }
+                else if (caller != null) {
+                    l.add(caller);
+                }
+            }
+        }
+        return l;
+	}
+	
 	public static String get(VariableStack stack) {
 		StringBuffer buf = new StringBuffer();
-		boolean first = true;
-		for (int li = stack.frameCount() - 1; li >= 0; li--) {
-			StackFrame frame = stack.getFrame(li);
-			if (first) {
-				if (frame.isDefined("#caller")) {
-					buf.append('\t');
-					buf.append(frame.getVar("#caller"));
-					buf.append('\n');
-					first = false;
-				}
-			}
-			else {
-				if (frame.isDefined(ELEMENT)) {
-					buf.append('\t');
-					buf.append(frame.getVar(ELEMENT));
-					buf.append('\n');
-				}
-				else if (frame.isDefined("#caller")) {
-					buf.append('\t');
-					buf.append(frame.getVar("#caller"));
-					buf.append('\n');
-				}
-			}
+		List<Object> l = getAsList(stack);
+		for (Object o : l) {
+			buf.append('\t');
+			buf.append(o);
+			buf.append('\n');
 		}
 		return buf.toString();
 	}
Index: modules/karajan/src/org/globus/cog/karajan/workflow/nodes/FlowNode.java
===================================================================
--- modules/karajan/src/org/globus/cog/karajan/workflow/nodes/FlowNode.java	(revision 3427)
+++ modules/karajan/src/org/globus/cog/karajan/workflow/nodes/FlowNode.java	(working copy)
@@ -332,7 +332,7 @@
 		return sb.toString();
 	}
 
-	protected String getTextualName() {
+	public String getTextualName() {
 		String tmp = getElementType();
 		if (tmp == null) {
 			tmp = this.getClass().getName();



More information about the Swift-commit mailing list