Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Local.java

00001 package ca.mcgill.sable.soot.jimple;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Jimple, a 3-address code Java(TM) bytecode representation.        *
00005  * Copyright (C) 1997, 1998 Raja Vallee-Rai (kor@sable.mcgill.ca)    *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * Modifications by Madeleine Mony are                               *
00009  * Copyright (C) 1998 Madeleine Mony.  All                           *
00010  * rights reserved.                                                  *
00011  *                                                                   *
00012  * Modifications by Patrick Lam (plam@sable.mcgill.ca) are           *
00013  * Copyright (C) 1999 Patrick Lam.  All rights reserved.             *
00014  *                                                                   *
00015  * This work was done as a project of the Sable Research Group,      *
00016  * School of Computer Science, McGill University, Canada             *
00017  * (http://www.sable.mcgill.ca/).  It is understood that any         *
00018  * modification not identified as such is not covered by the         *
00019  * preceding statement.                                              *
00020  *                                                                   *
00021  * This work is free software; you can redistribute it and/or        *
00022  * modify it under the terms of the GNU Library General Public       *
00023  * License as published by the Free Software Foundation; either      *
00024  * version 2 of the License, or (at your option) any later version.  *
00025  *                                                                   *
00026  * This work is distributed in the hope that it will be useful,      *
00027  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00028  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00029  * Library General Public License for more details.                  *
00030  *                                                                   *
00031  * You should have received a copy of the GNU Library General Public *
00032  * License along with this library; if not, write to the             *
00033  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00034  * Boston, MA  02111-1307, USA.                                      *
00035  *                                                                   *
00036  * Java is a trademark of Sun Microsystems, Inc.                     *
00037  *                                                                   *
00038  * To submit a bug report, send a comment, or get the latest news on *
00039  * this project and other Sable Research Group projects, please      *
00040  * visit the web site: http://www.sable.mcgill.ca/                   *
00041  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00042 
00043 /*
00044  Reference Version
00045  -----------------
00046  This is the latest official version on which this file is based.
00047  The reference version is: $SootVersion: 1.beta.4 $
00048 
00049  Change History
00050  --------------
00051  A) Notes:
00052 
00053  Please use the following template.  Most recent changes should
00054  appear at the top of the list.
00055 
00056  - Modified on [date (March 1, 1900)] by [name]. [(*) if appropriate]
00057    [description of modification].
00058 
00059  Any Modification flagged with "(*)" was done as a project of the
00060  Sable Research Group, School of Computer Science,
00061  McGill University, Canada (http://www.sable.mcgill.ca/).
00062 
00063  You should add your copyright, using the following template, at
00064  the top of this file, along with other copyrights.
00065 
00066  *                                                                   *
00067  * Modifications by [name] are                                       *
00068  * Copyright (C) [year(s)] [your name (or company)].  All rights     *
00069  * reserved.                                                         *
00070  *                                                                   *
00071 
00072  B) Changes:
00073 
00074  - Modified on February 3, 1999 by Patrick Lam (plam@sable.mcgill.ca) (*)
00075    Added changes in support of the Grimp intermediate
00076    representation (with aggregated-expressions).
00077 
00078  - Modified on November 13, 1998 by Madeleine Mony
00079    Implemented fixed hash code idea.
00080    
00081  - Modified on November 2, 1998 by Raja Vallee-Rai (kor@sable.mcgill.ca) (*)
00082    Repackaged all source files and performed extensive modifications.
00083    First initial release of Soot.
00084 
00085  - Modified on 15-Jun-1998 by Raja Vallee-Rai (kor@sable.mcgill.ca). (*)
00086    First internal release (Version 0.1).
00087 */
00088 
00089 import ca.mcgill.sable.soot.*;
00090 import ca.mcgill.sable.util.*;
00091 
00092 public class Local implements Value, ToBriefString
00093 {
00094     String name;
00095     Type type;
00096 
00097     int fixedHashCode;
00098     boolean isHashCodeChosen;
00099         
00100     public Local(String name, Type t)
00101     {
00102         this.name = name;
00103         this.type = t;
00104     }
00105     public void apply(Switch sw)
00106     {
00107         ((JimpleValueSwitch) sw).caseLocal(this);
00108     }
00109     public Object clone()
00110     {
00111         return new Local(name, type);
00112     }
00113     public boolean equals(Object o)
00114     {
00115         if (o instanceof Local)
00116             return (((Local)o).name).equals(name)
00117                 && (((Local)o).type).equals(type);
00118         return false;
00119     }
00120     public String getName()
00121     {
00122         return name;
00123     }
00124     public Type getType()
00125     {
00126         return type;
00127     }
00128     public List getUseBoxes()
00129     {
00130         return AbstractStmt.emptyList;
00131     }
00132     public int hashCode()
00133     {
00134         if(!isHashCodeChosen)
00135         {
00136             // Set the hash code for this object
00137             
00138             if(name != null & type != null)
00139                 fixedHashCode = name.hashCode() + 19 * type.hashCode();
00140             else if(name != null)
00141                 fixedHashCode = name.hashCode();
00142             else if(type != null)
00143                 fixedHashCode = type.hashCode();
00144             else
00145                 fixedHashCode = 1;
00146                 
00147             isHashCodeChosen = true;
00148         }
00149         
00150         return fixedHashCode;
00151     }
00152     public void setName(String name)
00153     {
00154         this.name = name;
00155     }
00156     public void setType(Type t)
00157     {
00158         this.type = t;
00159     }
00160     public String toBriefString()
00161     {
00162         return toString();
00163     }
00164     public String toString()
00165     {
00166         return getName();
00167     }
00168 }

Generated at Thu Feb 7 06:49:43 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001