Пример #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);
        }
Пример #2
0
        public static DebugFxlcOperand Parse(DebugBytecodeReader reader, uint componentCount, bool isScalarOp)
        {
            var result = new DebugFxlcOperand()
            {
                IsArray = reader.ReadUInt32("IsArray"),
                OpType  = reader.ReadEnum32 <FxlcOperandType>("OpType"),
                OpIndex = reader.ReadUInt32("OpIndex"),
            };

            result.ComponentCount = isScalarOp && result.OpType != FxlcOperandType.Literal ? 1 : componentCount;
            Debug.Assert(Enum.IsDefined(typeof(FxlcOperandType), result.OpType),
                         $"Unexpected FxlcOperandType OpType {result.OpType}");
            if (result.IsArray == 1)
            {
                result.ArrayType  = (FxlcOperandType)reader.ReadUInt32("ArrayType");
                result.ArrayIndex = reader.ReadUInt32("ArrayIndex");

                Debug.Assert(Enum.IsDefined(typeof(FxlcOperandType), result.ArrayType),
                             $"Unexpected FxlcOperandType ArrayType {result.ArrayType}");
            }

            return(result);
        }