Beispiel #1
0
        public static TableSwitch FromReader(IBigEndianReader reader)
        {
            var table = new TableSwitch
            {
                DefaultOffset = reader.ReadInt32(),
                Low           = reader.ReadInt32()
            };

            int high = reader.ReadInt32();

            for (int i = 0; i < (high - table.Low + 1); i++)
            {
                table.Offsets.Add(reader.ReadInt32());
            }

            return(table);
        }
Beispiel #2
0
        private object ReadRawOperand(ByteOpCode opcode)
        {
            switch (opcode.OperandType)
            {
            case ByteCodeOperandType.None:
                return(null);

            case ByteCodeOperandType.Byte:
            case ByteCodeOperandType.ConstantIndex:
            case ByteCodeOperandType.LocalIndex:
            case ByteCodeOperandType.PrimitiveType:
                return(_reader.ReadByte());

            case ByteCodeOperandType.Short:
            case ByteCodeOperandType.WideConstantIndex:
            case ByteCodeOperandType.BranchOffset:
            case ByteCodeOperandType.LocalConst:
            case ByteCodeOperandType.FieldIndex:
            case ByteCodeOperandType.MethodIndex:
            case ByteCodeOperandType.ClassIndex:
                return(_reader.ReadInt16());

            case ByteCodeOperandType.TableSwitch:
                _reader.Position = FileSegment.Align((uint)_reader.Position, 4);
                return(TableSwitch.FromReader(_reader));

            case ByteCodeOperandType.LookupSwitch:
                _reader.Position = FileSegment.Align((uint)_reader.Position, 4);
                return(LookupSwitch.FromReader(_reader));

            case ByteCodeOperandType.WideIndexCountZero:
            case ByteCodeOperandType.WideIndexByte:
            case ByteCodeOperandType.WideBranchOffset:
            case ByteCodeOperandType.DynamicIndex:
                return(_reader.ReadInt32());

            default:
                throw new ArgumentOutOfRangeException();
            }
        }