00001 package edu.ksu.cis.bandera.abstraction.typeinference; 00002 00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00004 * Bandera, a Java(TM) analysis and transformation toolkit * 00005 * Copyright (C) 1998, 1999, 2000 Shawn Laubach (laubach@acm.org) * 00006 * All rights reserved. * 00007 * * 00008 * Modifications by Robby (robby@cis.ksu.edu) are * 00009 * Copyright (C) 2000 Robby. All rights reserved. * 00010 * * 00011 * This work was done as a project in the SAnToS Laboratory, * 00012 * Department of Computing and Information Sciences, Kansas State * 00013 * University, USA (http://www.cis.ksu.edu/santos). * 00014 * It is understood that any modification not identified as such is * 00015 * not covered by the preceding statement. * 00016 * * 00017 * This work is free software; you can redistribute it and/or * 00018 * modify it under the terms of the GNU Library General Public * 00019 * License as published by the Free Software Foundation; either * 00020 * version 2 of the License, or (at your option) any later version. * 00021 * * 00022 * This work is distributed in the hope that it will be useful, * 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00025 * Library General Public License for more details. * 00026 * * 00027 * You should have received a copy of the GNU Library General Public * 00028 * License along with this toolkit; if not, write to the * 00029 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * 00030 * Boston, MA 02111-1307, USA. * 00031 * * 00032 * Java is a trademark of Sun Microsystems, Inc. * 00033 * * 00034 * To submit a bug report, send a comment, or get the latest news on * 00035 * this project and other SAnToS projects, please visit the web-site * 00036 * http://www.cis.ksu.edu/santos * 00037 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00038 import java.util.*; 00039 public class ArrayTypeStructure implements TypeStructure { 00040 protected TypeStructure index; 00041 protected TypeStructure elements; 00042 /** 00043 * 00044 * @param elements edu.ksu.cis.bandera.abstraction.typeinference.TypeStructure 00045 * @param index edu.ksu.cis.bandera.abstraction.typeinference.TypeStructure 00046 */ 00047 public ArrayTypeStructure(TypeStructure elements, TypeStructure index) { 00048 this.elements = elements; 00049 this.index = index; 00050 } 00051 /** 00052 * getCoerceConstraints method comment. 00053 */ 00054 public java.util.Set genCoerceConstraints(TypeStructure ats) { 00055 Set set = new HashSet(); 00056 if (ats instanceof ArrayTypeStructure) { 00057 ArrayTypeStructure bts = (ArrayTypeStructure) ats; 00058 set.addAll(index.genCoerceConstraints(bts.index)); 00059 set.addAll(elements.genCoerceConstraints(bts.elements)); 00060 } else 00061 System.out.println("Cannot mix type structures."); 00062 return set; 00063 } 00064 /** 00065 * getEqualConstraints method comment. 00066 */ 00067 public java.util.Set genEqualConstraints(TypeStructure ats) { 00068 Set set = new HashSet(); 00069 if (ats instanceof ArrayTypeStructure) { 00070 ArrayTypeStructure bts = (ArrayTypeStructure) ats; 00071 set.addAll(index.genEqualConstraints(bts.index)); 00072 set.addAll(elements.genEqualConstraints(bts.elements)); 00073 } else 00074 System.out.println("Cannot mix type structures."); 00075 return set; 00076 } 00077 /** 00078 * 00079 * @return edu.ksu.cis.bandera.abstraction.typeinference.TypeStructure 00080 */ 00081 public TypeStructure getElements() { 00082 return elements; 00083 } 00084 /** 00085 * 00086 * @return edu.ksu.cis.bandera.abstraction.typeinference.TypeStructure 00087 */ 00088 public TypeStructure getIndex() { 00089 return index; 00090 } 00091 /** 00092 * 00093 * @param newElements edu.ksu.cis.bandera.abstraction.typeinference.TypeStructure 00094 */ 00095 protected void setElements(TypeStructure newElements) { 00096 elements = newElements; 00097 } 00098 /** 00099 * 00100 * @param newIndex edu.ksu.cis.bandera.abstraction.typeinference.TypeStructure 00101 */ 00102 protected void setIndex(TypeStructure newIndex) { 00103 index = newIndex; 00104 } 00105 }