예제 #1
0
        private void ilList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ilList.SelectedItem is ILInstruction)
            {
                var selectedInstruction = (ILInstruction)ilList.SelectedItem;

                this.descriptionLabel.Content = OpCodeDescriber.Describe(selectedInstruction.OpCode);
            }
        }
예제 #2
0
        /// <summary>
        /// Executes the IL instruction, returns an offset if branching was requested.
        /// </summary>
        /// <param name="instruction">The instruction to execute</param>
        /// <param name="vCLRExecContext">The context of the executed method</param>
        /// <param name="callerContext">A reference to caller's context</param>
        /// <returns>Returns an offset (if branching was requested)</returns>
        private object ExecuteInstruction(ILInstruction instruction, VCLRExecContext vCLRExecContext, VCLRExecContext callerContext = null)
        {
            switch (instruction.OpCode)
            {
            case EnumOpCode.Nop:
                break;           //do nothing

            case EnumOpCode.Ret: //Returns from the current method, pushing a return value (if present) from the callee's evaluation stack onto the caller's evaluation stack.
                Ret(instruction, vCLRExecContext, callerContext);
                break;

            case EnumOpCode.Blt:
                Blt(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Pop:
                Pop(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4:
                Ldc_I4(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_0:
                Ldc_I4_0(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_1:
                Ldc_I4_1(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_2:
                Ldc_I4_2(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_3:
                Ldc_I4_3(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_4:
                Ldc_I4_4(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_5:
                Ldc_I4_5(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_7:
                Ldc_I4_7(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_8:
                Ldc_I4_8(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_M1:
                Ldc_I4_M1(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldc_I4_S:
                Ldc_I4_S(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldloc_S:
                Ldloc_S(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldloc_0:
                Ldloc_0(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldloc_1:
                Ldloc_1(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldloc_2:
                Ldloc_2(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldloc_3:
                Ldloc_3(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stloc_S:
                Stloc(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stloc_0:
                Stloc_0(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stloc_1:
                Stloc_1(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stloc_2:
                Stloc_2(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stloc_3:
                Stloc_3(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Br_S:
                return(Br_S(instruction, vCLRExecContext));

            case EnumOpCode.Blt_S:
                return(Blt_S(instruction, vCLRExecContext));

            case EnumOpCode.Clt:
                Clt(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Cgt:
                Cgt(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ceq:
                Ceq(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Br:
                return(Br(instruction, vCLRExecContext));

                break;

            case EnumOpCode.Brtrue_S:
                return(Brtrue_S(instruction, vCLRExecContext));

            case EnumOpCode.Ldstr:
                Ldstr(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Add:
                Add(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Call:
                Call(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Callvirt:
                Callvirt(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldarg_0:
                Ldarg_0(instruction, vCLRExecContext, callerContext);
                break;

            case EnumOpCode.Ldarg_1:
                Ldarg_1(instruction, vCLRExecContext, callerContext);
                break;

            case EnumOpCode.Ldarg_2:
                Ldarg_2(instruction, vCLRExecContext, callerContext);
                break;

            case EnumOpCode.Ldarg_3:
                Ldarg_3(instruction, vCLRExecContext, callerContext);
                break;

            case EnumOpCode.Box:
                Box(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stfld:
                Stfld(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Newobj:
                Newobj(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Dup:
                Dup(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Newarr:
                Newarr(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stelem_Ref:
                Stelem_Ref(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Brtrue:
                return(Brtrue(instruction, vCLRExecContext));

                break;

            case EnumOpCode.Leave_S:
                return(Leave_S(instruction, vCLRExecContext));

                break;

            case EnumOpCode.Ldlen:
                Ldlen(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Conv_I4:
                Conv_I4(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldelem_Ref:
                Ldelem_Ref(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Brfalse_S:
                return(Brfalse_S(instruction, vCLRExecContext));

                break;

            case EnumOpCode.Ldsfld:
                Ldsfld(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldsflda:
                Ldsflda(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldnull:
                Ldnull(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldftn:
                Ldftn(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Stsfld:
                Stsfld(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ldfld:
                Ldfld(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Volatile:
                Volatile(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Mkrefany:
                Mkrefany(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Throw:
                Throw(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Bne_Un_S:
                return(Bne_Un_S(instruction, vCLRExecContext));

            case EnumOpCode.Ldloca_S:
                Ldloca_S(instruction, vCLRExecContext);
                break;

            case EnumOpCode.Ble_S:
                return(Ble_S(instruction, vCLRExecContext));

            case EnumOpCode.Conv_I8:
                Conv_I8(instruction, vCLRExecContext);
                break;

            default:
                throw new NotImplementedException(string.Format("OpCode {0} - Not Implemented\r\nDescription: {1}", instruction.OpCodeInfo.Name, OpCodeDescriber.Describe(instruction.OpCode)));
            }

            return(null);
        }