public override string ToString() { string new_line_separator = DecompilerContext.GetNewLineSeparator(); return("from: " + from + " to: " + to + " handler: " + handler + new_line_separator + "from_instr: " + from_instr + " to_instr: " + to_instr + " handler_instr: " + handler_instr + new_line_separator + "exceptionClass: " + exceptionClass + new_line_separator); }
public virtual void DumpMapping(TextBuffer buffer, bool offsetsToHex) { if ((mapping.Count == 0) && (linesMapping.Count == 0)) { return; } string lineSeparator = DecompilerContext.GetNewLineSeparator(); foreach (KeyValuePair <string, Dictionary <string, Dictionary <int, int> > > class_entry in mapping) { Dictionary <string, Dictionary <int, int> > class_mapping = class_entry.Value; buffer.Append("class '" + class_entry.Key + "' {" + lineSeparator); bool is_first_method = true; foreach (KeyValuePair <string, Dictionary <int, int> > method_entry in class_mapping) { Dictionary <int, int> method_mapping = method_entry.Value; if (!is_first_method) { buffer.AppendLineSeparator(); } buffer.AppendIndent(1).Append("method '" + method_entry.Key + "' {" + lineSeparator ); List <int> lstBytecodeOffsets = new List <int>(method_mapping.Keys); lstBytecodeOffsets.Sort(); foreach (int offset in lstBytecodeOffsets) { int? line = method_mapping.GetOrNullable(offset); string strOffset = offsetsToHex ? Sharpen.Runtime.ToHexString(offset) : line.ToString(); buffer.AppendIndent(2).Append(strOffset).AppendIndent(2).Append((line.Value + offset_total ) + lineSeparator); } buffer.AppendIndent(1).Append("}").AppendLineSeparator(); is_first_method = false; } buffer.Append("}").AppendLineSeparator().AppendLineSeparator(); } // lines mapping buffer.Append("Lines mapping:").AppendLineSeparator(); IDictionary <int, int> sorted = new SortedDictionary <int, int>(linesMapping); foreach (KeyValuePair <int, int> entry in sorted) { buffer.Append(entry.Key).Append(" <-> ").Append(entry.Value + offset_total + 1).AppendLineSeparator (); } if (!(unmappedLines.Count == 0)) { buffer.Append("Not mapped:").AppendLineSeparator(); foreach (int line in unmappedLines) { if (!linesMapping.ContainsKey(line)) { buffer.Append(line).AppendLineSeparator(); } } } }
public override TextBuffer ToJava(int indent, BytecodeMappingTracer tracer) { string new_line_separator = DecompilerContext.GetNewLineSeparator(); TextBuffer buf = new TextBuffer(); buf.Append(ExprProcessor.ListToJava(varDefinitions, indent, tracer)); bool labeled = IsLabeled(); if (labeled) { buf.AppendIndent(indent).Append("label").Append(this.id.ToString()).Append(":").AppendLineSeparator (); tracer.IncrementCurrentSourceLine(); } List <StatEdge> lstSuccs = first.GetSuccessorEdges(Statedge_Direct_All); if (first.type == Type_Trycatch && (first.varDefinitions.Count == 0) && isFinally__ && !labeled && !first.IsLabeled() && ((lstSuccs.Count == 0) || !lstSuccs[0].@explicit )) { TextBuffer content = ExprProcessor.JmpWrapper(first, indent, true, tracer); content.SetLength(content.Length() - new_line_separator.Length); tracer.IncrementCurrentSourceLine(-1); buf.Append(content); } else { buf.AppendIndent(indent).Append("try {").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); buf.Append(ExprProcessor.JmpWrapper(first, indent + 1, true, tracer)); buf.AppendIndent(indent).Append("}"); } buf.Append(isFinally__ ? " finally" : " catch (" + vars[0].ToJava(indent, tracer) + ")").Append(" {").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); if (monitor != null) { buf.AppendIndent(indent + 1).Append("if (").Append(monitor.ToJava(indent, tracer) ).Append(") {").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); } buf.Append(ExprProcessor.JmpWrapper(handler, indent + 1 + (monitor != null ? 1 : 0), true, tracer)); if (monitor != null) { buf.AppendIndent(indent + 1).Append("}").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); } buf.AppendIndent(indent).Append("}").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); return(buf); }
public override string ToString() { if (blocks == null) { return("Empty"); } string new_line_separator = DecompilerContext.GetNewLineSeparator(); StringBuilder buf = new StringBuilder(); foreach (BasicBlock block in blocks) { buf.Append("----- Block ").Append(block.id).Append(" -----").Append(new_line_separator ); buf.Append(block.ToString()); buf.Append("----- Edges -----").Append(new_line_separator); List <BasicBlock> suc = block.GetSuccs(); foreach (BasicBlock aSuc in suc) { buf.Append(">>>>>>>>(regular) Block ").Append(aSuc.id).Append(new_line_separator); } suc = block.GetSuccExceptions(); foreach (BasicBlock handler in suc) { ExceptionRangeCFG range = GetExceptionRange(handler, block); if (range == null) { buf.Append(">>>>>>>>(exception) Block ").Append(handler.id).Append("\t").Append("ERROR: range not found!" ).Append(new_line_separator); } else { List <string> exceptionTypes = range.GetExceptionTypes(); if (exceptionTypes == null) { buf.Append(">>>>>>>>(exception) Block ").Append(handler.id).Append("\t").Append("NULL" ).Append(new_line_separator); } else { foreach (string exceptionType in exceptionTypes) { buf.Append(">>>>>>>>(exception) Block ").Append(handler.id).Append("\t").Append(exceptionType ).Append(new_line_separator); } } } } buf.Append("----- ----- -----").Append(new_line_separator); } return(buf.ToString()); }
public virtual string ToString(int indent) { string new_line_separator = DecompilerContext.GetNewLineSeparator(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < collinstr.Count; i++) { buf.Append(TextUtil.GetIndentString(indent)); buf.Append(collinstr.GetKey(i)); buf.Append(": "); buf.Append(collinstr[i].ToString()); buf.Append(new_line_separator); } return(buf.ToString()); }
public override string ToString() { string new_line_separator = DecompilerContext.GetNewLineSeparator(); StringBuilder buf = new StringBuilder(); buf.Append("exceptionType:"); foreach (string exception_type in exceptionTypes) { buf.Append(" ").Append(exception_type); } buf.Append(new_line_separator); buf.Append("handler: ").Append(handler.id).Append(new_line_separator); buf.Append("range: "); foreach (BasicBlock block in protectedRange) { buf.Append(block.id).Append(" "); } buf.Append(new_line_separator); return(buf.ToString()); }