Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Cecil/0.9.5/Mono.Cecil-0.9.5/Symbols/Mono.Cecil.Pdb/Microsoft.Cci.Pdb/PdbConstant.cs @ 11937

Last change on this file since 11937 was 11700, checked in by jkarder, 9 years ago

#2077: created branch and added first version

File size: 2.0 KB
Line 
1//-----------------------------------------------------------------------------
2//
3// Copyright (C) Microsoft Corporation.  All Rights Reserved.
4//
5//-----------------------------------------------------------------------------
6using System;
7using System.Runtime.InteropServices;
8
9namespace Microsoft.Cci.Pdb {
10  internal class PdbConstant {
11    internal string name;
12    internal uint token;
13    internal object value;
14
15    internal PdbConstant(BitAccess bits) {
16      bits.ReadUInt32(out this.token);
17      byte tag1;
18      bits.ReadUInt8(out tag1);
19      byte tag2;
20      bits.ReadUInt8(out tag2);
21      if (tag2 == 0) {
22        this.value = tag1;
23      } else if (tag2 == 0x80) {
24        switch (tag1) {
25          case 0x01: //short
26            short s;
27            bits.ReadInt16(out s);
28            this.value = s;
29            break;
30          case 0x02: //ushort
31            ushort us;
32            bits.ReadUInt16(out us);
33            this.value = us;
34            break;
35          case 0x03: //int
36            int i;
37            bits.ReadInt32(out i);
38            this.value = i;
39            break;
40          case 0x04: //uint
41            uint ui;
42            bits.ReadUInt32(out ui);
43            this.value = ui;
44            break;
45          case 0x05: //float
46            this.value = bits.ReadFloat();
47            break;
48          case 0x06: //double
49            this.value = bits.ReadDouble();
50            break;
51          case 0x09: //long
52            long sl;
53            bits.ReadInt64(out sl);
54            this.value = sl;
55            break;
56          case 0x0a: //ulong
57            ulong ul;
58            bits.ReadUInt64(out ul);
59            this.value = ul;
60            break;
61          case 0x10: //string
62            string str;
63            bits.ReadBString(out str);
64            this.value = str;
65            break;
66          case 0x19: //decimal
67            this.value = bits.ReadDecimal();
68            break;
69          default:
70            //TODO: error
71            break;
72        }
73      } else {
74        //TODO: error
75      }
76      bits.ReadCString(out name);
77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.