KickJava   Java API By Example, From Geeks To Geeks.

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


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.FlowCheckerPass;
28 import org.aspectj.compiler.base.AssignmentCheckerPass;
29 import org.aspectj.compiler.base.JavaCompiler;
30 import org.aspectj.compiler.base.CodeWriter;
31
32 import java.util.*;
33
34 import org.aspectj.compiler.base.bcg.CodeBuilder;
35 import org.aspectj.compiler.base.bcg.Label;
36
37 /**
38  * @grammar (expr)
39  * @child Expr expr
40  *
41  */

42 public class ParenExpr extends Expr {
43
44     protected void bindNamesSelf() {
45         //setType(discoverType());
46
}
47
48     protected Type discoverType() {
49         return expr.getType();
50     }
51
52     public Expr makeReference() {
53         Expr ret = expr.makeReference();
54         if (!(ret instanceof ParenExpr)) return ret;
55         return super.makeReference();
56     }
57     
58     public boolean canBeCopied() {
59         return expr.canBeCopied();
60     }
61     
62     public boolean isUltimatelyLiteral() {
63         return expr.isUltimatelyLiteral();
64     }
65
66     public void unparse(CodeWriter writer) {
67         writer.write('(');
68         writer.write(expr);
69         writer.write(')');
70     }
71
72     // ------------------------------
73
// INTRO from AssignmentCheckerPass
74

75     public ASTObject postAssignmentCheck(AssignmentCheckerPass walker) {
76         if (expr instanceof LiteralExpr) {
77             return (LiteralExpr)expr.copy().setSource(this);
78         } else {
79             return this;
80         }
81     }
82
83     // ------------------------------
84
// bcg
85
protected void cgValue(CodeBuilder cb) {
86         expr.cgValue(cb);
87     }
88     protected void cgValue(CodeBuilder cb, Type castTo) {
89         expr.cgValue(cb, castTo);
90     }
91     protected void cgEffect(CodeBuilder cb) {
92         expr.cgEffect(cb);
93     }
94     protected void cgBuffer(CodeBuilder cb) {
95         expr.cgBuffer(cb);
96     }
97     protected void cgTest(CodeBuilder cb, Label tdest, Label fdest) {
98         expr.cgTest(cb, tdest, fdest);
99     }
100
101     //BEGIN: Generated from @child and @property
102
protected Expr expr;
103     public Expr getExpr() { return expr; }
104     public void setExpr(Expr _expr) {
105         if (_expr != null) _expr.setParent(this);
106         expr = _expr;
107     }
108
109     public ParenExpr(SourceLocation location, Expr _expr) {
110         super(location);
111         setExpr(_expr);
112     }
113     protected ParenExpr(SourceLocation source) {
114         super(source);
115     }
116
117     public ASTObject copyWalk(CopyWalker walker) {
118         ParenExpr ret = new ParenExpr(getSourceLocation());
119         ret.preCopy(walker, this);
120         if (expr != null) ret.setExpr( (Expr)walker.process(expr) );
121         return ret;
122     }
123
124     public ASTObject getChildAt(int childIndex) {
125         switch(childIndex) {
126         case 0: return expr;
127         default: return super.getChildAt(childIndex);
128         }
129     }
130      public String JavaDoc getChildNameAt(int childIndex) {
131         switch(childIndex) {
132         case 0: return "expr";
133         default: return super.getChildNameAt(childIndex);
134         }
135     }
136      public void setChildAt(int childIndex, ASTObject child) {
137         switch(childIndex) {
138         case 0: setExpr((Expr)child); return;
139         default: super.setChildAt(childIndex, child); return;
140         }
141     }
142      public int getChildCount() {
143         return 1;
144     }
145
146     public String JavaDoc getDefaultDisplayName() {
147         return "ParenExpr()";
148     }
149
150     //END: Generated from @child and @property
151
}
152
Popular Tags