summaryrefslogtreecommitdiff
path: root/boil/TypeFactory.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-26 15:50:38 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-26 15:50:38 -0600
commit1851f5e76018ec1df3b55dce6cc9a64c9497bf7a (patch)
tree30f629f7b137a494d4202487f4e22df2d9456481 /boil/TypeFactory.java
parent012298517078170762112abe2654dc69b2f146e1 (diff)
Rearrange directory structure
Diffstat (limited to 'boil/TypeFactory.java')
-rw-r--r--boil/TypeFactory.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/boil/TypeFactory.java b/boil/TypeFactory.java
new file mode 100644
index 0000000..d5b61f3
--- /dev/null
+++ b/boil/TypeFactory.java
@@ -0,0 +1,51 @@
+package boil;
+
+import misc.*;
+import java.util.HashMap;
+
+public class TypeFactory {
+
+ private int type_num;
+ private HashMap<String,String> map;
+
+ public void reset() {
+ this.type_num = 0;
+ this.map = new HashMap<>();
+ }
+
+ public String alias(String t) {
+ /**
+ * Given a TypeInstance, return the designated
+ * vapor alias. If the alias does not exist, create it.
+ */
+ String alias;
+ if ((alias = this.map.get(t)) == null) {
+ alias = String.format("t.%d", this.type_num++);
+ MinimalLogger.info(String.format("Created alias %s for %s...",
+ alias,
+ t));
+
+ this.map.put(t, alias);
+ }
+
+ return alias;
+ }
+
+ public String retrieveRecentList(int x) {
+ /**
+ * Given int x, retrieve a space-delimited
+ * list of the x most recent entries.
+ */
+ String rtn = "";
+ if (x > 0) {
+ rtn += String.format("t.%d",
+ type_num-x);
+ for (int i = type_num-(x-1); i < type_num; ++i) {
+ rtn += String.format(" t.%d",
+ i);
+ }
+ }
+
+ return rtn;
+ }
+}