src
Public Types | Public Member Functions | Public Attributes | List of all members
re2c::Go Struct Reference

#include <go.h>

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

Public Types

enum  {
  EMPTY, SWITCH_IF, BITMAP, CPGOTO,
  DOT
}
 

Public Member Functions

 Go ()
 
 ~Go ()
 
void init (const State *from)
 
void emit (OutputFile &o, uint32_t ind, bool &readCh)
 
void used_labels (std::set< label_t > &used)
 
 Go (const Go &g)
 
Gooperator= (const Go &g)
 

Public Attributes

uint32_t nSpans
 
Spanspan
 
enum re2c::Go:: { ... }  type
 
union {
   SwitchIf *   switchif
 
   GoBitmap *   bitmap
 
   Cpgoto *   cpgoto
 
   Dot *   dot
 
info
 

Detailed Description

Definition at line 172 of file go.h.

Member Enumeration Documentation

anonymous enum
Enumerator
EMPTY 
SWITCH_IF 
BITMAP 
CPGOTO 
DOT 

Definition at line 176 of file go.h.

177  {
178  EMPTY,
179  SWITCH_IF,
180  BITMAP,
181  CPGOTO,
182  DOT
183  } type;
enum re2c::Go::@3 type

Constructor & Destructor Documentation

re2c::Go::Go ( )

Definition at line 183 of file go_construct.cc.

184  : nSpans (0)
185  , span (NULL)
186  , type (EMPTY)
187  , info ()
188 {}
enum re2c::Go::@3 type
uint32_t nSpans
Definition: go.h:174
union re2c::Go::@4 info
Span * span
Definition: go.h:175
re2c::Go::~Go ( )

Definition at line 78 of file go_destruct.cc.

79 {
80  switch (type)
81  {
82  case EMPTY:
83  break;
84  case SWITCH_IF:
85  delete info.switchif;
86  break;
87  case BITMAP:
88  delete info.bitmap;
89  break;
90  case CPGOTO:
91  delete info.cpgoto;
92  break;
93  case DOT:
94  delete info.dot;
95  break;
96  }
97 }
enum re2c::Go::@3 type
union re2c::Go::@4 info
re2c::Go::Go ( const Go g)
inline

Definition at line 198 of file go.h.

199  : nSpans (g.nSpans)
200  , span (g.span)
201  , type (g.type)
202  , info (g.info)
203  {}
enum re2c::Go::@3 type
uint32_t nSpans
Definition: go.h:174
union re2c::Go::@4 info
Span * span
Definition: go.h:175

Member Function Documentation

void re2c::Go::emit ( OutputFile o,
uint32_t  ind,
bool &  readCh 
)

Definition at line 250 of file go_emit.cc.

251 {
252  switch (type)
253  {
254  case EMPTY:
255  break;
256  case SWITCH_IF:
257  info.switchif->emit (o, ind, readCh);
258  break;
259  case BITMAP:
260  info.bitmap->emit (o, ind, readCh);
261  break;
262  case CPGOTO:
263  info.cpgoto->emit (o, ind, readCh);
264  break;
265  case DOT:
266  info.dot->emit (o);
267  break;
268  }
269 }
enum re2c::Go::@3 type
union re2c::Go::@4 info
void re2c::Go::init ( const State from)

Definition at line 190 of file go_construct.cc.

191 {
192  if (nSpans == 0)
193  {
194  return;
195  }
196 
197  // initialize high (wide) spans
198  uint32_t hSpans = 0;
199  const Span * hspan = NULL;
200  for (uint32_t i = 0; i < nSpans; ++i)
201  {
202  if (span[i].ub > 0x100)
203  {
204  hspan = &span[i];
205  hSpans = nSpans - i;
206  break;
207  }
208  }
209 
210  // initialize bitmaps
211  uint32_t nBitmaps = 0;
212  const BitMap * bitmap = NULL;
213  const State * bitmap_state = NULL;
214  for (uint32_t i = 0; i < nSpans; ++i)
215  {
216  if (span[i].to->isBase)
217  {
218  const BitMap *b = BitMap::find (span[i].to);
219  if (b && matches(b->go->span, b->go->nSpans, b->on, span, nSpans, span[i].to))
220  {
221  if (bitmap == NULL)
222  {
223  bitmap = b;
224  bitmap_state = span[i].to;
225  }
226  nBitmaps++;
227  }
228  }
229  }
230 
231  const uint32_t dSpans = nSpans - hSpans - nBitmaps;
232  if (opts->target == opt_t::DOT)
233  {
234  type = DOT;
235  info.dot = new Dot (span, nSpans, from);
236  }
237  else if (opts->gFlag && (dSpans >= opts->cGotoThreshold))
238  {
239  type = CPGOTO;
240  info.cpgoto = new Cpgoto (span, nSpans, hspan, hSpans, from->next);
241  }
242  else if (opts->bFlag && (nBitmaps > 0))
243  {
244  type = BITMAP;
245  info.bitmap = new GoBitmap (span, nSpans, hspan, hSpans, bitmap, bitmap_state, from->next);
246  bUsedYYBitmap = true;
247  }
248  else
249  {
250  type = SWITCH_IF;
251  info.switchif = new SwitchIf (span, nSpans, from->next);
252  }
253 }
bool bFlag
Definition: opt.h:118
enum re2c::Go::@3 type
uint32_t nSpans
Definition: go.h:174
State * to
Definition: go.h:22
bool bUsedYYBitmap
Definition: main.cc:16
uint32_t cGotoThreshold
Definition: opt.h:118
opt_t::target_t target
Definition: opt.h:118
bool gFlag
Definition: opt.h:118
Opt opts
Definition: opt.cc:7
GoBitmap * bitmap
Definition: go.h:187
static const BitMap * find(const Go *, const State *)
Definition: bitmap.cc:30
union re2c::Go::@4 info
Span * span
Definition: go.h:175
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:

Go& re2c::Go::operator= ( const Go g)
inline

Definition at line 204 of file go.h.

205  {
206  nSpans = g.nSpans;
207  span = g.span;
208  type = g.type;
209  info = g.info;
210  return * this;
211  }
enum re2c::Go::@3 type
uint32_t nSpans
Definition: go.h:174
union re2c::Go::@4 info
Span * span
Definition: go.h:175
void re2c::Go::used_labels ( std::set< label_t > &  used)

Definition at line 92 of file go_used_labels.cc.

93 {
94  switch (type)
95  {
96  case EMPTY:
97  case DOT:
98  break;
99  case SWITCH_IF:
100  info.switchif->used_labels (used);
101  break;
102  case BITMAP:
103  info.bitmap->used_labels (used);
104  break;
105  case CPGOTO:
106  info.cpgoto->used_labels (used);
107  break;
108  }
109 }
enum re2c::Go::@3 type
union re2c::Go::@4 info

Member Data Documentation

GoBitmap* re2c::Go::bitmap

Definition at line 187 of file go.h.

Cpgoto* re2c::Go::cpgoto

Definition at line 188 of file go.h.

Dot* re2c::Go::dot

Definition at line 189 of file go.h.

union { ... } re2c::Go::info
uint32_t re2c::Go::nSpans

Definition at line 174 of file go.h.

Span* re2c::Go::span

Definition at line 175 of file go.h.

SwitchIf* re2c::Go::switchif

Definition at line 186 of file go.h.

enum { ... } re2c::Go::type

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