コード例 #1
0
        ActionBase IActionVisitor <ushort, ActionBase> .Visit(ActionTry action, ushort length)
        {
            action.Reserved        = (byte)_reader.ReadUnsignedBits(5);
            action.CatchInRegister = _reader.ReadBit();
            action.FinallyBlock    = _reader.ReadBit();
            action.CatchBlock      = _reader.ReadBit();
            var trySize     = _reader.ReadUInt16();
            var catchSize   = _reader.ReadUInt16();
            var finallySize = _reader.ReadUInt16();

            if (action.CatchInRegister)
            {
                action.CatchRegister = _reader.ReadByte();
            }
            else
            {
                action.CatchName = _reader.ReadString();
            }
            ReadActions(_reader, trySize, action.Try);
            if (action.CatchBlock)
            {
                ReadActions(_reader, catchSize, action.Catch);
            }
            if (action.FinallyBlock)
            {
                ReadActions(_reader, finallySize, action.Finally);
            }
            return(action);
        }
コード例 #2
0
ファイル: ActionWriter.cs プロジェクト: shhadi/SwfLib
        object IActionVisitor <ISwfStreamWriter, object> .Visit(ActionTry action, ISwfStreamWriter writer)
        {
            writer.WriteUnsignedBits(action.Reserved, 5);
            writer.WriteBit(action.CatchInRegister);
            writer.WriteBit(action.FinallyBlock);
            writer.WriteBit(action.CatchBlock);

            var tryBlock     = GetBody(action.Try);
            var catchBlock   = action.CatchBlock ? GetBody(action.Catch) : null;
            var finallyBlock = action.FinallyBlock ? GetBody(action.Finally) : null;

            writer.WriteUInt16((ushort)tryBlock.Length);
            writer.WriteUInt16(catchBlock != null ? (ushort)catchBlock.Length : (ushort)0);
            writer.WriteUInt16(finallyBlock != null ? (ushort)finallyBlock.Length : (ushort)0);

            if (action.CatchInRegister)
            {
                writer.WriteByte(action.CatchRegister);
            }
            else
            {
                writer.WriteString(action.CatchName);
            }

            writer.WriteBytes(tryBlock);
            if (catchBlock != null)
            {
                writer.WriteBytes(catchBlock);
            }
            if (finallyBlock != null)
            {
                writer.WriteBytes(finallyBlock);
            }
            return(null);
        }