KickJava   Java API By Example, From Geeks To Geeks.

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


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.AssignmentCheckerPass;
28 import org.aspectj.compiler.base.*;
29 import org.aspectj.compiler.crosscuts.AccessFixer;
30
31 import java.util.*;
32
33 import org.aspectj.compiler.base.bcg.CodeBuilder;
34
35 /**
36  *
37  * @grammar x {<<=, >>=, >>>=} y
38  */

39 public class ShiftAssignExpr extends AssignExpr {
40
41     public Type discoverType() {
42         Type ty1 = lhs.getType();
43         Type ty2 = rhs.getType();
44         if (! ((ty1 instanceof IntegralType)
45                && (ty2 instanceof IntegralType))) {
46             showOperatorTypeError(op, ty1, ty2);
47         }
48         return ty1;
49     }
50
51     // ------------------------------
52
// bcg
53
protected void cgValue(CodeBuilder cb) {
54         cgValueEffect(cb, true);
55     }
56     protected void cgEffect(CodeBuilder cb) {
57         cgValueEffect(cb, false);
58     }
59     private void cgValueEffect(CodeBuilder cb, boolean needsValue) {
60         AssignableExpr lhs = getLhs();
61         Expr rhs = getRhs();
62         String JavaDoc op = getOp();
63         Type lhsTy = lhs.getType();
64         lhs.cgLvalue(cb);
65         lhs.cgDupLvalue(cb);
66         lhs.cgLtoRvalue(cb);
67         rhs.cgValue(cb, getTypeManager().intType);
68         lhsTy.emitShiftOp(cb, op);
69         if (lhsTy instanceof IntishType) {
70             ((IntishType)lhsTy).emitCastFromInt(cb);
71         }
72         if (needsValue) {
73             lhs.cgDupRvalue(cb);
74         }
75         lhs.cgAssignment(cb);
76     }
77
78     //BEGIN: Generated from @child and @property
79

80     public ShiftAssignExpr(SourceLocation location, AssignableExpr _lhs, String JavaDoc _op, Expr _rhs) {
81         super(location, _lhs, _op, _rhs);
82
83     }
84     protected ShiftAssignExpr(SourceLocation source) {
85         super(source);
86     }
87
88     public ASTObject copyWalk(CopyWalker walker) {
89         ShiftAssignExpr ret = new ShiftAssignExpr(getSourceLocation());
90         ret.preCopy(walker, this);
91         if (lhs != null) ret.setLhs( (AssignableExpr)walker.process(lhs) );
92         ret.op = op;
93         if (rhs != null) ret.setRhs( (Expr)walker.process(rhs) );
94         return ret;
95     }
96
97
98     public String JavaDoc getDefaultDisplayName() {
99         return "ShiftAssignExpr(op: "+op+")";
100     }
101
102     //END: Generated from @child and @property
103
}
104
Popular Tags