KickJava   Java API By Example, From Geeks To Geeks.

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


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.JavaCompiler;
28 import org.aspectj.compiler.base.CodeWriter;
29 import java.io.IOException JavaDoc;
30
31 import org.aspectj.compiler.base.bcg.CodeBuilder;
32 import org.aspectj.compiler.base.bcg.Label;
33
34 /**
35   * @grammar
36   */

37 public abstract class AssignableExpr extends Expr {
38
39     public boolean isLhs() {
40         ASTObject parent = this.getParent();
41         return (parent instanceof BangExpr &&
42                 ((BangExpr)parent).getLhs() == this);
43     }
44
45     // ------------------------------
46
// bcg
47
protected void cgValue(CodeBuilder cb) {
48         cgLvalue(cb);
49         cgLtoRvalue(cb);
50     }
51
52     /** Generate code to place the lvalue of this expression on the
53         top of the stack. Only assignable expressions have lvalues.
54         Some assignable expressions (such as static field access
55         expressions) do not have lvalues, and for them this method is
56         a noop. */

57     abstract protected void cgLvalue(CodeBuilder cb);
58
59     /** Generate code to remove the lvalue at the top of the stack (if
60         any) and place the appropriate rvalue on the stack. Assumes
61         that said lvalue was generated by this expression. */

62     abstract protected void cgLtoRvalue(CodeBuilder cb);
63
64     /** Generate code to actually assign into this assignable.
65         Assumes that the new rvalue is at the top of the stack, and
66         that this expression's lvalue (if any) is just below it. */

67     abstract protected void cgAssignment(CodeBuilder cb);
68
69     /** Generates code to duplicate the top lvalue on the stack. Assumes
70         that said lvalue on the stack was generated by this expression. */

71     abstract protected void cgDupLvalue(CodeBuilder cb);
72
73     /** Generates code to duplicate the top rvalue on the stack and
74         places it BELOW the lvalue that may be just below it. Assumes
75         that said lvalue and rvalue on the stack were generated by this
76         expression. */

77     abstract protected void cgDupRvalue(CodeBuilder cb);
78
79     /** Is this an expression that we can generate an IINC code for?
80         That is, a VarExpr to a variable of type int with an index
81         that will fit in one byte? */

82     protected boolean isIncable() { return false; }
83
84     //BEGIN: Generated from @child and @property
85

86     public AssignableExpr(SourceLocation location) {
87         super(location);
88
89     }
90
91
92     public String JavaDoc getDefaultDisplayName() {
93         return "AssignableExpr()";
94     }
95
96     //END: Generated from @child and @property
97
}
98
Popular Tags