KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > spark > pag > FieldRefNode


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2002 Ondrej Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.jimple.spark.pag;
21 import soot.jimple.spark.*;
22 import soot.*;
23 import soot.jimple.spark.sets.PointsToSetInternal;
24
25 /** Represents a field reference node (Red) in the pointer assignment graph.
26  * @author Ondrej Lhotak
27  */

28 public class FieldRefNode extends ValNode {
29     /** Returns the base of this field reference. */
30     public VarNode getBase() { return base; }
31     public Node getReplacement() {
32         if( replacement == this ) {
33             if( base.replacement == base ) return this;
34             Node baseRep = base.getReplacement();
35             FieldRefNode newRep = pag.makeFieldRefNode( (VarNode) baseRep, field );
36             newRep.mergeWith( this );
37             return replacement = newRep.getReplacement();
38         } else {
39             return replacement = replacement.getReplacement();
40         }
41     }
42     /** Returns the field of this field reference. */
43     public SparkField getField() { return field; }
44     public String JavaDoc toString() {
45     return "FieldRefNode "+getNumber()+" "+base+"."+field;
46     }
47
48     /* End of public methods. */
49
50     FieldRefNode( PAG pag, VarNode base, SparkField field ) {
51     super( pag, null );
52     if( field == null ) throw new RuntimeException JavaDoc( "null field" );
53     this.base = base;
54     this.field = field;
55     base.addField( this, field );
56         pag.getFieldRefNodeNumberer().add( this );
57     }
58
59     /* End of package methods. */
60
61     protected VarNode base;
62     protected SparkField field;
63 }
64
65
Popular Tags