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

#include <go.h>

Public Member Functions

 Linear (const Span *s, uint32_t n, const State *next)
 
 ~Linear ()
 
void emit (OutputFile &o, uint32_t ind, bool &readCh)
 
void used_labels (std::set< label_t > &used)
 

Public Attributes

std::vector< std::pair< const Cond *, const State * > > branches
 

Detailed Description

Definition at line 75 of file go.h.

Constructor & Destructor Documentation

re2c::Linear::Linear ( const Span s,
uint32_t  n,
const State next 
)

Definition at line 63 of file go_construct.cc.

64  : branches ()
65 {
66  for (;;)
67  {
68  const State *bg = s[0].to;
69  while (n >= 3 && s[2].to == bg && (s[1].ub - s[0].ub) == 1)
70  {
71  if (s[1].to == next && n == 3)
72  {
73  branches.push_back (std::make_pair (new Cond ("!=", s[0].ub), bg));
74  return ;
75  }
76  else
77  {
78  branches.push_back (std::make_pair (new Cond ("==", s[0].ub), s[1].to));
79  }
80  n -= 2;
81  s += 2;
82  }
83  if (n == 1)
84  {
85  if (next == NULL || s[0].to != next)
86  {
87  branches.push_back (std::make_pair (static_cast<const Cond *> (NULL), s[0].to));
88  }
89  return;
90  }
91  else if (n == 2 && bg == next)
92  {
93  branches.push_back (std::make_pair (new Cond (">=", s[0].ub), s[1].to));
94  return;
95  }
96  else
97  {
98  branches.push_back (std::make_pair (new Cond ("<=", s[0].ub - 1), bg));
99  n -= 1;
100  s += 1;
101  }
102  }
103 }
std::vector< std::pair< const Cond *, const State * > > branches
Definition: go.h:77
re2c::Linear::~Linear ( )

Definition at line 22 of file go_destruct.cc.

23 {
24  for (uint32_t i = 0; i < branches.size (); ++i)
25  {
26  delete branches[i].first;
27  }
28 }
std::vector< std::pair< const Cond *, const State * > > branches
Definition: go.h:77

Member Function Documentation

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

Definition at line 119 of file go_emit.cc.

120 {
121  for (uint32_t i = 0; i < branches.size (); ++i)
122  {
123  if (branches[i].first != NULL)
124  {
125  output_if (o, ind, readCh, branches[i].first->compare, branches[i].first->value);
126  output_goto (o, 0, readCh, branches[i].second->label);
127  }
128  else
129  {
130  output_goto (o, ind, readCh, branches[i].second->label);
131  }
132  }
133 }
std::vector< std::pair< const Cond *, const State * > > branches
Definition: go.h:77
static void output_goto(OutputFile &o, uint32_t ind, bool &readCh, label_t to)
Definition: go_emit.cc:44
static void output_if(OutputFile &o, uint32_t ind, bool &readCh, const std::string &compare, uint32_t value)
Definition: go_emit.cc:39

Here is the call graph for this function:

void re2c::Linear::used_labels ( std::set< label_t > &  used)

Definition at line 28 of file go_used_labels.cc.

29 {
30  for (uint32_t i = 0; i < branches.size (); ++i)
31  {
32  used.insert (branches[i].second->label);
33  }
34 }
std::vector< std::pair< const Cond *, const State * > > branches
Definition: go.h:77

Member Data Documentation

std::vector<std::pair<const Cond *, const State *> > re2c::Linear::branches

Definition at line 77 of file go.h.


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