After replacing some instructions that are the target of jumps, the target references still point to the old, removed instructions, this causes the removed instruction to be used as the key for the stack_sizes dictionary, so the new target instructions completely ignore the transferred stack_size.
Here is an example log showing the changing stack sizes, the associated entry in the stack_sizes dictionary for each instruction, and the actual instruction where the branch stack_size is being copied to (note that those instructions were replaced). Stack Size | Branch Stack Size | Instruction ... > 1 | x | IL_00f8: ldarg.0 > 1 | x | IL_00f9: ldfld System.Collections.Generic.Queue`1<System.String> > StardewValley.Minigames.GrandpaStory::grandpaSpeech > 2 | x | IL_00fe: ldstr "Quando isso acontecer," > 3 | x | IL_0103: ldsfld StardewValley.Farmer StardewValley.Game1::player > 3 | x | IL_0108: ldfld System.Boolean StardewValley.Farmer::isMale > Copying branch stack to IL_0116: ldstr " my boy," > 2 | x | IL_010d: brtrue.s IL_0116 > 3 | x | IL_010f: ldstr " minha querida, você estará pronta" > Copying branch stack to IL_011b: ldstr " you'll be ready for this gift." > 0 | x | IL_0114: br.s IL_011b > 1 | x | IL_0116: ldstr " meu garoto, você estará pronto" > 2 | x | IL_011b: ldstr " para esse presente." > 0 | x | IL_0120: call System.String > System.String::Concat(System.String,System.String,System.String) > -2 | x | IL_0125: callvirt System.Void > System.Collections.Generic.Queue`1<System.String>::Enqueue(!0) > -1 | x | IL_012a: ldarg.0 > ... As the example shows, it can lead to negative stack_size and incorrect .maxstack . -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
