- # Add a live type to the pool
- #
- # If the types is already live, then do nothing.
- #
- # REQUIRE: not mtype.need_anchor
- fun add_type(mtype: MClassType)
- do
- if self.live_types.has(mtype) then return
-
- assert not mtype.need_anchor
- self.live_types.add(mtype)
-
- # Collect default attributes
- for cd in mtype.collect_mclassdefs(self.mainmodule)
- do
- var nclassdef = self.modelbuilder.mclassdef2nclassdef[cd]
- for npropdef in nclassdef.n_propdefs do
- if not npropdef isa AAttrPropdef then continue
- var nexpr = npropdef.n_expr
- if nexpr == null then continue
- var v = new RapidTypeVisitor(self, nclassdef, npropdef.mpropdef.as(not null), mtype)
- v.enter_visit(nexpr)
- end
+ # Live method definitions.
+ var live_methoddefs = new HashSet[MMethodDef]
+
+ # Live methods.
+ var live_methods = new HashSet[MMethod]
+
+ # Live call-to-super.
+ var live_super_sends = new HashSet[MMethodDef]
+
+ # Return a ready-to-save CSV document objet that agregates informations about live types.
+ # Each discovered type is listed in a line, with its status: resolution, liveness, cast-liveness.
+ # Note: types are listed in an alphanumeric order to improve human reading.
+ fun live_types_to_csv: CSVDocument
+ do
+ # Gather all kind of type
+ var typeset = new HashSet[MType]
+ typeset.add_all(live_types)
+ typeset.add_all(live_open_types)
+ typeset.add_all(live_cast_types)
+ typeset.add_all(live_open_cast_types)
+ var types = typeset.to_a
+ (new CachedAlphaComparator).sort(types)
+ var res = new CSVDocument
+ res.header = ["Type", "Resolution", "Liveness", "Cast-liveness"]
+ for t in types do
+ var reso
+ if t.need_anchor then reso = "OPEN " else reso = "CLOSED"
+ var live
+ if t isa MClassType and (live_types.has(t) or live_open_types.has(t)) then live = "LIVE" else live = "DEAD"
+ var cast
+ if live_cast_types.has(t) or live_open_cast_types.has(t) then cast = "CAST LIVE" else cast = "CAST DEAD"
+ res.add_line(t, reso, live, cast)