SwfDotNet.IO.ByteCode.Actions.ActionPush.CompileBody C# (CSharp) Method

CompileBody() public method

compile push type and value (but not action code), so method can be used by ActionPushList as well
public CompileBody ( BinaryWriter w ) : void
w System.IO.BinaryWriter
return void
        public void CompileBody(BinaryWriter w)
        {
            w.Write(Convert.ToByte(Type));

            switch ( (PushType) Type) {

                case PushType.String:
                            string stringToWrite = (string) Value;
                            BinaryStringRW.WriteString(w,stringToWrite);
                            break;

                case PushType.Float:
                            w.Write(Convert.ToSingle(Value));
                            break;

                case PushType.Register:
                            w.Write(Convert.ToByte(Value));
                            break;

                case PushType.Boolean:
                            w.Write((bool)Value);
                            break;

                case PushType.Double:
                            byte[] b = BitConverter.GetBytes((double)Value);
                            for (int i=0; i<4; i++) {
                                byte temp = b[i];
                                b[i] = b[4+i];
                                b[4+i] = temp;
                            }
                            w.Write(b);
                            break;

                case PushType.Int:
                            w.Write((int)Value);
                            break;

                case PushType.Constant8:
                            w.Write(Convert.ToByte(Value));
                            break;

                case PushType.Constant16:
                            w.Write(Convert.ToUInt16(Value));
                            break;

            }
        }