Coverage Report

Created: 2025-11-29 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/proc/self/cwd/common/expr.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_H_
16
#define THIRD_PARTY_CEL_CPP_COMMON_EXPR_H_
17
18
#include <cstdint>
19
#include <memory>
20
#include <string>
21
#include <utility>
22
#include <vector>
23
24
#include "absl/algorithm/container.h"
25
#include "absl/base/attributes.h"
26
#include "absl/strings/string_view.h"
27
#include "absl/types/span.h"
28
#include "absl/types/variant.h"
29
#include "common/constant.h"
30
31
namespace cel {
32
33
using ExprId = int64_t;
34
35
class Expr;
36
class UnspecifiedExpr;
37
class IdentExpr;
38
class SelectExpr;
39
class CallExpr;
40
class ListExprElement;
41
class ListExpr;
42
class StructExprField;
43
class StructExpr;
44
class MapExprEntry;
45
class MapExpr;
46
class ComprehensionExpr;
47
48
inline constexpr absl::string_view kAccumulatorVariableName = "__result__";
49
50
bool operator==(const Expr& lhs, const Expr& rhs);
51
52
0
inline bool operator!=(const Expr& lhs, const Expr& rhs) {
53
0
  return !operator==(lhs, rhs);
54
0
}
55
56
bool operator==(const ListExprElement& lhs, const ListExprElement& rhs);
57
58
0
inline bool operator!=(const ListExprElement& lhs, const ListExprElement& rhs) {
59
0
  return !operator==(lhs, rhs);
60
0
}
61
62
bool operator==(const StructExprField& lhs, const StructExprField& rhs);
63
64
0
inline bool operator!=(const StructExprField& lhs, const StructExprField& rhs) {
65
0
  return !operator==(lhs, rhs);
66
0
}
67
68
bool operator==(const MapExprEntry& lhs, const MapExprEntry& rhs);
69
70
0
inline bool operator!=(const MapExprEntry& lhs, const MapExprEntry& rhs) {
71
0
  return !operator==(lhs, rhs);
72
0
}
73
74
// `UnspecifiedExpr` is the default alternative of `Expr`. It is used for
75
// default construction of `Expr` or as a placeholder for when errors occur.
76
class UnspecifiedExpr final {
77
 public:
78
  UnspecifiedExpr() = default;
79
  UnspecifiedExpr(UnspecifiedExpr&&) = default;
80
  UnspecifiedExpr& operator=(UnspecifiedExpr&&) = default;
81
82
  UnspecifiedExpr(const UnspecifiedExpr&) = delete;
83
  UnspecifiedExpr& operator=(const UnspecifiedExpr&) = delete;
84
85
0
  void Clear() {}
86
87
0
  friend void swap(UnspecifiedExpr&, UnspecifiedExpr&) noexcept {}
88
89
 private:
90
  friend class Expr;
91
92
  static const UnspecifiedExpr& default_instance();
93
};
94
95
0
inline bool operator==(const UnspecifiedExpr&, const UnspecifiedExpr&) {
96
0
  return true;
97
0
}
98
99
0
inline bool operator!=(const UnspecifiedExpr& lhs, const UnspecifiedExpr& rhs) {
100
0
  return !operator==(lhs, rhs);
101
0
}
102
103
// `IdentExpr` is an alternative of `Expr`, representing an identifier.
104
class IdentExpr final {
105
 public:
106
770k
  IdentExpr() = default;
107
2.55M
  IdentExpr(IdentExpr&&) = default;
108
892
  IdentExpr& operator=(IdentExpr&&) = default;
109
110
0
  explicit IdentExpr(std::string name) { set_name(std::move(name)); }
111
112
0
  explicit IdentExpr(absl::string_view name) { set_name(name); }
113
114
0
  explicit IdentExpr(const char* name) { set_name(name); }
115
116
  IdentExpr(const IdentExpr&) = delete;
117
  IdentExpr& operator=(const IdentExpr&) = delete;
118
119
0
  void Clear() { name_.clear(); }
120
121
  // Holds a single, unqualified identifier, possibly preceded by a '.'.
122
  //
123
  // Qualified names are represented by the [Expr.Select][] expression.
124
  ABSL_MUST_USE_RESULT const std::string& name() const
125
385k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
126
385k
    return name_;
127
385k
  }
128
129
766k
  void set_name(std::string name) { name_ = std::move(name); }
130
131
4.36k
  void set_name(absl::string_view name) {
132
4.36k
    name_.assign(name.data(), name.size());
133
4.36k
  }
134
135
0
  void set_name(const char* name) { set_name(absl::NullSafeStringView(name)); }
136
137
0
  ABSL_MUST_USE_RESULT std::string release_name() { return release(name_); }
138
139
0
  friend void swap(IdentExpr& lhs, IdentExpr& rhs) noexcept {
140
0
    using std::swap;
141
0
    swap(lhs.name_, rhs.name_);
142
0
  }
143
144
 private:
145
  friend class Expr;
146
147
  static const IdentExpr& default_instance();
148
149
0
  static std::string release(std::string& property) {
150
0
    std::string result;
151
0
    result.swap(property);
152
0
    return result;
153
0
  }
154
155
  std::string name_;
156
};
157
158
0
inline bool operator==(const IdentExpr& lhs, const IdentExpr& rhs) {
159
0
  return lhs.name() == rhs.name();
160
0
}
161
162
0
inline bool operator!=(const IdentExpr& lhs, const IdentExpr& rhs) {
163
0
  return !operator==(lhs, rhs);
164
0
}
165
166
// `SelectExpr` is an alternative of `Expr`, representing field access.
167
class SelectExpr final {
168
 public:
169
7.80k
  SelectExpr() = default;
170
35.8k
  SelectExpr(SelectExpr&&) = default;
171
0
  SelectExpr& operator=(SelectExpr&&) = default;
172
173
  SelectExpr(const SelectExpr&) = delete;
174
  SelectExpr& operator=(const SelectExpr&) = delete;
175
176
  void Clear();
177
178
9.28k
  ABSL_MUST_USE_RESULT bool has_operand() const { return operand_ != nullptr; }
179
180
  // The target of the selection expression.
181
  //
182
  // For example, in the select expression `request.auth`, the `request`
183
  // portion of the expression is the `operand`.
184
  ABSL_MUST_USE_RESULT const Expr& operand() const
185
      ABSL_ATTRIBUTE_LIFETIME_BOUND;
186
187
  Expr& mutable_operand() ABSL_ATTRIBUTE_LIFETIME_BOUND;
188
189
  void set_operand(Expr operand);
190
191
  void set_operand(std::unique_ptr<Expr> operand);
192
193
  ABSL_MUST_USE_RESULT std::unique_ptr<Expr> release_operand();
194
195
  // The name of the field to select.
196
  //
197
  // For example, in the select expression `request.auth`, the `auth` portion
198
  // of the expression would be the `field`.
199
  ABSL_MUST_USE_RESULT const std::string& field() const
200
752
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
201
752
    return field_;
202
752
  }
203
204
7.80k
  void set_field(std::string field) { field_ = std::move(field); }
205
206
0
  void set_field(absl::string_view field) {
207
0
    field_.assign(field.data(), field.size());
208
0
  }
209
210
0
  void set_field(const char* field) {
211
0
    set_field(absl::NullSafeStringView(field));
212
0
  }
213
214
24
  ABSL_MUST_USE_RESULT std::string release_field() { return release(field_); }
215
216
  // Whether the select is to be interpreted as a field presence test.
217
  //
218
  // This results from the macro `has(request.auth)`.
219
783
  ABSL_MUST_USE_RESULT bool test_only() const { return test_only_; }
220
221
7.80k
  void set_test_only(bool test_only) { test_only_ = test_only; }
222
223
0
  friend void swap(SelectExpr& lhs, SelectExpr& rhs) noexcept {
224
0
    using std::swap;
225
0
    swap(lhs.operand_, rhs.operand_);
226
0
    swap(lhs.field_, rhs.field_);
227
0
    swap(lhs.test_only_, rhs.test_only_);
228
0
  }
229
230
 private:
231
  friend class Expr;
232
233
  static const SelectExpr& default_instance();
234
235
24
  static std::string release(std::string& property) {
236
24
    std::string result;
237
24
    result.swap(property);
238
24
    return result;
239
24
  }
240
241
  static std::unique_ptr<Expr> release(std::unique_ptr<Expr>& property);
242
243
  std::unique_ptr<Expr> operand_;
244
  std::string field_;
245
  bool test_only_ = false;
246
};
247
248
0
inline bool operator==(const SelectExpr& lhs, const SelectExpr& rhs) {
249
0
  return lhs.operand() == rhs.operand() && lhs.field() == rhs.field() &&
250
0
         lhs.test_only() == rhs.test_only();
251
0
}
252
253
0
inline bool operator!=(const SelectExpr& lhs, const SelectExpr& rhs) {
254
0
  return !operator==(lhs, rhs);
255
0
}
256
257
// `CallExpr` is an alternative of `Expr`, representing a function call.
258
class CallExpr final {
259
 public:
260
895k
  CallExpr() = default;
261
2.67M
  CallExpr(CallExpr&&) = default;
262
324
  CallExpr& operator=(CallExpr&&) = default;
263
264
  CallExpr(const CallExpr&) = delete;
265
  CallExpr& operator=(const CallExpr&) = delete;
266
267
  void Clear();
268
269
  // The name of the function or method being called.
270
  ABSL_MUST_USE_RESULT const std::string& function() const
271
414k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
272
414k
    return function_;
273
414k
  }
274
275
37.9k
  void set_function(std::string function) { function_ = std::move(function); }
276
277
857k
  void set_function(absl::string_view function) {
278
857k
    function_.assign(function.data(), function.size());
279
857k
  }
280
281
4.38k
  void set_function(const char* function) {
282
4.38k
    set_function(absl::NullSafeStringView(function));
283
4.38k
  }
284
285
0
  ABSL_MUST_USE_RESULT std::string release_function() {
286
0
    return release(function_);
287
0
  }
288
289
416k
  ABSL_MUST_USE_RESULT bool has_target() const { return target_ != nullptr; }
290
291
  // The target of an method call-style expression. For example, `x` in `x.f()`.
292
  ABSL_MUST_USE_RESULT const Expr& target() const ABSL_ATTRIBUTE_LIFETIME_BOUND;
293
294
  Expr& mutable_target() ABSL_ATTRIBUTE_LIFETIME_BOUND;
295
296
  void set_target(Expr target);
297
298
  void set_target(std::unique_ptr<Expr> target);
299
300
  ABSL_MUST_USE_RESULT std::unique_ptr<Expr> release_target();
301
302
  // The arguments.
303
  ABSL_MUST_USE_RESULT const std::vector<Expr>& args() const
304
1.24M
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
305
1.24M
    return args_;
306
1.24M
  }
307
308
  ABSL_MUST_USE_RESULT std::vector<Expr>& mutable_args()
309
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
310
0
    return args_;
311
0
  }
312
313
  void set_args(std::vector<Expr> args);
314
315
  void set_args(absl::Span<Expr> args);
316
317
  Expr& add_args() ABSL_ATTRIBUTE_LIFETIME_BOUND;
318
319
  ABSL_MUST_USE_RESULT std::vector<Expr> release_args();
320
321
0
  friend void swap(CallExpr& lhs, CallExpr& rhs) noexcept {
322
0
    using std::swap;
323
0
    swap(lhs.function_, rhs.function_);
324
0
    swap(lhs.target_, rhs.target_);
325
0
    swap(lhs.args_, rhs.args_);
326
0
  }
327
328
 private:
329
  friend class Expr;
330
331
  static const CallExpr& default_instance();
332
333
0
  static std::string release(std::string& property) {
334
0
    std::string result;
335
0
    result.swap(property);
336
0
    return result;
337
0
  }
338
339
  static std::unique_ptr<Expr> release(std::unique_ptr<Expr>& property);
340
341
  std::string function_;
342
  std::unique_ptr<Expr> target_;
343
  std::vector<Expr> args_;
344
};
345
346
bool operator==(const CallExpr& lhs, const CallExpr& rhs);
347
348
0
inline bool operator!=(const CallExpr& lhs, const CallExpr& rhs) {
349
0
  return !operator==(lhs, rhs);
350
0
}
351
352
// `ListExprElement` represents an element in `ListExpr`.
353
class ListExprElement final {
354
 public:
355
277k
  ListExprElement() = default;
356
277k
  ListExprElement(ListExprElement&&) = default;
357
  ListExprElement& operator=(ListExprElement&&) = default;
358
359
  ListExprElement(const ListExprElement&) = delete;
360
  ListExprElement& operator=(const ListExprElement&) = delete;
361
362
  void Clear();
363
364
278k
  ABSL_MUST_USE_RESULT bool has_expr() const { return expr_ != nullptr; }
365
366
  ABSL_MUST_USE_RESULT const Expr& expr() const ABSL_ATTRIBUTE_LIFETIME_BOUND;
367
368
  ABSL_MUST_USE_RESULT Expr& mutable_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND;
369
370
  void set_expr(Expr expr);
371
372
  void set_expr(std::unique_ptr<Expr> expr);
373
374
  ABSL_MUST_USE_RESULT Expr release_expr();
375
376
469
  ABSL_MUST_USE_RESULT bool optional() const { return optional_; }
377
378
277k
  void set_optional(bool optional) { optional_ = optional; }
379
380
  friend void swap(ListExprElement& lhs, ListExprElement& rhs) noexcept;
381
382
 private:
383
  static Expr release(std::unique_ptr<Expr>& property);
384
385
  std::unique_ptr<Expr> expr_;
386
  bool optional_ = false;
387
};
388
389
// `ListExpr` is an alternative of `Expr`, representing a list.
390
class ListExpr final {
391
 public:
392
2.67k
  ListExpr() = default;
393
10.5k
  ListExpr(ListExpr&&) = default;
394
0
  ListExpr& operator=(ListExpr&&) = default;
395
396
  ListExpr(const ListExpr&) = delete;
397
  ListExpr& operator=(const ListExpr&) = delete;
398
399
  void Clear();
400
401
  // The elements of the list.
402
  ABSL_MUST_USE_RESULT const std::vector<ListExprElement>& elements() const
403
2.24k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
404
2.24k
    return elements_;
405
2.24k
  }
406
407
  ABSL_MUST_USE_RESULT std::vector<ListExprElement>& mutable_elements()
408
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
409
0
    return elements_;
410
0
  }
411
412
  void set_elements(std::vector<ListExprElement> elements);
413
414
  void set_elements(absl::Span<ListExprElement> elements);
415
416
  ListExprElement& add_elements() ABSL_ATTRIBUTE_LIFETIME_BOUND;
417
418
  ABSL_MUST_USE_RESULT std::vector<ListExprElement> release_elements();
419
420
0
  friend void swap(ListExpr& lhs, ListExpr& rhs) noexcept {
421
0
    using std::swap;
422
0
    swap(lhs.elements_, rhs.elements_);
423
0
  }
424
425
 private:
426
  friend class Expr;
427
428
  static const ListExpr& default_instance();
429
430
  std::vector<ListExprElement> elements_;
431
};
432
433
bool operator==(const ListExpr& lhs, const ListExpr& rhs);
434
435
0
inline bool operator!=(const ListExpr& lhs, const ListExpr& rhs) {
436
0
  return !operator==(lhs, rhs);
437
0
}
438
439
// `StructExprField` represents a field in `StructExpr`.
440
class StructExprField final {
441
 public:
442
2.77k
  StructExprField() = default;
443
2.77k
  StructExprField(StructExprField&&) = default;
444
  StructExprField& operator=(StructExprField&&) = default;
445
446
  StructExprField(const StructExprField&) = delete;
447
  StructExprField& operator=(const StructExprField&) = delete;
448
449
  void Clear();
450
451
181
  ABSL_MUST_USE_RESULT ExprId id() const { return id_; }
452
453
2.77k
  void set_id(ExprId id) { id_ = id; }
454
455
  ABSL_MUST_USE_RESULT const std::string& name() const
456
181
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
457
181
    return name_;
458
181
  }
459
460
2.77k
  void set_name(std::string name) { name_ = std::move(name); }
461
462
0
  void set_name(absl::string_view name) {
463
0
    name_.assign(name.data(), name.size());
464
0
  }
465
466
0
  void set_name(const char* name) { set_name(absl::NullSafeStringView(name)); }
467
468
0
  ABSL_MUST_USE_RESULT std::string release_name() { return std::move(name_); }
469
470
3.14k
  ABSL_MUST_USE_RESULT bool has_value() const { return value_ != nullptr; }
471
472
  ABSL_MUST_USE_RESULT const Expr& value() const ABSL_ATTRIBUTE_LIFETIME_BOUND;
473
474
  ABSL_MUST_USE_RESULT Expr& mutable_value() ABSL_ATTRIBUTE_LIFETIME_BOUND;
475
476
  void set_value(Expr value);
477
478
  void set_value(std::unique_ptr<Expr> value);
479
480
  ABSL_MUST_USE_RESULT Expr release_value();
481
482
181
  ABSL_MUST_USE_RESULT bool optional() const { return optional_; }
483
484
2.77k
  void set_optional(bool optional) { optional_ = optional; }
485
486
  friend void swap(StructExprField& lhs, StructExprField& rhs) noexcept;
487
488
 private:
489
  static Expr release(std::unique_ptr<Expr>& property);
490
491
  ExprId id_ = 0;
492
  std::string name_;
493
  std::unique_ptr<Expr> value_;
494
  bool optional_ = false;
495
};
496
497
// `StructExpr` is an alternative of `Expr`, representing a struct.
498
class StructExpr final {
499
 public:
500
1.68k
  StructExpr() = default;
501
5.30k
  StructExpr(StructExpr&&) = default;
502
0
  StructExpr& operator=(StructExpr&&) = default;
503
504
  StructExpr(const StructExpr&) = delete;
505
  StructExpr& operator=(const StructExpr&) = delete;
506
507
  void Clear();
508
509
  // The type name of the struct to be created.
510
  ABSL_MUST_USE_RESULT const std::string& name() const
511
145
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
512
145
    return name_;
513
145
  }
514
515
1.68k
  void set_name(std::string name) { name_ = std::move(name); }
516
517
0
  void set_name(absl::string_view name) {
518
0
    name_.assign(name.data(), name.size());
519
0
  }
520
521
0
  void set_name(const char* name) { set_name(absl::NullSafeStringView(name)); }
522
523
0
  ABSL_MUST_USE_RESULT std::string release_name() { return release(name_); }
524
525
  // The fields of the struct.
526
  ABSL_MUST_USE_RESULT const std::vector<StructExprField>& fields() const
527
179
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
528
179
    return fields_;
529
179
  }
530
531
  ABSL_MUST_USE_RESULT std::vector<StructExprField>& mutable_fields()
532
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
533
0
    return fields_;
534
0
  }
535
536
  void set_fields(std::vector<StructExprField> fields);
537
538
  void set_fields(absl::Span<StructExprField> fields);
539
540
  StructExprField& add_fields() ABSL_ATTRIBUTE_LIFETIME_BOUND;
541
542
  ABSL_MUST_USE_RESULT std::vector<StructExprField> release_fields();
543
544
0
  friend void swap(StructExpr& lhs, StructExpr& rhs) noexcept {
545
0
    using std::swap;
546
0
    swap(lhs.name_, rhs.name_);
547
0
    swap(lhs.fields_, rhs.fields_);
548
0
  }
549
550
 private:
551
  friend class Expr;
552
553
  static const StructExpr& default_instance();
554
555
0
  static std::string release(std::string& property) {
556
0
    std::string result;
557
0
    result.swap(property);
558
0
    return result;
559
0
  }
560
561
  std::string name_;
562
  std::vector<StructExprField> fields_;
563
};
564
565
bool operator==(const StructExpr& lhs, const StructExpr& rhs);
566
567
0
inline bool operator!=(const StructExpr& lhs, const StructExpr& rhs) {
568
0
  return !operator==(lhs, rhs);
569
0
}
570
571
// `MapExprEntry` represents an entry in `MapExpr`.
572
class MapExprEntry final {
573
 public:
574
391k
  MapExprEntry() = default;
575
391k
  MapExprEntry(MapExprEntry&&) = default;
576
  MapExprEntry& operator=(MapExprEntry&&) = default;
577
578
  MapExprEntry(const MapExprEntry&) = delete;
579
  MapExprEntry& operator=(const MapExprEntry&) = delete;
580
581
  void Clear();
582
583
304k
  ABSL_MUST_USE_RESULT ExprId id() const { return id_; }
584
585
391k
  void set_id(ExprId id) { id_ = id; }
586
587
999k
  ABSL_MUST_USE_RESULT bool has_key() const { return key_ != nullptr; }
588
589
  ABSL_MUST_USE_RESULT const Expr& key() const ABSL_ATTRIBUTE_LIFETIME_BOUND;
590
591
  ABSL_MUST_USE_RESULT Expr& mutable_key() ABSL_ATTRIBUTE_LIFETIME_BOUND;
592
593
  void set_key(Expr key);
594
595
  void set_key(std::unique_ptr<Expr> key);
596
597
  ABSL_MUST_USE_RESULT Expr release_key();
598
599
999k
  ABSL_MUST_USE_RESULT bool has_value() const { return value_ != nullptr; }
600
601
  ABSL_MUST_USE_RESULT const Expr& value() const ABSL_ATTRIBUTE_LIFETIME_BOUND;
602
603
  ABSL_MUST_USE_RESULT Expr& mutable_value() ABSL_ATTRIBUTE_LIFETIME_BOUND;
604
605
  void set_value(Expr value);
606
607
  void set_value(std::unique_ptr<Expr> value);
608
609
  ABSL_MUST_USE_RESULT Expr release_value();
610
611
304k
  ABSL_MUST_USE_RESULT bool optional() const { return optional_; }
612
613
391k
  void set_optional(bool optional) { optional_ = optional; }
614
615
  friend void swap(MapExprEntry& lhs, MapExprEntry& rhs) noexcept;
616
617
 private:
618
  static Expr release(std::unique_ptr<Expr>& property);
619
620
  ExprId id_ = 0;
621
  std::unique_ptr<Expr> key_;
622
  std::unique_ptr<Expr> value_;
623
  bool optional_ = false;
624
};
625
626
// `MapExpr` is an alternative of `Expr`, representing a map.
627
class MapExpr final {
628
 public:
629
1.44k
  MapExpr() = default;
630
6.38k
  MapExpr(MapExpr&&) = default;
631
0
  MapExpr& operator=(MapExpr&&) = default;
632
633
  MapExpr(const MapExpr&) = delete;
634
  MapExpr& operator=(const MapExpr&) = delete;
635
636
  void Clear();
637
638
  // The entries of the map.
639
  ABSL_MUST_USE_RESULT const std::vector<MapExprEntry>& entries() const
640
329
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
641
329
    return entries_;
642
329
  }
643
644
  ABSL_MUST_USE_RESULT std::vector<MapExprEntry>& mutable_entries()
645
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
646
0
    return entries_;
647
0
  }
648
649
  void set_entries(std::vector<MapExprEntry> entries);
650
651
  void set_entries(absl::Span<MapExprEntry> entries);
652
653
  MapExprEntry& add_entries() ABSL_ATTRIBUTE_LIFETIME_BOUND;
654
655
  ABSL_MUST_USE_RESULT std::vector<MapExprEntry> release_entries();
656
657
0
  friend void swap(MapExpr& lhs, MapExpr& rhs) noexcept {
658
0
    using std::swap;
659
0
    swap(lhs.entries_, rhs.entries_);
660
0
  }
661
662
 private:
663
  friend class Expr;
664
665
  static const MapExpr& default_instance();
666
667
  std::vector<MapExprEntry> entries_;
668
};
669
670
bool operator==(const MapExpr& lhs, const MapExpr& rhs);
671
672
0
inline bool operator!=(const MapExpr& lhs, const MapExpr& rhs) {
673
0
  return !operator==(lhs, rhs);
674
0
}
675
676
// `ComprehensionExpr` is an alternative of `Expr`, representing a
677
// comprehension. These are always synthetic as there is no way to express them
678
// directly in the Common Expression Language, and are created by macros.
679
class ComprehensionExpr final {
680
 public:
681
1.49k
  ComprehensionExpr() = default;
682
9.61k
  ComprehensionExpr(ComprehensionExpr&&) = default;
683
0
  ComprehensionExpr& operator=(ComprehensionExpr&&) = default;
684
685
  ComprehensionExpr(const ComprehensionExpr&) = delete;
686
  ComprehensionExpr& operator=(const ComprehensionExpr&) = delete;
687
688
  void Clear();
689
690
  ABSL_MUST_USE_RESULT const std::string& iter_var() const
691
221
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
692
221
    return iter_var_;
693
221
  }
694
695
1.49k
  void set_iter_var(std::string iter_var) { iter_var_ = std::move(iter_var); }
696
697
0
  void set_iter_var(absl::string_view iter_var) {
698
0
    iter_var_.assign(iter_var.data(), iter_var.size());
699
0
  }
700
701
0
  void set_iter_var(const char* iter_var) {
702
0
    set_iter_var(absl::NullSafeStringView(iter_var));
703
0
  }
704
705
0
  ABSL_MUST_USE_RESULT std::string release_iter_var() {
706
0
    return release(iter_var_);
707
0
  }
708
709
  ABSL_MUST_USE_RESULT const std::string& iter_var2() const
710
221
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
711
221
    return iter_var2_;
712
221
  }
713
714
0
  void set_iter_var2(std::string iter_var2) {
715
0
    iter_var2_ = std::move(iter_var2);
716
0
  }
717
718
1.49k
  void set_iter_var2(absl::string_view iter_var2) {
719
1.49k
    iter_var2_.assign(iter_var2.data(), iter_var2.size());
720
1.49k
  }
721
722
1.49k
  void set_iter_var2(const char* iter_var2) {
723
1.49k
    set_iter_var2(absl::NullSafeStringView(iter_var2));
724
1.49k
  }
725
726
0
  ABSL_MUST_USE_RESULT std::string release_iter_var2() {
727
0
    return release(iter_var2_);
728
0
  }
729
730
1.93k
  ABSL_MUST_USE_RESULT bool has_iter_range() const {
731
1.93k
    return iter_range_ != nullptr;
732
1.93k
  }
733
734
  ABSL_MUST_USE_RESULT const Expr& iter_range() const
735
      ABSL_ATTRIBUTE_LIFETIME_BOUND;
736
737
  Expr& mutable_iter_range() ABSL_ATTRIBUTE_LIFETIME_BOUND;
738
739
  void set_iter_range(Expr iter_range);
740
741
  void set_iter_range(std::unique_ptr<Expr> iter_range);
742
743
  ABSL_MUST_USE_RESULT std::unique_ptr<Expr> release_iter_range();
744
745
  ABSL_MUST_USE_RESULT const std::string& accu_var() const
746
221
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
747
221
    return accu_var_;
748
221
  }
749
750
0
  void set_accu_var(std::string accu_var) { accu_var_ = std::move(accu_var); }
751
752
1.49k
  void set_accu_var(absl::string_view accu_var) {
753
1.49k
    accu_var_.assign(accu_var.data(), accu_var.size());
754
1.49k
  }
755
756
0
  void set_accu_var(const char* accu_var) {
757
0
    set_accu_var(absl::NullSafeStringView(accu_var));
758
0
  }
759
760
0
  ABSL_MUST_USE_RESULT std::string release_accu_var() {
761
0
    return release(accu_var_);
762
0
  }
763
764
1.93k
  ABSL_MUST_USE_RESULT bool has_accu_init() const {
765
1.93k
    return accu_init_ != nullptr;
766
1.93k
  }
767
768
  ABSL_MUST_USE_RESULT const Expr& accu_init() const
769
      ABSL_ATTRIBUTE_LIFETIME_BOUND;
770
771
  Expr& mutable_accu_init() ABSL_ATTRIBUTE_LIFETIME_BOUND;
772
773
  void set_accu_init(Expr accu_init);
774
775
  void set_accu_init(std::unique_ptr<Expr> accu_init);
776
777
  ABSL_MUST_USE_RESULT std::unique_ptr<Expr> release_accu_init();
778
779
1.93k
  ABSL_MUST_USE_RESULT bool has_loop_condition() const {
780
1.93k
    return loop_condition_ != nullptr;
781
1.93k
  }
782
783
  ABSL_MUST_USE_RESULT const Expr& loop_condition() const
784
      ABSL_ATTRIBUTE_LIFETIME_BOUND;
785
786
  Expr& mutable_loop_condition() ABSL_ATTRIBUTE_LIFETIME_BOUND;
787
788
  void set_loop_condition(Expr loop_condition);
789
790
  void set_loop_condition(std::unique_ptr<Expr> loop_condition);
791
792
  ABSL_MUST_USE_RESULT std::unique_ptr<Expr> release_loop_condition();
793
794
1.93k
  ABSL_MUST_USE_RESULT bool has_loop_step() const {
795
1.93k
    return loop_step_ != nullptr;
796
1.93k
  }
797
798
  ABSL_MUST_USE_RESULT const Expr& loop_step() const
799
      ABSL_ATTRIBUTE_LIFETIME_BOUND;
800
801
  Expr& mutable_loop_step() ABSL_ATTRIBUTE_LIFETIME_BOUND;
802
803
  void set_loop_step(Expr loop_step);
804
805
  void set_loop_step(std::unique_ptr<Expr> loop_step);
806
807
  ABSL_MUST_USE_RESULT std::unique_ptr<Expr> release_loop_step();
808
809
1.93k
  ABSL_MUST_USE_RESULT bool has_result() const { return result_ != nullptr; }
810
811
  ABSL_MUST_USE_RESULT const Expr& result() const ABSL_ATTRIBUTE_LIFETIME_BOUND;
812
813
  Expr& mutable_result() ABSL_ATTRIBUTE_LIFETIME_BOUND;
814
815
  void set_result(Expr result);
816
817
  void set_result(std::unique_ptr<Expr> result);
818
819
  ABSL_MUST_USE_RESULT std::unique_ptr<Expr> release_result();
820
821
0
  friend void swap(ComprehensionExpr& lhs, ComprehensionExpr& rhs) noexcept {
822
0
    using std::swap;
823
0
    swap(lhs.iter_var_, rhs.iter_var_);
824
0
    swap(lhs.iter_var2_, rhs.iter_var2_);
825
0
    swap(lhs.iter_range_, rhs.iter_range_);
826
0
    swap(lhs.accu_var_, rhs.accu_var_);
827
0
    swap(lhs.accu_init_, rhs.accu_init_);
828
0
    swap(lhs.loop_condition_, rhs.loop_condition_);
829
0
    swap(lhs.loop_step_, rhs.loop_step_);
830
0
    swap(lhs.result_, rhs.result_);
831
0
  }
832
833
 private:
834
  friend class Expr;
835
836
  static const ComprehensionExpr& default_instance();
837
838
0
  static std::string release(std::string& property) {
839
0
    std::string result;
840
0
    result.swap(property);
841
0
    return result;
842
0
  }
843
844
  static std::unique_ptr<Expr> release(std::unique_ptr<Expr>& property);
845
846
  std::string iter_var_;
847
  std::string iter_var2_;
848
  std::unique_ptr<Expr> iter_range_;
849
  std::string accu_var_;
850
  std::unique_ptr<Expr> accu_init_;
851
  std::unique_ptr<Expr> loop_condition_;
852
  std::unique_ptr<Expr> loop_step_;
853
  std::unique_ptr<Expr> result_;
854
};
855
856
inline bool operator==(const ComprehensionExpr& lhs,
857
0
                       const ComprehensionExpr& rhs) {
858
0
  return lhs.iter_var() == rhs.iter_var() &&
859
0
         lhs.iter_range() == rhs.iter_range() &&
860
0
         lhs.accu_var() == rhs.accu_var() &&
861
0
         lhs.accu_init() == rhs.accu_init() &&
862
0
         lhs.loop_condition() == rhs.loop_condition() &&
863
0
         lhs.loop_step() == rhs.loop_step() && lhs.result() == rhs.result();
864
0
}
865
866
inline bool operator!=(const ComprehensionExpr& lhs,
867
0
                       const ComprehensionExpr& rhs) {
868
0
  return !operator==(lhs, rhs);
869
0
}
870
871
using ExprKind =
872
    absl::variant<UnspecifiedExpr, Constant, IdentExpr, SelectExpr, CallExpr,
873
                  ListExpr, StructExpr, MapExpr, ComprehensionExpr>;
874
875
enum class ExprKindCase {
876
  kUnspecifiedExpr,
877
  kConstant,
878
  kIdentExpr,
879
  kSelectExpr,
880
  kCallExpr,
881
  kListExpr,
882
  kStructExpr,
883
  kMapExpr,
884
  kComprehensionExpr,
885
};
886
887
// `Expr` is a node in the Common Expression Language's abstract syntax tree. It
888
// is composed of a numeric ID and a kind variant.
889
class Expr final {
890
 public:
891
5.66M
  Expr() = default;
892
9.99M
  Expr(Expr&&) = default;
893
  Expr& operator=(Expr&&);
894
895
  Expr(const Expr&);
896
  Expr& operator=(const Expr&);
897
898
  void Clear();
899
900
1.41M
  ABSL_MUST_USE_RESULT ExprId id() const { return id_; }
901
902
4.58M
  void set_id(ExprId id) { id_ = id; }
903
904
  ABSL_MUST_USE_RESULT const ExprKind& kind() const
905
1.41M
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
906
1.41M
    return kind_;
907
1.41M
  }
908
909
2.78M
  ABSL_MUST_USE_RESULT ExprKind& mutable_kind() ABSL_ATTRIBUTE_LIFETIME_BOUND {
910
2.78M
    return kind_;
911
2.78M
  }
912
913
  void set_kind(ExprKind kind);
914
915
  ABSL_MUST_USE_RESULT ExprKind release_kind();
916
917
0
  ABSL_MUST_USE_RESULT bool has_const_expr() const {
918
0
    return absl::holds_alternative<Constant>(kind());
919
0
  }
920
921
  ABSL_MUST_USE_RESULT const Constant& const_expr() const
922
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
923
0
    return get_kind<Constant>();
924
0
  }
925
926
1.10M
  Constant& mutable_const_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND {
927
1.10M
    return try_emplace_kind<Constant>();
928
1.10M
  }
929
930
0
  void set_const_expr(Constant const_expr) {
931
0
    try_emplace_kind<Constant>() = std::move(const_expr);
932
0
  }
933
934
0
  ABSL_MUST_USE_RESULT Constant release_const_expr() {
935
0
    return release_kind<Constant>();
936
0
  }
937
938
1.87k
  ABSL_MUST_USE_RESULT bool has_ident_expr() const {
939
1.87k
    return absl::holds_alternative<IdentExpr>(kind());
940
1.87k
  }
941
942
  ABSL_MUST_USE_RESULT const IdentExpr& ident_expr() const
943
4.53k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
944
4.53k
    return get_kind<IdentExpr>();
945
4.53k
  }
946
947
770k
  IdentExpr& mutable_ident_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND {
948
770k
    return try_emplace_kind<IdentExpr>();
949
770k
  }
950
951
0
  void set_ident_expr(IdentExpr ident_expr) {
952
0
    try_emplace_kind<IdentExpr>() = std::move(ident_expr);
953
0
  }
954
955
0
  ABSL_MUST_USE_RESULT IdentExpr release_ident_expr() {
956
0
    return release_kind<IdentExpr>();
957
0
  }
958
959
1.60k
  ABSL_MUST_USE_RESULT bool has_select_expr() const {
960
1.60k
    return absl::holds_alternative<SelectExpr>(kind());
961
1.60k
  }
962
963
  ABSL_MUST_USE_RESULT const SelectExpr& select_expr() const
964
31
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
965
31
    return get_kind<SelectExpr>();
966
31
  }
967
968
7.85k
  SelectExpr& mutable_select_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND {
969
7.85k
    return try_emplace_kind<SelectExpr>();
970
7.85k
  }
971
972
0
  void set_select_expr(SelectExpr select_expr) {
973
0
    try_emplace_kind<SelectExpr>() = std::move(select_expr);
974
0
  }
975
976
0
  ABSL_MUST_USE_RESULT SelectExpr release_select_expr() {
977
0
    return release_kind<SelectExpr>();
978
0
  }
979
980
0
  ABSL_MUST_USE_RESULT bool has_call_expr() const {
981
0
    return absl::holds_alternative<CallExpr>(kind());
982
0
  }
983
984
  ABSL_MUST_USE_RESULT const CallExpr& call_expr() const
985
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
986
0
    return get_kind<CallExpr>();
987
0
  }
988
989
895k
  CallExpr& mutable_call_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND {
990
895k
    return try_emplace_kind<CallExpr>();
991
895k
  }
992
993
  void set_call_expr(CallExpr call_expr);
994
995
  ABSL_MUST_USE_RESULT CallExpr release_call_expr();
996
997
0
  ABSL_MUST_USE_RESULT bool has_list_expr() const {
998
0
    return absl::holds_alternative<ListExpr>(kind());
999
0
  }
1000
1001
  ABSL_MUST_USE_RESULT const ListExpr& list_expr() const
1002
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1003
0
    return get_kind<ListExpr>();
1004
0
  }
1005
1006
2.67k
  ListExpr& mutable_list_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1007
2.67k
    return try_emplace_kind<ListExpr>();
1008
2.67k
  }
1009
1010
  void set_list_expr(ListExpr list_expr);
1011
1012
  ABSL_MUST_USE_RESULT ListExpr release_list_expr();
1013
1014
0
  ABSL_MUST_USE_RESULT bool has_struct_expr() const {
1015
0
    return absl::holds_alternative<StructExpr>(kind());
1016
0
  }
1017
1018
  ABSL_MUST_USE_RESULT const StructExpr& struct_expr() const
1019
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1020
0
    return get_kind<StructExpr>();
1021
0
  }
1022
1023
1.68k
  StructExpr& mutable_struct_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1024
1.68k
    return try_emplace_kind<StructExpr>();
1025
1.68k
  }
1026
1027
  void set_struct_expr(StructExpr struct_expr);
1028
1029
  ABSL_MUST_USE_RESULT StructExpr release_struct_expr();
1030
1031
0
  ABSL_MUST_USE_RESULT bool has_map_expr() const {
1032
0
    return absl::holds_alternative<MapExpr>(kind());
1033
0
  }
1034
1035
  ABSL_MUST_USE_RESULT const MapExpr& map_expr() const
1036
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1037
0
    return get_kind<MapExpr>();
1038
0
  }
1039
1040
1.44k
  MapExpr& mutable_map_expr() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1041
1.44k
    return try_emplace_kind<MapExpr>();
1042
1.44k
  }
1043
1044
  void set_map_expr(MapExpr map_expr);
1045
1046
  ABSL_MUST_USE_RESULT MapExpr release_map_expr();
1047
1048
0
  ABSL_MUST_USE_RESULT bool has_comprehension_expr() const {
1049
0
    return absl::holds_alternative<ComprehensionExpr>(kind());
1050
0
  }
1051
1052
  ABSL_MUST_USE_RESULT const ComprehensionExpr& comprehension_expr() const
1053
0
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1054
0
    return get_kind<ComprehensionExpr>();
1055
0
  }
1056
1057
  ComprehensionExpr& mutable_comprehension_expr()
1058
1.49k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1059
1.49k
    return try_emplace_kind<ComprehensionExpr>();
1060
1.49k
  }
1061
1062
0
  void set_comprehension_expr(ComprehensionExpr comprehension_expr) {
1063
0
    try_emplace_kind<ComprehensionExpr>() = std::move(comprehension_expr);
1064
0
  }
1065
1066
0
  ABSL_MUST_USE_RESULT ComprehensionExpr release_comprehension_expr() {
1067
0
    return release_kind<ComprehensionExpr>();
1068
0
  }
1069
1070
  ExprKindCase kind_case() const;
1071
1072
  friend void swap(Expr& lhs, Expr& rhs) noexcept;
1073
1074
 private:
1075
  friend class IdentExpr;
1076
  friend class SelectExpr;
1077
  friend class CallExpr;
1078
  friend class ListExpr;
1079
  friend class StructExpr;
1080
  friend class MapExpr;
1081
  friend class ComprehensionExpr;
1082
  friend class ListExprElement;
1083
  friend class StructExprField;
1084
  friend class MapExprEntry;
1085
1086
  static const Expr& default_instance();
1087
1088
  template <typename T, typename... Args>
1089
  ABSL_MUST_USE_RESULT T& try_emplace_kind(Args&&... args)
1090
2.78M
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
2.78M
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
48
      return *alt;
1093
48
    }
1094
2.78M
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
2.78M
  }
cel::Constant& cel::Expr::try_emplace_kind<cel::Constant>()
Line
Count
Source
1090
1.10M
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
1.10M
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
0
      return *alt;
1093
0
    }
1094
1.10M
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
1.10M
  }
cel::IdentExpr& cel::Expr::try_emplace_kind<cel::IdentExpr>()
Line
Count
Source
1090
770k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
770k
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
0
      return *alt;
1093
0
    }
1094
770k
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
770k
  }
cel::SelectExpr& cel::Expr::try_emplace_kind<cel::SelectExpr>()
Line
Count
Source
1090
7.85k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
7.85k
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
48
      return *alt;
1093
48
    }
1094
7.80k
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
7.85k
  }
cel::CallExpr& cel::Expr::try_emplace_kind<cel::CallExpr>()
Line
Count
Source
1090
895k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
895k
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
0
      return *alt;
1093
0
    }
1094
895k
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
895k
  }
cel::ListExpr& cel::Expr::try_emplace_kind<cel::ListExpr>()
Line
Count
Source
1090
2.67k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
2.67k
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
0
      return *alt;
1093
0
    }
1094
2.67k
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
2.67k
  }
cel::StructExpr& cel::Expr::try_emplace_kind<cel::StructExpr>()
Line
Count
Source
1090
1.68k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
1.68k
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
0
      return *alt;
1093
0
    }
1094
1.68k
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
1.68k
  }
cel::MapExpr& cel::Expr::try_emplace_kind<cel::MapExpr>()
Line
Count
Source
1090
1.44k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
1.44k
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
0
      return *alt;
1093
0
    }
1094
1.44k
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
1.44k
  }
cel::ComprehensionExpr& cel::Expr::try_emplace_kind<cel::ComprehensionExpr>()
Line
Count
Source
1090
1.49k
      ABSL_ATTRIBUTE_LIFETIME_BOUND {
1091
1.49k
    if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1092
0
      return *alt;
1093
0
    }
1094
1.49k
    return kind_.emplace<T>(std::forward<Args>(args)...);
1095
1.49k
  }
1096
1097
  template <typename T>
1098
4.57k
  ABSL_MUST_USE_RESULT const T& get_kind() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
1099
4.57k
    if (const auto* alt = absl::get_if<T>(&kind()); alt) {
1100
4.57k
      return *alt;
1101
4.57k
    }
1102
0
    return T::default_instance();
1103
4.57k
  }
Unexecuted instantiation: cel::Constant const& cel::Expr::get_kind<cel::Constant>() const
cel::IdentExpr const& cel::Expr::get_kind<cel::IdentExpr>() const
Line
Count
Source
1098
4.53k
  ABSL_MUST_USE_RESULT const T& get_kind() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
1099
4.53k
    if (const auto* alt = absl::get_if<T>(&kind()); alt) {
1100
4.53k
      return *alt;
1101
4.53k
    }
1102
0
    return T::default_instance();
1103
4.53k
  }
cel::SelectExpr const& cel::Expr::get_kind<cel::SelectExpr>() const
Line
Count
Source
1098
31
  ABSL_MUST_USE_RESULT const T& get_kind() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
1099
31
    if (const auto* alt = absl::get_if<T>(&kind()); alt) {
1100
31
      return *alt;
1101
31
    }
1102
0
    return T::default_instance();
1103
31
  }
Unexecuted instantiation: cel::CallExpr const& cel::Expr::get_kind<cel::CallExpr>() const
Unexecuted instantiation: cel::ListExpr const& cel::Expr::get_kind<cel::ListExpr>() const
Unexecuted instantiation: cel::StructExpr const& cel::Expr::get_kind<cel::StructExpr>() const
Unexecuted instantiation: cel::MapExpr const& cel::Expr::get_kind<cel::MapExpr>() const
Unexecuted instantiation: cel::ComprehensionExpr const& cel::Expr::get_kind<cel::ComprehensionExpr>() const
1104
1105
  template <typename T>
1106
  ABSL_MUST_USE_RESULT T release_kind();
1107
1108
  ExprId id_ = 0;
1109
  ExprKind kind_;
1110
};
1111
1112
0
inline bool operator==(const Expr& lhs, const Expr& rhs) {
1113
0
  return lhs.id() == rhs.id() && lhs.kind() == rhs.kind();
1114
0
}
1115
1116
0
inline bool operator==(const CallExpr& lhs, const CallExpr& rhs) {
1117
0
  return lhs.function() == rhs.function() && lhs.target() == rhs.target() &&
1118
0
         absl::c_equal(lhs.args(), rhs.args());
1119
0
}
1120
1121
0
inline void SelectExpr::Clear() {
1122
0
  operand_.reset();
1123
0
  field_.clear();
1124
0
  test_only_ = false;
1125
0
}
1126
1127
ABSL_MUST_USE_RESULT inline std::unique_ptr<Expr>
1128
24
SelectExpr::release_operand() {
1129
24
  return release(operand_);
1130
24
}
1131
1132
752
inline const Expr& SelectExpr::operand() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
1133
752
  return has_operand() ? *operand_ : Expr::default_instance();
1134
752
}
1135
1136
7.78k
inline Expr& SelectExpr::mutable_operand() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1137
7.78k
  if (!has_operand()) {
1138
7.78k
    operand_ = std::make_unique<Expr>();
1139
7.78k
  }
1140
7.78k
  return *operand_;
1141
7.78k
}
1142
1143
7.78k
inline void SelectExpr::set_operand(Expr operand) {
1144
7.78k
  mutable_operand() = std::move(operand);
1145
7.78k
}
1146
1147
24
inline void SelectExpr::set_operand(std::unique_ptr<Expr> operand) {
1148
24
  operand_ = std::move(operand);
1149
24
}
1150
1151
inline std::unique_ptr<Expr> SelectExpr::release(
1152
24
    std::unique_ptr<Expr>& property) {
1153
24
  std::unique_ptr<Expr> result;
1154
24
  result.swap(property);
1155
24
  return result;
1156
24
}
1157
1158
0
inline void ComprehensionExpr::Clear() {
1159
0
  iter_var_.clear();
1160
0
  iter_range_.reset();
1161
0
  accu_var_.clear();
1162
0
  accu_init_.reset();
1163
0
  loop_condition_.reset();
1164
0
  loop_step_.reset();
1165
0
  result_.reset();
1166
0
}
1167
1168
inline const Expr& ComprehensionExpr::iter_range() const
1169
221
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1170
221
  return has_iter_range() ? *iter_range_ : Expr::default_instance();
1171
221
}
1172
1173
inline Expr& ComprehensionExpr::mutable_iter_range()
1174
1.49k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1175
1.49k
  if (!has_iter_range()) {
1176
1.49k
    iter_range_ = std::make_unique<Expr>();
1177
1.49k
  }
1178
1.49k
  return *iter_range_;
1179
1.49k
}
1180
1181
1.49k
inline void ComprehensionExpr::set_iter_range(Expr iter_range) {
1182
1.49k
  mutable_iter_range() = std::move(iter_range);
1183
1.49k
}
1184
1185
inline void ComprehensionExpr::set_iter_range(
1186
0
    std::unique_ptr<Expr> iter_range) {
1187
0
  iter_range_ = std::move(iter_range);
1188
0
}
1189
1190
ABSL_MUST_USE_RESULT inline std::unique_ptr<Expr>
1191
0
ComprehensionExpr::release_iter_range() {
1192
0
  return release(iter_range_);
1193
0
}
1194
1195
inline const Expr& ComprehensionExpr::accu_init() const
1196
221
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1197
221
  return has_accu_init() ? *accu_init_ : Expr::default_instance();
1198
221
}
1199
1200
ABSL_MUST_USE_RESULT inline std::unique_ptr<Expr>
1201
0
ComprehensionExpr::release_accu_init() {
1202
0
  return release(accu_init_);
1203
0
}
1204
1205
inline Expr& ComprehensionExpr::mutable_accu_init()
1206
1.49k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1207
1.49k
  if (!has_accu_init()) {
1208
1.49k
    accu_init_ = std::make_unique<Expr>();
1209
1.49k
  }
1210
1.49k
  return *accu_init_;
1211
1.49k
}
1212
1213
1.49k
inline void ComprehensionExpr::set_accu_init(Expr accu_init) {
1214
1.49k
  mutable_accu_init() = std::move(accu_init);
1215
1.49k
}
1216
1217
0
inline void ComprehensionExpr::set_accu_init(std::unique_ptr<Expr> accu_init) {
1218
0
  accu_init_ = std::move(accu_init);
1219
0
}
1220
1221
inline const Expr& ComprehensionExpr::loop_step() const
1222
221
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1223
221
  return has_loop_step() ? *loop_step_ : Expr::default_instance();
1224
221
}
1225
1226
inline Expr& ComprehensionExpr::mutable_loop_step()
1227
1.49k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1228
1.49k
  if (!has_loop_step()) {
1229
1.49k
    loop_step_ = std::make_unique<Expr>();
1230
1.49k
  }
1231
1.49k
  return *loop_step_;
1232
1.49k
}
1233
1234
1.49k
inline void ComprehensionExpr::set_loop_step(Expr loop_step) {
1235
1.49k
  mutable_loop_step() = std::move(loop_step);
1236
1.49k
}
1237
1238
0
inline void ComprehensionExpr::set_loop_step(std::unique_ptr<Expr> loop_step) {
1239
0
  loop_step_ = std::move(loop_step);
1240
0
}
1241
1242
ABSL_MUST_USE_RESULT inline std::unique_ptr<Expr>
1243
0
ComprehensionExpr::release_loop_step() {
1244
0
  return release(loop_step_);
1245
0
}
1246
1247
inline const Expr& ComprehensionExpr::loop_condition() const
1248
221
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1249
221
  return has_loop_condition() ? *loop_condition_ : Expr::default_instance();
1250
221
}
1251
1252
ABSL_MUST_USE_RESULT inline std::unique_ptr<Expr>
1253
0
ComprehensionExpr::release_loop_condition() {
1254
0
  return release(loop_condition_);
1255
0
}
1256
1257
inline Expr& ComprehensionExpr::mutable_loop_condition()
1258
1.49k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1259
1.49k
  if (!has_loop_condition()) {
1260
1.49k
    loop_condition_ = std::make_unique<Expr>();
1261
1.49k
  }
1262
1.49k
  return *loop_condition_;
1263
1.49k
}
1264
1265
1.49k
inline void ComprehensionExpr::set_loop_condition(Expr loop_condition) {
1266
1.49k
  mutable_loop_condition() = std::move(loop_condition);
1267
1.49k
}
1268
1269
inline void ComprehensionExpr::set_loop_condition(
1270
0
    std::unique_ptr<Expr> loop_condition) {
1271
0
  loop_condition_ = std::move(loop_condition);
1272
0
}
1273
1274
inline const Expr& ComprehensionExpr::result() const
1275
221
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1276
221
  return has_result() ? *result_ : Expr::default_instance();
1277
221
}
1278
1279
1.49k
inline Expr& ComprehensionExpr::mutable_result() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1280
1.49k
  if (!has_result()) {
1281
1.49k
    result_ = std::make_unique<Expr>();
1282
1.49k
  }
1283
1.49k
  return *result_;
1284
1.49k
}
1285
1286
1.49k
inline void ComprehensionExpr::set_result(Expr result) {
1287
1.49k
  mutable_result() = std::move(result);
1288
1.49k
}
1289
1290
0
inline void ComprehensionExpr::set_result(std::unique_ptr<Expr> result) {
1291
0
  result_ = std::move(result);
1292
0
}
1293
1294
ABSL_MUST_USE_RESULT inline std::unique_ptr<Expr>
1295
0
ComprehensionExpr::release_result() {
1296
0
  return release(result_);
1297
0
}
1298
1299
inline std::unique_ptr<Expr> ComprehensionExpr::release(
1300
0
    std::unique_ptr<Expr>& property) {
1301
0
  std::unique_ptr<Expr> result;
1302
0
  result.swap(property);
1303
0
  return result;
1304
0
}
1305
1306
0
inline bool operator==(const ListExprElement& lhs, const ListExprElement& rhs) {
1307
0
  return lhs.expr() == rhs.expr() && lhs.optional() == rhs.optional();
1308
0
}
1309
1310
0
inline bool operator==(const ListExpr& lhs, const ListExpr& rhs) {
1311
0
  return absl::c_equal(lhs.elements(), rhs.elements());
1312
0
}
1313
1314
0
inline bool operator==(const StructExprField& lhs, const StructExprField& rhs) {
1315
0
  return lhs.id() == rhs.id() && lhs.name() == rhs.name() &&
1316
0
         lhs.value() == rhs.value() && lhs.optional() == rhs.optional();
1317
0
}
1318
1319
0
inline bool operator==(const StructExpr& lhs, const StructExpr& rhs) {
1320
0
  return lhs.name() == rhs.name() && absl::c_equal(lhs.fields(), rhs.fields());
1321
0
}
1322
1323
0
inline bool operator==(const MapExprEntry& lhs, const MapExprEntry& rhs) {
1324
0
  return lhs.id() == rhs.id() && lhs.key() == rhs.key() &&
1325
0
         lhs.value() == rhs.value() && lhs.optional() == rhs.optional();
1326
0
}
1327
1328
0
inline bool operator==(const MapExpr& lhs, const MapExpr& rhs) {
1329
0
  return absl::c_equal(lhs.entries(), rhs.entries());
1330
0
}
1331
1332
0
inline void MapExpr::Clear() { entries_.clear(); }
1333
1334
1.44k
inline void MapExpr::set_entries(std::vector<MapExprEntry> entries) {
1335
1.44k
  entries_ = std::move(entries);
1336
1.44k
}
1337
1338
0
inline void MapExpr::set_entries(absl::Span<MapExprEntry> entries) {
1339
0
  entries_.clear();
1340
0
  entries_.reserve(entries.size());
1341
0
  for (auto& entry : entries) {
1342
0
    entries_.push_back(std::move(entry));
1343
0
  }
1344
0
}
1345
1346
0
inline MapExprEntry& MapExpr::add_entries() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1347
0
  return mutable_entries().emplace_back();
1348
0
}
1349
1350
0
inline std::vector<MapExprEntry> MapExpr::release_entries() {
1351
0
  std::vector<MapExprEntry> entries;
1352
0
  entries.swap(entries_);
1353
0
  return entries;
1354
0
}
1355
1356
0
inline void Expr::Clear() {
1357
0
  id_ = 0;
1358
0
  mutable_kind().emplace<UnspecifiedExpr>();
1359
0
}
1360
1361
1.08M
inline Expr& Expr::operator=(Expr&&) = default;
1362
1363
0
inline void Expr::set_kind(ExprKind kind) { kind_ = std::move(kind); }
1364
1365
0
inline ABSL_MUST_USE_RESULT ExprKind Expr::release_kind() {
1366
0
  ExprKind kind = std::move(kind_);
1367
0
  kind_.emplace<UnspecifiedExpr>();
1368
0
  return kind;
1369
0
}
1370
1371
0
inline void Expr::set_call_expr(CallExpr call_expr) {
1372
0
  try_emplace_kind<CallExpr>() = std::move(call_expr);
1373
0
}
1374
1375
0
inline ABSL_MUST_USE_RESULT CallExpr Expr::release_call_expr() {
1376
0
  return release_kind<CallExpr>();
1377
0
}
1378
1379
0
inline void Expr::set_list_expr(ListExpr list_expr) {
1380
0
  try_emplace_kind<ListExpr>() = std::move(list_expr);
1381
0
}
1382
1383
0
inline ListExpr Expr::release_list_expr() { return release_kind<ListExpr>(); }
1384
1385
0
inline void Expr::set_struct_expr(StructExpr struct_expr) {
1386
0
  try_emplace_kind<StructExpr>() = std::move(struct_expr);
1387
0
}
1388
1389
0
inline StructExpr Expr::release_struct_expr() {
1390
0
  return release_kind<StructExpr>();
1391
0
}
1392
1393
0
inline void Expr::set_map_expr(MapExpr map_expr) {
1394
0
  try_emplace_kind<MapExpr>() = std::move(map_expr);
1395
0
}
1396
1397
0
inline MapExpr Expr::release_map_expr() { return release_kind<MapExpr>(); }
1398
1399
template <typename T>
1400
0
ABSL_MUST_USE_RESULT T Expr::release_kind() {
1401
0
  T result;
1402
0
  if (auto* alt = absl::get_if<T>(&mutable_kind()); alt) {
1403
0
    result = std::move(*alt);
1404
0
  }
1405
0
  kind_.emplace<UnspecifiedExpr>();
1406
0
  return result;
1407
0
}
Unexecuted instantiation: cel::Constant cel::Expr::release_kind<cel::Constant>()
Unexecuted instantiation: cel::IdentExpr cel::Expr::release_kind<cel::IdentExpr>()
Unexecuted instantiation: cel::SelectExpr cel::Expr::release_kind<cel::SelectExpr>()
Unexecuted instantiation: cel::ComprehensionExpr cel::Expr::release_kind<cel::ComprehensionExpr>()
Unexecuted instantiation: cel::CallExpr cel::Expr::release_kind<cel::CallExpr>()
Unexecuted instantiation: cel::ListExpr cel::Expr::release_kind<cel::ListExpr>()
Unexecuted instantiation: cel::StructExpr cel::Expr::release_kind<cel::StructExpr>()
Unexecuted instantiation: cel::MapExpr cel::Expr::release_kind<cel::MapExpr>()
1408
1409
0
inline ExprKindCase Expr::kind_case() const {
1410
0
  static_assert(absl::variant_size_v<ExprKind> == 9);
1411
0
  if (kind_.index() <= 9) {
1412
0
    return static_cast<ExprKindCase>(kind_.index());
1413
0
  }
1414
0
  return ExprKindCase::kUnspecifiedExpr;
1415
0
}
1416
1417
0
inline void swap(Expr& lhs, Expr& rhs) noexcept {
1418
0
  using std::swap;
1419
0
  swap(lhs.id_, rhs.id_);
1420
0
  swap(lhs.kind_, rhs.kind_);
1421
0
}
1422
1423
0
inline void CallExpr::Clear() {
1424
0
  function_.clear();
1425
0
  target_.reset();
1426
0
  args_.clear();
1427
0
}
1428
1429
197
inline const Expr& CallExpr::target() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
1430
197
  return has_target() ? *target_ : Expr::default_instance();
1431
197
}
1432
1433
1.65k
inline Expr& CallExpr::mutable_target() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1434
1.65k
  if (!has_target()) {
1435
1.65k
    target_ = std::make_unique<Expr>();
1436
1.65k
  }
1437
1.65k
  return *target_;
1438
1.65k
}
1439
1440
1.65k
inline void CallExpr::set_target(Expr target) {
1441
1.65k
  mutable_target() = std::move(target);
1442
1.65k
}
1443
1444
0
inline void CallExpr::set_target(std::unique_ptr<Expr> target) {
1445
0
  target_ = std::move(target);
1446
0
}
1447
1448
0
ABSL_MUST_USE_RESULT inline std::unique_ptr<Expr> CallExpr::release_target() {
1449
0
  return release(target_);
1450
0
}
1451
1452
895k
inline void CallExpr::set_args(std::vector<Expr> args) {
1453
895k
  args_ = std::move(args);
1454
895k
}
1455
1456
0
inline void CallExpr::set_args(absl::Span<Expr> args) {
1457
0
  args_.clear();
1458
0
  args_.reserve(args.size());
1459
0
  for (auto& arg : args) {
1460
0
    args_.push_back(std::move(arg));
1461
0
  }
1462
0
}
1463
1464
0
inline Expr& CallExpr::add_args() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1465
0
  return mutable_args().emplace_back();
1466
0
}
1467
1468
0
inline std::vector<Expr> CallExpr::release_args() {
1469
0
  std::vector<Expr> args;
1470
0
  args.swap(args_);
1471
0
  return args;
1472
0
}
1473
1474
inline std::unique_ptr<Expr> CallExpr::release(
1475
0
    std::unique_ptr<Expr>& property) {
1476
0
  std::unique_ptr<Expr> result;
1477
0
  result.swap(property);
1478
0
  return result;
1479
0
}
1480
1481
0
inline void ListExprElement::Clear() {
1482
0
  expr_.reset();
1483
0
  optional_ = false;
1484
0
}
1485
1486
inline ABSL_MUST_USE_RESULT const Expr& ListExprElement::expr() const
1487
469
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1488
469
  return has_expr() ? *expr_ : Expr::default_instance();
1489
469
}
1490
1491
inline ABSL_MUST_USE_RESULT Expr& ListExprElement::mutable_expr()
1492
277k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1493
277k
  if (!has_expr()) {
1494
277k
    expr_ = std::make_unique<Expr>();
1495
277k
  }
1496
277k
  return *expr_;
1497
277k
}
1498
1499
277k
inline void ListExprElement::set_expr(Expr expr) {
1500
277k
  mutable_expr() = std::move(expr);
1501
277k
}
1502
1503
0
inline void ListExprElement::set_expr(std::unique_ptr<Expr> expr) {
1504
0
  expr_ = std::move(expr);
1505
0
}
1506
1507
0
inline ABSL_MUST_USE_RESULT Expr ListExprElement::release_expr() {
1508
0
  return release(expr_);
1509
0
}
1510
1511
0
inline void swap(ListExprElement& lhs, ListExprElement& rhs) noexcept {
1512
0
  using std::swap;
1513
0
  swap(lhs.expr_, rhs.expr_);
1514
0
  swap(lhs.optional_, rhs.optional_);
1515
0
}
1516
1517
0
inline Expr ListExprElement::release(std::unique_ptr<Expr>& property) {
1518
0
  std::unique_ptr<Expr> result;
1519
0
  result.swap(property);
1520
0
  if (result != nullptr) {
1521
0
    return std::move(*result);
1522
0
  }
1523
0
  return Expr{};
1524
0
}
1525
1526
0
inline void ListExpr::Clear() { elements_.clear(); }
1527
1528
2.67k
inline void ListExpr::set_elements(std::vector<ListExprElement> elements) {
1529
2.67k
  elements_ = std::move(elements);
1530
2.67k
}
1531
1532
0
inline void ListExpr::set_elements(absl::Span<ListExprElement> elements) {
1533
0
  elements_.clear();
1534
0
  elements_.reserve(elements.size());
1535
0
  for (auto& element : elements) {
1536
0
    elements_.push_back(std::move(element));
1537
0
  }
1538
0
}
1539
1540
0
inline ListExprElement& ListExpr::add_elements() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1541
0
  return mutable_elements().emplace_back();
1542
0
}
1543
1544
0
inline std::vector<ListExprElement> ListExpr::release_elements() {
1545
0
  std::vector<ListExprElement> elements;
1546
0
  elements.swap(elements_);
1547
0
  return elements;
1548
0
}
1549
1550
0
inline void StructExprField::Clear() {
1551
0
  id_ = 0;
1552
0
  name_.clear();
1553
0
  value_.reset();
1554
0
  optional_ = false;
1555
0
}
1556
1557
inline ABSL_MUST_USE_RESULT const Expr& StructExprField::value() const
1558
181
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1559
181
  return has_value() ? *value_ : Expr::default_instance();
1560
181
}
1561
1562
inline ABSL_MUST_USE_RESULT Expr& StructExprField::mutable_value()
1563
2.77k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1564
2.77k
  if (!has_value()) {
1565
2.77k
    value_ = std::make_unique<Expr>();
1566
2.77k
  }
1567
2.77k
  return *value_;
1568
2.77k
}
1569
1570
2.77k
inline void StructExprField::set_value(Expr value) {
1571
2.77k
  mutable_value() = std::move(value);
1572
2.77k
}
1573
1574
0
inline void StructExprField::set_value(std::unique_ptr<Expr> value) {
1575
0
  value_ = std::move(value);
1576
0
}
1577
1578
0
inline ABSL_MUST_USE_RESULT Expr StructExprField::release_value() {
1579
0
  return release(value_);
1580
0
}
1581
1582
0
inline void swap(StructExprField& lhs, StructExprField& rhs) noexcept {
1583
0
  using std::swap;
1584
0
  swap(lhs.id_, rhs.id_);
1585
0
  swap(lhs.name_, rhs.name_);
1586
0
  swap(lhs.value_, rhs.value_);
1587
0
  swap(lhs.optional_, rhs.optional_);
1588
0
}
1589
1590
0
inline Expr StructExprField::release(std::unique_ptr<Expr>& property) {
1591
0
  std::unique_ptr<Expr> result;
1592
0
  result.swap(property);
1593
0
  if (result != nullptr) {
1594
0
    return std::move(*result);
1595
0
  }
1596
0
  return Expr{};
1597
0
}
1598
1599
0
inline void StructExpr::Clear() {
1600
0
  name_.clear();
1601
0
  fields_.clear();
1602
0
}
1603
1604
1.68k
inline void StructExpr::set_fields(std::vector<StructExprField> fields) {
1605
1.68k
  fields_ = std::move(fields);
1606
1.68k
}
1607
1608
0
inline void StructExpr::set_fields(absl::Span<StructExprField> fields) {
1609
0
  fields_.clear();
1610
0
  fields_.reserve(fields.size());
1611
0
  for (auto& field : fields) {
1612
0
    fields_.push_back(std::move(field));
1613
0
  }
1614
0
}
1615
1616
0
inline StructExprField& StructExpr::add_fields() ABSL_ATTRIBUTE_LIFETIME_BOUND {
1617
0
  return mutable_fields().emplace_back();
1618
0
}
1619
1620
0
inline std::vector<StructExprField> StructExpr::release_fields() {
1621
0
  std::vector<StructExprField> fields;
1622
0
  fields.swap(fields_);
1623
0
  return fields;
1624
0
}
1625
1626
0
inline void MapExprEntry::Clear() {
1627
0
  id_ = 0;
1628
0
  key_.reset();
1629
0
  value_.reset();
1630
0
  optional_ = false;
1631
0
}
1632
1633
inline ABSL_MUST_USE_RESULT const Expr& MapExprEntry::key() const
1634
304k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1635
304k
  return has_key() ? *key_ : Expr::default_instance();
1636
304k
}
1637
1638
inline ABSL_MUST_USE_RESULT Expr& MapExprEntry::mutable_key()
1639
391k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1640
391k
  if (!has_key()) {
1641
391k
    key_ = std::make_unique<Expr>();
1642
391k
  }
1643
391k
  return *key_;
1644
391k
}
1645
1646
391k
inline void MapExprEntry::set_key(Expr key) { mutable_key() = std::move(key); }
1647
1648
0
inline void MapExprEntry::set_key(std::unique_ptr<Expr> key) {
1649
0
  key_ = std::move(key);
1650
0
}
1651
1652
0
inline ABSL_MUST_USE_RESULT Expr MapExprEntry::release_key() {
1653
0
  return release(key_);
1654
0
}
1655
1656
inline ABSL_MUST_USE_RESULT const Expr& MapExprEntry::value() const
1657
304k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1658
304k
  return has_value() ? *value_ : Expr::default_instance();
1659
304k
}
1660
1661
inline ABSL_MUST_USE_RESULT Expr& MapExprEntry::mutable_value()
1662
391k
    ABSL_ATTRIBUTE_LIFETIME_BOUND {
1663
391k
  if (!has_value()) {
1664
391k
    value_ = std::make_unique<Expr>();
1665
391k
  }
1666
391k
  return *value_;
1667
391k
}
1668
1669
391k
inline void MapExprEntry::set_value(Expr value) {
1670
391k
  mutable_value() = std::move(value);
1671
391k
}
1672
1673
0
inline void MapExprEntry::set_value(std::unique_ptr<Expr> value) {
1674
0
  value_ = std::move(value);
1675
0
}
1676
1677
0
inline ABSL_MUST_USE_RESULT Expr MapExprEntry::release_value() {
1678
0
  return release(value_);
1679
0
}
1680
1681
0
inline void swap(MapExprEntry& lhs, MapExprEntry& rhs) noexcept {
1682
0
  using std::swap;
1683
0
  swap(lhs.id_, rhs.id_);
1684
0
  swap(lhs.key_, rhs.key_);
1685
0
  swap(lhs.value_, rhs.value_);
1686
0
  swap(lhs.optional_, rhs.optional_);
1687
0
}
1688
1689
0
inline Expr MapExprEntry::release(std::unique_ptr<Expr>& property) {
1690
0
  std::unique_ptr<Expr> result;
1691
0
  result.swap(property);
1692
0
  if (result != nullptr) {
1693
0
    return std::move(*result);
1694
0
  }
1695
0
  return Expr{};
1696
0
}
1697
1698
}  // namespace cel
1699
1700
#endif  // THIRD_PARTY_CEL_CPP_COMMON_EXPR_H_