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


C# Cil.Instruction类代码示例

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


Instruction类属于Mono.Cecil.Cil命名空间,在下文中一共展示了Instruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadOperand

		public object ReadOperand(Instruction instruction)
		{
			while (instruction.Operand is Instruction)
				instruction = (Instruction)instruction.Operand;

			return instruction.Operand;
		}
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:7,代码来源:ILAnalyzer.cs

示例2: IsCastTo

		private static bool IsCastTo(TypeDefinition castTarget, Instruction instruction)
		{
			if (instruction.OpCode != OpCodes.Castclass) return false;

			TypeReference typeReference = (TypeReference)instruction.Operand;
			return typeReference.Resolve() == castTarget;
		}
开发者ID:Galigator,项目名称:db4o,代码行数:7,代码来源:StackAnalyzerTestCase.Helper.cs

示例3: InsertFront

 public static void InsertFront(this ILProcessor processor, Instruction instr)
 {
     if (processor.Body.Instructions.Count <= 0)
         processor.Append(instr);
     else
         processor.InsertBefore(processor.Body.Instructions[0], instr);
 }
开发者ID:stschake,项目名称:obfuscatus,代码行数:7,代码来源:Extensions.cs

示例4: GetCallArguments

        /// <summary>
        /// Gets the instructions that generate the arguments for the call in the given instructions.
        /// </summary>
        public static Instruction[] GetCallArguments(this Instruction call, ILSequence sequence, bool includeThis)
        {
            var method = (MethodReference)call.Operand;
            var count = method.Parameters.Count;
            if (includeThis && method.HasThis)
            {
                count++;
            }
            var result = new Instruction[count];

            var current = call;
            var height = count;
            for (int i = count - 1; i >= 0; i--)
            {
                // Look for the starting instruction where stack height is i
                while (result[i] == null)
                {
                    var prevIndex = sequence.IndexOf(current);
                    var prev = (prevIndex >= 1) ? sequence[prevIndex - 1] : null;
                    if (prev == null)
                        throw new ArgumentException(string.Format("Cannot find arguments for call to {0}", method));
                    height -= prev.GetPushDelta();
                    if (height == i)
                        result[i] = prev;
                    height += prev.GetPopDelta(0, true);
                    current = prev;
                }
            }

            return result;
        }
开发者ID:rfcclub,项目名称:dot42,代码行数:34,代码来源:Instructions.cs

示例5: IsMethodCallOnList

		private static bool IsMethodCallOnList(Instruction candidate)
		{
			if (candidate.OpCode != OpCodes.Call && candidate.OpCode != OpCodes.Callvirt) return false;

			MethodDefinition callee = ((MethodReference)candidate.Operand).Resolve();
			return callee.DeclaringType.Resolve().FullName == callee.DeclaringType.Module.Import(typeof(List<>)).FullName;
		}
开发者ID:Galigator,项目名称:db4o,代码行数:7,代码来源:StackAnalyzerTestCase.Helper.cs

示例6: OptimizeInstruction

        /// <summary>
        /// Performs the optimization starting at the current instruction.
        /// </summary>
        /// <param name="instruction">The instruction to target.</param>
        /// <param name="worker">The worker for optimization actions.</param>
        public override void OptimizeInstruction(Instruction instruction, OptimizationWorker worker)
        {
            // TODO: allow arguments
            // TODO: allow return values
            // TODO: allow generic methods
            // TODO: allow non-static methods
            var opCode = instruction.OpCode;
            if (opCode.FlowControl != FlowControl.Call)
            {
                return;
            }

            var methodRef = (MethodReference) instruction.Operand;
            var typeRef = methodRef.DeclaringType;
            var module = typeRef.Module;

            var type = module.Types[typeRef.FullName];
            if (type == null)
            {
                return;
            }

            var method = type.Methods.GetMethod(methodRef.Name, methodRef.Parameters);
            bool shouldInlineMethod;
            if (!this.shouldInline.TryGetValue(method, out shouldInlineMethod))
            {
                shouldInlineMethod = this.configuration.ShouldInline(method);
                this.shouldInline[method] = shouldInlineMethod;
            }

            if (shouldInlineMethod)
            {
                InlineMethod(instruction, worker, method);
            }
        }
开发者ID:OliverHallam,项目名称:Illustrious,代码行数:40,代码来源:InlineFunctionCall.cs

示例7: CompiledString

        public CompiledString(MethodDefinition method, Instruction instruction)
        {
            Method = method;
            Instruction = instruction;

            OriginalValue = Value;
        }
开发者ID:Xcelled,项目名称:net-string-editor,代码行数:7,代码来源:CompiledString.cs

示例8: ChangeThreeToSeven

 public static void ChangeThreeToSeven(Instruction i)
 {
     if (i.OpCode.Code == Code.Ldc_I4_3 && i.Previous.OpCode == OpCodes.Stloc_S && i.Next.OpCode == OpCodes.Stloc_S)
     {
         i.OpCode = OpCodes.Ldc_I4_7;
     }
 }
开发者ID:Jonesey13,项目名称:TF-8-Player,代码行数:7,代码来源:VersusRoundResults.cs

示例9: EmitCodeInit

 private Instruction EmitCodeInit(TypeReference role, Instruction instructionBeforeInit, ILProcessor il)
 {
     var current = instructionBeforeInit;
       current = InsertAfter(il, current, il.Create(OpCodes.Ldarg_0));
       current = InsertAfter(il, current, il.Create(OpCodes.Call, ResolveInitReference(role)));
       return current;
 }
开发者ID:cessationoftime,项目名称:nroles,代码行数:7,代码来源:RoleComposer.Initialization.cs

示例10: StackAnalysisResult

		public StackAnalysisResult(Instruction consumer, int offset, bool match, int stackHeight)
		{
			_consumer = consumer;
			_offset = offset;
			_match = match;
			_stackHeight = stackHeight;
		}
开发者ID:superyfwy,项目名称:db4o,代码行数:7,代码来源:StackAnalysisResult.cs

示例11: IsCallVirt

		// look for a virtual call to a specific method
		static bool IsCallVirt (Instruction ins, string typeName, string methodName)
		{
			if (ins.OpCode.Code != Code.Callvirt)
				return false;
			MethodReference mr = (ins.Operand as MethodReference);
			return ((mr != null) && (mr.Name == methodName) && (mr.DeclaringType.FullName == typeName));
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:8,代码来源:Pattern.cs

示例12: CountElementsInTheStack

		private static int CountElementsInTheStack (MethodDefinition method, Instruction start, Instruction end)
		{
			Instruction current = start;
			int counter = 0;
			bool newarrDetected = false;
			while (end != current) {
				if (newarrDetected) {
					//Count only the stelem instructions if
					//there are a newarr instruction.
					if (current.OpCode == OpCodes.Stelem_Ref)
						counter++;
				}
				else {
					//Count with the stack
					counter += current.GetPushCount ();
					counter -= current.GetPopCount (method);
				}
				//If there are a newarr we need an special
				//behaviour
				if (current.OpCode == OpCodes.Newarr) {
					newarrDetected = true;
					counter = 0;
				}
				current = current.Next;
			}
			return counter;
		}
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:27,代码来源:ProvideCorrectArgumentsToFormattingMethodsRule.cs

示例13: _Pushes

 protected override int _Pushes(Instruction i)
 {
     MethodReference method = (MethodReference)i.Operand;
     if (method.ReturnType == null)
         return 0;
     return 1;
 }
开发者ID:Robby777,项目名称:ambientsmell,代码行数:7,代码来源:InstructionInfo.cs

示例14: _Pops

 protected override int _Pops(Instruction i, int stackSize)
 {
     // Check i.Operand?
     if (stackSize == 1)
         return 1;
     return 0;
 }
开发者ID:Robby777,项目名称:ambientsmell,代码行数:7,代码来源:InstructionInfo.cs

示例15: IsFloatingPointArguments

		static bool IsFloatingPointArguments (Instruction ins, MethodDefinition method)
		{
			TypeReference tr = ins.GetOperandType (method);
			if (tr == null)
				return false;
			return tr.IsFloatingPoint ();
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:7,代码来源:ReviewCastOnIntegerMultiplicationRule.cs


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