|
1 |
| package edu.rice.cs.javalanglevels.tree; |
|
2 |
| |
|
3 |
| import edu.rice.cs.javalanglevels.SourceInfo; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| public class TryCatchFinallyStatement extends TryCatchStatement { |
|
11 |
| private final Block _finallyBlock; |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
17
| public TryCatchFinallyStatement(SourceInfo in_sourceInfo, Block in_tryBlock, CatchBlock[] in_catchBlocks, Block in_finallyBlock) {
|
|
18 |
17
| super(in_sourceInfo, in_tryBlock, in_catchBlocks);
|
|
19 |
| |
|
20 |
17
| if (in_finallyBlock == null) {
|
|
21 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'finallyBlock' to the TryCatchFinallyStatement constructor was null. This class may not have null field values.");
|
|
22 |
| } |
|
23 |
17
| _finallyBlock = in_finallyBlock;
|
|
24 |
| } |
|
25 |
| |
|
26 |
24
| final public Block getFinallyBlock() { return _finallyBlock; }
|
|
27 |
| |
|
28 |
22
| public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forTryCatchFinallyStatement(this); }
|
|
29 |
0
| public void visit(JExpressionIFVisitor_void visitor) { visitor.forTryCatchFinallyStatement(this); }
|
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
0
| public java.lang.String toString() {
|
|
36 |
0
| java.io.StringWriter w = new java.io.StringWriter();
|
|
37 |
0
| output(w);
|
|
38 |
0
| return w.toString();
|
|
39 |
| } |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
0
| public void output(java.io.Writer writer) {
|
|
45 |
0
| outputHelp(new TabPrintWriter(writer, 2));
|
|
46 |
| } |
|
47 |
| |
|
48 |
2
| public void outputHelp(TabPrintWriter writer) {
|
|
49 |
2
| writer.print("TryCatchFinallyStatement" + ":");
|
|
50 |
2
| writer.indent();
|
|
51 |
| |
|
52 |
2
| writer.startLine("");
|
|
53 |
2
| writer.print("sourceInfo = ");
|
|
54 |
2
| SourceInfo temp_sourceInfo = getSourceInfo();
|
|
55 |
2
| if (temp_sourceInfo == null) {
|
|
56 |
0
| writer.print("null");
|
|
57 |
| } else { |
|
58 |
2
| writer.print(temp_sourceInfo);
|
|
59 |
| } |
|
60 |
| |
|
61 |
2
| writer.startLine("");
|
|
62 |
2
| writer.print("tryBlock = ");
|
|
63 |
2
| Block temp_tryBlock = getTryBlock();
|
|
64 |
2
| if (temp_tryBlock == null) {
|
|
65 |
0
| writer.print("null");
|
|
66 |
| } else { |
|
67 |
2
| temp_tryBlock.outputHelp(writer);
|
|
68 |
| } |
|
69 |
| |
|
70 |
2
| writer.startLine("");
|
|
71 |
2
| writer.print("catchBlocks = ");
|
|
72 |
2
| writer.print("{");
|
|
73 |
2
| writer.indent();
|
|
74 |
2
| for (int i = 0; i < getCatchBlocks().length; i++) {
|
|
75 |
2
| CatchBlock temp_catchBlocks = getCatchBlocks()[i];
|
|
76 |
2
| writer.startLine("#" + i + ": ");
|
|
77 |
2
| if (temp_catchBlocks == null) {
|
|
78 |
0
| writer.print("null");
|
|
79 |
| } else { |
|
80 |
2
| temp_catchBlocks.outputHelp(writer);
|
|
81 |
| } |
|
82 |
| } |
|
83 |
2
| writer.unindent();
|
|
84 |
2
| if (getCatchBlocks().length > 0) {
|
|
85 |
2
| writer.startLine("");
|
|
86 |
| } |
|
87 |
2
| writer.print("}");
|
|
88 |
| |
|
89 |
2
| writer.startLine("");
|
|
90 |
2
| writer.print("finallyBlock = ");
|
|
91 |
2
| Block temp_finallyBlock = getFinallyBlock();
|
|
92 |
2
| if (temp_finallyBlock == null) {
|
|
93 |
0
| writer.print("null");
|
|
94 |
| } else { |
|
95 |
2
| temp_finallyBlock.outputHelp(writer);
|
|
96 |
| } |
|
97 |
2
| writer.unindent();
|
|
98 |
| } |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
0
| public boolean equals(java.lang.Object obj) {
|
|
106 |
0
| if (obj == null) return false;
|
|
107 |
0
| if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
|
|
108 |
0
| return false;
|
|
109 |
| } else { |
|
110 |
0
| TryCatchFinallyStatement casted = (TryCatchFinallyStatement) obj;
|
|
111 |
0
| if (! (getTryBlock().equals(casted.getTryBlock()))) return false;
|
|
112 |
0
| if (this.getCatchBlocks().length != casted.getCatchBlocks().length) return false;
|
|
113 |
0
| for (int i = 0; i < getCatchBlocks().length; i++) if (! getCatchBlocks()[i].equals(casted.getCatchBlocks()[i])) return false;
|
|
114 |
0
| if (! (getFinallyBlock().equals(casted.getFinallyBlock()))) return false;
|
|
115 |
0
| return true;
|
|
116 |
| } |
|
117 |
| } |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
0
| protected int generateHashCode() {
|
|
126 |
0
| int code = getClass().hashCode();
|
|
127 |
0
| code ^= 0;
|
|
128 |
0
| code ^= getTryBlock().hashCode();
|
|
129 |
0
| for (int i = 0; i < getCatchBlocks().length; i++) code ^= getCatchBlocks()[i].hashCode();
|
|
130 |
0
| code ^= getFinallyBlock().hashCode();
|
|
131 |
0
| return code;
|
|
132 |
| } |
|
133 |
| } |