~ubuntu-branches/ubuntu/oneiric/cecil/oneiric

« back to all changes in this revision

Viewing changes to symbols/pdb/Microsoft.Cci.Pdb/BitSet.cs

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane, Iain Lane, Jo Shields
  • Date: 2011-08-07 22:38:20 UTC
  • mfrom: (1.1.7 upstream) (6.1.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110807223820-nfdm4q0pk2smjm11
Tags: 0.9.5+dfsg-1
[ Iain Lane ]
* [411dc78] Update to use my d.o email address
* [74bedaf] Disable clilibs; this is an unstable library
  apps grow unnecessary depends otherwise
* [5288c1f] Mangle debian version in watch file to take care of repacking.
  Also update watch file to look at new github location for tarballs
* [8f7110f] Relax version restriction on cli-common-dev; anything from 0.8
  will do

[ Jo Shields ]
* [e846eb8] Imported Upstream version 0.9.5+dfsg
* [3017d96] Bump build dependencies, as we're building for Mono 2.10 now.
* [27c2cff] Set to DebSrc 3.0, so we can apply patches via Quilt.
* [d0447b3] Update build to use XBuild, not manual compiler invocation.
* [08d2b92] Patch to avoid building tests (which rely on NUnit 2.4)
* [fa5a033] Update install file to include all new assemblies and locations.
* [43bd1e2] Since upstream no longer ships a pcfile, add our own.
* [942ead4] Don't try to ship a Changelog when none exists.
* [ba8232d] Erase obj/ folders in clean rule.
* [090af34] Exclude modulerefs on Windowsy libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//-----------------------------------------------------------------------------
 
2
//
 
3
// Copyright (C) Microsoft Corporation.  All Rights Reserved.
 
4
//
 
5
//-----------------------------------------------------------------------------
 
6
using System;
 
7
 
 
8
namespace Microsoft.Cci.Pdb {
 
9
  internal struct BitSet {
 
10
    internal BitSet(BitAccess bits) {
 
11
      bits.ReadInt32(out size);    // 0..3 : Number of words
 
12
      words = new uint[size];
 
13
      bits.ReadUInt32(words);
 
14
    }
 
15
 
 
16
    internal BitSet(int size) {
 
17
      this.size = size;
 
18
      words = new uint[size];
 
19
    }
 
20
 
 
21
    internal bool IsSet(int index) {
 
22
      int word = index / 32;
 
23
      if (word >= this.size) return false;
 
24
      return ((words[word] & GetBit(index)) != 0);
 
25
    }
 
26
 
 
27
    internal void Set(int index) {
 
28
      int word = index / 32;
 
29
      if (word >= this.size) return;
 
30
      words[word] |= GetBit(index);
 
31
    }
 
32
 
 
33
    internal void Clear(int index) {
 
34
      int word = index / 32;
 
35
      if (word >= this.size) return;
 
36
      words[word] &= ~GetBit(index);
 
37
    }
 
38
 
 
39
    private uint GetBit(int index) {
 
40
      return ((uint)1 << (index % 32));
 
41
    }
 
42
 
 
43
    private uint ReverseBits(uint value) {
 
44
      uint o = 0;
 
45
      for (int i = 0; i < 32; i++) {
 
46
        o = (o << 1) | (value & 1);
 
47
        value >>= 1;
 
48
      }
 
49
      return o;
 
50
    }
 
51
 
 
52
    internal bool IsEmpty {
 
53
      get { return size == 0; }
 
54
    }
 
55
 
 
56
    internal bool GetWord(int index, out uint word) {
 
57
      if (index < size) {
 
58
        word = ReverseBits(words[index]);
 
59
        return true;
 
60
      }
 
61
      word = 0;
 
62
      return false;
 
63
    }
 
64
 
 
65
    private int size;
 
66
    private uint[] words;
 
67
  }
 
68
 
 
69
}