Ejemplo n.º 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);
            result.IsScalarInstruction = token.DecodeValue <bool>(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)}");

            reader.AddNote("Token", result.Type);
            reader.AddNote("TokenComponentCount", tokenComponentCount);
            reader.AddNote("IsScalarInstruction", result.IsScalarInstruction);

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

            for (int i = 0; i < operandCount; i++)
            {
                var isScalarOp = i == 0 && result.IsScalarInstruction;
                result.Operands.Add(DebugFxlcOperand.Parse(reader, tokenComponentCount, isScalarOp));
            }
            // destination operand
            result.Operands.Insert(0, DebugFxlcOperand.Parse(reader, tokenComponentCount, false));
            return(result);
        }
Ejemplo n.º 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);
        }