当前位置: 首页>>代码示例>>C#>>正文


C# ILProcessor.Replace方法代码示例

本文整理汇总了C#中Mono.Cecil.Cil.ILProcessor.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# ILProcessor.Replace方法的具体用法?C# ILProcessor.Replace怎么用?C# ILProcessor.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.Cil.ILProcessor的用法示例。


在下文中一共展示了ILProcessor.Replace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessCachedStaticFieldPattern

		private void ProcessCachedStaticFieldPattern(ILProcessor il, Instruction queryInvocation)
		{
			MethodReference predicateMethod = GetMethodReferenceFromStaticFieldPattern(queryInvocation);
			il.InsertBefore(queryInvocation, il.Create(OpCodes.Ldtoken, predicateMethod));

			// At this point the stack is like this:
			//     runtime method handle, delegate reference, ObjectContainer
			
			il.Replace(queryInvocation,
			               il.Create(OpCodes.Call,
			                             InstantiateGenericMethod(
			                             	_NativeQueryHandler_ExecuteInstrumentedStaticDelegateQuery,
			                             	GetQueryCallExtent(queryInvocation))));
		}
开发者ID:superyfwy,项目名称:db4o,代码行数:14,代码来源:QueryInvocationProcessor.cs

示例2: ProcessPredicateCreationPattern

		private void ProcessPredicateCreationPattern(ILProcessor il, Instruction queryInvocation)
		{
			MethodReference predicateMethod = GetMethodReferenceFromInlinePredicatePattern(queryInvocation);

			Instruction ldftn = GetNthPrevious(queryInvocation, 2);
			il.InsertBefore(ldftn, il.Create(OpCodes.Dup));

			il.InsertBefore(queryInvocation, il.Create(OpCodes.Ldtoken, predicateMethod));

			// At this point the stack is like this:
			//     runtime method handle, delegate reference, target object, ObjectContainer
			il.Replace(queryInvocation,
			               il.Create(OpCodes.Call,
			                             InstantiateGenericMethod(
			                             	_NativeQueryHandler_ExecuteInstrumentedDelegateQuery,
			                             	GetQueryCallExtent(queryInvocation))));
		}
开发者ID:erdincay,项目名称:db4o,代码行数:17,代码来源:QueryInvocationProcessor.cs

示例3: ReplaceFixedArrayStatement

        private void ReplaceFixedArrayStatement(MethodDefinition method, ILProcessor ilProcessor, Instruction fixedtoPatch)
        {
            var paramT = ((GenericInstanceMethod)fixedtoPatch.Operand).GenericArguments[0];
            // Preparing locals
            // local(0) T*
            method.Body.Variables.Add(new VariableDefinition("pin", new PinnedType(new ByReferenceType(paramT))));

            int index = method.Body.Variables.Count - 1;

            Instruction ldlocFixed;
            Instruction stlocFixed;
            switch (index)
            {
                case 0:
                    stlocFixed = ilProcessor.Create(OpCodes.Stloc_0);
                    ldlocFixed = ilProcessor.Create(OpCodes.Ldloc_0);
                    break;
                case 1:
                    stlocFixed = ilProcessor.Create(OpCodes.Stloc_1);
                    ldlocFixed = ilProcessor.Create(OpCodes.Ldloc_1);
                    break;
                case 2:
                    stlocFixed = ilProcessor.Create(OpCodes.Stloc_2);
                    ldlocFixed = ilProcessor.Create(OpCodes.Ldloc_2);
                    break;
                case 3:
                    stlocFixed = ilProcessor.Create(OpCodes.Stloc_3);
                    ldlocFixed = ilProcessor.Create(OpCodes.Ldloc_3);
                    break;
                default:
                    stlocFixed = ilProcessor.Create(OpCodes.Stloc, index);
                    ldlocFixed = ilProcessor.Create(OpCodes.Ldloc, index);
                    break;
            }

            var instructionLdci40 = ilProcessor.Create(OpCodes.Ldc_I4_0);
            ilProcessor.InsertBefore(fixedtoPatch, instructionLdci40);
            var instructionLdElema = ilProcessor.Create(OpCodes.Ldelema, paramT);
            ilProcessor.InsertBefore(fixedtoPatch, instructionLdElema);
            ilProcessor.InsertBefore(fixedtoPatch, stlocFixed);
            ilProcessor.Replace(fixedtoPatch, ldlocFixed);
        }
开发者ID:RecursiveCall,项目名称:SharpDX,代码行数:42,代码来源:InteropApp.cs

示例4: ReplaceSizeOfStructGeneric

 private void ReplaceSizeOfStructGeneric(MethodDefinition method, ILProcessor ilProcessor, Instruction fixedtoPatch)
 {
     var paramT = ((GenericInstanceMethod)fixedtoPatch.Operand).GenericArguments[0];
     var copyInstruction = ilProcessor.Create(OpCodes.Sizeof, paramT);
     ilProcessor.Replace(fixedtoPatch, copyInstruction);
 }
开发者ID:RecursiveCall,项目名称:SharpDX,代码行数:6,代码来源:InteropApp.cs

示例5: ReplaceIncrementPinnedStructGeneric

        private void ReplaceIncrementPinnedStructGeneric(MethodDefinition method, ILProcessor ilProcessor, Instruction incrementPinnedToPatch)
        {
            var paramT = ((GenericInstanceMethod)incrementPinnedToPatch.Operand).GenericArguments[0];

            var sizeOfInst = ilProcessor.Create(OpCodes.Sizeof, paramT);

            ilProcessor.Replace(incrementPinnedToPatch, sizeOfInst);
            ilProcessor.InsertAfter(sizeOfInst, ilProcessor.Create(OpCodes.Add));
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:9,代码来源:InteropProcessor.cs

示例6: ReplaceWriteInline

 private static void ReplaceWriteInline(MethodReference methodDescr, ILProcessor ilGen, Instruction instructionToPatch)
 {
     TypeReference paramT = ((GenericInstanceMethod) instructionToPatch.Operand).GenericArguments[0];
     Instruction newInstruction = ilGen.Create(OpCodes.Cpobj, paramT);
     ilGen.Replace(instructionToPatch, newInstruction);
 }
开发者ID:Relfos,项目名称:assimp_terra_exporter,代码行数:6,代码来源:Program.cs

示例7: ReplaceBranchesWithLeaves

 private void ReplaceBranchesWithLeaves(ILProcessor il, ExceptionHandler handler)
 {
     var current = handler.TryStart;
     while (current != handler.TryEnd)
     {
         var next = current.Next;
         if (current.OpCode == OpCodes.Br && ((Instruction)current.Operand).Offset > handler.TryEnd.Offset)
             il.Replace(current, il.Create(OpCodes.Leave, (Instruction)current.Operand));
         current = next;
     }
 }
开发者ID:ropean,项目名称:Usable,代码行数:11,代码来源:ModuleWeaver.cs


注:本文中的Mono.Cecil.Cil.ILProcessor.Replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。