summaryrefslogtreecommitdiff
path: root/src/spiglet/spiglet2kanga/SpgSimpExpr.java
blob: 9b7d98ad8ddb3e510f974b8d3b93d1a057655a27 (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
package spiglet.spiglet2kanga;

import java.util.HashSet;

public class SpgSimpExpr extends SpgExpr {
	public enum SExprType { TEMP, INT, LB };
	SExprType type;
	public int num;
	public String s;
	
	public SpgSimpExpr(SExprType t) {
		super(SpgExpr.ExpType.Simple);
		type = t;
	}
	
	public String toString() {
		switch (type) {
		case INT:
			return String.valueOf(num);
		case LB:
			return s;
		case TEMP:
			return ((SpgTemp)this).toString();
		default:
			return null;
		
		}
	}
	
	public HashSet<SpgTemp> getTmpUsed() {
		if (this instanceof SpgTemp) {
			HashSet<SpgTemp> s = new HashSet<SpgTemp>();
			s.add((SpgTemp)this);
			return s;
		} else {
			return null;
		}
	}
}