src
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
re2c::BitMap Class Reference

#include <bitmap.h>

Collaboration diagram for re2c::BitMap:
Collaboration graph
[legend]

Public Member Functions

 BitMap (const Go *, const State *)
 
 ~BitMap ()
 
 FORBID_COPY (BitMap)
 

Static Public Member Functions

static const BitMapfind (const Go *, const State *)
 
static const BitMapfind (const State *)
 
static void gen (OutputFile &, uint32_t ind, uint32_t, uint32_t)
 

Public Attributes

const Gogo
 
const Stateon
 
const BitMapnext
 
uint32_t i
 
uint32_t m
 

Static Public Attributes

static BitMapfirst = NULL
 

Detailed Description

Definition at line 16 of file bitmap.h.

Constructor & Destructor Documentation

re2c::BitMap::BitMap ( const Go g,
const State x 
)

Definition at line 15 of file bitmap.cc.

16  : go(g)
17  , on(x)
18  , next(first)
19  , i(0)
20  , m(0)
21 {
22  first = this;
23 }
const State * on
Definition: bitmap.h:22
const BitMap * next
Definition: bitmap.h:23
uint32_t m
Definition: bitmap.h:25
uint32_t i
Definition: bitmap.h:24
const Go * go
Definition: bitmap.h:21
static BitMap * first
Definition: bitmap.h:19

Here is the caller graph for this function:

re2c::BitMap::~BitMap ( )

Definition at line 25 of file bitmap.cc.

26 {
27  delete next;
28 }
const BitMap * next
Definition: bitmap.h:23

Member Function Documentation

const BitMap * re2c::BitMap::find ( const Go g,
const State x 
)
static

Definition at line 30 of file bitmap.cc.

31 {
32  for (const BitMap *b = first; b; b = b->next)
33  {
34  if (matches(b->go->span, b->go->nSpans, b->on, g->span, g->nSpans, x))
35  {
36  return b;
37  }
38  }
39 
40  return new BitMap(g, x);
41 }
const BitMap * next
Definition: bitmap.h:23
BitMap(const Go *, const State *)
Definition: bitmap.cc:15
static BitMap * first
Definition: bitmap.h:19
bool matches(const Span *b1, uint32_t n1, const State *s1, const Span *b2, uint32_t n2, const State *s2)
Definition: bitmap.cc:134

Here is the call graph for this function:

Here is the caller graph for this function:

const BitMap * re2c::BitMap::find ( const State x)
static

Definition at line 43 of file bitmap.cc.

44 {
45  for (const BitMap *b = first; b; b = b->next)
46  {
47  if (b->on == x)
48  {
49  return b;
50  }
51  }
52 
53  return NULL;
54 }
const BitMap * next
Definition: bitmap.h:23
BitMap(const Go *, const State *)
Definition: bitmap.cc:15
static BitMap * first
Definition: bitmap.h:19
re2c::BitMap::FORBID_COPY ( BitMap  )
void re2c::BitMap::gen ( OutputFile o,
uint32_t  ind,
uint32_t  lb,
uint32_t  ub 
)
static

Definition at line 75 of file bitmap.cc.

76 {
77  if (first && bUsedYYBitmap)
78  {
79  o.wind(ind).ws("static const unsigned char ").wstring(opts->yybm).ws("[] = {");
80 
81  uint32_t c = 1, n = ub - lb;
82  const BitMap *cb = first;
83 
84  while((cb = cb->next) != NULL) {
85  ++c;
86  }
87  BitMap *b = first;
88 
89  uint32_t *bm = new uint32_t[n];
90 
91  for (uint32_t i = 0, t = 1; b; i += n, t += 8)
92  {
93  memset(bm, 0, n * sizeof(uint32_t));
94 
95  for (uint32_t m = 0x80; b && m; m >>= 1)
96  {
97  b->i = i;
98  b->m = m;
99  doGen(b->go, b->on, bm, lb, m);
100  b = const_cast<BitMap*>(b->next);
101  }
102 
103  if (c > 8)
104  {
105  o.ws("\n").wind(ind+1).ws("/* table ").wu32(t).ws(" .. ").wu32(std::min(c, t+7)).ws(": ").wu32(i).ws(" */");
106  }
107 
108  for (uint32_t j = 0; j < n; ++j)
109  {
110  if (j % 8 == 0)
111  {
112  o.ws("\n").wind(ind+1);
113  }
114 
115  if (opts->yybmHexTable)
116  {
117  o.wu32_hex(bm[j]);
118  }
119  else
120  {
121  o.wu32_width(bm[j], 3);
122  }
123  o.ws(", ");
124  }
125  }
126 
127  o.ws("\n").wind(ind).ws("};\n");
128 
129  delete[] bm;
130  }
131 }
std::string yybm
Definition: opt.h:118
bool bUsedYYBitmap
Definition: main.cc:16
uint32_t m
Definition: bitmap.h:25
uint32_t i
Definition: bitmap.h:24
BitMap(const Go *, const State *)
Definition: bitmap.cc:15
Opt opts
Definition: opt.cc:7
static void doGen(const Go *g, const State *s, uint32_t *bm, uint32_t f, uint32_t m)
Definition: bitmap.cc:56
static BitMap * first
Definition: bitmap.h:19
bool yybmHexTable
Definition: opt.h:118

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

BitMap * re2c::BitMap::first = NULL
static

Definition at line 19 of file bitmap.h.

const Go* re2c::BitMap::go

Definition at line 21 of file bitmap.h.

uint32_t re2c::BitMap::i

Definition at line 24 of file bitmap.h.

uint32_t re2c::BitMap::m

Definition at line 25 of file bitmap.h.

const BitMap* re2c::BitMap::next

Definition at line 23 of file bitmap.h.

const State* re2c::BitMap::on

Definition at line 22 of file bitmap.h.


The documentation for this class was generated from the following files: