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


C# Instruction.AsReverseEnumerable方法代码示例

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


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

示例1: ProcessNameOfCallInstruction

 private static void ProcessNameOfCallInstruction(Instruction instruction, ILProcessor ilProcessor)
 {
     var instructions = instruction.AsReverseEnumerable().Take(patterns.Value.First().Length).ToArray(); // Take an instruction set with a maximum size of the longest pattern.
     Boolean possibleMatch = false;
     PatternInstruction[] patternMatched = null;
     Func<String> terminal = null;
     foreach (var pattern in patterns.Value) {
         possibleMatch = true;
         terminal = null;
         for (Int32 i = 0, j = 0; i < pattern.Length && j < instructions.Length; ++i, ++j) {
             while (pattern[i] is OptionalPatternInstruction && !pattern[i].EligibleOpCodes.Contains(instructions[j].OpCode))
                 ++i;
             var patternInstruction = pattern[i];
             var currentInstruction = instructions[j];
             if (patternInstruction.EligibleOpCodes.Contains(currentInstruction.OpCode) && patternInstruction.IsPredicated(currentInstruction, ilProcessor)) {
                 if (patternInstruction.Terminal != null && terminal == null)
                     terminal = () => patternInstruction.Terminal(currentInstruction, ilProcessor);
                 if (patternInstruction.Action != null)
                     patternInstruction.Action(currentInstruction);
             }
             else {
                 possibleMatch = false;
                 break;
             }
         }
         if (possibleMatch && pattern.Count(x => !(x is OptionalPatternInstruction)) <= instructions.Length) {
             patternMatched = pattern;
             break;
         }
     }
     if (!possibleMatch)
         throw GetNotSupportedException(instruction); // The usage of Name.Of is not supported
     if (terminal == null)
         throw new NotImplementedException("There is no terminal expression implemented for the matched pattern.");
     String name;
     try {
         name = terminal();
         if (IsNullOrWhiteSpace(name))
             throw new Exception("Name not found.");
     }
     catch {
         throw GetNotSupportedException(instruction);
     }
     // TODO: Remove the anonymous methods generated by lamdba expressions in some uses of Name.Of...
     ilProcessor.InsertAfter(instruction, Instruction.Create(OpCodes.Ldstr, name));
     for (Int32 i = 0, j = 0; i < patternMatched.Length && j < instructions.Length; ++i, ++j) {
         while (patternMatched[i] is OptionalPatternInstruction && !patternMatched[i].EligibleOpCodes.Contains(instructions[j].OpCode))
             ++i;
         ilProcessor.Remove(instructions[j]);
     }
 }
开发者ID:Kleptine,项目名称:NameOf,代码行数:51,代码来源:ModuleWeaver.cs


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