summaryrefslogtreecommitdiff
path: root/vaporize/library/Kettle.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-19 19:04:01 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-19 19:04:01 -0600
commit66ffeaf968bd332f1e18cb27aad11b50e4dd0eab (patch)
treec0d52e8e82590c0656f915610b5a7027a6abd057 /vaporize/library/Kettle.java
parente98ca14483fb531c41d51677cc7075a0b8e6bd55 (diff)
Switched to use of Logger Module
Diffstat (limited to 'vaporize/library/Kettle.java')
-rw-r--r--vaporize/library/Kettle.java52
1 files changed, 38 insertions, 14 deletions
diff --git a/vaporize/library/Kettle.java b/vaporize/library/Kettle.java
index 340d53e..fb9ddc4 100644
--- a/vaporize/library/Kettle.java
+++ b/vaporize/library/Kettle.java
@@ -1,6 +1,11 @@
package vaporize.library;
+import java.util.logging.Logger;
+import java.util.logging.ConsoleHandler;
+
import cs132.vapor.ast.*;
+import misc.*;
+
import java.util.ArrayList;
/**
@@ -12,9 +17,17 @@ import java.util.ArrayList;
*/
class Kettle {
+ private static Logger log = Logger.getLogger(Kettle.class.getName());
+ private static ConsoleHandler consoleHandler = new ConsoleHandler();
+ static {
+ consoleHandler.setFormatter(new MinimalSimpleFormatter());
+ log.addHandler(consoleHandler);
+ }
+
ArrayList<String> vapor;
protected Kettle(ArrayList<String> vapor) {
+ log.info("Pouring program into kettle...");
this.vapor = vapor;
}
@@ -27,12 +40,31 @@ class Kettle {
protected void replaceFunctionDeclare(VFunction prev, int in,
int out, int local) {
- this.set(prev,
- String.format("func %s [in %d, out %d, local %d]",
- this.parseFuncName(this.get(prev)),
- in,
- out,
- local));
+ /**
+ * Replaces a function declaraction in the program
+ * with the vapor equivalent.
+ */
+ String next = String.format("func %s [in %d, out %d, local %d]",
+ this.parseFuncName(prev),
+ in,
+ out,
+ local);
+
+ log.info(String.format("Replacing function declaraction\n%s\nwith\n%s",
+ this.get(prev),
+ next));
+
+ this.set(prev, next);
+ }
+
+ protected String parseFuncName(VFunction func) {
+ /**
+ * Helper for replaceFunctionDeclare
+ * "func A_foo(this t.1)" -> "A_foo"
+ */
+ String str = this.get(func);
+ int openParenIndex = str.indexOf('(');
+ return str.substring(5, openParenIndex).trim();
}
protected String spill() {
@@ -59,12 +91,4 @@ class Kettle {
this.vapor.set(this.indexOf(n), s);
}
- private static String parseFuncName(String func) {
- /**
- * "func A_foo(this t.1)" -> "A_foo"
- */
- int openParenIndex = func.indexOf('(');
- return func.substring(5, openParenIndex);
- }
-
}