コード例 #1
0
        public void Write(Stream output)
        {
            Int64 recordSizePos = output.Position;

            output.WriteValueU32(recordSize, Endian.Big);
            output.WriteValueU16(numOfLocals, Endian.Big);
            output.WriteValueU16(numOfRegs, Endian.Big);
            output.WriteValueU16(numOfChildren, Endian.Big);
            output.WriteValueU32(iseqLength, Endian.Big);
            Int64 skipped = MainClass.AlignToSkip(output.Position);

            output.WriteBytes(new byte[skipped]);
            for (UInt32 i = 0; i < iseqLength; ++i)
            {
                output.WriteValueU32(iseqCode[i], Endian.Big);
            }
            output.WriteValueU32(poolLength, Endian.Big);
            for (UInt32 i = 0; i < poolLength; ++i)
            {
                pool[i].Write(output);
            }
            output.WriteValueU32(symbolLength, Endian.Big);
            for (UInt32 i = 0; i < symbolLength; ++i)
            {
                symbols[i].Write(output);
            }
            recordSize = (UInt32)(output.Position - recordSizePos - skipped + 4);
            Int64 savePos = output.Position;

            output.Position = recordSizePos;
            output.WriteValueU32(recordSize, Endian.Big);
            output.Position = savePos;
        }
コード例 #2
0
        public void Read(Stream input)
        {
            // Int64 beginRecord = input.Position;
            recordSize    = input.ReadValueU32(Endian.Big);
            numOfLocals   = input.ReadValueU16(Endian.Big);
            numOfRegs     = input.ReadValueU16(Endian.Big);
            numOfChildren = input.ReadValueU16(Endian.Big);
            iseqLength    = input.ReadValueU32(Endian.Big);
            Int64 skipped = MainClass.AlignToSkip(input.Position);

            input.Seek(skipped, SeekOrigin.Current);
            iseqCode = new UInt32[iseqLength];
            for (UInt32 i = 0; i < iseqLength; ++i)
            {
                iseqCode[i] = input.ReadValueU32(Endian.Big);
            }
            poolLength = input.ReadValueU32(Endian.Big);
            pool       = new RiteIREPPoolEntry[poolLength];
            for (UInt32 i = 0; i < poolLength; ++i)
            {
                pool[i] = new RiteIREPPoolEntry();
                pool[i].Read(input);
            }
            symbolLength = input.ReadValueU32(Endian.Big);
            symbols      = new RiteIREPSymbolEntry[symbolLength];
            for (UInt32 i = 0; i < symbolLength; ++i)
            {
                symbols[i] = new RiteIREPSymbolEntry();
                symbols[i].Read(input);
            }
            // Console.WriteLine("record_size=" + recordSize + " diff=" + (input.Position - beginRecord - skipped + 4));
        }