Skip to content
Snippets Groups Projects
Commit 674247d7 authored by Jan Gruteser's avatar Jan Gruteser
Browse files

use one util method for declaration map

parent b26ab680
Branches
Tags
No related merge requests found
...@@ -147,12 +147,10 @@ public class SpecAnalyser extends BuiltInOPs { ...@@ -147,12 +147,10 @@ public class SpecAnalyser extends BuiltInOPs {
} }
findRecursiveConstructs(); findRecursiveConstructs();
for (OpDeclNode var : moduleNode.getVariableDecls()) { namingMap.putAll(TlaUtils.getDeclarationsMap(moduleNode.getVariableDecls()));
namingMap.put(var.getName().toString(), var);
}
DebugUtils.printMsg("Number of variables detected: " + moduleNode.getVariableDecls().length); DebugUtils.printMsg("Number of variables detected: " + moduleNode.getVariableDecls().length);
namingMap.putAll(TlaUtils.getConstantsMap(moduleNode.getConstantDecls())); namingMap.putAll(TlaUtils.getDeclarationsMap(moduleNode.getConstantDecls()));
DebugUtils.printMsg("Number of constants detected: " + moduleNode.getConstantDecls().length); DebugUtils.printMsg("Number of constants detected: " + moduleNode.getConstantDecls().length);
namingMap.putAll(TlaUtils.getOpDefsMap(usedDefinitions.toArray(new OpDefNode[0]))); namingMap.putAll(TlaUtils.getOpDefsMap(usedDefinitions.toArray(new OpDefNode[0])));
......
...@@ -58,7 +58,7 @@ public class ConfigfileEvaluator { ...@@ -58,7 +58,7 @@ public class ConfigfileEvaluator {
this.configAst = configAst; this.configAst = configAst;
this.moduleNode = moduleNode; this.moduleNode = moduleNode;
this.definitions = TlaUtils.getOpDefsMap(moduleNode.getOpDefs()); this.definitions = TlaUtils.getOpDefsMap(moduleNode.getOpDefs());
this.constants = TlaUtils.getConstantsMap(moduleNode.getConstantDecls()); this.constants = TlaUtils.getDeclarationsMap(moduleNode.getConstantDecls());
this.bConstantList.addAll(constants.values()); this.bConstantList.addAll(constants.values());
this.nextNode = evalPredicate(configAst.getNext(), "next state"); // check if NEXT declaration is a valid definition this.nextNode = evalPredicate(configAst.getNext(), "next state"); // check if NEXT declaration is a valid definition
......
...@@ -8,12 +8,12 @@ import java.util.Map; ...@@ -8,12 +8,12 @@ import java.util.Map;
public class TlaUtils { public class TlaUtils {
public static Map<String, OpDeclNode> getConstantsMap(OpDeclNode[] constantNodes) { public static Map<String, OpDeclNode> getDeclarationsMap(OpDeclNode[] declNodes) {
Map<String, OpDeclNode> constants = new HashMap<>(); Map<String, OpDeclNode> decl = new HashMap<>();
for (OpDeclNode con : constantNodes) { for (OpDeclNode con : declNodes) {
constants.put(con.getName().toString(), con); decl.put(con.getName().toString(), con);
} }
return constants; return decl;
} }
public static Map<String, OpDefNode> getOpDefsMap(OpDefNode[] opDefNodes) { public static Map<String, OpDefNode> getOpDefsMap(OpDefNode[] opDefNodes) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment