MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / FunctionResult

Class FunctionResult

base/function_result.h:27–58  ·  view source on GitHub ↗

Represents a function result that is unknown at the time of execution. This allows for lazy evaluation of expensive functions.

Source from the content-addressed store, hash-verified

25// Represents a function result that is unknown at the time of execution. This
26// allows for lazy evaluation of expensive functions.
27class FunctionResult final {
28 public:
29 FunctionResult() = delete;
30 FunctionResult(const FunctionResult&) = default;
31 FunctionResult(FunctionResult&&) = default;
32 FunctionResult& operator=(const FunctionResult&) = default;
33 FunctionResult& operator=(FunctionResult&&) = default;
34
35 FunctionResult(FunctionDescriptor descriptor, int64_t expr_id)
36 : descriptor_(std::move(descriptor)), expr_id_(expr_id) {}
37
38 // The descriptor of the called function that return Unknown.
39 const FunctionDescriptor& descriptor() const { return descriptor_; }
40
41 // The id of the |Expr| that triggered the function call step. Provided
42 // informationally -- if two different |Expr|s generate the same unknown call,
43 // they will be treated as the same unknown function result.
44 int64_t call_expr_id() const { return expr_id_; }
45
46 // Equality operator provided for testing. Compatible with set less-than
47 // comparator.
48 // Compares descriptor then arguments elementwise.
49 bool IsEqualTo(const FunctionResult& other) const {
50 return descriptor() == other.descriptor();
51 }
52
53 // TODO(uncreated-issue/5): re-implement argument capture
54
55 private:
56 FunctionDescriptor descriptor_;
57 int64_t expr_id_;
58};
59
60inline bool operator==(const FunctionResult& lhs, const FunctionResult& rhs) {
61 return lhs.IsEqualTo(rhs);

Callers 1

CreateUnknownSetMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected