summaryrefslogtreecommitdiff
path: root/vaporize/library/Kettle.java
blob: 2590d4b2e9bfb89c04fe2a48303a62a98f845c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
    }
}