From 435e365c89352a3f3c180ccfd1dd90faccf296c7 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 1 Aug 2018 22:21:32 -0400 Subject: [PATCH] Code tidying in parser/ast/Declaration classes. --- prism/src/parser/ast/Declaration.java | 2 +- prism/src/parser/ast/DeclarationBool.java | 26 ++++--------------- prism/src/parser/ast/DeclarationClock.java | 25 ++---------------- prism/src/parser/ast/DeclarationInt.java | 25 ++---------------- .../parser/ast/DeclarationIntUnbounded.java | 25 ++---------------- prism/src/parser/ast/DeclarationType.java | 2 +- 6 files changed, 13 insertions(+), 92 deletions(-) diff --git a/prism/src/parser/ast/Declaration.java b/prism/src/parser/ast/Declaration.java index 7cb5a29c..cc689540 100644 --- a/prism/src/parser/ast/Declaration.java +++ b/prism/src/parser/ast/Declaration.java @@ -94,7 +94,7 @@ public class Declaration extends ASTElement /** * Get the specified initial value of this variable, - * using the default value for its type if not specified. + * using the default value for its type if not specified. */ public Expression getStartOrDefault() { diff --git a/prism/src/parser/ast/DeclarationBool.java b/prism/src/parser/ast/DeclarationBool.java index 03f0bbea..cc0b262f 100644 --- a/prism/src/parser/ast/DeclarationBool.java +++ b/prism/src/parser/ast/DeclarationBool.java @@ -41,43 +41,27 @@ public class DeclarationBool extends DeclarationType setType(TypeBool.getInstance()); } - /** - * Return the default start value for a variable of this type. - */ + @Override public Expression getDefaultStart() { return Expression.False(); } - /*TODO - public Expression getStart(ModulesFile parent) - { - if (parent != null && parent.getInitialStates() != null) - return null; - - return start != null ? start : Expression.False(); - }*/ - + // Methods required for ASTElement: - /** - * Visitor method. - */ + @Override public Object accept(ASTVisitor v) throws PrismLangException { return v.visit(this); } - /** - * Convert to string. - */ + @Override public String toString() { return "bool"; } - /** - * Perform a deep copy. - */ + @Override public ASTElement deepCopy() { DeclarationBool ret = new DeclarationBool(); diff --git a/prism/src/parser/ast/DeclarationClock.java b/prism/src/parser/ast/DeclarationClock.java index bbfa9d01..acdcfa5a 100644 --- a/prism/src/parser/ast/DeclarationClock.java +++ b/prism/src/parser/ast/DeclarationClock.java @@ -40,47 +40,26 @@ public class DeclarationClock extends DeclarationType setType(TypeClock.getInstance()); } - /** - * Return the default start value for a variable of this type. - */ + @Override public Expression getDefaultStart() { return Expression.Double(0); } - /* TODO: - @Override - public Expression getStart(ModulesFile parent) - { - if (parent != null && parent.getInitialStates() != null) - return null; - - return start != null ? start : low; - } - */ - // Methods required for ASTElement: - /** - * Visitor method. - */ + @Override public Object accept(ASTVisitor v) throws PrismLangException { return v.visit(this); } - /** - * Convert to string. - */ @Override public String toString() { return "clock"; } - /** - * Perform a deep copy. - */ @Override public ASTElement deepCopy() { diff --git a/prism/src/parser/ast/DeclarationInt.java b/prism/src/parser/ast/DeclarationInt.java index 00163bd6..5fe31860 100644 --- a/prism/src/parser/ast/DeclarationInt.java +++ b/prism/src/parser/ast/DeclarationInt.java @@ -68,47 +68,26 @@ public class DeclarationInt extends DeclarationType return high; } - /** - * Return the default start value for a variable of this type. - */ + @Override public Expression getDefaultStart() { return low; } - /* TODO: - @Override - public Expression getStart(ModulesFile parent) - { - if (parent != null && parent.getInitialStates() != null) - return null; - - return start != null ? start : low; - } - */ - // Methods required for ASTElement: - /** - * Visitor method. - */ + @Override public Object accept(ASTVisitor v) throws PrismLangException { return v.visit(this); } - /** - * Convert to string. - */ @Override public String toString() { return "[" + low + ".." + high + "]"; } - /** - * Perform a deep copy. - */ @Override public ASTElement deepCopy() { diff --git a/prism/src/parser/ast/DeclarationIntUnbounded.java b/prism/src/parser/ast/DeclarationIntUnbounded.java index 0da204f0..911e53f4 100644 --- a/prism/src/parser/ast/DeclarationIntUnbounded.java +++ b/prism/src/parser/ast/DeclarationIntUnbounded.java @@ -40,47 +40,26 @@ public class DeclarationIntUnbounded extends DeclarationType setType(TypeInt.getInstance()); } - /** - * Return the default start value for a variable of this type. - */ + @Override public Expression getDefaultStart() { return Expression.Int(0); } - /* TODO: - @Override - public Expression getStart(ModulesFile parent) - { - if (parent != null && parent.getInitialStates() != null) - return null; - - return start != null ? start : low; - } - */ - // Methods required for ASTElement: - /** - * Visitor method. - */ + @Override public Object accept(ASTVisitor v) throws PrismLangException { return v.visit(this); } - /** - * Convert to string. - */ @Override public String toString() { return "int"; } - /** - * Perform a deep copy. - */ @Override public ASTElement deepCopy() { diff --git a/prism/src/parser/ast/DeclarationType.java b/prism/src/parser/ast/DeclarationType.java index 31b7d6ad..a3a5b8dc 100644 --- a/prism/src/parser/ast/DeclarationType.java +++ b/prism/src/parser/ast/DeclarationType.java @@ -30,7 +30,7 @@ package parser.ast; public abstract class DeclarationType extends ASTElement { /** - * Return the default start value for a variable of this type. + * Return the default start value for a variable of this type, as an Expression. */ public abstract Expression getDefaultStart(); }