KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > jjs > ast > JTryStatement


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
21
22 /**
23  * Java try statement.
24  */

25 public class JTryStatement extends JStatement {
26
27   private final List JavaDoc catchArgs;
28   private final List JavaDoc catchBlocks;
29   private final JBlock finallyBlock;
30   private final JBlock tryBlock;
31
32   public JTryStatement(JProgram program, SourceInfo info, JBlock tryBlock,
33       List JavaDoc/* <JLocalRef> */catchArgs, List JavaDoc/* <JBlock> */catchBlocks,
34       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 JavaDoc getCatchArgs() {
44     return catchArgs;
45   }
46
47   public List JavaDoc/* <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 }
72
Popular Tags