コード例 #1
0
        public static DebugFxlcToken Parse(DebugBytecodeReader reader)
        {
            var result = new DebugFxlcToken();

            var token = reader.ReadUInt32($"Token");
            var tokenComponentCount = token.DecodeValue(0, 2);

            result.Type = (FxlcOpcode)token.DecodeValue(20, 30);
            var singleFirstComponent = token.DecodeValue(31, 31);

            Debug.Assert(Enum.IsDefined(typeof(FxlcOpcode), result.Type),
                         $"Unknown FxlcTokenType {result.Type}");

            Debug.Assert(token.DecodeValue(3, 19) == 0,
                         $"Unexpected data in FxlcToken bits 3-19 {token.DecodeValue(3, 19)}");

            var info = reader.Members.Last();

            info.AddNote("Token", result.Type.ToString());
            info.AddNote("TokenComponentCount", tokenComponentCount.ToString());
            info.AddNote("SingleFirstComponent", singleFirstComponent.ToString());

            var operandCount = result.OperandCount = reader.ReadUInt32("OperandCount");

            for (int i = 0; i < operandCount; i++)
            {
                var componentCount = i == 0 && singleFirstComponent == 1 ?
                                     1 : tokenComponentCount;
                result.Operands.Add(DebugFxlcOperand.Parse(reader, componentCount));
            }
            // destination operand
            result.Operands.Insert(0, DebugFxlcOperand.Parse(reader, tokenComponentCount));
            return(result);
        }
コード例 #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);
        }