View Javadoc

1   // If.java, created Jul 7, 2004 11:50:51 PM by joewhaley
2   // Copyright (C) 2004 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package net.sf.bddbddb.ir.dynamic;
5   
6   import java.util.Collections;
7   import java.util.Iterator;
8   import java.util.List;
9   import net.sf.bddbddb.IterationList;
10  import net.sf.bddbddb.Relation;
11  import net.sf.bddbddb.ir.Operation;
12  import net.sf.bddbddb.ir.OperationVisitor;
13  
14  /***
15   * If
16   * 
17   * @author John Whaley
18   * @version $Id: If.java 328 2004-10-16 02:45:30Z joewhaley $
19   */
20  public class If extends Operation {
21      IRBoolean bool;
22      IterationList block;
23  
24      public If(IRBoolean bool, IterationList block) {
25          this.bool = bool;
26          this.block = block;
27      }
28  
29      /*
30       * (non-Javadoc)
31       * 
32       * @see net.sf.bddbddb.ir.Operation#visit(net.sf.bddbddb.ir.OperationVisitor)
33       */
34      public Object visit(DynamicOperationVisitor i) {
35          return i.visit(this);
36      }
37  
38      public Object visit(OperationVisitor i) {
39          return i.visit(this);
40      }
41  
42      /*
43       * (non-Javadoc)
44       * 
45       * @see java.lang.Object#toString()
46       */
47      public String toString() {
48          StringBuffer sb = new StringBuffer();
49          sb.append("If(" + bool.getName() + ") " + block + ": [ ");
50          for (Iterator it = block.iterator(); it.hasNext();) {
51              Object elem = (Object) it.next();
52              sb.append(elem.toString() + "; ");
53          }
54          sb.append("]");
55          return sb.toString();
56      }
57  
58      /*
59       * (non-Javadoc)
60       * 
61       * @see net.sf.bddbddb.ir.Operation#getDest()
62       */
63      public Relation getRelationDest() {
64          return null;
65      }
66  
67      /*
68       * (non-Javadoc)
69       * 
70       * @see net.sf.bddbddb.ir.Operation#getSrcs()
71       */
72      public List getSrcs() {
73          return Collections.EMPTY_LIST;
74      }
75  
76      public IRBoolean getBoolSrc() {
77          return bool;
78      }
79  
80      /*
81       * (non-Javadoc)
82       * 
83       * @see net.sf.bddbddb.ir.Operation#getExpressionString()
84       */
85      public String getExpressionString() {
86          return toString();
87      }
88  
89      /***
90       * @return the target block
91       */
92      public IterationList getBlock() {
93          return block;
94      }
95  
96      /*
97       * (non-Javadoc)
98       * 
99       * @see net.sf.bddbddb.ir.Operation#setRelationDest(net.sf.bddbddb.Relation)
100      */
101     public Operation copy() {
102         return new If(bool, block);
103     }
104 
105     /*
106      * (non-Javadoc)
107      * 
108      * @see net.sf.bddbddb.ir.Operation#replaceSrc(net.sf.bddbddb.Relation,
109      *      net.sf.bddbddb.Relation)
110      */
111     public void replaceSrc(Relation r_old, Relation r_new) {
112     }
113 
114     /*
115      * (non-Javadoc)
116      * 
117      * @see net.sf.bddbddb.ir.Operation#setRelationDest(net.sf.bddbddb.Relation)
118      */
119     public void setRelationDest(Relation r0) {
120     }
121 }