From bf59b2c9f7c7cc75a8ef1bf8db7e029b5aa4f4e7 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Tue, 8 Dec 2015 00:15:08 +0000 Subject: [PATCH] Fix bug from new ModelInfo stuff: shows up when PropertiesFile model info is null (e.g. from GUI). git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11017 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/parser/ast/PropertiesFile.java | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/prism/src/parser/ast/PropertiesFile.java b/prism/src/parser/ast/PropertiesFile.java index 13254ee0..050bf4aa 100644 --- a/prism/src/parser/ast/PropertiesFile.java +++ b/prism/src/parser/ast/PropertiesFile.java @@ -74,16 +74,18 @@ public class PropertiesFile extends ASTElement /** Attach model information (so can access labels/constants etc.) */ public void setModelInfo(ModelInfo modelInfo) { - // Store ModelInfo - this.modelInfo = modelInfo; - // If the ModelInfo is not a ModulesFile, we need to create a balnk one - if (modelInfo instanceof ModulesFile) { - this.modulesFile = (ModulesFile) modelInfo; + // Store ModelInfo. Need a ModulesFile too for now. Create a dummy one if needed. + if (modelInfo == null) { + this.modelInfo = this.modulesFile = new ModulesFile(); + this.modulesFile.setFormulaList(new FormulaList()); + this.modulesFile.setConstantList(new ConstantList()); + } else if (modelInfo instanceof ModulesFile) { + this.modelInfo = this.modulesFile = (ModulesFile) modelInfo; } else { - ModulesFile mf = new ModulesFile(); - mf.setFormulaList(new FormulaList()); - mf.setConstantList(new ConstantList()); - this.modulesFile = mf; + this.modelInfo = modelInfo; + this.modulesFile = new ModulesFile(); + this.modulesFile.setFormulaList(new FormulaList()); + this.modulesFile.setConstantList(new ConstantList()); } } @@ -295,7 +297,7 @@ public class PropertiesFile extends ASTElement findAllPropRefs(null, this); // Check property references for cyclic dependencies findCyclesInPropertyReferences(); - + // Various semantic checks doSemanticChecks(); // Type checking @@ -462,7 +464,7 @@ public class PropertiesFile extends ASTElement PropertiesSemanticCheck visitor = new PropertiesSemanticCheck(this, modelInfo); accept(visitor); } - + /** * Get a list of all undefined constants in the properties files * ("const int x;" rather than "const int x = 1;")