aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/Expression.java
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-09-11 13:43:10 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-09-11 14:22:37 +0000
commit90a159670963ff30eda0c05af565ebee3812de60 (patch)
tree45929142c20660bf0967af9f050438cc26370a09 /src/main/java/com/google/devtools/build/lib/syntax/Expression.java
parent6a832d042d53a448bf7e7c89a72a01b66d7aac6a (diff)
Fixed Skylark stack trace:
- Moved registration mechanism from BaseFunction into ASTNode / Statement / Expression - Added more details about statements/expressions to the output trace (including if's) - Fixed wrong locations -- MOS_MIGRATED_REVID=102841164
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/Expression.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/Expression.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Expression.java b/src/main/java/com/google/devtools/build/lib/syntax/Expression.java
index 1886843e86..f23746ad7e 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Expression.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Expression.java
@@ -36,8 +36,26 @@ public abstract class Expression extends ASTNode {
* @return the result of evaluting the expression: a Java object corresponding
* to a datatype in the BUILD language.
* @throws EvalException if the expression could not be evaluated.
+ * @throws InterruptedException may be thrown in a sub class.
*/
- abstract Object eval(Environment env) throws EvalException, InterruptedException;
+ final Object eval(Environment env) throws EvalException, InterruptedException {
+ try {
+ return doEval(env);
+ } catch (EvalException | RuntimeException ex) {
+ throw handleException(ex);
+ }
+ }
+
+ /**
+ * Evaluates the expression and returns the result.
+ *
+ * <p>This method is only invoked by the super class {@link Expression} when calling {@link
+ * #eval(Environment)}.
+ *
+ * @throws EvalException if the expression could not be evaluated
+ * @throws InterruptedException may be thrown in a sub class.
+ */
+ abstract Object doEval(Environment env) throws EvalException, InterruptedException;
/**
* Returns the inferred type of the result of the Expression.