X-Git-Url: http://nitlanguage.org diff --git a/src/analysis/icode_dump.nit b/src/analysis/icode_dump.nit index d634376..926a6fc 100644 --- a/src/analysis/icode_dump.nit +++ b/src/analysis/icode_dump.nit @@ -35,6 +35,12 @@ redef class IRoutine if r != null then icd.write "Result: {icd.register(r)}" end + if std_slots_nb > 0 then + icd.write "StdSlots: {std_slots_nb}" + end + if tag_slots_nb > 0 then + icd.write "TagSlots: {tag_slots_nb}" + end var closdecls = closure_decls if closdecls != null then for c in closdecls do @@ -59,9 +65,16 @@ redef class IClosureDecl end class ICodeDumper + readable var _dump_locations: Bool + readable var _dump_line_numbers: Bool var _ids: HashMap[Object, String] = new HashMap[Object, String] var _last_value: Int = 0 + init(dump_locations: Bool, dump_line_numbers: Bool) do + _dump_locations = dump_locations + _dump_line_numbers = dump_line_numbers + end + # Return the name of e # If e is unknown, a new name is gived fun register(e: IRegister): String @@ -77,7 +90,14 @@ class ICodeDumper return s else _last_value += 1 - var s = "REG{i}(r{_last_value})" + var s: String + if e.in_tag_slots then + s = "BREG{i}(r{_last_value})" + else if e.is_local then + s = "LREG{i}(r{_last_value})" + else + s = "REG{i}(r{_last_value})" + end _ids[e] = s return s end @@ -114,7 +134,7 @@ class ICodeDumper var _last_label: Int = 0 # Return the name of e # If e is unknown, a new name is gived - fun lab(e: ISeq): String + fun lab(e: IEscapeMark): String do if _ids.has_key(e) then return _ids[e] @@ -141,7 +161,7 @@ class ICodeDumper end # Is the label e known? (because we goto to it) - fun has_lab(e: ISeq): Bool + fun has_lab(e: IEscapeMark): Bool do return _ids.has_key(e) end @@ -155,7 +175,7 @@ class ICodeDumper print s end - var _indent_level: Int = 0 + readable var _indent_level: Int = 0 # Indent the next writes fun indent do _indent_level += 1 @@ -169,15 +189,19 @@ redef class ICode fun dump(icd: ICodeDumper) do var result = result - var s = "" - var l = location - if l != null then - s = " ... {l}" + var s_loc = "" + var s_line = "" + var loc = location + if loc != null and icd.dump_locations then + s_loc = " ... {loc}" + end + if icd.dump_line_numbers then + s_line = "{icd.line(self)}: " end if result == null then - icd.write "{icd.line(self)}: {dump_intern(icd)}{s}" + icd.write "{s_line}{dump_intern(icd)}{s_loc}" else - icd.write "{icd.line(self)}: {icd.register(result)} := {dump_intern(icd)}{s}" + icd.write "{s_line}{icd.register(result)} := {dump_intern(icd)}{s_loc}" end end @@ -211,7 +235,8 @@ redef class ISeq for ic in icodes do ic.dump(icd) end - if icd.has_lab(self) then icd.write("{icd.lab(self)}:") + var mark = iescape_mark + if mark != null and icd.has_lab(mark) then icd.write("{icd.lab(mark)}:") end end @@ -240,14 +265,15 @@ redef class ILoop end icd.unindent icd.write "}" - if icd.has_lab(self) then icd.write("{icd.lab(self)}:") + var mark = iescape_mark + if mark != null and icd.has_lab(mark) then icd.write("{icd.lab(mark)}:") end end redef class IEscape redef fun dump_intern(icd) do - return "ESCAPE {icd.lab(seq)}" + return "ESCAPE {icd.lab(iescape_mark)}" end end @@ -338,18 +364,49 @@ end redef class ITypeCheck redef fun dump_intern(icd) do - return "CHECKTYPE {icd.register(expr)} isa {stype}" + return "CHECKTYPE {icd.register(expr2)} isa {stype}" end end redef class INative redef fun dump_intern(icd) do - if exprs.is_empty then - return "NATIVE \"{code}\"" - else - return "NATIVE \"{code}\"({icd.register_all(exprs)})" - end + return "NATIVE \"{method.full_name}\"({icd.register_all(exprs)})" + end +end + +redef class IIntValue + redef fun dump_intern(icd) + do + return "INTVALUE {value}" + end +end + +redef class IBoolValue + redef fun dump_intern(icd) + do + return "BOOLVALUE {value}" + end +end + +redef class IStringValue + redef fun dump_intern(icd) + do + return "STRINGVALUE {value}" + end +end + +redef class ICharValue + redef fun dump_intern(icd) + do + return "CHARVALUE {value}" + end +end + +redef class IFloatValue + redef fun dump_intern(icd) + do + return "FLOATVALUE {value}" end end