KickJava   Java API By Example, From Geeks To Geeks.

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


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 OrOrOpExpr 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.process(getRand1());
53         FlowCheckerPass.Vars p1 = w.getVars();
54
55         w.setVars(p1.getFalse());
56         w.process(getRand2());
57         FlowCheckerPass.Vars p2 = w.getVars();
58
59         w.setVars(p1.getTrue().join(p2.getTrue()), p2.getFalse());
60     }
61
62     // ------------------------------
63
// INTRO from ByteCodeCleanupPass
64

65     public ASTObject postCleanup(ByteCodeCleanupPass w) {
66         if (getRand1().isConstantTrue() || getRand2().isConstantFalse()) {
67             return getRand1();
68         } else if (getRand1().isConstantFalse()) {
69             return getRand2();
70         } else {
71             return this;
72         }
73     }
74
75     // ------------------------------
76
// bcg
77

78     protected void cgTest(CodeBuilder cb, Label tdest, Label fdest) {
79         Label mid = cb.genLabel();
80         getRand1().cgTest(cb, tdest, mid);
81         cb.emitLabel(mid);
82         getRand2().cgTest(cb, tdest, fdest);
83     }
84
85     //BEGIN: Generated from @child and @property
86

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