KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > base > ast > BreakStmt


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the compiler and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

24
25 package org.aspectj.compiler.base.ast;
26
27 import org.aspectj.compiler.base.*;
28 import org.aspectj.compiler.base.JavaCompiler;
29 import org.aspectj.compiler.base.CodeWriter;
30 import java.io.IOException JavaDoc;
31
32 import org.aspectj.compiler.base.bcg.CodeBuilder;
33 import org.aspectj.compiler.base.bcg.Label;
34
35 /**
36   * @grammar break label?
37   * @property String label
38   */

39 public class BreakStmt extends Stmt {
40
41     public void unparse(CodeWriter writer) throws IOException JavaDoc {
42         writer.writeKeyword("break");
43         if (label != null) {
44             writer.requiredSpace();
45             writer.write(label);
46         }
47         writer.closeStmt();
48     }
49
50     // ------------------------------
51
// INTRO from FlowCheckerPass
52

53     public void walkFlow(FlowCheckerPass w) {
54         try {
55             w.doBreak(getLabel());
56         } catch (java.util.NoSuchElementException JavaDoc e) {
57             if (getLabel() == null)
58                 showError("break outside of switch or loop");
59             else
60                 showError("undefined label: " + getLabel());
61         }
62         w.setLive(false);
63         w.setVars(w.getAllVars());
64     }
65
66     // ------------------------------
67
// INTRO from ByteCodeCleanupPass
68

69     public void walkCleanup(ByteCodeCleanupPass w) {
70         w.doBreak(getLabel());
71         w.setLive(false);
72     }
73
74     // ------------------------------
75
// bcg
76

77     protected void cgStmt(CodeBuilder cb) {
78         cb.doBreak(label);
79     }
80     // do not register a line number for me, since often I won't have a bytecode
81
protected void registerLocation(CodeBuilder cb) { }
82
83     //BEGIN: Generated from @child and @property
84
protected String JavaDoc label;
85     public String JavaDoc getLabel() { return label; }
86     public void setLabel(String JavaDoc _label) { label = _label; }
87
88     public BreakStmt(SourceLocation location, String JavaDoc _label) {
89         super(location);
90         setLabel(_label);
91     }
92     protected BreakStmt(SourceLocation source) {
93         super(source);
94     }
95
96     public ASTObject copyWalk(CopyWalker walker) {
97         BreakStmt ret = new BreakStmt(getSourceLocation());
98         ret.preCopy(walker, this);
99         ret.label = label;
100         return ret;
101     }
102
103
104     public String JavaDoc getDefaultDisplayName() {
105         return "BreakStmt(label: "+label+")";
106     }
107
108     //END: Generated from @child and @property
109
}
110
111
112
Popular Tags