Skip to content

Commit ee66a12

Browse files
committed
Prettify castclass generated code
1 parent 09e2fe7 commit ee66a12

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

il2cpp/MethodGenerator.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2693,15 +2693,24 @@ private void GenCastclass(InstInfo inst, TypeX tyX)
26932693

26942694
RefTypeImpl(tyX);
26952695

2696-
inst.InstCode = string.Format(
2697-
"if ({0} == nullptr || {1}({0}->TypeID)) {2}\n" +
2698-
"else IL2CPP_THROW_INVALIDCAST;",
2696+
CodePrinter prt = new CodePrinter();
2697+
prt.AppendFormatLine("if ({0} == nullptr || {1}({0}->TypeID))",
26992698
TempName(slotPop),
2700-
GenContext.GetIsTypeFuncName(tyX),
2699+
GenContext.GetIsTypeFuncName(tyX));
2700+
++prt.Indents;
2701+
prt.AppendLine(
27012702
GenAssign(
27022703
TempName(slotPush),
27032704
TempName(slotPop),
27042705
slotPush.SlotType));
2706+
--prt.Indents;
2707+
2708+
prt.AppendLine("else");
2709+
++prt.Indents;
2710+
prt.Append("IL2CPP_THROW_INVALIDCAST;");
2711+
--prt.Indents;
2712+
2713+
inst.InstCode = prt.ToString();
27052714
}
27062715

27072716
private void GenLdfld(InstInfo inst, FieldX fldX, bool isAddr = false)

0 commit comments

Comments
 (0)