Browse Source

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
master
Dave Parker 14 years ago
parent
commit
bf59e25a49
  1. 4
      prism/src/parser/ast/ASTElement.java
  2. 2
      prism/src/parser/ast/PropertiesFile.java
  3. 7
      prism/src/parser/visitor/GetAllUndefinedConstantsRecursively.java

4
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<String> getAllUndefinedConstantsRecursively(ConstantList constantList, LabelList labelList)
{

2
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<String> getUndefinedConstantsUsedInLabels()
{

7
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) {

Loading…
Cancel
Save