diff --git a/prism/src/parser/ast/ModulesFile.java b/prism/src/parser/ast/ModulesFile.java index 8636361c..1a23383b 100644 --- a/prism/src/parser/ast/ModulesFile.java +++ b/prism/src/parser/ast/ModulesFile.java @@ -26,6 +26,7 @@ package parser.ast; +import java.nio.file.Path; import java.util.*; import param.BigRational; @@ -75,6 +76,9 @@ public class ModulesFile extends ASTElement implements ModelInfo // Actual values of (some or all) constants private Values constantValues; + /** (Optional) The location (file) from which this ModulesFile was obtained */ + private Path location; + // Constructor public ModulesFile() @@ -1217,6 +1221,25 @@ public class ModulesFile extends ASTElement implements ModelInfo return new VarList(this); } + /** + * Sets the path to the file underlying this ModulesFile, + * or {@code null} to designate "unknown". + */ + public void setLocation(Path location) + { + // System.err.println("Model: " + location); + this.location = location; + } + + /** + * Returns the path to the file underlying this ModulesFile, if known. + * Returns {@code null} otherwise. + */ + public Path getLocation() + { + return location; + } + // Methods required for ASTElement: /** @@ -1333,7 +1356,10 @@ public class ModulesFile extends ASTElement implements ModelInfo ret.varNames = (varNames == null) ? null : (Vector)varNames.clone(); ret.varTypes = (varTypes == null) ? null : (Vector)varTypes.clone(); ret.constantValues = (constantValues == null) ? null : new Values(constantValues); - + + // a Path is immutable, no need for deep-copy + ret.location = location; + return ret; } } diff --git a/prism/src/parser/ast/PropertiesFile.java b/prism/src/parser/ast/PropertiesFile.java index e0666363..f5db9fab 100644 --- a/prism/src/parser/ast/PropertiesFile.java +++ b/prism/src/parser/ast/PropertiesFile.java @@ -26,6 +26,7 @@ package parser.ast; +import java.nio.file.Path; import java.util.*; import parser.*; @@ -55,6 +56,9 @@ public class PropertiesFile extends ASTElement // actual values of (some or all) constants private Values constantValues; + /** (Optional) The location (file) from which this PropertiesFile was obtained */ + private Path location; + // Constructor public PropertiesFile(ModelInfo modelInfo) @@ -623,6 +627,25 @@ public class PropertiesFile extends ASTElement return constantValues; } + /** + * Sets the path to the file underlying this PropertiesFile, + * or {@code null} to designate "unknown". + */ + public void setLocation(Path location) + { + // System.err.println("Properties: " + location); + this.location = location; + } + + /** + * Returns the path to the file underlying this PropertiesFile, if known. + * Returns {@code null} otherwise. + */ + public Path getLocation() + { + return location; + } + // Methods required for ASTElement: /** @@ -689,6 +712,9 @@ public class PropertiesFile extends ASTElement ret.allIdentsUsed = (allIdentsUsed == null) ? null : (Vector) allIdentsUsed.clone(); ret.constantValues = (constantValues == null) ? null : new Values(constantValues); + // a Path is immutable, no need for deep-copy + ret.location = location; + return ret; } }