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

ArrayIndexManagerValueVariant.java

00001 package edu.ksu.cis.bandera.bofa;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998, 1999                                          *
00006  * John Hatcliff (hatcliff@cis.ksu.edu)
00007  * All rights reserved.                                              *
00008  *                                                                   *
00009  * This work was done as a project in the SAnToS Laboratory,         *
00010  * Department of Computing and Information Sciences, Kansas State    *
00011  * University, USA (http://www.cis.ksu.edu/santos).                  *
00012  * It is understood that any modification not identified as such is  *
00013  * not covered by the preceding statement.                           *
00014  *                                                                   *
00015  * This work is free software; you can redistribute it and/or        *
00016  * modify it under the terms of the GNU Library General Public       *
00017  * License as published by the Free Software Foundation; either      *
00018  * version 2 of the License, or (at your option) any later version.  *
00019  *                                                                   *
00020  * This work is distributed in the hope that it will be useful,      *
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00023  * Library General Public License for more details.                  *
00024  *                                                                   *
00025  * You should have received a copy of the GNU Library General Public *
00026  * License along with this toolkit; if not, write to the             *
00027  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00028  * Boston, MA  02111-1307, USA.                                      *
00029  *                                                                   *
00030  * Java is a trademark of Sun Microsystems, Inc.                     *
00031  *                                                                   *
00032  * To submit a bug report, send a comment, or get the latest news on *
00033  * this project and other SAnToS projects, please visit the web-site *
00034  *                http://www.cis.ksu.edu/santos                      *
00035  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00036 
00037 import ca.mcgill.sable.util.*;
00038 
00039 /*
00040  * ArrayIndexManagerValueVariant.java
00041  * $Id: ArrayIndexManagerValueVariant.java,v 1.1.1.1 2002/01/24 03:42:07 pserver Exp $
00042  */
00043 
00044 /**
00045  * This implementation of <code>ArrayIndexManager</code> provides
00046  * <code>ArrayIndex</code> to partition <code>ArrayVariant</code>s in 1-1
00047  * correspondence with <code>ValueVariant</code> for the array creation
00048  * expression.
00049  *
00050  * @author <A HREF="http://www.cis.ksu.edu/~hatcliff">John Hatcliff</A> 
00051  * @author 
00052  * <a href="http://www.cis.ksu.edu/~rvprasad">Venkatesh Prasad Ranganath</a>
00053  * @version $Name:  $($Revision: 1.1.1.1 $)
00054  */
00055 public class ArrayIndexManagerValueVariant implements ArrayIndexManager
00056 {
00057     /** 
00058      * A Map from <code>ValueVariant</code>s to <code>ArrayIndex</code>s.  
00059      */
00060     private Map valueVariantMap;
00061 
00062     /**
00063      * This implementation of <code>Index</code> provides an
00064      * <code>ArrayIndex</code> in 1-1 correspondence with the
00065      * <code>ValueVariant</code> for the array object.
00066      */
00067     class ArrayIndexValueVariant extends Index
00068     {
00069         /**
00070          * The <code>ValueVariant</code> to which the <code>ArrayIndex</code>
00071          * corresponds to.
00072          */
00073         ValueVariant valueVariant;
00074         
00075         /**
00076          * Creates a new <code>ArrayIndexValueVariant</code> instance.
00077          *
00078          * @param valueVariant the <code>ValueVariant</code> corresponding to
00079          * the array creation expression. 
00080          */
00081         ArrayIndexValueVariant(ValueVariant valueVariant) { 
00082             this.valueVariant = valueVariant; 
00083         }
00084     }
00085 
00086     /**
00087      * Constructor for the class. 
00088      */
00089     public ArrayIndexManagerValueVariant()
00090     {
00091         valueVariantMap = new HashMap();
00092     }
00093     /**
00094      * Reset the data structures in the Manager.
00095      *
00096      */
00097     public void reset() 
00098     {
00099         if (valueVariantMap != null) {
00100             valueVariantMap.clear();
00101         } // end of if (valueVariant != null)
00102     }
00103     /**
00104      * This method provides the <code>ArrayIndex</code> mapped to the given
00105      * <code>ValueVariant</code>.
00106      *
00107      * @param valueVariant the <code>ValueVariant</code> corresponding to array
00108      * creation expression. 
00109      * @return the <code>Index</code> corresponding to the provided
00110      * <code>ValueVariant</code>. */ 
00111     public Index select(ValueVariant valueVariant)
00112     {
00113         ArrayIndexValueVariant arrayIndex;
00114         
00115         if (valueVariantMap.containsKey(valueVariant)) {
00116             // if valueVariant is registered, then return index
00117             arrayIndex = (ArrayIndexValueVariant) 
00118                 valueVariantMap.get(valueVariant);
00119         } else {
00120             // if value variant is not registered, then register it 
00121             // with a new ArrayIndexValueVariant
00122             arrayIndex = new ArrayIndexValueVariant(valueVariant);
00123             valueVariantMap.put(valueVariant,arrayIndex);
00124         }
00125         return arrayIndex;
00126     }
00127 }

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