Exemplo n.º 1
0
        public Instructiong Deserialized(Instruction reader)
        {
            var id    = ((Tuple <short, int>)reader.Operand).Item1;
            var token = ((Tuple <short, int>)reader.Operand).Item2;

            var asm   = Initializebytes.GetBody(MemeVM_Devirt.InitPhase.Initializebytes.assembly).GetReference(id);
            var field = asm.ManifestModule.ResolveField(token);

            return(new Instructiong(Opcodes.Stfld, Initializebytes.Moduledefmd.Import(field)));
        }
Exemplo n.º 2
0
        public Instructiong Deserialized(Instruction reader)
        {
            var tuple = (Tuple <short, int>)reader.Operand;

            var refid = tuple.Item1;
            var token = tuple.Item2;

            var asm  = Initializebytes.GetBody(MemeVM_Devirt.InitPhase.Initializebytes.assembly).GetReference(refid).ManifestModule;
            var type = asm.ResolveType(token);

            return(new Instructiong(Opcodes.Newarr, Initializebytes.Moduledefmd.Import(type)));
        }
Exemplo n.º 3
0
 public Instructiong Deserialized(Instruction reader)
 {
     try
     {
         var op = (Tuple <short, int, bool>)reader.Operand;
         if (!op.Item3)
         {
             var        asm = Initializebytes.GetBody(MemeVM_Devirt.InitPhase.Initializebytes.assembly).GetReference(op.Item1);
             MemberInfo info;
             try
             {
                 info = asm.ManifestModule.ResolveMember(op.Item2);
             }
             catch
             {
                 info = null;
             }
             var target = asm.ManifestModule.ResolveMethod(op.Item2);
             if (info != null && (info.MemberType & MemberTypes.Constructor) == MemberTypes.Constructor)
             {
                 var ctorinfo = (ConstructorInfo)info;
                 return(new Instructiong(Opcodes.Callvirt, Initializebytes.Moduledefmd.Import(ctorinfo)));
             }
             else
             {
                 return(new Instructiong(Opcodes.Call, Initializebytes.Moduledefmd.Import(target)));
             }
         }
         else
         {
             return(new Instructiong(Opcodes.Newobj, Initializebytes.Moduledefmd.Import(typeof(object))));
         }
     }
     catch
     {
         return(Opcodes.Nop.ToInstruction());
     }
 }