示例#1
0
        bool ReadCommentToken(DebugBytecodeReader reader)
        {
            var fourCC = reader.PeakUInt32Ahead(4);

            if (KnownCommentTypes.ContainsKey(fourCC))
            {
                reader.AddIndent(KnownCommentTypes[fourCC].ToString());
            }
            else
            {
                return(false);
            }
            var    instructionToken = reader.ReadUInt32("Token");
            var    startPosition    = reader._reader.BaseStream.Position;
            var    entry            = reader.Members.Last();
            Opcode opcode           = (Opcode)(instructionToken & 0xffff);

            entry.AddNote("TokenOpcode", opcode.ToString());
            var size = (int)((instructionToken >> 16) & 0x7FFF);

            entry.AddNote("TokenSize", size.ToString());
            reader.ReadBytes("FourCC", 4);

            switch (KnownCommentTypes[fourCC])
            {
            case CommentType.CTAB:
                ConstantTable = DebugConstantTable.Parse(reader);
                break;

            case CommentType.C**T:
                Cli = DebugCliToken.Parse(reader);
                break;

            case CommentType.FXLC:
                Fxlc = DebugFxlc.Parse(reader, (uint)size * 4);
                break;

            case CommentType.PRES:
                Preshader = DebugPreshader.Parse(reader);
                break;

            case CommentType.PRSI:
                Prsi = DebugPrsiToken.Parse(reader, (uint)size);
                break;

            default:
                return(false);
            }
            reader.RemoveIndent();
            reader._reader.BaseStream.Position = startPosition + size * 4;
            return(true);
        }
示例#2
0
        public static DebugFxlc Parse(DebugBytecodeReader reader, uint size)
        {
            var result       = new DebugFxlc();
            var basePosition = reader._reader.BaseStream.Position;
            var tokenCount   = reader.ReadUInt32("TokenCount");

            for (int i = 0; i < tokenCount; i++)
            {
                var token = reader.PeakUint32();
                var type  = (FxlcOpcode)token.DecodeValue(20, 30);
                reader.AddIndent($"Token{i}({type})");
                result.Tokens.Add(DebugFxlcToken.Parse(reader));
                reader.RemoveIndent();
            }
            var padding       = reader.ReadBytes($"Padding", 8);
            var paddingUint64 = BitConverter.ToInt64(padding, 0);
            var expected      = 0x0F0F0f0FF0F0F0F0;

            Debug.Assert(paddingUint64 == expected);
            return(result);
        }