示例#1
0
 internal void Advance()
 {
     this.instruction = this.instruction.Next;
 }
示例#2
0
 internal void Reset(Instruction instruction)
 {
     this.instruction = instruction;
     this.success = true;
 }
示例#3
0
 internal MatchContext(Instruction instruction)
 {
     Reset (instruction);
 }
示例#4
0
        void ResolveBranches()
        {
            foreach (var instruction in instructions) {
                switch (instruction.OpCode.OperandType) {
                case OperandType.ShortInlineBrTarget:
                case OperandType.InlineBrTarget:
                    instruction.Operand = GetInstruction (instructions, (int) instruction.Operand);
                    break;
                case OperandType.InlineSwitch:
                    var offsets = (int []) instruction.Operand;
                    var branches = new Instruction [offsets.Length];
                    for (int j = 0; j < offsets.Length; j++)
                        branches [j] = GetInstruction (instructions, offsets [j]);

                    instruction.Operand = branches;
                    break;
                }
            }
        }
示例#5
0
        void ReadOperand(Instruction instruction)
        {
            switch (instruction.OpCode.OperandType) {
            case OperandType.InlineNone:
                break;
            case OperandType.InlineSwitch:
                int length = il.ReadInt32 ();
                int base_offset = il.position + (4 * length);
                int [] branches = new int [length];
                for (int i = 0; i < length; i++)
                    branches [i] = il.ReadInt32 () + base_offset;

                instruction.Operand = branches;
                break;
            case OperandType.ShortInlineBrTarget:
                instruction.Operand = (((sbyte) il.ReadByte ()) + il.position);
                break;
            case OperandType.InlineBrTarget:
                instruction.Operand = il.ReadInt32 () + il.position;
                break;
            case OperandType.ShortInlineI:
                if (instruction.OpCode == OpCodes.Ldc_I4_S)
                    instruction.Operand = (sbyte) il.ReadByte ();
                else
                    instruction.Operand = il.ReadByte ();
                break;
            case OperandType.InlineI:
                instruction.Operand = il.ReadInt32 ();
                break;
            case OperandType.ShortInlineR:
                instruction.Operand = il.ReadSingle ();
                break;
            case OperandType.InlineR:
                instruction.Operand = il.ReadDouble ();
                break;
            case OperandType.InlineI8:
                instruction.Operand = il.ReadInt64 ();
                break;
            case OperandType.InlineSig:
                instruction.Operand = module.ResolveSignature (il.ReadInt32 ());
                break;
            case OperandType.InlineString:
                instruction.Operand = module.ResolveString (il.ReadInt32 ());
                break;
            case OperandType.InlineTok:
            case OperandType.InlineType:
            case OperandType.InlineMethod:
            case OperandType.InlineField:
                instruction.Operand = module.ResolveMember (il.ReadInt32 (), type_arguments, method_arguments);
                break;
            case OperandType.ShortInlineVar:
                instruction.Operand = GetVariable (instruction, il.ReadByte ());
                break;
            case OperandType.InlineVar:
                instruction.Operand = GetVariable (instruction, il.ReadInt16 ());
                break;
            default:
                throw new NotSupportedException ();
            }
        }
示例#6
0
 object GetVariable(Instruction instruction, int index)
 {
     return TargetsLocalVariable (instruction.OpCode)
         ? (object) GetLocalVariable (index)
         : (object) GetParameter (index);
 }
示例#7
0
 static void AppendLabel(StringBuilder builder, Instruction instruction)
 {
     builder.Append ("IL_");
     builder.Append (instruction.offset.ToString ("x4"));
 }