summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-07-15 12:08:58 +0000
committerpaltherr <paltherr@epfl.ch>2003-07-15 12:08:58 +0000
commit3279825ba3936a9d1f9c7a953fb23d604177fd7c (patch)
tree2efe96372e99c09cb7390cee8f9c2bd519b1b7bb
parent8b025da06474598c54300264e472a6461d7b025f (diff)
downloadscala-3279825ba3936a9d1f9c7a953fb23d604177fd7c.tar.gz
scala-3279825ba3936a9d1f9c7a953fb23d604177fd7c.tar.bz2
scala-3279825ba3936a9d1f9c7a953fb23d604177fd7c.zip
- Fixed interepreter trace code to handle excep...
- Fixed interepreter trace code to handle exceptions raised by the interpreter itsef (internal errors, for example assertion errors).
-rw-r--r--sources/scala/tools/scalai/Evaluator.java19
-rw-r--r--sources/scala/tools/scalai/EvaluatorException.java10
2 files changed, 26 insertions, 3 deletions
diff --git a/sources/scala/tools/scalai/Evaluator.java b/sources/scala/tools/scalai/Evaluator.java
index d418d7aa7a..1444eec8ac 100644
--- a/sources/scala/tools/scalai/Evaluator.java
+++ b/sources/scala/tools/scalai/Evaluator.java
@@ -105,9 +105,20 @@ public class Evaluator {
}
public Object evaluate(CodeContainer code, Object object, Object[] args) {
+ return trace(code, object, args);
+ }
+
+ //########################################################################
+ // Private Methods - trace
+
+ private Object trace(CodeContainer code, Object object, Object[] args) {
try {
stack = new EvaluationStack(stack, code, object, args);
return evaluate(code.code);
+ } catch (EvaluatorException exception) {
+ throw exception;
+ } catch (Throwable exception) {
+ return throw_(exception, "trace");
} finally {
stack = stack.stack;
}
@@ -163,6 +174,8 @@ public class Evaluator {
if (stack != null)
exception.addScalaCall(stack.symbol, stack.source, pos);
throw exception;
+// } catch (Throwable exception) {
+// return abort(exception);
}
case Create(ScalaTemplate template):
@@ -441,12 +454,16 @@ public class Evaluator {
// Private Methods - throw
private Object throw_(Throwable exception) {
+ return throw_(exception, null);
+ }
+
+ private Object throw_(Throwable exception, String method) {
if (exception.getCause() != null && (
exception instanceof ExceptionInInitializerError ||
exception instanceof InvocationTargetException))
exception = exception.getCause();
if (trace.getCause() != exception) trace.reset(exception);
- trace.addScalaLeavePoint();
+ trace.addScalaLeavePoint(getClass().getName(), method);
throw trace;
}
diff --git a/sources/scala/tools/scalai/EvaluatorException.java b/sources/scala/tools/scalai/EvaluatorException.java
index dc8c1fa905..a0d9f3e80d 100644
--- a/sources/scala/tools/scalai/EvaluatorException.java
+++ b/sources/scala/tools/scalai/EvaluatorException.java
@@ -71,10 +71,10 @@ public class EvaluatorException extends RuntimeException {
while (traceAtStartsWith(entry, "$Proxy")) entry++;
}
- public void addScalaLeavePoint() {
+ public void addScalaLeavePoint(String clasz, String method) {
// find leave point
int leave = entry;
- while (leave < trace.length && !traceAtStartsWith(leave, "scalai."))
+ while (leave < trace.length && !traceAtEquals(leave, clasz, method))
leave++;
if (leave < trace.length) {
// skip calls through reflection
@@ -106,6 +106,12 @@ public class EvaluatorException extends RuntimeException {
//########################################################################
// Private Methods
+ private boolean traceAtEquals(int index, String clasz, String method) {
+ if (index < 0 || trace.length <= index) return false;
+ if (!trace[index].getClassName().equals(clasz)) return false;
+ return method == null || trace[index].getMethodName().equals(method);
+ }
+
private boolean traceAtStartsWith(int index, String prefix) {
if (index < 0 || trace.length <= index) return false;
return trace[index].getClassName().startsWith(prefix);