View Javadoc

1   // GenKillTransferFunction.java, created Mar 22, 2004 2:15:05 PM 2004 by jwhaley
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 joeq.Compiler.Dataflow;
5   
6   import jwutil.math.BitString;
7   import jwutil.strings.Strings;
8   
9   public class GenKillTransferFunction implements TransferFunction {
10  
11      protected final BitString gen, kill;
12  
13      GenKillTransferFunction(int size) {
14          this.gen = new BitString(size);
15          this.kill = new BitString(size);
16      }
17      GenKillTransferFunction(BitString g, BitString k) {
18          this.gen = g; this.kill = k;
19      }
20  
21      public String toString() {
22          return "   Gen: "+gen+Strings.lineSep+"   Kill: "+kill;
23      }
24  
25      /* (non-Javadoc)
26       * @see joeq.Compiler.Dataflow.TransferFunction#apply(joeq.Compiler.Dataflow.Fact)
27       */
28      public Fact apply(Fact f) {
29          BitVectorFact r = (BitVectorFact) f;
30          BitString s = new BitString(r.fact.size());
31          s.or(r.fact);
32          s.minus(kill);
33          s.or(gen);
34          return r.makeNew(s);
35      }
36      
37  }