| 77 | }; |
| 78 | |
| 79 | struct scope { |
| 80 | struct scope *parent; |
| 81 | /// available to table_ref productions |
| 82 | vector<named_relation*> tables; |
| 83 | /// available to column_ref productions |
| 84 | vector<named_relation*> refs; |
| 85 | struct schema *schema; |
| 86 | /// Counters for prefixed stmt-unique identifiers |
| 87 | shared_ptr<map<string,unsigned int> > stmt_seq; |
| 88 | scope(struct scope *parent = 0) : parent(parent) { |
| 89 | if (parent) { |
| 90 | schema = parent->schema; |
| 91 | tables = parent->tables; |
| 92 | refs = parent->refs; |
| 93 | stmt_seq = parent->stmt_seq; |
| 94 | } |
| 95 | } |
| 96 | vector<pair<named_relation*, column> > refs_of_type(sqltype *t) { |
| 97 | vector<pair<named_relation*, column> > result; |
| 98 | for (auto r : refs) |
| 99 | for (auto c : r->columns()) |
| 100 | if (t->consistent(c.type)) |
| 101 | result.push_back(make_pair(r,c)); |
| 102 | return result; |
| 103 | } |
| 104 | /** Generate unique identifier with prefix. */ |
| 105 | string stmt_uid(const char* prefix) { |
| 106 | string result(prefix); |
| 107 | result += "_"; |
| 108 | result += std::to_string((*stmt_seq)[result]++); |
| 109 | return result; |
| 110 | } |
| 111 | /** Reset unique identifier counters. */ |
| 112 | void new_stmt() { |
| 113 | stmt_seq = std::make_shared<map<string,unsigned int> >(); |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | struct op { |
| 118 | string name; |
nothing calls this directly
no outgoing calls
no test coverage detected