當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。