// post is always null! // ***************************************************************************** // public methods // ***************************************************************************** public static Statement IsHead(Statement head) { if (head.GetLastBasicType() == Lastbasictype_General && !head.IsMonitorEnter()) { // at most one outgoing edge StatEdge edge = null; List <StatEdge> lstSuccs = head.GetSuccessorEdges(Statedge_Direct_All); if (!(lstSuccs.Count == 0)) { edge = lstSuccs[0]; } // regular loop if (edge != null && edge.GetType() == StatEdge.Type_Regular && edge.GetDestination () == head) { return(new DoStatement(head)); } // continues if (head.type != Type_Do && (edge == null || edge.GetType() != StatEdge.Type_Regular ) && head.GetContinueSet().Contains(head.GetBasichead())) { return(new DoStatement(head)); } } return(null); }
public virtual HashSet <Statement> BuildContinueSet() { continueSet.Clear(); foreach (Statement st in stats) { Sharpen.Collections.AddAll(continueSet, st.BuildContinueSet()); if (st != first) { continueSet.Remove(st.GetBasichead()); } } foreach (StatEdge edge in GetEdges(StatEdge.Type_Continue, Direction_Forward)) { continueSet.Add(edge.GetDestination().GetBasichead()); } if (type == Type_Do) { continueSet.Remove(first.GetBasichead()); } return(continueSet); }
public override TextBuffer ToJava(int indent, BytecodeMappingTracer tracer) { TextBuffer buf = new TextBuffer(); buf.Append(ExprProcessor.ListToJava(varDefinitions, indent, tracer)); if (IsLabeled()) { buf.AppendIndent(indent).Append("label").Append(this.id.ToString()).Append(":").AppendLineSeparator (); tracer.IncrementCurrentSourceLine(); } buf.AppendIndent(indent).Append("try {").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); buf.Append(ExprProcessor.JmpWrapper(first, indent + 1, true, tracer)); buf.AppendIndent(indent).Append("}"); for (int i = 1; i < stats.Count; i++) { Statement stat = stats[i]; // map first instruction storing the exception to the catch statement BasicBlock block = stat.GetBasichead().GetBlock(); if (!block.GetSeq().IsEmpty() && block.GetInstruction(0).opcode == ICodeConstants .opc_astore) { int offset = block.GetOldOffset(0); if (offset > -1) { tracer.AddMapping(offset); } } buf.Append(" catch ("); List <string> exception_types = exctstrings[i - 1]; if (exception_types.Count > 1) { // multi-catch, Java 7 style for (int exc_index = 1; exc_index < exception_types.Count; ++exc_index) { VarType exc_type = new VarType(ICodeConstants.Type_Object, 0, exception_types[exc_index ]); string exc_type_name = ExprProcessor.GetCastTypeName(exc_type); buf.Append(exc_type_name).Append(" | "); } } buf.Append(vars[i - 1].ToJava(indent, tracer)); buf.Append(") {").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); buf.Append(ExprProcessor.JmpWrapper(stat, indent + 1, false, tracer)).AppendIndent (indent).Append("}"); } buf.AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); return(buf); }
private void MapMonitorExitInstr(BytecodeMappingTracer tracer) { BasicBlock block = body.GetBasichead().GetBlock(); if (!block.GetSeq().IsEmpty() && block.GetLastInstruction().opcode == ICodeConstants .opc_monitorexit) { int offset = block.GetOldOffset(block.Size() - 1); if (offset > -1) { tracer.AddMapping(offset); } } }