public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            // apply the flat junctions traspiler
            instructions = FlatJunctionsCommons.ModifyFlatJunctionsTranspiler(instructions, targetMethod_);

            CodeInstruction ldarg_startNodeID       = GetLDArg(targetMethod_, "startNodeID"); // push startNodeID into stack,
            CodeInstruction ldarg_segmentID         = GetLDArg(targetMethod_, "ignoreSegmentID");
            CodeInstruction ldarg_leftSide          = GetLDArg(targetMethod_, "leftSide");
            CodeInstruction call_GetMinCornerOffset = new CodeInstruction(OpCodes.Call, mGetMinCornerOffset);

            int n = 0;

            foreach (var instruction in instructions)
            {
                yield return(instruction);

                bool is_ldfld_minCornerOffset =
                    instruction.opcode == OpCodes.Ldfld && instruction.operand == f_minCornerOffset;
                if (is_ldfld_minCornerOffset)
                {
                    n++;
                    yield return(ldarg_startNodeID);

                    yield return(ldarg_segmentID);

                    yield return(ldarg_leftSide);

                    yield return(call_GetMinCornerOffset);
                }
            }

            Log.Debug($"TRANSPILER CalculateCornerPatch: Successfully patched NetSegment.CalculateCorner(). " +
                      $"found {n} instances of Ldfld NetInfo.m_minCornerOffset");
            yield break;
        }
예제 #2
0
 public static IEnumerable <CodeInstruction> Transpiler(
     IEnumerable <CodeInstruction> instructions, MethodBase original)
 {
     return(FlatJunctionsCommons.ModifyFlatJunctionsTranspiler(instructions, original));
 }
 public static IEnumerable <CodeInstruction> Transpiler(ILGenerator il, IEnumerable <CodeInstruction> instructions)
 {
     return(FlatJunctionsCommons.ModifyFlatJunctionsTranspiler(instructions, targetMethod_));
 }