01: /*
02: * @(#)ControlEnv.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution of
07: * this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.compiler;
10:
11: import pnuts.lang.PnutsParserTreeConstants;
12: import java.util.Stack;
13:
14: class ControlEnv {
15: Label breakLabel;
16: Label continueLabel;
17: Stack finallyBlocks;
18: ControlEnv parent;
19:
20: ControlEnv(int id, ControlEnv parent) {
21: this .parent = parent;
22: if (parent != null) {
23: finallyBlocks = parent.finallyBlocks;
24: if (id == PnutsParserTreeConstants.JJTSWITCHSTATEMENT) {
25: continueLabel = parent.continueLabel;
26: }
27: } else {
28: finallyBlocks = new Stack();
29: }
30: }
31:
32: void pushFinallyBlock(Label label) {
33: finallyBlocks.push(label);
34: }
35:
36: Label popFinallyBlock() {
37: if (finallyBlocks.size() > 0) {
38: return (Label) finallyBlocks.pop();
39: } else {
40: return null;
41: }
42: }
43: }
|