src
go_used_labels.cc
Go to the documentation of this file.
1 #include <stddef.h>
2 #include "src/util/c99_stdint.h"
3 #include <set>
4 #include <utility>
5 #include <vector>
6 
7 #include "src/codegen/go.h"
8 #include "src/codegen/label.h"
9 #include "src/ir/adfa/adfa.h"
10 
11 namespace re2c
12 {
13 
14 void Cases::used_labels (std::set<label_t> & used)
15 {
16  for (uint32_t i = 0; i < cases_size; ++i)
17  {
18  used.insert (cases[i].to->label);
19  }
20 }
21 
22 void Binary::used_labels (std::set<label_t> & used)
23 {
24  thn->used_labels (used);
25  els->used_labels (used);
26 }
27 
28 void Linear::used_labels (std::set<label_t> & used)
29 {
30  for (uint32_t i = 0; i < branches.size (); ++i)
31  {
32  used.insert (branches[i].second->label);
33  }
34 }
35 
36 void If::used_labels (std::set<label_t> & used)
37 {
38  switch (type)
39  {
40  case BINARY:
41  info.binary->used_labels (used);
42  break;
43  case LINEAR:
44  info.linear->used_labels (used);
45  break;
46  }
47 }
48 
49 void SwitchIf::used_labels (std::set<label_t> & used)
50 {
51  switch (type)
52  {
53  case SWITCH:
54  info.cases->used_labels (used);
55  break;
56  case IF:
57  info.ifs->used_labels (used);
58  break;
59  }
60 }
61 
62 void GoBitmap::used_labels (std::set<label_t> & used)
63 {
64  if (hgo != NULL)
65  {
66  hgo->used_labels (used);
67  }
68  used.insert (bitmap_state->label);
69  if (lgo != NULL)
70  {
71  lgo->used_labels (used);
72  }
73 }
74 
75 void CpgotoTable::used_labels (std::set<label_t> & used)
76 {
77  for (uint32_t i = 0; i < TABLE_SIZE; ++i)
78  {
79  used.insert (table[i]->label);
80  }
81 }
82 
83 void Cpgoto::used_labels (std::set<label_t> & used)
84 {
85  if (hgo != NULL)
86  {
87  hgo->used_labels (used);
88  }
89  table->used_labels (used);
90 }
91 
92 void Go::used_labels (std::set<label_t> & used)
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 }
110 
111 } // namespace re2c
If * thn
Definition: go.h:65
static const uint32_t TABLE_SIZE
Definition: go.h:136
SwitchIf * hgo
Definition: go.h:124
CpgotoTable * table
Definition: go.h:152
enum re2c::Go::@3 type
void used_labels(std::set< label_t > &used)
void used_labels(std::set< label_t > &used)
SwitchIf * hgo
Definition: go.h:151
void used_labels(std::set< label_t > &used)
enum re2c::SwitchIf::@1 type
const State ** table
Definition: go.h:137
void used_labels(std::set< label_t > &used)
uint32_t cases_size
Definition: go.h:45
Case * cases
Definition: go.h:44
SwitchIf * lgo
Definition: go.h:125
void used_labels(std::set< label_t > &used)
label_t label
Definition: adfa.h:25
std::vector< std::pair< const Cond *, const State * > > branches
Definition: go.h:77
const State * bitmap_state
Definition: go.h:123
union re2c::If::@0 info
void used_labels(std::set< label_t > &used)
void used_labels(std::set< label_t > &used)
void used_labels(std::set< label_t > &used)
union re2c::SwitchIf::@2 info
If * els
Definition: go.h:66
union re2c::Go::@4 info
enum re2c::If::type_t type
Definition: bitmap.cc:10
void used_labels(std::set< label_t > &used)