From 158f8ef180d4ea448b351599529db53ff5e88f8c Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Wed, 19 Jul 2017 20:24:40 +0200 Subject: Starting a Java implementation of ast-to-instr. Keeping things clean, this time. --- ast-to-instr/src/Strings.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ast-to-instr/src/Strings.java (limited to 'ast-to-instr/src/Strings.java') diff --git a/ast-to-instr/src/Strings.java b/ast-to-instr/src/Strings.java new file mode 100644 index 0000000..bc1778f --- /dev/null +++ b/ast-to-instr/src/Strings.java @@ -0,0 +1,30 @@ +import java.util.Map; +import java.util.HashMap; + +public class Strings +{ + private static final Map TO_ID; + + static + { + TO_ID = new HashMap(); + } + + private Strings () {} /* Utility class. */ + + public static IDs get_id_from_string (final String string) + { + IDs result; + + result = TO_ID.get(string); + + if (result == null) + { + result = IDs.generate_new_id("string"); + + TO_ID.put(string, result); + } + + return result; + } +} -- cgit v1.2.3-70-g09d2