diff --git a/prism/src/parser/ast/ConstantList.java b/prism/src/parser/ast/ConstantList.java index 2cfe6ed5..57f097fd 100644 --- a/prism/src/parser/ast/ConstantList.java +++ b/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 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. diff --git a/prism/src/parser/ast/ModulesFile.java b/prism/src/parser/ast/ModulesFile.java index 4f9a069e..ac51e38f 100644 --- a/prism/src/parser/ast/ModulesFile.java +++ b/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)}. diff --git a/prism/src/parser/ast/PropertiesFile.java b/prism/src/parser/ast/PropertiesFile.java index 4472af18..1a14d8e3 100644 --- a/prism/src/parser/ast/PropertiesFile.java +++ b/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)}