コード例 #1
0
ファイル: BinaryReader.cs プロジェクト: sebastianhaba/api
		public virtual double ReadDouble() {
			FillBuffer(8);

            var byteArrayInputStream = new ByteArrayInputStream(ReadSwapped(8));
            var dataInputStream = new DataInputStream(byteArrayInputStream);

            var result = dataInputStream.ReadDouble();

            byteArrayInputStream.Close();
            dataInputStream.Close();

			return result;
		}
コード例 #2
0
ファイル: ConstantPool.cs プロジェクト: NickAcPT/NFernflower
        /// <exception cref="IOException"/>
        public ConstantPool(DataInputStream @in)
        {
            int size = @in.ReadUnsignedShort();

            pool = new List <PooledConstant>(size);
            BitSet[] nextPass = new BitSet[] { new BitSet(size), new BitSet(size), new BitSet
                                                   (size) };
            // first dummy constant
            pool.Add(null);
            // first pass: read the elements
            for (int i = 1; i < size; i++)
            {
                byte tag = unchecked ((byte)@in.ReadUnsignedByte());
                switch (tag)
                {
                case ICodeConstants.CONSTANT_Utf8:
                {
                    pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Utf8, @in.ReadUTF()));
                    break;
                }

                case ICodeConstants.CONSTANT_Integer:
                {
                    pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Integer, (@in.ReadInt
                                                                                         ())));
                    break;
                }

                case ICodeConstants.CONSTANT_Float:
                {
                    pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Float, @in.ReadFloat()));
                    break;
                }

                case ICodeConstants.CONSTANT_Long:
                {
                    pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Long, @in.ReadLong()));
                    pool.Add(null);
                    i++;
                    break;
                }

                case ICodeConstants.CONSTANT_Double:
                {
                    pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Double, @in.ReadDouble()));
                    pool.Add(null);
                    i++;
                    break;
                }

                case ICodeConstants.CONSTANT_Class:
                case ICodeConstants.CONSTANT_String:
                case ICodeConstants.CONSTANT_MethodType:
                {
                    pool.Add(new PrimitiveConstant(tag, @in.ReadUnsignedShort()));
                    nextPass[0].Set(i);
                    break;
                }

                case ICodeConstants.CONSTANT_NameAndType:
                {
                    pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort()));
                    nextPass[0].Set(i);
                    break;
                }

                case ICodeConstants.CONSTANT_Fieldref:
                case ICodeConstants.CONSTANT_Methodref:
                case ICodeConstants.CONSTANT_InterfaceMethodref:
                case ICodeConstants.CONSTANT_InvokeDynamic:
                {
                    pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort()));
                    nextPass[1].Set(i);
                    break;
                }

                case ICodeConstants.CONSTANT_MethodHandle:
                {
                    pool.Add(new LinkConstant(tag, @in.ReadUnsignedByte(), @in.ReadUnsignedShort()));
                    nextPass[2].Set(i);
                    break;
                }
                }
            }
            // resolving complex pool elements
            foreach (BitSet pass in nextPass)
            {
                int idx = 0;
                while ((idx = pass.NextSetBit(idx + 1)) > 0)
                {
                    pool[idx].ResolveConstant(this);
                }
            }
            // get global constant pool interceptor instance, if any available
            interceptor = DecompilerContext.GetPoolInterceptor();
        }