summaryrefslogtreecommitdiff
path: root/vaporize/library/Kettle.java
diff options
context:
space:
mode:
Diffstat (limited to 'vaporize/library/Kettle.java')
-rw-r--r--vaporize/library/Kettle.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/vaporize/library/Kettle.java b/vaporize/library/Kettle.java
new file mode 100644
index 0000000..2590d4b
--- /dev/null
+++ b/vaporize/library/Kettle.java
@@ -0,0 +1,43 @@
+package vaporize.library;
+
+import cs132.vapor.ast.*;
+import java.util.ArrayList;
+
+/**
+ * This class contains various generic methods for
+ * assembling common-use vaporm strings.
+ *
+ * Robert Martin cries
+ */
+class Kettle {
+
+ ArrayList<String> vapor;
+
+ protected Kettle(ArrayList<String> vapor) {
+ this.vapor = vapor;
+ }
+
+ protected String indexOriginal(Node n) {
+ /**
+ * Given the source position of a Node, returns the original line.
+ */
+ return this.vapor.get(n.sourcePos.line-1);
+ }
+
+ protected String functionParameters(VFunction prev, int in,
+ int out, int local) {
+ return String.format("func %s [in %d, out %d, local %d]",
+ this.indexOriginal(prev).split(" ")[1],
+ in,
+ out,
+ local);
+ }
+
+ protected String spill() {
+ return null;
+ }
+
+ protected String backup() {
+ return null;
+ }
+}