From b55cebf36cfba78e2914cbbdf2192dec3656f23d Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Thu, 29 Feb 2024 16:31:19 +0100 Subject: [PATCH] removed diagnostics code and added some info to the overflow error --- .../exceptions/RascalStackOverflowError.java | 12 +++++++++++- .../interpreter/result/RascalFunction.java | 13 +------------ src/org/rascalmpl/semantics/dynamic/Expression.java | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/org/rascalmpl/exceptions/RascalStackOverflowError.java b/src/org/rascalmpl/exceptions/RascalStackOverflowError.java index 80c65cccb42..2abd8326f7c 100644 --- a/src/org/rascalmpl/exceptions/RascalStackOverflowError.java +++ b/src/org/rascalmpl/exceptions/RascalStackOverflowError.java @@ -26,10 +26,12 @@ public class RascalStackOverflowError extends RuntimeException { private static final long serialVersionUID = -3947588548271683963L; private final Environment deepestEnvironment; private final AbstractAST currentAST; + private final int depth; - public RascalStackOverflowError(AbstractAST current, Environment deepest) { + public RascalStackOverflowError(AbstractAST current, Environment deepest, int depth) { this.deepestEnvironment = deepest; this.currentAST = current; + this.depth = depth; } public Throw makeThrow() { @@ -43,4 +45,12 @@ public Throw makeThrow() { return RuntimeExceptionFactory.stackOverflow(currentAST, trace); } + + public Environment getEnvironment() { + return deepestEnvironment; + } + + public int getDepth() { + return depth; + } } diff --git a/src/org/rascalmpl/interpreter/result/RascalFunction.java b/src/org/rascalmpl/interpreter/result/RascalFunction.java index b1a2c57c2b3..629c3f4eeb3 100644 --- a/src/org/rascalmpl/interpreter/result/RascalFunction.java +++ b/src/org/rascalmpl/interpreter/result/RascalFunction.java @@ -40,6 +40,7 @@ import org.rascalmpl.ast.Statement; import org.rascalmpl.ast.Type.Structured; import org.rascalmpl.exceptions.ImplementationError; +import org.rascalmpl.exceptions.RascalStackOverflowError; import org.rascalmpl.exceptions.RuntimeExceptionFactory; import org.rascalmpl.interpreter.Accumulator; import org.rascalmpl.interpreter.IEvaluator; @@ -304,18 +305,6 @@ public Result call(Type[] actualStaticTypes, IValue[] actuals, Map 0) { - // trace.add(env.getLocation(), env.getName()); - // env = env.getCallerScope(); - // } - - throw new RuntimeException("hello"); - } } matchers[0].initMatch(makeResult(actualStaticTypesTuple.getFieldType(0), actuals[0], ctx)); diff --git a/src/org/rascalmpl/semantics/dynamic/Expression.java b/src/org/rascalmpl/semantics/dynamic/Expression.java index d4dce5267a6..fbb35caf223 100644 --- a/src/org/rascalmpl/semantics/dynamic/Expression.java +++ b/src/org/rascalmpl/semantics/dynamic/Expression.java @@ -546,7 +546,7 @@ public Result interpret(IEvaluator> eval) { } catch (StackOverflowError e) { // this should not use so much stack as to trigger another StackOverflowError - throw new RascalStackOverflowError(this, eval.getCurrentEnvt()); + throw new RascalStackOverflowError(this, eval.getCurrentEnvt(), eval.getCallNesting()); } return res; }