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

Function ConfigureCompiler

codelab/solutions/exercise10.cc:44–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42namespace {
43
44absl::StatusOr<std::unique_ptr<cel::Compiler>> ConfigureCompiler() {
45 absl::StatusOr<std::unique_ptr<cel::CompilerBuilder>> compiler_builder =
46 cel::NewCompilerBuilder(cel::GetMinimalDescriptorPool());
47 if (!compiler_builder.ok()) {
48 return std::move(compiler_builder).status();
49 }
50 absl::Status s =
51 (*compiler_builder)->AddLibrary(cel::StandardCompilerLibrary());
52 // ===========================================================================
53 // Codelab: Update compiler builder with functions from network_functions.h
54 // and add a varible for the input IP.
55 // ===========================================================================
56 s.Update((*compiler_builder)->AddLibrary(NetworkFunctionsCompilerLibrary()));
57 s.Update((*compiler_builder)
58 ->GetCheckerBuilder()
59 .AddVariable(cel::MakeVariableDecl("ip", cel::StringType())));
60 if (!s.ok()) return s;
61
62 return (*compiler_builder)->Build();
63}
64
65absl::StatusOr<std::unique_ptr<cel::Runtime>> ConfigureRuntime() {
66 cel::RuntimeOptions runtime_options;

Callers 1

Calls 9

StandardCompilerLibraryFunction · 0.85
MakeVariableDeclFunction · 0.85
AddVariableMethod · 0.80
NewCompilerBuilderFunction · 0.50
StringTypeClass · 0.50
okMethod · 0.45
AddLibraryMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected