+ return self.flatten_mclass_hierarchy_cache.as(not null)
+ end
+
+ # Adds another class definition in the modue.
+ # Updates the class hierarchy cache.
+ fun add_mclassdef(mclassdef: MClassDef)
+ do
+ self.mclassdefs.add(mclassdef)
+ if self.flatten_mclass_hierarchy_cache != null then
+ unsafe_update_hierarchy_cache(mclassdef)
+ end
+ end
+
+ # Adds a class definition inside `flatten_mclass_hierarchy_cache` without
+ # null check. The caller must have initialized the cache.
+ protected fun unsafe_update_hierarchy_cache(mclassdef: MClassDef)
+ do
+ var hierarchy = self.flatten_mclass_hierarchy_cache.as(not null)
+ # Update the cache
+ var c = mclassdef.mclass
+ hierarchy.add_node(c)
+ for s in mclassdef.supertypes do
+ hierarchy.add_edge(c, s.mclass)
+ end
+ end