1 //-----------------------------------------------------------------------------
3 // Copyright (C) Microsoft Corporation. All Rights Reserved.
5 //-----------------------------------------------------------------------------
8 namespace Microsoft.Cci.Pdb {
9 internal class PdbScope {
10 internal PdbConstant[] constants;
11 internal PdbSlot[] slots;
12 internal PdbScope[] scopes;
13 internal string[] usedNamespaces;
15 internal uint segment;
16 internal uint address;
19 internal PdbScope(uint funcAddress, BlockSym32 block, BitAccess bits, out uint typind) {
20 this.segment = block.seg;
21 this.address = block.off - funcAddress;
22 this.length = block.len;
29 PdbFunction.CountScopesAndSlots(bits, block.end, out constantCount, out scopeCount, out slotCount, out namespaceCount);
30 constants = new PdbConstant[constantCount];
31 scopes = new PdbScope[scopeCount];
32 slots = new PdbSlot[slotCount];
33 usedNamespaces = new string[namespaceCount];
39 while (bits.Position < block.end) {
43 bits.ReadUInt16(out siz);
44 int star = bits.Position;
45 int stop = bits.Position + siz;
47 bits.ReadUInt16(out rec);
51 BlockSym32 sub = new BlockSym32();
53 bits.ReadUInt32(out sub.parent);
54 bits.ReadUInt32(out sub.end);
55 bits.ReadUInt32(out sub.len);
56 bits.ReadUInt32(out sub.off);
57 bits.ReadUInt16(out sub.seg);
58 bits.SkipCString(out sub.name);
61 scopes[scope++] = new PdbScope(funcAddress, sub, bits, out typind);
66 slots[slot++] = new PdbSlot(bits, out typind);
70 case SYM.S_UNAMESPACE:
71 bits.ReadCString(out usedNamespaces[usedNs++]);
79 case SYM.S_MANCONSTANT:
80 constants[constant++] = new PdbConstant(bits);
85 throw new PdbException("Unknown SYM in scope {0}", (SYM)rec);
86 // bits.Position = stop;
90 if (bits.Position != block.end) {
91 throw new Exception("Not at S_END");
96 bits.ReadUInt16(out esiz);
97 bits.ReadUInt16(out erec);
99 if (erec != (ushort)SYM.S_END) {
100 throw new Exception("Missing S_END");