Ejemplo n.º 1
0
        public static FxlcToken Parse(BytecodeReader reader)
        {
            var result = new FxlcToken();
            var token  = reader.ReadUInt32();
            var tokenComponentCount = token.DecodeValue(0, 2);

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

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

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

            var operandCount = reader.ReadUInt32();

            for (int i = 0; i < operandCount; i++)
            {
                var componentCount = i == 0 && singleFirstComponent == 1 ?
                                     1 : tokenComponentCount;
                result.Operands.Add(FxlcOperand.Parse(reader, componentCount));
            }
            // destination operand
            result.Operands.Insert(0, FxlcOperand.Parse(reader, tokenComponentCount));
            return(result);
        }
Ejemplo n.º 2
0
        public static FxlcOperand Parse(BytecodeReader reader, uint componentCount)
        {
            var result = new FxlcOperand()
            {
                ComponentCount = componentCount,
                IsArray        = reader.ReadUInt32(),
                OpType         = (FxlcOperandType)reader.ReadUInt32(),
                OpIndex        = reader.ReadUInt32(),
            };

            Debug.Assert(Enum.IsDefined(typeof(FxlcOperandType), result.OpType),
                         $"Unexpected FxlcOperandType OpType {result.OpType}");
            if (result.IsArray == 1)
            {
                result.ArrayType  = (FxlcOperandType)reader.ReadUInt32();
                result.ArrayIndex = reader.ReadUInt32();

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

            return(result);
        }