[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[imp-commit] r22839 - trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/type

Author: jvinju
Date: 2011-01-13 07:38:29 -0500 (Thu, 13 Jan 2011)
New Revision: 22839

Modified:
   trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/type/TypeStore.java
Log:
* added getter methods for all the information stored in a TypeStore. This allows a client to clone most of the TypeStore while changing some other thing. The alternative to add destructive access to the contents of a TypeStore was avoided because we observe that and expect that TypeStores  "travel" widely acros class and package boundaries. We don't want to make systems that use TypeStores brittle for referential integrity issues.

Modified: trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/type/TypeStore.java
===================================================================
--- trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/type/TypeStore.java	2011-01-07 15:56:46 UTC (rev 22838)
+++ trunk/org.eclipse.imp.pdb.values/src/org/eclipse/imp/pdb/facts/type/TypeStore.java	2011-01-13 12:38:29 UTC (rev 22839)
@@ -12,6 +12,7 @@
 package org.eclipse.imp.pdb.facts.type;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -74,6 +75,57 @@
 	}
     
     /**
+     * Retrieves all ADT's declared in this TypeStore. Note that it does
+     * not return the ADT's of imported TypeStores.
+     */
+    public Collection<Type> getAbstractDataTypes() {
+    	return Collections.unmodifiableCollection(fADTs.values());
+    }
+    
+    /**
+     * Retrieves all aliases declared in this TypeStore. Note that it does
+     * not return the aliases of imported TypeStores.
+     */
+    public Collection<Type> getAliases() {
+    	return Collections.unmodifiableCollection(fAliases.values());
+    }
+    
+    /**
+     * Retrieves all annotations declared in this TypeStore. Note that it does
+     * not return the annotations of imported TypeStores.
+     * 
+     * @return a map of types for which annotations are declared to a map of names of these
+     * annotations to the types of the values that give access to these annotations.
+     */
+    public Map<Type, Map<String, Type>> getAnnotations() {
+    	Map<Type, Map<String,Type>> unmodifiableMap = new HashMap<Type,Map<String,Type>>();
+    	for (Type key : fAnnotations.keySet()) {
+    		unmodifiableMap.put(key, Collections.unmodifiableMap(fAnnotations.get(key)));
+    	}
+    	return unmodifiableMap;
+    }
+    
+    /**
+     * Retrieves all constructors declared in this TypeStore. Note that it does
+     * not return the constructors of imported TypeStores.
+     */
+    public Collection<Type> getConstructors() {
+    	Set<Type> result = new HashSet<Type>();
+    	for (Set<Type> adt : fConstructors.values()) {
+    		result.addAll(adt);
+    	}
+    	return Collections.unmodifiableCollection(result);
+    }
+    
+    /**
+     * Retrieves all imports declared in this TypeStore. Note that it does
+     * not return the imports of imported TypeStores.
+     */
+    public Collection<TypeStore> getImports() {
+    	return Collections.unmodifiableCollection(fImports);
+    }
+    
+    /**
      * Add other stores to the set of imported stores.
      * Note that imports are not transitive.
      *