/proc/self/cwd/common/expr_factory.h
Line | Count | Source |
1 | | // Copyright 2024 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef THIRD_PARTY_CEL_CPP_COMMON_EXPR_FACTORY_H_ |
16 | | #define THIRD_PARTY_CEL_CPP_COMMON_EXPR_FACTORY_H_ |
17 | | |
18 | | #include <cstddef> |
19 | | #include <cstdint> |
20 | | #include <memory> |
21 | | #include <string> |
22 | | #include <type_traits> |
23 | | #include <utility> |
24 | | #include <vector> |
25 | | |
26 | | #include "absl/strings/string_view.h" |
27 | | #include "absl/types/span.h" |
28 | | #include "common/constant.h" |
29 | | #include "common/expr.h" |
30 | | |
31 | | namespace cel { |
32 | | |
33 | | class MacroExprFactory; |
34 | | class ParserMacroExprFactory; |
35 | | |
36 | | class ExprFactory { |
37 | | protected: |
38 | | // `IsExprLike` determines whether `T` is some `Expr`. Currently that means |
39 | | // either `Expr` or `std::unique_ptr<Expr>`. This allows us to make the |
40 | | // factory functions generic and avoid redefining them for every argument |
41 | | // combination. |
42 | | template <typename T> |
43 | | struct IsExprLike |
44 | | : std::bool_constant<std::disjunction_v< |
45 | | std::is_same<T, Expr>, std::is_same<T, std::unique_ptr<Expr>>>> {}; |
46 | | |
47 | | // `IsStringLike` determines whether `T` is something that looks like a |
48 | | // string. Currently that means `const char*`, `std::string`, or |
49 | | // `absl::string_view`. This allows us to make the factory functions generic |
50 | | // and avoid redefining them for every argument combination. This is necessary |
51 | | // to avoid copies if possible. |
52 | | template <typename T> |
53 | | struct IsStringLike |
54 | | : std::bool_constant<std::disjunction_v< |
55 | | std::is_same<T, char*>, std::is_same<T, const char*>, |
56 | | std::is_same<T, std::string>, std::is_same<T, absl::string_view>>> { |
57 | | }; |
58 | | |
59 | | template <size_t N> |
60 | | struct IsStringLike<const char[N]> : std::true_type {}; |
61 | | |
62 | | // `IsArrayLike` determines whether `T` is something that looks like an array |
63 | | // or span of some element. |
64 | | template <typename Element, typename Array> |
65 | | struct IsArrayLike : std::false_type {}; |
66 | | |
67 | | template <typename Element> |
68 | | struct IsArrayLike<Element, absl::Span<Element>> : std::true_type {}; |
69 | | |
70 | | template <typename Element> |
71 | | struct IsArrayLike<Element, std::vector<Element>> : std::true_type {}; |
72 | | |
73 | | public: |
74 | | ExprFactory(const ExprFactory&) = delete; |
75 | | ExprFactory(ExprFactory&&) = delete; |
76 | | ExprFactory& operator=(const ExprFactory&) = delete; |
77 | | ExprFactory& operator=(ExprFactory&&) = delete; |
78 | | |
79 | 4.20k | virtual ~ExprFactory() = default; |
80 | | |
81 | 1.79M | Expr NewUnspecified(ExprId id) { |
82 | 1.79M | Expr expr; |
83 | 1.79M | expr.set_id(id); |
84 | 1.79M | return expr; |
85 | 1.79M | } |
86 | | |
87 | 1.10M | Expr NewConst(ExprId id, Constant value) { |
88 | 1.10M | Expr expr; |
89 | 1.10M | expr.set_id(id); |
90 | 1.10M | expr.mutable_const_expr() = std::move(value); |
91 | 1.10M | return expr; |
92 | 1.10M | } |
93 | | |
94 | 466 | Expr NewNullConst(ExprId id) { |
95 | 466 | Constant constant; |
96 | 466 | constant.set_null_value(); |
97 | 466 | return NewConst(id, std::move(constant)); |
98 | 466 | } |
99 | | |
100 | 2.40k | Expr NewBoolConst(ExprId id, bool value) { |
101 | 2.40k | Constant constant; |
102 | 2.40k | constant.set_bool_value(value); |
103 | 2.40k | return NewConst(id, std::move(constant)); |
104 | 2.40k | } |
105 | | |
106 | 696k | Expr NewIntConst(ExprId id, int64_t value) { |
107 | 696k | Constant constant; |
108 | 696k | constant.set_int_value(value); |
109 | 696k | return NewConst(id, std::move(constant)); |
110 | 696k | } |
111 | | |
112 | 1.71k | Expr NewUintConst(ExprId id, uint64_t value) { |
113 | 1.71k | Constant constant; |
114 | 1.71k | constant.set_uint_value(value); |
115 | 1.71k | return NewConst(id, std::move(constant)); |
116 | 1.71k | } |
117 | | |
118 | 10.6k | Expr NewDoubleConst(ExprId id, double value) { |
119 | 10.6k | Constant constant; |
120 | 10.6k | constant.set_double_value(value); |
121 | 10.6k | return NewConst(id, std::move(constant)); |
122 | 10.6k | } |
123 | | |
124 | 0 | Expr NewBytesConst(ExprId id, BytesConstant value) { |
125 | 0 | Constant constant; |
126 | 0 | constant.set_bytes_value(std::move(value)); |
127 | 0 | return NewConst(id, std::move(constant)); |
128 | 0 | } |
129 | | |
130 | 1.35k | Expr NewBytesConst(ExprId id, std::string value) { |
131 | 1.35k | Constant constant; |
132 | 1.35k | constant.set_bytes_value(std::move(value)); |
133 | 1.35k | return NewConst(id, std::move(constant)); |
134 | 1.35k | } |
135 | | |
136 | 0 | Expr NewBytesConst(ExprId id, absl::string_view value) { |
137 | 0 | Constant constant; |
138 | 0 | constant.set_bytes_value(value); |
139 | 0 | return NewConst(id, std::move(constant)); |
140 | 0 | } |
141 | | |
142 | 0 | Expr NewBytesConst(ExprId id, const char* value) { |
143 | 0 | Constant constant; |
144 | 0 | constant.set_bytes_value(value); |
145 | 0 | return NewConst(id, std::move(constant)); |
146 | 0 | } |
147 | | |
148 | 0 | Expr NewStringConst(ExprId id, StringConstant value) { |
149 | 0 | Constant constant; |
150 | 0 | constant.set_string_value(std::move(value)); |
151 | 0 | return NewConst(id, std::move(constant)); |
152 | 0 | } |
153 | | |
154 | 391k | Expr NewStringConst(ExprId id, std::string value) { |
155 | 391k | Constant constant; |
156 | 391k | constant.set_string_value(std::move(value)); |
157 | 391k | return NewConst(id, std::move(constant)); |
158 | 391k | } |
159 | | |
160 | 0 | Expr NewStringConst(ExprId id, absl::string_view value) { |
161 | 0 | Constant constant; |
162 | 0 | constant.set_string_value(value); |
163 | 0 | return NewConst(id, std::move(constant)); |
164 | 0 | } |
165 | | |
166 | 1.86k | Expr NewStringConst(ExprId id, const char* value) { |
167 | 1.86k | Constant constant; |
168 | 1.86k | constant.set_string_value(value); |
169 | 1.86k | return NewConst(id, std::move(constant)); |
170 | 1.86k | } |
171 | | |
172 | | template <typename Name, |
173 | | typename = std::enable_if_t<IsStringLike<Name>::value>> |
174 | 770k | Expr NewIdent(ExprId id, Name name) { |
175 | 770k | Expr expr; |
176 | 770k | expr.set_id(id); |
177 | 770k | auto& ident_expr = expr.mutable_ident_expr(); |
178 | 770k | ident_expr.set_name(std::move(name)); |
179 | 770k | return expr; |
180 | 770k | } cel::Expr cel::ExprFactory::NewIdent<std::__1::basic_string_view<char, std::__1::char_traits<char> >, void>(long, std::__1::basic_string_view<char, std::__1::char_traits<char> >) Line | Count | Source | 174 | 4.36k | Expr NewIdent(ExprId id, Name name) { | 175 | 4.36k | Expr expr; | 176 | 4.36k | expr.set_id(id); | 177 | 4.36k | auto& ident_expr = expr.mutable_ident_expr(); | 178 | 4.36k | ident_expr.set_name(std::move(name)); | 179 | 4.36k | return expr; | 180 | 4.36k | } |
cel::Expr cel::ExprFactory::NewIdent<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void>(long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) Line | Count | Source | 174 | 766k | Expr NewIdent(ExprId id, Name name) { | 175 | 766k | Expr expr; | 176 | 766k | expr.set_id(id); | 177 | 766k | auto& ident_expr = expr.mutable_ident_expr(); | 178 | 766k | ident_expr.set_name(std::move(name)); | 179 | 766k | return expr; | 180 | 766k | } |
|
181 | | |
182 | 5.86k | absl::string_view AccuVarName() { return accu_var_; } |
183 | | |
184 | 4.36k | Expr NewAccuIdent(ExprId id) { return NewIdent(id, AccuVarName()); } |
185 | | |
186 | | template <typename Operand, typename Field, |
187 | | typename = std::enable_if_t<IsExprLike<Operand>::value>, |
188 | | typename = std::enable_if_t<IsStringLike<Field>::value>> |
189 | 7.78k | Expr NewSelect(ExprId id, Operand operand, Field field) { |
190 | 7.78k | Expr expr; |
191 | 7.78k | expr.set_id(id); |
192 | 7.78k | auto& select_expr = expr.mutable_select_expr(); |
193 | 7.78k | select_expr.set_operand(std::move(operand)); |
194 | 7.78k | select_expr.set_field(std::move(field)); |
195 | 7.78k | select_expr.set_test_only(false); |
196 | 7.78k | return expr; |
197 | 7.78k | } |
198 | | |
199 | | template <typename Operand, typename Field, |
200 | | typename = std::enable_if_t<IsExprLike<Operand>::value>, |
201 | | typename = std::enable_if_t<IsStringLike<Field>::value>> |
202 | 24 | Expr NewPresenceTest(ExprId id, Operand operand, Field field) { |
203 | 24 | Expr expr; |
204 | 24 | expr.set_id(id); |
205 | 24 | auto& select_expr = expr.mutable_select_expr(); |
206 | 24 | select_expr.set_operand(std::move(operand)); |
207 | 24 | select_expr.set_field(std::move(field)); |
208 | 24 | select_expr.set_test_only(true); |
209 | 24 | return expr; |
210 | 24 | } Unexecuted instantiation: cel::Expr cel::ExprFactory::NewPresenceTest<cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void, void>(long, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) cel::Expr cel::ExprFactory::NewPresenceTest<std::__1::unique_ptr<cel::Expr, std::__1::default_delete<cel::Expr> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void, void>(long, std::__1::unique_ptr<cel::Expr, std::__1::default_delete<cel::Expr> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) Line | Count | Source | 202 | 24 | Expr NewPresenceTest(ExprId id, Operand operand, Field field) { | 203 | 24 | Expr expr; | 204 | 24 | expr.set_id(id); | 205 | 24 | auto& select_expr = expr.mutable_select_expr(); | 206 | 24 | select_expr.set_operand(std::move(operand)); | 207 | 24 | select_expr.set_field(std::move(field)); | 208 | 24 | select_expr.set_test_only(true); | 209 | 24 | return expr; | 210 | 24 | } |
|
211 | | |
212 | | template <typename Function, typename Args, |
213 | | typename = std::enable_if_t<IsStringLike<Function>::value>, |
214 | | typename = std::enable_if_t<IsArrayLike<Expr, Args>::value>> |
215 | 893k | Expr NewCall(ExprId id, Function function, Args args) { |
216 | 893k | Expr expr; |
217 | 893k | expr.set_id(id); |
218 | 893k | auto& call_expr = expr.mutable_call_expr(); |
219 | 893k | call_expr.set_function(std::move(function)); |
220 | 893k | call_expr.set_args(std::move(args)); |
221 | 893k | return expr; |
222 | 893k | } cel::Expr cel::ExprFactory::NewCall<char const*, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >, void, void>(long, char const*, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >) Line | Count | Source | 215 | 4.38k | Expr NewCall(ExprId id, Function function, Args args) { | 216 | 4.38k | Expr expr; | 217 | 4.38k | expr.set_id(id); | 218 | 4.38k | auto& call_expr = expr.mutable_call_expr(); | 219 | 4.38k | call_expr.set_function(std::move(function)); | 220 | 4.38k | call_expr.set_args(std::move(args)); | 221 | 4.38k | return expr; | 222 | 4.38k | } |
cel::Expr cel::ExprFactory::NewCall<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >, void, void>(long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >) Line | Count | Source | 215 | 37.9k | Expr NewCall(ExprId id, Function function, Args args) { | 216 | 37.9k | Expr expr; | 217 | 37.9k | expr.set_id(id); | 218 | 37.9k | auto& call_expr = expr.mutable_call_expr(); | 219 | 37.9k | call_expr.set_function(std::move(function)); | 220 | 37.9k | call_expr.set_args(std::move(args)); | 221 | 37.9k | return expr; | 222 | 37.9k | } |
cel::Expr cel::ExprFactory::NewCall<std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >, void, void>(long, std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >) Line | Count | Source | 215 | 851k | Expr NewCall(ExprId id, Function function, Args args) { | 216 | 851k | Expr expr; | 217 | 851k | expr.set_id(id); | 218 | 851k | auto& call_expr = expr.mutable_call_expr(); | 219 | 851k | call_expr.set_function(std::move(function)); | 220 | 851k | call_expr.set_args(std::move(args)); | 221 | 851k | return expr; | 222 | 851k | } |
|
223 | | |
224 | | template <typename Function, typename Target, typename Args, |
225 | | typename = std::enable_if_t<IsStringLike<Function>::value>, |
226 | | typename = std::enable_if_t<IsExprLike<Target>::value>, |
227 | | typename = std::enable_if_t<IsArrayLike<Expr, Args>::value>> |
228 | 1.65k | Expr NewMemberCall(ExprId id, Function function, Target target, Args args) { |
229 | 1.65k | Expr expr; |
230 | 1.65k | expr.set_id(id); |
231 | 1.65k | auto& call_expr = expr.mutable_call_expr(); |
232 | 1.65k | call_expr.set_function(std::move(function)); |
233 | 1.65k | call_expr.set_target(std::move(target)); |
234 | 1.65k | call_expr.set_args(std::move(args)); |
235 | 1.65k | return expr; |
236 | 1.65k | } Unexecuted instantiation: cel::Expr cel::ExprFactory::NewMemberCall<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >, void, void, void>(long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >) cel::Expr cel::ExprFactory::NewMemberCall<std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Expr, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >, void, void, void>(long, std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Expr, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >) Line | Count | Source | 228 | 1.65k | Expr NewMemberCall(ExprId id, Function function, Target target, Args args) { | 229 | 1.65k | Expr expr; | 230 | 1.65k | expr.set_id(id); | 231 | 1.65k | auto& call_expr = expr.mutable_call_expr(); | 232 | 1.65k | call_expr.set_function(std::move(function)); | 233 | 1.65k | call_expr.set_target(std::move(target)); | 234 | 1.65k | call_expr.set_args(std::move(args)); | 235 | 1.65k | return expr; | 236 | 1.65k | } |
Unexecuted instantiation: cel::Expr cel::ExprFactory::NewMemberCall<char const*, cel::Expr, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >, void, void, void>(long, char const*, cel::Expr, std::__1::vector<cel::Expr, std::__1::allocator<cel::Expr> >) |
237 | | |
238 | | template <typename Expr, typename = std::enable_if_t<IsExprLike<Expr>::value>> |
239 | 277k | ListExprElement NewListElement(Expr expr, bool optional = false) { |
240 | 277k | ListExprElement element; |
241 | 277k | element.set_expr(std::move(expr)); |
242 | 277k | element.set_optional(optional); |
243 | 277k | return element; |
244 | 277k | } |
245 | | |
246 | | template <typename Elements, |
247 | | typename = |
248 | | std::enable_if_t<IsArrayLike<ListExprElement, Elements>::value>> |
249 | 2.67k | Expr NewList(ExprId id, Elements elements) { |
250 | 2.67k | Expr expr; |
251 | 2.67k | expr.set_id(id); |
252 | 2.67k | auto& list_expr = expr.mutable_list_expr(); |
253 | 2.67k | list_expr.set_elements(std::move(elements)); |
254 | 2.67k | return expr; |
255 | 2.67k | } |
256 | | |
257 | | template <typename Name, typename Value, |
258 | | typename = std::enable_if_t<IsStringLike<Name>::value>, |
259 | | typename = std::enable_if_t<IsExprLike<Value>::value>> |
260 | | StructExprField NewStructField(ExprId id, Name name, Value value, |
261 | 2.77k | bool optional = false) { |
262 | 2.77k | StructExprField field; |
263 | 2.77k | field.set_id(id); |
264 | 2.77k | field.set_name(std::move(name)); |
265 | 2.77k | field.set_value(std::move(value)); |
266 | 2.77k | field.set_optional(optional); |
267 | 2.77k | return field; |
268 | 2.77k | } |
269 | | |
270 | | template < |
271 | | typename Name, typename Fields, |
272 | | typename = std::enable_if_t<IsStringLike<Name>::value>, |
273 | | typename = std::enable_if_t<IsArrayLike<StructExprField, Fields>::value>> |
274 | 1.68k | Expr NewStruct(ExprId id, Name name, Fields fields) { |
275 | 1.68k | Expr expr; |
276 | 1.68k | expr.set_id(id); |
277 | 1.68k | auto& struct_expr = expr.mutable_struct_expr(); |
278 | 1.68k | struct_expr.set_name(std::move(name)); |
279 | 1.68k | struct_expr.set_fields(std::move(fields)); |
280 | 1.68k | return expr; |
281 | 1.68k | } |
282 | | |
283 | | template <typename Key, typename Value, |
284 | | typename = std::enable_if_t<IsExprLike<Key>::value>, |
285 | | typename = std::enable_if_t<IsExprLike<Value>::value>> |
286 | | MapExprEntry NewMapEntry(ExprId id, Key key, Value value, |
287 | 391k | bool optional = false) { |
288 | 391k | MapExprEntry entry; |
289 | 391k | entry.set_id(id); |
290 | 391k | entry.set_key(std::move(key)); |
291 | 391k | entry.set_value(std::move(value)); |
292 | 391k | entry.set_optional(optional); |
293 | 391k | return entry; |
294 | 391k | } |
295 | | |
296 | | template <typename Entries, typename = std::enable_if_t< |
297 | | IsArrayLike<MapExprEntry, Entries>::value>> |
298 | 1.44k | Expr NewMap(ExprId id, Entries entries) { |
299 | 1.44k | Expr expr; |
300 | 1.44k | expr.set_id(id); |
301 | 1.44k | auto& map_expr = expr.mutable_map_expr(); |
302 | 1.44k | map_expr.set_entries(std::move(entries)); |
303 | 1.44k | return expr; |
304 | 1.44k | } |
305 | | |
306 | | template <typename IterVar, typename IterRange, typename AccuVar, |
307 | | typename AccuInit, typename LoopCondition, typename LoopStep, |
308 | | typename Result, |
309 | | typename = std::enable_if_t<IsStringLike<IterVar>::value>, |
310 | | typename = std::enable_if_t<IsExprLike<IterRange>::value>, |
311 | | typename = std::enable_if_t<IsStringLike<AccuVar>::value>, |
312 | | typename = std::enable_if_t<IsExprLike<AccuInit>::value>, |
313 | | typename = std::enable_if_t<IsExprLike<LoopStep>::value>, |
314 | | typename = std::enable_if_t<IsExprLike<LoopCondition>::value>, |
315 | | typename = std::enable_if_t<IsExprLike<Result>::value>> |
316 | | Expr NewComprehension(ExprId id, IterVar iter_var, IterRange iter_range, |
317 | | AccuVar accu_var, AccuInit accu_init, |
318 | | LoopCondition loop_condition, LoopStep loop_step, |
319 | 1.49k | Result result) { |
320 | 1.49k | return NewComprehension(id, std::move(iter_var), "", std::move(iter_range), |
321 | 1.49k | std::move(accu_var), std::move(accu_init), |
322 | 1.49k | std::move(loop_condition), std::move(loop_step), |
323 | 1.49k | std::move(result)); |
324 | 1.49k | } Unexecuted instantiation: cel::Expr cel::ExprFactory::NewComprehension<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr, void, void, void, void, void, void, void>(long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr) cel::Expr cel::ExprFactory::NewComprehension<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr, void, void, void, void, void, void, void>(long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr) Line | Count | Source | 319 | 1.49k | Result result) { | 320 | 1.49k | return NewComprehension(id, std::move(iter_var), "", std::move(iter_range), | 321 | 1.49k | std::move(accu_var), std::move(accu_init), | 322 | 1.49k | std::move(loop_condition), std::move(loop_step), | 323 | 1.49k | std::move(result)); | 324 | 1.49k | } |
Unexecuted instantiation: cel::Expr cel::ExprFactory::NewComprehension<char const*, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr, void, void, void, void, void, void, void>(long, char const*, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr) |
325 | | |
326 | | template <typename IterVar, typename IterVar2, typename IterRange, |
327 | | typename AccuVar, typename AccuInit, typename LoopCondition, |
328 | | typename LoopStep, typename Result, |
329 | | typename = std::enable_if_t<IsStringLike<IterVar>::value>, |
330 | | typename = std::enable_if_t<IsStringLike<IterVar2>::value>, |
331 | | typename = std::enable_if_t<IsExprLike<IterRange>::value>, |
332 | | typename = std::enable_if_t<IsStringLike<AccuVar>::value>, |
333 | | typename = std::enable_if_t<IsExprLike<AccuInit>::value>, |
334 | | typename = std::enable_if_t<IsExprLike<LoopStep>::value>, |
335 | | typename = std::enable_if_t<IsExprLike<LoopCondition>::value>, |
336 | | typename = std::enable_if_t<IsExprLike<Result>::value>> |
337 | | Expr NewComprehension(ExprId id, IterVar iter_var, IterVar2 iter_var2, |
338 | | IterRange iter_range, AccuVar accu_var, |
339 | | AccuInit accu_init, LoopCondition loop_condition, |
340 | 1.49k | LoopStep loop_step, Result result) { |
341 | 1.49k | Expr expr; |
342 | 1.49k | expr.set_id(id); |
343 | 1.49k | auto& comprehension_expr = expr.mutable_comprehension_expr(); |
344 | 1.49k | comprehension_expr.set_iter_var(std::move(iter_var)); |
345 | 1.49k | comprehension_expr.set_iter_var2(std::move(iter_var2)); |
346 | 1.49k | comprehension_expr.set_iter_range(std::move(iter_range)); |
347 | 1.49k | comprehension_expr.set_accu_var(std::move(accu_var)); |
348 | 1.49k | comprehension_expr.set_accu_init(std::move(accu_init)); |
349 | 1.49k | comprehension_expr.set_loop_condition(std::move(loop_condition)); |
350 | 1.49k | comprehension_expr.set_loop_step(std::move(loop_step)); |
351 | 1.49k | comprehension_expr.set_result(std::move(result)); |
352 | 1.49k | return expr; |
353 | 1.49k | } Unexecuted instantiation: cel::Expr cel::ExprFactory::NewComprehension<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const*, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr, void, void, void, void, void, void, void, void>(long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const*, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr) cel::Expr cel::ExprFactory::NewComprehension<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const*, cel::Expr, std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr, void, void, void, void, void, void, void, void>(long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, char const*, cel::Expr, std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr) Line | Count | Source | 340 | 1.49k | LoopStep loop_step, Result result) { | 341 | 1.49k | Expr expr; | 342 | 1.49k | expr.set_id(id); | 343 | 1.49k | auto& comprehension_expr = expr.mutable_comprehension_expr(); | 344 | 1.49k | comprehension_expr.set_iter_var(std::move(iter_var)); | 345 | 1.49k | comprehension_expr.set_iter_var2(std::move(iter_var2)); | 346 | 1.49k | comprehension_expr.set_iter_range(std::move(iter_range)); | 347 | 1.49k | comprehension_expr.set_accu_var(std::move(accu_var)); | 348 | 1.49k | comprehension_expr.set_accu_init(std::move(accu_init)); | 349 | 1.49k | comprehension_expr.set_loop_condition(std::move(loop_condition)); | 350 | 1.49k | comprehension_expr.set_loop_step(std::move(loop_step)); | 351 | 1.49k | comprehension_expr.set_result(std::move(result)); | 352 | 1.49k | return expr; | 353 | 1.49k | } |
Unexecuted instantiation: cel::Expr cel::ExprFactory::NewComprehension<char const*, char const*, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr, void, void, void, void, void, void, void, void>(long, char const*, char const*, cel::Expr, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, cel::Expr, cel::Expr, cel::Expr, cel::Expr) |
354 | | |
355 | | private: |
356 | | friend class MacroExprFactory; |
357 | | friend class ParserMacroExprFactory; |
358 | | |
359 | 0 | ExprFactory() : accu_var_(kAccumulatorVariableName) {} |
360 | 4.20k | explicit ExprFactory(absl::string_view accu_var) : accu_var_(accu_var) {} |
361 | | |
362 | | std::string accu_var_; |
363 | | }; |
364 | | |
365 | | } // namespace cel |
366 | | |
367 | | #endif // THIRD_PARTY_CEL_CPP_COMMON_EXPR_FACTORY_H_ |