KickJava   Java API By Example, From Geeks To Geeks.

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


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 expr;
37   * @child Expr expr
38   */

39 public class ExprStmt extends Stmt {
40
41     public void unparse(CodeWriter writer) throws IOException JavaDoc {
42         writer.write(expr);
43         writer.closeStmt();
44     }
45
46     public void checkSpec() {
47         if (!expr.isLegalStmt()) {
48             showError("not a statement");
49         }
50     }
51
52     // ------------------------------
53
// INTRO from FlowCheckerPass
54

55     public void walkFlow(FlowCheckerPass w) {
56         w.process(getExpr());
57     }
58
59     // ------------------------------
60
// bcg
61

62     protected void cgStmt(CodeBuilder cb) {
63         expr.cgEffect(cb);
64     }
65
66     //BEGIN: Generated from @child and @property
67
protected Expr expr;
68     public Expr getExpr() { return expr; }
69     public void setExpr(Expr _expr) {
70         if (_expr != null) _expr.setParent(this);
71         expr = _expr;
72     }
73
74     public ExprStmt(SourceLocation location, Expr _expr) {
75         super(location);
76         setExpr(_expr);
77     }
78     protected ExprStmt(SourceLocation source) {
79         super(source);
80     }
81
82     public ASTObject copyWalk(CopyWalker walker) {
83         ExprStmt ret = new ExprStmt(getSourceLocation());
84         ret.preCopy(walker, this);
85         if (expr != null) ret.setExpr( (Expr)walker.process(expr) );
86         return ret;
87     }
88
89     public ASTObject getChildAt(int childIndex) {
90         switch(childIndex) {
91         case 0: return expr;
92         default: return super.getChildAt(childIndex);
93         }
94     }
95      public String JavaDoc getChildNameAt(int childIndex) {
96         switch(childIndex) {
97         case 0: return "expr";
98         default: return super.getChildNameAt(childIndex);
99         }
100     }
101      public void setChildAt(int childIndex, ASTObject child) {
102         switch(childIndex) {
103         case 0: setExpr((Expr)child); return;
104         default: super.setChildAt(childIndex, child); return;
105         }
106     }
107      public int getChildCount() {
108         return 1;
109     }
110
111     public String JavaDoc getDefaultDisplayName() {
112         return "ExprStmt()";
113     }
114
115     //END: Generated from @child and @property
116
}
117
118
119
Popular Tags