Esempio n. 1
0
 public void PutOpcode(Microsoft.Cci.OperationCode opcode)
 {
     if (opcode < Microsoft.Cci.OperationCode.Arglist)
     {
         writer.WriteByte((byte)opcode);
     }
     else
     {
         writer.WriteByte((byte)((ushort)opcode >> 8));
         writer.WriteByte((byte)((ushort)opcode & 0xff));
     }
 }
Esempio n. 2
0
 public void PutOpcode(ILOpCode code)
 {
     if (code.Size() == 1)
     {
         writer.WriteByte((byte)code);
     }
     else
     {
         Debug.Assert(code.Size() == 2);
         writer.WriteByte((byte)((ushort)code >> 8));
         writer.WriteByte((byte)((ushort)code & 0xff));
     }
 }
Esempio n. 3
0
        private static void WriteOpCode(Microsoft.Cci.BinaryWriter writer, ILOpCode code)
        {
            var size = code.Size();

            if (size == 1)
            {
                writer.WriteByte((byte)code);
            }
            else
            {
                // IL opcodes that occupy two bytes are written to
                // the byte stream with the high-order byte first,
                // in contrast to the little-endian format of the
                // numeric arguments and tokens.

                Debug.Assert(size == 2);
                writer.WriteByte((byte)((ushort)code >> 8));
                writer.WriteByte((byte)((ushort)code & 0xff));
            }
        }
Esempio n. 4
0
        public void Serialize(Microsoft.Cci.BinaryWriter to)
        {
            switch (this.Discriminator)
            {
            case ConstantValueTypeDiscriminator.Boolean:
                to.WriteBool(this.BooleanValue);
                break;

            case ConstantValueTypeDiscriminator.SByte:
                to.WriteSbyte(this.SByteValue);
                break;

            case ConstantValueTypeDiscriminator.Byte:
                to.WriteByte(this.ByteValue);
                break;

            case ConstantValueTypeDiscriminator.Char:
            case ConstantValueTypeDiscriminator.Int16:
                to.WriteShort(this.Int16Value);
                break;

            case ConstantValueTypeDiscriminator.UInt16:
                to.WriteUshort(this.UInt16Value);
                break;

            case ConstantValueTypeDiscriminator.Single:
                to.WriteFloat(this.SingleValue);
                break;

            case ConstantValueTypeDiscriminator.Int32:
                to.WriteInt(this.Int32Value);
                break;

            case ConstantValueTypeDiscriminator.UInt32:
                to.WriteUint(this.UInt32Value);
                break;

            case ConstantValueTypeDiscriminator.Double:
                to.WriteDouble(this.DoubleValue);
                break;

            case ConstantValueTypeDiscriminator.Int64:
                to.WriteLong(this.Int64Value);
                break;

            case ConstantValueTypeDiscriminator.UInt64:
                to.WriteUlong(this.UInt64Value);
                break;

            default: throw ExceptionUtilities.UnexpectedValue(this.Discriminator);
            }
        }