diff --git a/src/main/java/de/tla2bAst/Translator.java b/src/main/java/de/tla2bAst/Translator.java index 3249a7e8f5150ed3d4d91bd8a8c919a6016c83c2..7fe4d4f57e5e090a39729522385bd0b3c012c828 100644 --- a/src/main/java/de/tla2bAst/Translator.java +++ b/src/main/java/de/tla2bAst/Translator.java @@ -39,15 +39,10 @@ import java.util.List; import java.util.stream.Collectors; public class Translator implements TranslationGlobals { - private String moduleFileName; private String parentPath; private File moduleFile; private File configFile; private List<File> moduleFiles = new ArrayList<>(); - private Start BAst; - private Map<Node, TLAType> types; - - private Definitions bDefinitions; private BAstCreator bAstCreator; @@ -59,8 +54,6 @@ public class Translator implements TranslationGlobals { private TypeChecker typechecker; public Translator(String moduleFileName) throws TLA2BFrontEndException { - this.moduleFileName = moduleFileName; - this.moduleFile = new File(moduleFileName); if (!moduleFile.exists()) { throw new RuntimeException("Can not find module file: '" + moduleFileName + "'"); @@ -119,7 +112,6 @@ public class Translator implements TranslationGlobals { try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(moduleFile.toPath()), StandardCharsets.UTF_8))) { out.write(moduleString); } - moduleFileName = moduleFile.getAbsolutePath(); } catch (IOException e) { e.printStackTrace(); } @@ -212,11 +204,9 @@ public class Translator implements TranslationGlobals { new BMacroHandler(specAnalyser, conEval), new RecursiveFunctionHandler(specAnalyser)); - this.types = bAstCreator.getTypes(); - this.bDefinitions = bAstCreator.getBDefinitions(); this.moduleFiles = bAstCreator.getFilesOrderedById().stream() .map(file -> new File(parentPath, file + ".tla")).collect(Collectors.toList()); - return this.BAst = bAstCreator.getStartNode(); + return getBAST(); } public void createProbFile() { @@ -249,15 +239,12 @@ public class Translator implements TranslationGlobals { } public void createMachineFile() { - String bFile = FileUtils.removeExtension(moduleFile.getAbsolutePath()); - bFile = bFile + "_tla.txt"; + String bFile = FileUtils.removeExtension(moduleFile.getAbsolutePath()) + "_tla.txt"; - File machineFile; - machineFile = new File(bFile); + File machineFile = new File(bFile); if (machineFile.exists()) { try { - BufferedReader in; - in = new BufferedReader(new FileReader(machineFile)); + BufferedReader in = new BufferedReader(new FileReader(machineFile)); String firstLine = in.readLine(); in.close(); if (firstLine != null && !firstLine.startsWith("/*@ generated by TLA2B ")) { @@ -280,7 +267,7 @@ public class Translator implements TranslationGlobals { PrettyPrinter pp = new PrettyPrinter(); pp.setRenaming(new SuffixIdentifierRenaming()); - BAst.apply(pp); + getBAST().apply(pp); String result = "/*@ generated by TLA2B " + VERSION_NUMBER + " */\n" + pp.getPrettyPrint(); try { @@ -336,7 +323,7 @@ public class Translator implements TranslationGlobals { } public Definitions getBDefinitions() { - return bDefinitions; + return bAstCreator.getBDefinitions(); } public ModuleNode getModuleNode() { @@ -352,7 +339,7 @@ public class Translator implements TranslationGlobals { } public Start getBAST() { - return BAst; + return bAstCreator.getStartNode(); } public File getModuleFile() { @@ -364,7 +351,7 @@ public class Translator implements TranslationGlobals { } public Map<Node, TLAType> getTypes() { - return this.types; + return bAstCreator.getTypes(); } }