Debian Codegraph @

external/cecil/symbols/pdb/Microsoft.Cci.Pdb/PdbConstant.cs

raw
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 using System;
5 using System.Runtime.InteropServices;
6
7 namespace Microsoft.Cci.Pdb {
8 /// <summary />
9 internal class PdbConstant {
10 internal string name;
11 internal uint token;
12 internal object value;
13
14 internal PdbConstant(string name, uint token, object value) {
15 this.name = name;
16 this.token = token;
17 this.value = value;
18 }
19
20 internal PdbConstant(BitAccess bits) {
21 bits.ReadUInt32(out this.token);
22 byte tag1;
23 bits.ReadUInt8(out tag1);
24 byte tag2;
25 bits.ReadUInt8(out tag2);
26 if (tag2 == 0) {
27 this.value = tag1;
28 } else if (tag2 == 0x80) {
29 switch (tag1) {
30 case 0x00: //sbyte
31 sbyte sb;
32 bits.ReadInt8(out sb);
33 this.value = sb;
34 break;
35 case 0x01: //short
36 short s;
37 bits.ReadInt16(out s);
38 this.value = s;
39 break;
40 case 0x02: //ushort
41 ushort us;
42 bits.ReadUInt16(out us);
43 this.value = us;
44 break;
45 case 0x03: //int
46 int i;
47 bits.ReadInt32(out i);
48 this.value = i;
49 break;
50 case 0x04: //uint
51 uint ui;
52 bits.ReadUInt32(out ui);
53 this.value = ui;
54 break;
55 case 0x05: //float
56 this.value = bits.ReadFloat();
57 break;
58 case 0x06: //double
59 this.value = bits.ReadDouble();
60 break;
61 case 0x09: //long
62 long sl;
63 bits.ReadInt64(out sl);
64 this.value = sl;
65 break;
66 case 0x0a: //ulong
67 ulong ul;
68 bits.ReadUInt64(out ul);
69 this.value = ul;
70 break;
71 case 0x10: //string
72 string str;
73 bits.ReadBString(out str);
74 this.value = str;
75 break;
76 case 0x19: //decimal
77 this.value = bits.ReadDecimal();
78 break;
79 default:
80 //TODO: error
81 break;
82 }
83 } else {
84 //TODO: error
85 }
86 bits.ReadCString(out name);
87 }
88 }
89 }