From 52dc54df5b94761498b7db5c3dd5323c1a4eab58 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Tue, 9 Aug 2016 18:26:27 +0000 Subject: [PATCH] ConstantList: methods for removing a constant definition git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11595 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/parser/ast/ConstantList.java | 32 +++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/prism/src/parser/ast/ConstantList.java b/prism/src/parser/ast/ConstantList.java index 05ff0012..c10f9a04 100644 --- a/prism/src/parser/ast/ConstantList.java +++ b/prism/src/parser/ast/ConstantList.java @@ -121,9 +121,39 @@ public class ConstantList extends ASTElement return names.indexOf(s); } + /** + * Remove the constant with the given name. + * @param name the name of the constant + * @param ignoreNonexistent if true, don't throw an exception if the constant does not exist + * @throws PrismLangException if the constant does not exist (if not ignoreNonexistent) + */ + public void removeConstant(String name, boolean ignoreNonexistent) throws PrismLangException + { + int constantIndex = getConstantIndex(name); + if (constantIndex == -1) { + if (ignoreNonexistent) { + return; + } + throw new PrismLangException("Can not remove nonexistent constant: " + name); + } + removeConstant(constantIndex); + } + + /** + * Remove the constant with the given index. + * @param i the index + */ + public void removeConstant(int i) + { + names.remove(i); + constants.remove(i); + types.remove(i); + nameIdents.remove(i); + } + /** * Find cyclic dependencies. - */ + */ public void findCycles() throws PrismLangException { // Create boolean matrix of dependencies