| 1 | package CodeGeneration; |
| 2 | |
| 3 | public class PCode { |
| 4 | private CodeType type; |
| 5 | private Object value1 = null; |
| 6 | private Object value2 = null; |
| 7 | |
| 8 | public PCode(CodeType type) { |
| 9 | this.type = type; |
| 10 | } |
| 11 | |
| 12 | public PCode(CodeType type, Object value1) { |
| 13 | this.type = type; |
| 14 | this.value1 = value1; |
| 15 | } |
| 16 | |
| 17 | public PCode(CodeType type, Object value1, Object value2) { |
| 18 | this.type = type; |
| 19 | this.value1 = value1; |
| 20 | this.value2 = value2; |
| 21 | } |
| 22 | |
| 23 | public void setValue2(Object value2) { |
| 24 | this.value2 = value2; |
| 25 | } |
| 26 | |
| 27 | public CodeType getType() { |
| 28 | return type; |
| 29 | } |
| 30 | |
| 31 | public Object getValue1() { |
| 32 | return value1; |
| 33 | } |
| 34 | |
| 35 | public Object getValue2() { |
| 36 | return value2; |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public String toString() { |
| 41 | if (type.equals(CodeType.LABEL)) { |
| 42 | return value1.toString() + ": "; |
| 43 | } |
| 44 | if (type.equals(CodeType.FUNC)) { |
| 45 | return "FUNC @" + value1.toString() + ":"; |
| 46 | } |
| 47 | if (type.equals(CodeType.CALL)) { |
| 48 | return "$" + value1.toString(); |
| 49 | } |
| 50 | if (type.equals(CodeType.PRINT)) { |
| 51 | return type + " " + value1; |
| 52 | } |
| 53 | String a = value1 != null ? value1.toString() : ""; |
| 54 | String b = value2 != null ? ", " + value2.toString() : ""; |
| 55 | return type + " " + a + b; |
| 56 | } |
| 57 | } |
nothing calls this directly
no outgoing calls
no test coverage detected