KickJava   Java API By Example, From Geeks To Geeks.

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


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.ByteCodeCleanupPass;
29 import org.aspectj.compiler.base.JavaCompiler;
30 import org.aspectj.compiler.base.CodeWriter;
31 import java.io.IOException JavaDoc;
32
33 import java.util.*;
34
35 import org.aspectj.compiler.base.bcg.CodeBuilder;
36 import org.aspectj.compiler.base.bcg.Label;
37
38 /**
39  * @grammar rand1 && rand2
40  */

41 public class AndAndOpExpr extends ConditionalOpExpr {
42
43     protected LiteralExpr halfFold(Type type, LiteralExpr lit1, LiteralExpr lit2) {
44         return type.foldBitwiseOp("&", lit1, lit2);
45     }
46
47     // ------------------------------
48
// INTRO from FlowCheckerPass
49

50     public void walkFlow(FlowCheckerPass w) {
51         // w.setArgs(w.getArgs())
52
w.processBoolean(getRand1());
53         FlowCheckerPass.Vars p1 = w.getVars();
54
55         w.setVars(p1.getTrue());
56         w.processBoolean(getRand2());
57         FlowCheckerPass.Vars p2 = w.getVars();
58
59         w.setVars(p2.getTrue(), p1.getFalse().join(p2.getFalse()));
60     }
61
62     // ------------------------------
63
// INTRO from ByteCodeCleanupPass
64

65     public ASTObject postCleanup(ByteCodeCleanupPass w) {
66         if (getRand1().isConstantTrue()) {
67             return getRand2();
68         } else if (getRand1().isConstantFalse() || getRand2().isConstantTrue()) {
69             return getRand1();
70         } else {
71             return this;
72         }
73     }
74
75     // ------------------------------
76
// bcg
77
protected void cgTest(CodeBuilder cb, Label tdest, Label fdest) {
78         Label mid = cb.genLabel();
79         getRand1().cgTest(cb, mid, fdest);
80         cb.emitLabel(mid);
81         getRand2().cgTest(cb, tdest, fdest);
82     }
83
84     //BEGIN: Generated from @child and @property
85

86     public AndAndOpExpr(SourceLocation location, Expr _rand1, String JavaDoc _op, Expr _rand2) {
87         super(location, _rand1, _op, _rand2);
88
89     }
90     protected AndAndOpExpr(SourceLocation source) {
91         super(source);
92     }
93
94     public ASTObject copyWalk(CopyWalker walker) {
95         AndAndOpExpr ret = new AndAndOpExpr(getSourceLocation());
96         ret.preCopy(walker, this);
97         if (rand1 != null) ret.setRand1( (Expr)walker.process(rand1) );
98         ret.op = op;
99         if (rand2 != null) ret.setRand2( (Expr)walker.process(rand2) );
100         return ret;
101     }
102
103
104     public String JavaDoc getDefaultDisplayName() {
105         return "AndAndOpExpr(op: "+op+")";
106     }
107
108     //END: Generated from @child and @property
109
}
110
Popular Tags