From d05bd3592050a9496dd87bcd8a49f8fdc8b6b58d Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 21 Jul 2017 16:50:25 +0200 Subject: Adds output support. --- ast-to-instr/src/Strings.java | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'ast-to-instr/src/Strings.java') diff --git a/ast-to-instr/src/Strings.java b/ast-to-instr/src/Strings.java index 5657cac..67189ad 100644 --- a/ast-to-instr/src/Strings.java +++ b/ast-to-instr/src/Strings.java @@ -4,15 +4,31 @@ import java.util.HashMap; public class Strings { private static final Map TO_ID; + private static final OutputFile STRING_MAP_OUTPUT; static { TO_ID = new HashMap(); + + /* TODO: filename as a param? */ + STRING_MAP_OUTPUT = OutputFile.new_output_file("string_to_instr.map"); } private Strings () {} /* Utility class. */ - public static IDs get_id_from_string (String string) + public static IDs get_id_from_string + ( + String string + ) + { + return get_id_from_string(Main.get_main_output(), string); + } + + public static IDs get_id_from_string + ( + final OutputFile output, + String string + ) { IDs result; @@ -21,19 +37,16 @@ public class Strings if (result == null) { - result = IDs.generate_new_id("string"); + result = IDs.generate_new_id(output, "string"); TO_ID.put(string, result); - /* TODO: remove, it's for debug. */ - System.out.println - ( - "[STR] (\"" - + string - + "\"->" - + result.get_value() - + ")" - ); + STRING_MAP_OUTPUT.write("(string->instr \""); + STRING_MAP_OUTPUT.write(string); + STRING_MAP_OUTPUT.write("\" "); + STRING_MAP_OUTPUT.write(Integer.toString(result.get_value())); + STRING_MAP_OUTPUT.write(")"); + STRING_MAP_OUTPUT.insert_newline(); } return result; -- cgit v1.2.3-70-g09d2