public static Statement FindFirstData(Statement stat) { if (stat.GetExprents() != null) { return(stat); } else if (stat.IsLabeled()) { // FIXME: Why?? return(null); } switch (stat.type) { case Statement.Type_Sequence: case Statement.Type_If: case Statement.Type_Root: case Statement.Type_Switch: case Statement.Type_Syncronized: { return(FindFirstData(stat.GetFirst())); } default: { return(null); } } }
public override TextBuffer ToJava(int indent, BytecodeMappingTracer tracer) { TextBuffer buf = new TextBuffer(); buf.Append(ExprProcessor.ListToJava(varDefinitions, indent, tracer)); buf.Append(first.ToJava(indent, tracer)); if (IsLabeled()) { buf.AppendIndent(indent).Append("label").Append(this.id.ToString()).Append(":").AppendLineSeparator (); tracer.IncrementCurrentSourceLine(); } buf.AppendIndent(indent).Append(headexprent[0].ToJava(indent, tracer)).Append(" {" ).AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); if (ifstat == null) { bool semicolon = false; if (ifedge.@explicit) { semicolon = true; if (ifedge.GetType() == StatEdge.Type_Break) { // break buf.AppendIndent(indent + 1).Append("break"); } else { // continue buf.AppendIndent(indent + 1).Append("continue"); } if (ifedge.labeled) { buf.Append(" label").Append(ifedge.closure.id.ToString()); } } if (semicolon) { buf.Append(";").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); } } else { buf.Append(ExprProcessor.JmpWrapper(ifstat, indent + 1, true, tracer)); } bool elseif = false; if (elsestat != null) { if (elsestat.type == Statement.Type_If && (elsestat.varDefinitions.Count == 0) && (elsestat.GetFirst().GetExprents().Count == 0) && !elsestat.IsLabeled() && ((elsestat .GetSuccessorEdges(Statedge_Direct_All).Count == 0) || !elsestat.GetSuccessorEdges (Statedge_Direct_All)[0].@explicit)) { // else if buf.AppendIndent(indent).Append("} else "); TextBuffer content = ExprProcessor.JmpWrapper(elsestat, indent, false, tracer); content.SetStart(TextUtil.GetIndentString(indent).Length); buf.Append(content); elseif = true; } else { BytecodeMappingTracer else_tracer = new BytecodeMappingTracer(tracer.GetCurrentSourceLine () + 1); TextBuffer content = ExprProcessor.JmpWrapper(elsestat, indent + 1, false, else_tracer ); if (content.Length() > 0) { buf.AppendIndent(indent).Append("} else {").AppendLineSeparator(); tracer.SetCurrentSourceLine(else_tracer.GetCurrentSourceLine()); tracer.AddTracer(else_tracer); buf.Append(content); } } } if (!elseif) { buf.AppendIndent(indent).Append("}").AppendLineSeparator(); tracer.IncrementCurrentSourceLine(); } return(buf); }