From bf59e25a49e4698f0662900129d8f98294297581 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Thu, 13 Oct 2011 21:59:11 +0000 Subject: [PATCH] Fixed a bug in getAllUndefinedConstantsRecursively. Showed up when running auto in embedded example. Bug found by Janne Kauttio. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@3983 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/parser/ast/ASTElement.java | 4 +++- prism/src/parser/ast/PropertiesFile.java | 2 +- .../visitor/GetAllUndefinedConstantsRecursively.java | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/prism/src/parser/ast/ASTElement.java b/prism/src/parser/ast/ASTElement.java index fdb387de..2ecfd45d 100644 --- a/prism/src/parser/ast/ASTElement.java +++ b/prism/src/parser/ast/ASTElement.java @@ -271,7 +271,9 @@ public abstract class ASTElement /** * Get all undefined constants used (i.e. in ExpressionConstant objects) recursively and return as a list. - * Recursive decent means that we find e.g. constants that are used within other constants, labels. + * Recursive descent means that we find e.g. constants that are used within other constants, labels. + * But note that we only look at/for constants in the passed in ConstantList. + * Any others discovered are ignored (and not descended into). */ public Vector getAllUndefinedConstantsRecursively(ConstantList constantList, LabelList labelList) { diff --git a/prism/src/parser/ast/PropertiesFile.java b/prism/src/parser/ast/PropertiesFile.java index ebd36208..9d36d703 100644 --- a/prism/src/parser/ast/PropertiesFile.java +++ b/prism/src/parser/ast/PropertiesFile.java @@ -366,7 +366,7 @@ public class PropertiesFile extends ASTElement /** * Get a list of undefined (properties file) constants appearing in labels of the properties file - * (undefined constants are those of form "const int x;" rather than "const int x = 1;") + * (undefined constants are those of form "const int x;" rather than "const int x = 1;") */ public Vector getUndefinedConstantsUsedInLabels() { diff --git a/prism/src/parser/visitor/GetAllUndefinedConstantsRecursively.java b/prism/src/parser/visitor/GetAllUndefinedConstantsRecursively.java index 329f599e..b76ad0cc 100644 --- a/prism/src/parser/visitor/GetAllUndefinedConstantsRecursively.java +++ b/prism/src/parser/visitor/GetAllUndefinedConstantsRecursively.java @@ -33,7 +33,9 @@ import prism.PrismLangException; /** * Get all undefined constants used (i.e. in ExpressionConstant objects) recursively and return as a list. - * Recursive decent means that we find e.g. constants that are used within other constants, labels. + * Recursive descent means that we find e.g. constants that are used within other constants, labels. + * But note that we only look at/for constants in the passed in ConstantList. + * Any others discovered are ignored (and not descended into). */ public class GetAllUndefinedConstantsRecursively extends ASTTraverse { @@ -52,8 +54,9 @@ public class GetAllUndefinedConstantsRecursively extends ASTTraverse { // Look up this constant in the constant list int i = constantList.getConstantIndex(e.getName()); + // Ignore constants not in the list if (i == -1) - throw new PrismLangException("Unknown constant \"" + e.getName() + "\""); + return; Expression expr = constantList.getConstant(i); // If constant is undefined, add to the list if (expr == null) {