|
7 | 7 | import java.util.HashMap; |
8 | 8 |
|
9 | 9 | /** |
10 | | - * |
11 | 10 | * @author Stuart |
12 | 11 | */ |
13 | | -public abstract class CodeInfo |
14 | | -{ |
15 | | - protected static CodeInfo current = null; |
| 12 | +public abstract class CodeInfo { |
| 13 | + protected static CodeInfo current = null; |
16 | 14 |
|
17 | | - protected final HashMap<Integer, Register> usedVars; |
| 15 | + protected final HashMap<Integer, Register> usedVars; |
18 | 16 |
|
19 | | - private Label labelBreak; |
20 | | - private Label labelContinue; |
| 17 | + private Label labelBreak; |
| 18 | + private Label labelContinue; |
21 | 19 |
|
22 | | - protected CodeInfo() |
23 | | - { |
24 | | - this.usedVars = new HashMap<Integer, Register>(); |
25 | | - this.labelBreak = null; |
26 | | - this.labelContinue = null; |
27 | | - } |
| 20 | + protected CodeInfo() { |
| 21 | + this.usedVars = new HashMap<Integer, Register>(); |
| 22 | + this.labelBreak = null; |
| 23 | + this.labelContinue = null; |
| 24 | + } |
28 | 25 |
|
29 | | - /** |
30 | | - * Gets the variables used in the function. |
31 | | - * @return the variables used in the function |
32 | | - */ |
33 | | - public HashMap<Integer, Register> getUsedVars() |
34 | | - { |
35 | | - return this.usedVars; |
36 | | - } |
| 26 | + /** |
| 27 | + * Gets the variables used in the function. |
| 28 | + * |
| 29 | + * @return the variables used in the function |
| 30 | + */ |
| 31 | + public HashMap<Integer, Register> getUsedVars() { |
| 32 | + return this.usedVars; |
| 33 | + } |
37 | 34 |
|
38 | | - /** |
39 | | - * Gets the current go-to label for a "break" instruction. |
40 | | - * @return the current go-to label for a "break" instruction |
41 | | - */ |
42 | | - public Label getBreakLabel() |
43 | | - { |
44 | | - return this.labelBreak; |
45 | | - } |
| 35 | + /** |
| 36 | + * Gets the current go-to label for a "break" instruction. |
| 37 | + * |
| 38 | + * @return the current go-to label for a "break" instruction |
| 39 | + */ |
| 40 | + public Label getBreakLabel() { |
| 41 | + return this.labelBreak; |
| 42 | + } |
46 | 43 |
|
47 | | - /** |
48 | | - * Sets the current go-to label for a "break" instruction. |
49 | | - * @param labelBreak the current go-to label for a "break" instruction |
50 | | - * @return the original value |
51 | | - */ |
52 | | - public Label setBreakLabel(Label labelBreak) |
53 | | - { |
54 | | - Label old = this.labelBreak; |
55 | | - this.labelBreak = labelBreak; |
56 | | - return old; |
57 | | - } |
| 44 | + /** |
| 45 | + * Sets the current go-to label for a "break" instruction. |
| 46 | + * |
| 47 | + * @param labelBreak the current go-to label for a "break" instruction |
| 48 | + * @return the original value |
| 49 | + */ |
| 50 | + public Label setBreakLabel(Label labelBreak) { |
| 51 | + Label old = this.labelBreak; |
| 52 | + this.labelBreak = labelBreak; |
| 53 | + return old; |
| 54 | + } |
58 | 55 |
|
59 | | - /** |
60 | | - * Gets the current go-to label for a "continue" instruction. |
61 | | - * @return the current go-to label for a "continue" instruction |
62 | | - */ |
63 | | - public Label getContinueLabel() |
64 | | - { |
65 | | - return this.labelContinue; |
66 | | - } |
| 56 | + /** |
| 57 | + * Gets the current go-to label for a "continue" instruction. |
| 58 | + * |
| 59 | + * @return the current go-to label for a "continue" instruction |
| 60 | + */ |
| 61 | + public Label getContinueLabel() { |
| 62 | + return this.labelContinue; |
| 63 | + } |
67 | 64 |
|
68 | | - /** |
69 | | - * Sets the current go-to label for a "continue" instruction. |
70 | | - * @param labelBreak the current go-to label for a "continue" instruction |
71 | | - * @return the original value |
72 | | - */ |
73 | | - public Label setContinueLabel(Label labelContinue) |
74 | | - { |
75 | | - Label old = this.labelContinue; |
76 | | - this.labelContinue = labelContinue; |
77 | | - return old; |
78 | | - } |
| 65 | + /** |
| 66 | + * Sets the current go-to label for a "continue" instruction. |
| 67 | + * |
| 68 | + * @param labelBreak the current go-to label for a "continue" instruction |
| 69 | + * @return the original value |
| 70 | + */ |
| 71 | + public Label setContinueLabel(Label labelContinue) { |
| 72 | + Label old = this.labelContinue; |
| 73 | + this.labelContinue = labelContinue; |
| 74 | + return old; |
| 75 | + } |
79 | 76 |
|
80 | | - /** |
81 | | - * Adds a variable to the used variables list. |
82 | | - * @param var the variable to add |
83 | | - */ |
84 | | - public void addUsedVar(Register var) |
85 | | - { |
86 | | - Integer key = Integer.valueOf(var.getIntegerValue()); |
87 | | - if (this.usedVars.get(key) == null) |
88 | | - this.usedVars.put(key, var); |
89 | | - } |
| 77 | + /** |
| 78 | + * Adds a variable to the used variables list. |
| 79 | + * |
| 80 | + * @param var the variable to add |
| 81 | + */ |
| 82 | + public void addUsedVar(Register var) { |
| 83 | + Integer key = Integer.valueOf(var.getIntegerValue()); |
| 84 | + if (this.usedVars.get(key) == null) this.usedVars.put(key, var); |
| 85 | + } |
90 | 86 |
|
91 | | - /** |
92 | | - * Gets the current code info. |
93 | | - * @return the current code info |
94 | | - */ |
95 | | - public static CodeInfo getCurrent() |
96 | | - { |
97 | | - return current; |
98 | | - } |
| 87 | + /** |
| 88 | + * Gets the current code info. |
| 89 | + * |
| 90 | + * @return the current code info |
| 91 | + */ |
| 92 | + public static CodeInfo getCurrent() { |
| 93 | + return current; |
| 94 | + } |
99 | 95 |
|
100 | | - /** |
101 | | - * Sets the current code info. |
102 | | - * @param codeInfo the current code info |
103 | | - */ |
104 | | - public static void setCurrent(CodeInfo codeInfo) |
105 | | - { |
106 | | - current = codeInfo; |
107 | | - } |
| 96 | + /** |
| 97 | + * Sets the current code info. |
| 98 | + * |
| 99 | + * @param codeInfo the current code info |
| 100 | + */ |
| 101 | + public static void setCurrent(CodeInfo codeInfo) { |
| 102 | + current = codeInfo; |
| 103 | + } |
108 | 104 | } |
0 commit comments