| (0001124) koreth
 05-12-06 15:25
 
 
 | I decided to have a whack at implementing this; here's what I added to ErrorModule.java. This is functional enough for our code but isn't really a complete implementation. 
 
 /**
 * Returns the active stack of function calls.
 */
 public static Value debug_backtrace(Env env)
 throws Exception
 {
 Value array = new ArrayValueImpl();
 Expr frame;
 int depth = 0;
 
 while ((frame = env.peekCall(depth++)) != null)
 {
 ArrayValue thisFunction = new ArrayValueImpl();
 Location location = frame.getLocation();
 String temp;
 
 if (location != null)
 {
 temp = location.getFunctionName();
 if (temp != null)
 thisFunction.put("function", temp);
 thisFunction.put("line", location.getLineNumber());
 temp = location.getFileName();
 if (temp != null)
 thisFunction.put("file", temp);
 temp = location.getClassName();
 if (temp != null)
 thisFunction.put("class", temp);
 // XXX - no way to populate "type" or "args"
 }
 else
 {
 thisFunction.put("function", "?");
 thisFunction.put("file", frame.getFunctionLocation());
 thisFunction.put("line", "");
 }
 
 array.put(thisFunction);
 }
 return array;
 }
 |