rego-cpp 1.0.0
A C++ implementation of the Rego language and runtime
Loading...
Searching...
No Matches
rego::VirtualMachine Class Reference

This class implements a virtual machine that can execute compiled Rego bundles. More...

#include <rego.hh>

Public Member Functions

Node run_entrypoint (const Location &entrypoint, Node input) const
 Executes the entrypoint plan in the bundle with the provided input.
 
Node run_query (Node input) const
 Executes the query plan in the bundle with the provided input.
 
VirtualMachinebuiltins (BuiltIns builtins)
 Sets the built-in functions to use during execution.
 
BuiltIns builtins () const
 Gets the built-in functions used during execution.
 
VirtualMachinebundle (Bundle bundle)
 Sets the bundle to use during execution.
 
Bundle bundle () const
 Gets the bundle used during execution.
 

Detailed Description

This class implements a virtual machine that can execute compiled Rego bundles.

For more information on the IR used by the virtual machine, see https://www.openpolicyagent.org/docs/ir.

Member Function Documentation

◆ builtins() [1/2]

BuiltIns rego::VirtualMachine::builtins ( ) const

Gets the built-in functions used during execution.

Returns
The built-in functions used.

◆ builtins() [2/2]

VirtualMachine & rego::VirtualMachine::builtins ( BuiltIns builtins)

Sets the built-in functions to use during execution.

Parameters
builtinsThe built-in functions to use.
Returns
A reference to this virtual machine.

◆ bundle()

VirtualMachine & rego::VirtualMachine::bundle ( Bundle bundle)

Sets the bundle to use during execution.

Parameters
bundleThe bundle to use.
Returns
A reference to this virtual machine.

◆ run_entrypoint()

Node rego::VirtualMachine::run_entrypoint ( const Location & entrypoint,
Node input ) const

Executes the entrypoint plan in the bundle with the provided input.

The entrypoint must have been specified when the bundle was built otherwise an error node will be returned.

Parameters
entrypointThe name of the entrypoint plan to execute.
inputThe input to the plan.
Returns
The result of executing the plan.

◆ run_query()

Node rego::VirtualMachine::run_query ( Node input) const

Executes the query plan in the bundle with the provided input.

The bundle must have been built with a query plan, otherwise an error node will be returned.

Parameters
inputThe input to the query.
Returns
The result of executing the query.

The documentation for this class was generated from the following file: