Browse Source

New isDefinedConstant methods (+ code tidy).

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@3437 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 15 years ago
parent
commit
3723afae6c
  1. 26
      prism/src/parser/ast/ConstantList.java
  2. 9
      prism/src/parser/ast/ModulesFile.java
  3. 9
      prism/src/parser/ast/PropertiesFile.java

26
prism/src/parser/ast/ConstantList.java

@ -32,8 +32,10 @@ import parser.*;
import parser.visitor.*;
import prism.PrismLangException;
import parser.type.*;
// class to store list of constants
/**
* Class to store list of (defined and undefined) constants
*/
public class ConstantList extends ASTElement
{
// Name/expression/type triples to define constants
@ -173,8 +175,9 @@ public class ConstantList extends ASTElement
}
}
// get number of undefined constants
/**
* Get the number of undefined constants in the list.
*/
public int getNumUndefined()
{
int i, n, res;
@ -192,8 +195,9 @@ public class ConstantList extends ASTElement
return res;
}
// get undefined constants
/**
* Get a list of the undefined constants in the list.
*/
public Vector<String> getUndefinedConstants()
{
int i, n;
@ -212,6 +216,18 @@ public class ConstantList extends ASTElement
return v;
}
/**
* Check if {@code name} is a *defined* constants in the list,
* i.e. a constant whose value was *not* left unspecified in the model/property.
*/
public boolean isDefinedConstant(String name)
{
int i = getConstantIndex(name);
if (i == -1)
return false;
return (getConstant(i) != null);
}
/**
* Set values for *all* undefined constants, evaluate values for *all* constants
* and return a Values object with values for *all* constants.

9
prism/src/parser/ast/ModulesFile.java

@ -771,6 +771,15 @@ public class ModulesFile extends ASTElement
semanticCheckAfterConstants(this, null);
}
/**
* Check if {@code name} is a *defined* constant in the model,
* i.e. a constant whose value was *not* left unspecified.
*/
public boolean isDefinedConstant(String name)
{
return constantList.isDefinedConstant(name);
}
/**
* Get access to the values for all constants in the model, including the
* undefined constants set previously via the method {@link #setUndefinedConstants(Values)}.

9
prism/src/parser/ast/PropertiesFile.java

@ -447,6 +447,15 @@ public class PropertiesFile extends ASTElement
// (and sometimes we don't want to have to define all constants)
}
/**
* Check if {@code name} is a *defined* constant in the properties file,
* i.e. a constant whose value was *not* left unspecified.
*/
public boolean isDefinedConstant(String name)
{
return constantList.isDefinedConstant(name);
}
/**
* Get access to the values for all constants in the properties file, including the
* undefined constants set previously via the method {@link #setUndefinedConstants(Values)}

Loading…
Cancel
Save