Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Use do while.
Browse files Browse the repository at this point in the history
  • Loading branch information
huanwu committed Dec 1, 2017
1 parent 9a3cf53 commit fbdf277
Showing 1 changed file with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2221,18 +2221,28 @@ private void WriteMemberElementsIf(Member[] members, Member anyElement, string e
string ns = e.Form == XmlSchemaForm.Qualified ? e.Namespace : "";
if (!isSequence && e.Any && (e.Name == null || e.Name.Length == 0)) continue;

if(!firstElement && isSequence)
if (!isSequence)
{
Writer.Write("else ");
if (firstElement && count == 0)
{
Writer.WriteLine("do {");
Writer.Indent++;
}
}
else if (isSequence)
else
{
Writer.Write("case ");
Writer.Write(cases.ToString(CultureInfo.InvariantCulture));
Writer.WriteLine(":");
Writer.Indent++;
if (!firstElement || (!isSequence && count > 0))
{
Writer.Write("else ");
}
else if (isSequence)
{
Writer.Write("case ");
Writer.Write(cases.ToString(CultureInfo.InvariantCulture));
Writer.WriteLine(":");
Writer.Indent++;
}
}

count++;
firstElement = false;
Writer.Write("if (");
Expand Down Expand Up @@ -2323,7 +2333,7 @@ private void WriteMemberElementsIf(Member[] members, Member anyElement, string e
}
if (!isSequence)
{
Writer.WriteLine("goto Finish;");
Writer.WriteLine("break;");
}
Writer.Indent--;
Writer.WriteLine("}");
Expand Down Expand Up @@ -2352,25 +2362,22 @@ private void WriteMemberElementsIf(Member[] members, Member anyElement, string e
{
if (isSequence)
Writer.WriteLine("default:");
else
{
Writer.WriteLine("Finish:");
}

Writer.Indent++;
}
WriteMemberElementsElse(anyElement, elementElseString);
if (count > 0)
{
if (isSequence)
{
Writer.WriteLine("break;");
Writer.Indent--;
Writer.WriteLine("}");
}
Writer.Indent--;
if (!isSequence)
{
Writer.WriteLine("} while (false);");
}
else
{
Writer.Indent--;
Writer.WriteLine("}");
}
}
}
Expand Down

0 comments on commit fbdf277

Please sign in to comment.