示例#1
0
文件: Newobj.cs 项目: fysxm/NashaVM
        public byte[] Serializer(NashaSettings settings, NashaInstruction instruction)
        {
            var buf = new byte[7];

            buf[0] = (byte)NashaOpcodes.Newobj.ShuffledID;
            var(referenceId, method) = (Tuple <short, IMethod>)instruction.Operand;
            Array.Copy(BitConverter.GetBytes(referenceId), 0, buf, 1, 2);
            Array.Copy(BitConverter.GetBytes(TokenGetter.GetMdToken(method)), 0, buf, 3, 4);
            return(buf);
        }
示例#2
0
        public byte[] Serialize(VMBody body, VMInstruction instruction, Offsets helper)
        {
            var buf = new byte[7];

            buf[0] = (byte)VMOpCode.Newarr;
            var(referenceid, type) = (Tuple <short, TypeDef>)instruction.Operand;
            Array.Copy(BitConverter.GetBytes(referenceid), 0, buf, 1, 2);
            Array.Copy(BitConverter.GetBytes(TokenGetter.GetMdToken(type)), 0, buf, 3, 4);
            return(buf);
        }
示例#3
0
        public byte[] Serialize(VMBody body, VMInstruction instruction, Offsets helper)
        {
            var buf = new byte[7];

            buf[0]            = (byte)VMOpCode.Ldfld;
            var(refid, field) = (Tuple <short, FieldDef>)instruction.Operand;
            Array.Copy(BitConverter.GetBytes(refid), 0, buf, 1, 2);
            Array.Copy(BitConverter.GetBytes(TokenGetter.GetMdToken(field)), 0, buf, 3, 4);
            return(buf);
        }
示例#4
0
        public byte[] Serialize(VMBody body, VMInstruction instruction, Offsets helper)
        {
            var buf = new byte[8];

            buf[0] = (byte)VMOpCode.Call;
            var(referenceId, method) = (Tuple <short, MethodDef>)instruction.Operand;

            if (!body.Translated.ContainsKey(method))
            {
                Array.Copy(BitConverter.GetBytes(referenceId), 0, buf, 1, 2);
                Array.Copy(BitConverter.GetBytes(TokenGetter.GetMdToken(method)), 0, buf, 3, 4);
                buf[7] = 0;
                return(buf);
            }

            Array.Copy(BitConverter.GetBytes((short)body.MethodToIndex[method]), 0, buf, 1, 2);
            Array.Copy(BitConverter.GetBytes(method.Parameters.Count), 0, buf, 3, 4);
            buf[7] = 1;
            return(buf);
        }