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

Function CreateCompiler

runtime/memory_safety_test.cc:86–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84using ParamType = std::tuple<TestCase, Options>;
85
86absl::StatusOr<std::unique_ptr<Compiler>> CreateCompiler() {
87 google::protobuf::LinkMessageReflection<cel::expr::conformance::proto3::TestAllTypes>();
88 google::protobuf::LinkMessageReflection<
89 cel::expr::conformance::proto3::NestedTestAllTypes>();
90
91 CEL_ASSIGN_OR_RETURN(
92 std::unique_ptr<CompilerBuilder> b,
93 NewCompilerBuilder(google::protobuf::DescriptorPool::generated_pool()));
94 CEL_RETURN_IF_ERROR(b->AddLibrary(StandardCompilerLibrary()));
95 CEL_RETURN_IF_ERROR(b->AddLibrary(OptionalCompilerLibrary()));
96 b->GetCheckerBuilder().set_container("cel.expr.conformance.proto3");
97 auto& cb = b->GetCheckerBuilder();
98 CEL_RETURN_IF_ERROR(cb.AddVariable(MakeVariableDecl("bool_var", BoolType())));
99 CEL_RETURN_IF_ERROR(
100 cb.AddVariable(MakeVariableDecl("string_var", StringType())));
101 CEL_RETURN_IF_ERROR(
102 cb.AddVariable(MakeVariableDecl("condition", BoolType())));
103 CEL_RETURN_IF_ERROR(cb.AddVariable(MakeVariableDecl(
104 "nested_test_all_types", MessageType(NestedTestAllTypes::descriptor()))));
105
106 CEL_RETURN_IF_ERROR(cb.AddFunction(
107 MakeFunctionDecl("IsPrivate", MakeOverloadDecl("IsPrivate_string",
108 BoolType(), StringType()))
109 .value()));
110 CEL_RETURN_IF_ERROR(cb.AddFunction(
111 MakeFunctionDecl(
112 "net.IsPrivate",
113 MakeOverloadDecl("net_IsPrivate_string", BoolType(), StringType()))
114 .value()));
115
116 return b->Build();
117}
118
119const Compiler& GetCompiler() {
120 static const Compiler* compiler = []() {

Callers 1

Calls 15

StandardCompilerLibraryFunction · 0.85
OptionalCompilerLibraryFunction · 0.85
MakeVariableDeclFunction · 0.85
MakeFunctionDeclFunction · 0.85
MakeOverloadDeclFunction · 0.85
AddVariableMethod · 0.80
CEL_ASSIGN_OR_RETURNFunction · 0.50
NewCompilerBuilderFunction · 0.50
BoolTypeClass · 0.50
StringTypeClass · 0.50
MessageTypeClass · 0.50
AddLibraryMethod · 0.45

Tested by

no test coverage detected