01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.jjs.ast;
17:
18: import com.google.gwt.dev.jjs.SourceInfo;
19:
20: import java.util.List;
21:
22: /**
23: * Java try statement.
24: */
25: public class JTryStatement extends JStatement {
26:
27: private final List<JLocalRef> catchArgs;
28: private final List<JBlock> catchBlocks;
29: private final JBlock finallyBlock;
30: private final JBlock tryBlock;
31:
32: public JTryStatement(JProgram program, SourceInfo info,
33: JBlock tryBlock, List<JLocalRef> catchArgs,
34: List<JBlock> catchBlocks, JBlock finallyBlock) {
35: super (program, info);
36: assert (catchArgs.size() == catchBlocks.size());
37: this .tryBlock = tryBlock;
38: this .catchArgs = catchArgs;
39: this .catchBlocks = catchBlocks;
40: this .finallyBlock = finallyBlock;
41: }
42:
43: public List<JLocalRef> getCatchArgs() {
44: return catchArgs;
45: }
46:
47: public List<JBlock> getCatchBlocks() {
48: return catchBlocks;
49: }
50:
51: public JBlock getFinallyBlock() {
52: return finallyBlock;
53: }
54:
55: public JBlock getTryBlock() {
56: return tryBlock;
57: }
58:
59: public void traverse(JVisitor visitor, Context ctx) {
60: if (visitor.visit(this , ctx)) {
61: visitor.accept(tryBlock);
62: visitor.accept(catchArgs);
63: visitor.accept(catchBlocks);
64: // TODO: normalize this so it's never null?
65: if (finallyBlock != null) {
66: visitor.accept(finallyBlock);
67: }
68: }
69: visitor.endVisit(this, ctx);
70: }
71: }
|