Esempio n. 1
0
            protected virtual partial void DisassembleNextOpCode(int currentIndex, short opcode)
            {
                switch (opcode)
                {
                case OpCodeConst.Nop:
                {
                    PushOperation(Inst.Nop());
                }
                    return;

                case OpCodeConst.Break:
                {
                    PushOperation(Inst.Break());
                }
                    return;

                case OpCodeConst.Ldarg_0:
                {
                    PushOperation(Inst.Ldarg_0());
                }
                    return;

                case OpCodeConst.Ldarg_1:
                {
                    PushOperation(Inst.Ldarg_1());
                }
                    return;

                case OpCodeConst.Ldarg_2:
                {
                    PushOperation(Inst.Ldarg_2());
                }
                    return;

                case OpCodeConst.Ldarg_3:
                {
                    PushOperation(Inst.Ldarg_3());
                }
                    return;

                case OpCodeConst.Ldloc_0:
                {
                    PushOperation(Inst.Ldloc_0());
                }
                    return;

                case OpCodeConst.Ldloc_1:
                {
                    PushOperation(Inst.Ldloc_1());
                }
                    return;

                case OpCodeConst.Ldloc_2:
                {
                    PushOperation(Inst.Ldloc_2());
                }
                    return;

                case OpCodeConst.Ldloc_3:
                {
                    PushOperation(Inst.Ldloc_3());
                }
                    return;

                case OpCodeConst.Stloc_0:
                {
                    PushOperation(Inst.Stloc_0());
                }
                    return;

                case OpCodeConst.Stloc_1:
                {
                    PushOperation(Inst.Stloc_1());
                }
                    return;

                case OpCodeConst.Stloc_2:
                {
                    PushOperation(Inst.Stloc_2());
                }
                    return;

                case OpCodeConst.Stloc_3:
                {
                    PushOperation(Inst.Stloc_3());
                }
                    return;

                case OpCodeConst.Ldarg_S:
                {
                    var value = ReadStreamHead <byte>();
                    PushOperation(Inst.Ldarg_S(value));
                }
                    return;

                case OpCodeConst.Ldarga_S:
                {
                    var value = ReadStreamHead <byte>();
                    PushOperation(Inst.Ldarga_S(value));
                }
                    return;

                case OpCodeConst.Starg_S:
                {
                    var value = ReadStreamHead <byte>();
                    PushOperation(Inst.Starg_S(value));
                }
                    return;

                case OpCodeConst.Ldloc_S:
                {
                    var value = ReadStreamHead <byte>();
                    PushOperation(Inst.Ldloc_S(value));
                }
                    return;

                case OpCodeConst.Ldloca_S:
                {
                    var value = ReadStreamHead <byte>();
                    PushOperation(Inst.Ldloca_S(value));
                }
                    return;

                case OpCodeConst.Stloc_S:
                {
                    var value = ReadStreamHead <byte>();
                    PushOperation(Inst.Stloc_S(value));
                }
                    return;

                case OpCodeConst.Ldnull:
                {
                    PushOperation(Inst.Ldnull());
                }
                    return;

                case OpCodeConst.Ldc_I4_M1:
                {
                    PushOperation(Inst.Ldc_I4_M1());
                }
                    return;

                case OpCodeConst.Ldc_I4_0:
                {
                    PushOperation(Inst.Ldc_I4_0());
                }
                    return;

                case OpCodeConst.Ldc_I4_1:
                {
                    PushOperation(Inst.Ldc_I4_1());
                }
                    return;

                case OpCodeConst.Ldc_I4_2:
                {
                    PushOperation(Inst.Ldc_I4_2());
                }
                    return;

                case OpCodeConst.Ldc_I4_3:
                {
                    PushOperation(Inst.Ldc_I4_3());
                }
                    return;

                case OpCodeConst.Ldc_I4_4:
                {
                    PushOperation(Inst.Ldc_I4_4());
                }
                    return;

                case OpCodeConst.Ldc_I4_5:
                {
                    PushOperation(Inst.Ldc_I4_5());
                }
                    return;

                case OpCodeConst.Ldc_I4_6:
                {
                    PushOperation(Inst.Ldc_I4_6());
                }
                    return;

                case OpCodeConst.Ldc_I4_7:
                {
                    PushOperation(Inst.Ldc_I4_7());
                }
                    return;

                case OpCodeConst.Ldc_I4_8:
                {
                    PushOperation(Inst.Ldc_I4_8());
                }
                    return;

                case OpCodeConst.Ldc_I4_S:
                {
                    var value = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Ldc_I4_S(value));
                }
                    return;

                case OpCodeConst.Ldc_I4:
                {
                    var value = ReadStreamHead <int>();
                    PushOperation(Inst.Ldc_I4(value));
                }
                    return;

                case OpCodeConst.Ldc_I8:
                {
                    var value = ReadStreamHead <long>();
                    PushOperation(Inst.Ldc_I8(value));
                }
                    return;

                case OpCodeConst.Ldc_R4:
                {
                    var value = ReadStreamHead <float>();
                    PushOperation(Inst.Ldc_R4(value));
                }
                    return;

                case OpCodeConst.Ldc_R8:
                {
                    var value = ReadStreamHead <double>();
                    PushOperation(Inst.Ldc_R8(value));
                }
                    return;

                case OpCodeConst.Dup:
                {
                    PushOperation(Inst.Dup());
                }
                    return;

                case OpCodeConst.Pop:
                {
                    PushOperation(Inst.Pop());
                }
                    return;

                case OpCodeConst.Jmp:
                {
                    var callable = Method.DeclaringType.Module.ResolveMethod(ReadStreamHead <int>());
                    if (callable is MethodInfo meth)
                    {
                        PushOperation(Inst.Jmp(meth));
                    }
                    else if (callable is ConstructorInfo ctor)
                    {
                        PushOperation(Inst.Jmp(ctor));
                    }
                }
                    return;

                case OpCodeConst.Call:
                {
                    var callable = Method.DeclaringType.Module.ResolveMethod(ReadStreamHead <int>());
                    if (callable is MethodInfo meth)
                    {
                        PushOperation(Inst.Call(meth));
                    }
                    else if (callable is ConstructorInfo ctor)
                    {
                        PushOperation(Inst.Call(ctor));
                    }
                }
                    return;

                case OpCodeConst.Calli:
                {
                    // var sig = Method.DeclaringType.Module.ResolveSignature(ReadStreamHead<int>());
                    // PushOperation(Inst.Calli(sig));
                    throw new NotSupportedException();
                }
                    return;

                case OpCodeConst.Ret:
                {
                    PushOperation(Inst.Ret());
                }
                    return;

                case OpCodeConst.Br_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Br_S(GetOrAddLabel(currentIndex + OpCodes.Br_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Brfalse_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Brfalse_S(GetOrAddLabel(currentIndex + OpCodes.Brfalse_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Brtrue_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Brtrue_S(GetOrAddLabel(currentIndex + OpCodes.Brtrue_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Beq_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Beq_S(GetOrAddLabel(currentIndex + OpCodes.Beq_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bge_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Bge_S(GetOrAddLabel(currentIndex + OpCodes.Bge_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bgt_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Bgt_S(GetOrAddLabel(currentIndex + OpCodes.Bgt_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Ble_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Ble_S(GetOrAddLabel(currentIndex + OpCodes.Ble_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Blt_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Blt_S(GetOrAddLabel(currentIndex + OpCodes.Blt_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bne_Un_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Bne_Un_S(GetOrAddLabel(currentIndex + OpCodes.Bne_Un_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bge_Un_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Bge_Un_S(GetOrAddLabel(currentIndex + OpCodes.Bge_Un_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bgt_Un_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Bgt_Un_S(GetOrAddLabel(currentIndex + OpCodes.Bgt_Un_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Ble_Un_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Ble_Un_S(GetOrAddLabel(currentIndex + OpCodes.Ble_Un_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Blt_Un_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Blt_Un_S(GetOrAddLabel(currentIndex + OpCodes.Blt_Un_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Br:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Br(GetOrAddLabel(currentIndex + OpCodes.Br.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Brfalse:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Brfalse(GetOrAddLabel(currentIndex + OpCodes.Brfalse.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Brtrue:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Brtrue(GetOrAddLabel(currentIndex + OpCodes.Brtrue.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Beq:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Beq(GetOrAddLabel(currentIndex + OpCodes.Beq.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bge:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Bge(GetOrAddLabel(currentIndex + OpCodes.Bge.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bgt:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Bgt(GetOrAddLabel(currentIndex + OpCodes.Bgt.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Ble:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Ble(GetOrAddLabel(currentIndex + OpCodes.Ble.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Blt:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Blt(GetOrAddLabel(currentIndex + OpCodes.Blt.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bne_Un:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Bne_Un(GetOrAddLabel(currentIndex + OpCodes.Bne_Un.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bge_Un:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Bge_Un(GetOrAddLabel(currentIndex + OpCodes.Bge_Un.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Bgt_Un:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Bgt_Un(GetOrAddLabel(currentIndex + OpCodes.Bgt_Un.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Ble_Un:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Ble_Un(GetOrAddLabel(currentIndex + OpCodes.Ble_Un.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Blt_Un:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Blt_Un(GetOrAddLabel(currentIndex + OpCodes.Blt_Un.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Switch:
                {
                    var labels = new LabelBuilder[ReadStreamHead <int>()];
                    for (var i = 0; i < labels.Length; ++i)
                    {
                        labels[i] = GetOrAddLabel(currentIndex + 4 * (1 + labels.Length) + ReadStreamHead <int>());
                    }
                    PushOperation(Inst.Switch(labels));
                }
                    return;

                case OpCodeConst.Ldind_I1:
                {
                    PushOperation(Inst.Ldind_I1());
                }
                    return;

                case OpCodeConst.Ldind_U1:
                {
                    PushOperation(Inst.Ldind_U1());
                }
                    return;

                case OpCodeConst.Ldind_I2:
                {
                    PushOperation(Inst.Ldind_I2());
                }
                    return;

                case OpCodeConst.Ldind_U2:
                {
                    PushOperation(Inst.Ldind_U2());
                }
                    return;

                case OpCodeConst.Ldind_I4:
                {
                    PushOperation(Inst.Ldind_I4());
                }
                    return;

                case OpCodeConst.Ldind_U4:
                {
                    PushOperation(Inst.Ldind_U4());
                }
                    return;

                case OpCodeConst.Ldind_I8:
                {
                    PushOperation(Inst.Ldind_I8());
                }
                    return;

                case OpCodeConst.Ldind_I:
                {
                    PushOperation(Inst.Ldind_I());
                }
                    return;

                case OpCodeConst.Ldind_R4:
                {
                    PushOperation(Inst.Ldind_R4());
                }
                    return;

                case OpCodeConst.Ldind_R8:
                {
                    PushOperation(Inst.Ldind_R8());
                }
                    return;

                case OpCodeConst.Ldind_Ref:
                {
                    PushOperation(Inst.Ldind_Ref());
                }
                    return;

                case OpCodeConst.Stind_Ref:
                {
                    PushOperation(Inst.Stind_Ref());
                }
                    return;

                case OpCodeConst.Stind_I1:
                {
                    PushOperation(Inst.Stind_I1());
                }
                    return;

                case OpCodeConst.Stind_I2:
                {
                    PushOperation(Inst.Stind_I2());
                }
                    return;

                case OpCodeConst.Stind_I4:
                {
                    PushOperation(Inst.Stind_I4());
                }
                    return;

                case OpCodeConst.Stind_I8:
                {
                    PushOperation(Inst.Stind_I8());
                }
                    return;

                case OpCodeConst.Stind_R4:
                {
                    PushOperation(Inst.Stind_R4());
                }
                    return;

                case OpCodeConst.Stind_R8:
                {
                    PushOperation(Inst.Stind_R8());
                }
                    return;

                case OpCodeConst.Add:
                {
                    PushOperation(Inst.Add());
                }
                    return;

                case OpCodeConst.Sub:
                {
                    PushOperation(Inst.Sub());
                }
                    return;

                case OpCodeConst.Mul:
                {
                    PushOperation(Inst.Mul());
                }
                    return;

                case OpCodeConst.Div:
                {
                    PushOperation(Inst.Div());
                }
                    return;

                case OpCodeConst.Div_Un:
                {
                    PushOperation(Inst.Div_Un());
                }
                    return;

                case OpCodeConst.Rem:
                {
                    PushOperation(Inst.Rem());
                }
                    return;

                case OpCodeConst.Rem_Un:
                {
                    PushOperation(Inst.Rem_Un());
                }
                    return;

                case OpCodeConst.And:
                {
                    PushOperation(Inst.And());
                }
                    return;

                case OpCodeConst.Or:
                {
                    PushOperation(Inst.Or());
                }
                    return;

                case OpCodeConst.Xor:
                {
                    PushOperation(Inst.Xor());
                }
                    return;

                case OpCodeConst.Shl:
                {
                    PushOperation(Inst.Shl());
                }
                    return;

                case OpCodeConst.Shr:
                {
                    PushOperation(Inst.Shr());
                }
                    return;

                case OpCodeConst.Shr_Un:
                {
                    PushOperation(Inst.Shr_Un());
                }
                    return;

                case OpCodeConst.Neg:
                {
                    PushOperation(Inst.Neg());
                }
                    return;

                case OpCodeConst.Not:
                {
                    PushOperation(Inst.Not());
                }
                    return;

                case OpCodeConst.Conv_I1:
                {
                    PushOperation(Inst.Conv_I1());
                }
                    return;

                case OpCodeConst.Conv_I2:
                {
                    PushOperation(Inst.Conv_I2());
                }
                    return;

                case OpCodeConst.Conv_I4:
                {
                    PushOperation(Inst.Conv_I4());
                }
                    return;

                case OpCodeConst.Conv_I8:
                {
                    PushOperation(Inst.Conv_I8());
                }
                    return;

                case OpCodeConst.Conv_R4:
                {
                    PushOperation(Inst.Conv_R4());
                }
                    return;

                case OpCodeConst.Conv_R8:
                {
                    PushOperation(Inst.Conv_R8());
                }
                    return;

                case OpCodeConst.Conv_U4:
                {
                    PushOperation(Inst.Conv_U4());
                }
                    return;

                case OpCodeConst.Conv_U8:
                {
                    PushOperation(Inst.Conv_U8());
                }
                    return;

                case OpCodeConst.Callvirt:
                {
                    var callable = Method.DeclaringType.Module.ResolveMethod(ReadStreamHead <int>());
                    if (callable is MethodInfo meth)
                    {
                        PushOperation(Inst.Callvirt(meth));
                    }
                    else if (callable is ConstructorInfo ctor)
                    {
                        PushOperation(Inst.Callvirt(ctor));
                    }
                }
                    return;

                case OpCodeConst.Cpobj:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Cpobj(type));
                }
                    return;

                case OpCodeConst.Ldobj:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Ldobj(type));
                }
                    return;

                case OpCodeConst.Ldstr:
                {
                    var str = Method.DeclaringType.Module.ResolveString(ReadStreamHead <int>());
                    PushOperation(Inst.Ldstr(str));
                }
                    return;

                case OpCodeConst.Newobj:
                {
                    var callable = Method.DeclaringType.Module.ResolveMethod(ReadStreamHead <int>());
                    if (callable is MethodInfo meth)
                    {
                        PushOperation(Inst.Newobj(meth));
                    }
                    else if (callable is ConstructorInfo ctor)
                    {
                        PushOperation(Inst.Newobj(ctor));
                    }
                }
                    return;

                case OpCodeConst.Castclass:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Castclass(type));
                }
                    return;

                case OpCodeConst.Isinst:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Isinst(type));
                }
                    return;

                case OpCodeConst.Conv_R_Un:
                {
                    PushOperation(Inst.Conv_R_Un());
                }
                    return;

                case OpCodeConst.Unbox:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Unbox(type));
                }
                    return;

                case OpCodeConst.Throw:
                {
                    PushOperation(Inst.Throw());
                }
                    return;

                case OpCodeConst.Ldfld:
                {
                    var fld = Method.DeclaringType.Module.ResolveField(ReadStreamHead <int>());
                    PushOperation(Inst.Ldfld(fld));
                }
                    return;

                case OpCodeConst.Ldflda:
                {
                    var fld = Method.DeclaringType.Module.ResolveField(ReadStreamHead <int>());
                    PushOperation(Inst.Ldflda(fld));
                }
                    return;

                case OpCodeConst.Stfld:
                {
                    var fld = Method.DeclaringType.Module.ResolveField(ReadStreamHead <int>());
                    PushOperation(Inst.Stfld(fld));
                }
                    return;

                case OpCodeConst.Ldsfld:
                {
                    var fld = Method.DeclaringType.Module.ResolveField(ReadStreamHead <int>());
                    PushOperation(Inst.Ldsfld(fld));
                }
                    return;

                case OpCodeConst.Ldsflda:
                {
                    var fld = Method.DeclaringType.Module.ResolveField(ReadStreamHead <int>());
                    PushOperation(Inst.Ldsflda(fld));
                }
                    return;

                case OpCodeConst.Stsfld:
                {
                    var fld = Method.DeclaringType.Module.ResolveField(ReadStreamHead <int>());
                    PushOperation(Inst.Stsfld(fld));
                }
                    return;

                case OpCodeConst.Stobj:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Stobj(type));
                }
                    return;

                case OpCodeConst.Conv_Ovf_I1_Un:
                {
                    PushOperation(Inst.Conv_Ovf_I1_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I2_Un:
                {
                    PushOperation(Inst.Conv_Ovf_I2_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I4_Un:
                {
                    PushOperation(Inst.Conv_Ovf_I4_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I8_Un:
                {
                    PushOperation(Inst.Conv_Ovf_I8_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U1_Un:
                {
                    PushOperation(Inst.Conv_Ovf_U1_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U2_Un:
                {
                    PushOperation(Inst.Conv_Ovf_U2_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U4_Un:
                {
                    PushOperation(Inst.Conv_Ovf_U4_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U8_Un:
                {
                    PushOperation(Inst.Conv_Ovf_U8_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I_Un:
                {
                    PushOperation(Inst.Conv_Ovf_I_Un());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U_Un:
                {
                    PushOperation(Inst.Conv_Ovf_U_Un());
                }
                    return;

                case OpCodeConst.Box:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Box(type));
                }
                    return;

                case OpCodeConst.Newarr:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Newarr(type));
                }
                    return;

                case OpCodeConst.Ldlen:
                {
                    PushOperation(Inst.Ldlen());
                }
                    return;

                case OpCodeConst.Ldelema:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Ldelema(type));
                }
                    return;

                case OpCodeConst.Ldelem_I1:
                {
                    PushOperation(Inst.Ldelem_I1());
                }
                    return;

                case OpCodeConst.Ldelem_U1:
                {
                    PushOperation(Inst.Ldelem_U1());
                }
                    return;

                case OpCodeConst.Ldelem_I2:
                {
                    PushOperation(Inst.Ldelem_I2());
                }
                    return;

                case OpCodeConst.Ldelem_U2:
                {
                    PushOperation(Inst.Ldelem_U2());
                }
                    return;

                case OpCodeConst.Ldelem_I4:
                {
                    PushOperation(Inst.Ldelem_I4());
                }
                    return;

                case OpCodeConst.Ldelem_U4:
                {
                    PushOperation(Inst.Ldelem_U4());
                }
                    return;

                case OpCodeConst.Ldelem_I8:
                {
                    PushOperation(Inst.Ldelem_I8());
                }
                    return;

                case OpCodeConst.Ldelem_I:
                {
                    PushOperation(Inst.Ldelem_I());
                }
                    return;

                case OpCodeConst.Ldelem_R4:
                {
                    PushOperation(Inst.Ldelem_R4());
                }
                    return;

                case OpCodeConst.Ldelem_R8:
                {
                    PushOperation(Inst.Ldelem_R8());
                }
                    return;

                case OpCodeConst.Ldelem_Ref:
                {
                    PushOperation(Inst.Ldelem_Ref());
                }
                    return;

                case OpCodeConst.Stelem_I:
                {
                    PushOperation(Inst.Stelem_I());
                }
                    return;

                case OpCodeConst.Stelem_I1:
                {
                    PushOperation(Inst.Stelem_I1());
                }
                    return;

                case OpCodeConst.Stelem_I2:
                {
                    PushOperation(Inst.Stelem_I2());
                }
                    return;

                case OpCodeConst.Stelem_I4:
                {
                    PushOperation(Inst.Stelem_I4());
                }
                    return;

                case OpCodeConst.Stelem_I8:
                {
                    PushOperation(Inst.Stelem_I8());
                }
                    return;

                case OpCodeConst.Stelem_R4:
                {
                    PushOperation(Inst.Stelem_R4());
                }
                    return;

                case OpCodeConst.Stelem_R8:
                {
                    PushOperation(Inst.Stelem_R8());
                }
                    return;

                case OpCodeConst.Stelem_Ref:
                {
                    PushOperation(Inst.Stelem_Ref());
                }
                    return;

                case OpCodeConst.Ldelem:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Ldelem(type));
                }
                    return;

                case OpCodeConst.Stelem:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Stelem(type));
                }
                    return;

                case OpCodeConst.Unbox_Any:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Unbox_Any(type));
                }
                    return;

                case OpCodeConst.Conv_Ovf_I1:
                {
                    PushOperation(Inst.Conv_Ovf_I1());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U1:
                {
                    PushOperation(Inst.Conv_Ovf_U1());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I2:
                {
                    PushOperation(Inst.Conv_Ovf_I2());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U2:
                {
                    PushOperation(Inst.Conv_Ovf_U2());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I4:
                {
                    PushOperation(Inst.Conv_Ovf_I4());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U4:
                {
                    PushOperation(Inst.Conv_Ovf_U4());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I8:
                {
                    PushOperation(Inst.Conv_Ovf_I8());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U8:
                {
                    PushOperation(Inst.Conv_Ovf_U8());
                }
                    return;

                case OpCodeConst.Refanyval:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Refanyval(type));
                }
                    return;

                case OpCodeConst.Ckfinite:
                {
                    PushOperation(Inst.Ckfinite());
                }
                    return;

                case OpCodeConst.Mkrefany:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Mkrefany(type));
                }
                    return;

                case OpCodeConst.Ldtoken:
                {
                    switch (Method.Module.ResolveMember(ReadStreamHead <int>()))
                    {
                    case Type type: PushOperation(Inst.Ldtoken(type));   break;

                    case MethodInfo method: PushOperation(Inst.Ldtoken(method)); break;

                    case FieldInfo field: PushOperation(Inst.Ldtoken(field));  break;

                    default: throw new InvalidOperationException();
                    }
                    throw new NotSupportedException();
                }
                    return;

                case OpCodeConst.Conv_U2:
                {
                    PushOperation(Inst.Conv_U2());
                }
                    return;

                case OpCodeConst.Conv_U1:
                {
                    PushOperation(Inst.Conv_U1());
                }
                    return;

                case OpCodeConst.Conv_I:
                {
                    PushOperation(Inst.Conv_I());
                }
                    return;

                case OpCodeConst.Conv_Ovf_I:
                {
                    PushOperation(Inst.Conv_Ovf_I());
                }
                    return;

                case OpCodeConst.Conv_Ovf_U:
                {
                    PushOperation(Inst.Conv_Ovf_U());
                }
                    return;

                case OpCodeConst.Add_Ovf:
                {
                    PushOperation(Inst.Add_Ovf());
                }
                    return;

                case OpCodeConst.Add_Ovf_Un:
                {
                    PushOperation(Inst.Add_Ovf_Un());
                }
                    return;

                case OpCodeConst.Mul_Ovf:
                {
                    PushOperation(Inst.Mul_Ovf());
                }
                    return;

                case OpCodeConst.Mul_Ovf_Un:
                {
                    PushOperation(Inst.Mul_Ovf_Un());
                }
                    return;

                case OpCodeConst.Sub_Ovf:
                {
                    PushOperation(Inst.Sub_Ovf());
                }
                    return;

                case OpCodeConst.Sub_Ovf_Un:
                {
                    PushOperation(Inst.Sub_Ovf_Un());
                }
                    return;

                case OpCodeConst.Endfinally:
                {
                    PushOperation(Inst.Endfinally());
                }
                    return;

                case OpCodeConst.Leave:
                {
                    var offset = ReadStreamHead <int>();
                    PushOperation(Inst.Leave(GetOrAddLabel(currentIndex + OpCodes.Leave.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Leave_S:
                {
                    var offset = ReadStreamHead <sbyte>();
                    PushOperation(Inst.Leave_S(GetOrAddLabel(currentIndex + OpCodes.Leave_S.GetTotalByteSize(offset) + offset)));
                }
                    return;

                case OpCodeConst.Stind_I:
                {
                    PushOperation(Inst.Stind_I());
                }
                    return;

                case OpCodeConst.Conv_U:
                {
                    PushOperation(Inst.Conv_U());
                }
                    return;

                case OpCodeConst.Arglist:
                {
                    PushOperation(Inst.Arglist());
                }
                    return;

                case OpCodeConst.Ceq:
                {
                    PushOperation(Inst.Ceq());
                }
                    return;

                case OpCodeConst.Cgt:
                {
                    PushOperation(Inst.Cgt());
                }
                    return;

                case OpCodeConst.Cgt_Un:
                {
                    PushOperation(Inst.Cgt_Un());
                }
                    return;

                case OpCodeConst.Clt:
                {
                    PushOperation(Inst.Clt());
                }
                    return;

                case OpCodeConst.Clt_Un:
                {
                    PushOperation(Inst.Clt_Un());
                }
                    return;

                case OpCodeConst.Ldftn:
                {
                    var callable = Method.DeclaringType.Module.ResolveMethod(ReadStreamHead <int>());
                    if (callable is MethodInfo meth)
                    {
                        PushOperation(Inst.Ldftn(meth));
                    }
                    else if (callable is ConstructorInfo ctor)
                    {
                        PushOperation(Inst.Ldftn(ctor));
                    }
                }
                    return;

                case OpCodeConst.Ldvirtftn:
                {
                    var callable = Method.DeclaringType.Module.ResolveMethod(ReadStreamHead <int>());
                    if (callable is MethodInfo meth)
                    {
                        PushOperation(Inst.Ldvirtftn(meth));
                    }
                    else if (callable is ConstructorInfo ctor)
                    {
                        PushOperation(Inst.Ldvirtftn(ctor));
                    }
                }
                    return;

                case OpCodeConst.Ldarg:
                {
                    var value = ReadStreamHead <ushort>();
                    PushOperation(Inst.Ldarg(value));
                }
                    return;

                case OpCodeConst.Ldarga:
                {
                    var value = ReadStreamHead <ushort>();
                    PushOperation(Inst.Ldarga(value));
                }
                    return;

                case OpCodeConst.Starg:
                {
                    var value = ReadStreamHead <ushort>();
                    PushOperation(Inst.Starg(value));
                }
                    return;

                case OpCodeConst.Ldloc:
                {
                    var value = ReadStreamHead <ushort>();
                    PushOperation(Inst.Ldloc(value));
                }
                    return;

                case OpCodeConst.Ldloca:
                {
                    var value = ReadStreamHead <ushort>();
                    PushOperation(Inst.Ldloca(value));
                }
                    return;

                case OpCodeConst.Stloc:
                {
                    var value = ReadStreamHead <ushort>();
                    PushOperation(Inst.Stloc(value));
                }
                    return;

                case OpCodeConst.Localloc:
                {
                    PushOperation(Inst.Localloc());
                }
                    return;

                case OpCodeConst.Endfilter:
                {
                    PushOperation(Inst.Endfilter());
                }
                    return;

                case OpCodeConst.Unaligned:
                {
                    var value = ReadStreamHead <byte>();
                    PushOperation(Inst.Unaligned(value));
                }
                    return;

                case OpCodeConst.Volatile:
                {
                    PushOperation(Inst.Volatile());
                }
                    return;

                case OpCodeConst.Tailcall:
                {
                    PushOperation(Inst.Tailcall());
                }
                    return;

                case OpCodeConst.Initobj:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Initobj(type));
                }
                    return;

                case OpCodeConst.Constrained:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Constrained(type));
                }
                    return;

                case OpCodeConst.Cpblk:
                {
                    PushOperation(Inst.Cpblk());
                }
                    return;

                case OpCodeConst.Initblk:
                {
                    PushOperation(Inst.Initblk());
                }
                    return;

                case OpCodeConst.Rethrow:
                {
                    PushOperation(Inst.Rethrow());
                }
                    return;

                case OpCodeConst.Sizeof:
                {
                    var type = Method.DeclaringType.Module.ResolveType(ReadStreamHead <int>());
                    PushOperation(Inst.Sizeof(type));
                }
                    return;

                case OpCodeConst.Refanytype:
                {
                    PushOperation(Inst.Refanytype());
                }
                    return;

                case OpCodeConst.Readonly:
                {
                    PushOperation(Inst.Readonly());
                }
                    return;

                default:
                    throw new NotImplementedException();
                }
            }
Esempio n. 2
0
        public InstEntry AddRecord(InstEntry t)
        {
            Inst.Add(t);

            return(t);
        }