Browse Source

ConstantList: add constructor from Values object

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11547 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 10 years ago
parent
commit
aa3ec454a8
  1. 20
      prism/src/parser/ast/ConstantList.java

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

@ -49,12 +49,28 @@ public class ConstantList extends ASTElement
// This is to just to provide positional info.
private Vector<ExpressionIdent> nameIdents = new Vector<ExpressionIdent>();
// Constructor
/** Constructor */
public ConstantList()
{
}
/** Constructor from a Values object, i.e., a list of name=value tuples */
public ConstantList(Values constValues) throws PrismLangException
{
for (int i = 0; i < constValues.getNumValues(); i++) {
Type type = constValues.getType(i);
if (type.equals(TypeBool.getInstance()) ||
type.equals(TypeInt.getInstance()) ||
type.equals(TypeDouble.getInstance())) {
addConstant(new ExpressionIdent(constValues.getName(i)),
new ExpressionLiteral(type, constValues.getValue(i)),
type);
} else {
throw new PrismLangException("Unsupported type for constant " + constValues.getName(i));
}
}
}
// Set methods
public void addConstant(ExpressionIdent n, Expression c, Type t)

Loading…
Cancel
Save