Manages the set of builtins used by an interpreter to resolve built-in calls.
More...
#include <rego.hh>
|
|
| BuiltInsDef () noexcept |
| | Constructor.
|
| |
| bool | is_builtin (const Location &name) const |
| | Determines whether the provided name refers to a built-in.
|
| |
| Node | decl (const Location &name) const |
| | Gets the declaration node for the specified built-in.
|
| |
| bool | is_deprecated (const Location &version, const Location &name) const |
| | Determines whether the provided builtin name is deprecated in the provided version.
|
| |
| Node | call (const Location &name, const Location &version, const Nodes &args) |
| | Calls the built-in with the provided name and arguments.
|
| |
|
void | clear () |
| | Called to clear any persistent state or caching.
|
| |
| BuiltInsDef & | register_builtin (const BuiltIn &built_in) |
| | Registers a built-in.
|
| |
| const BuiltIn & | at (const Location &name) const |
| | Gets the built-in with the provided name.
|
| |
| bool | strict_errors () const |
| | Whether to throw built-in errors.
|
| |
| BuiltInsDef & | strict_errors (bool strict_errors) |
| | Sets whether to throw built-in errors.
|
| |
| template<typename T > |
| BuiltInsDef & | register_builtins (const T &built_ins) |
| | Registers a set of built-ins.
|
| |
| BuiltInsDef & | register_standard_builtins () |
| | This registers the "standard library" of built-ins.
|
| |
| std::map< Location, BuiltIn >::const_iterator | begin () const |
| | Gets the beginning iterator for the built-ins map.
|
| |
| std::map< Location, BuiltIn >::const_iterator | end () const |
| | Gets the ending iterator for the built-ins map.
|
| |
Manages the set of builtins used by an interpreter to resolve built-in calls.
◆ at()
| const BuiltIn & rego::BuiltInsDef::at |
( |
const Location & | name | ) |
const |
Gets the built-in with the provided name.
- Parameters
-
| name | The name of the built-in to retrieve. |
- Returns
- The built-in with the specified name.
◆ begin()
| std::map< Location, BuiltIn >::const_iterator rego::BuiltInsDef::begin |
( |
| ) |
const |
Gets the beginning iterator for the built-ins map.
- Returns
- The beginning iterator for the built-ins map.
◆ call()
| Node rego::BuiltInsDef::call |
( |
const Location & | name, |
|
|
const Location & | version, |
|
|
const Nodes & | args ) |
Calls the built-in with the provided name and arguments.
- Parameters
-
| name | The name of the built-in to call. |
| version | The Rego version. |
| args | The arguments to pass to the built-in. |
- Returns
- The result of the built-in call.
◆ create()
| static std::shared_ptr< BuiltInsDef > rego::BuiltInsDef::create |
( |
| ) |
|
|
static |
Creates the standard builtin set.
- Returns
- A shared pointer to the created BuiltInsDef.
◆ decl()
| Node rego::BuiltInsDef::decl |
( |
const Location & | name | ) |
const |
Gets the declaration node for the specified built-in.
- Parameters
-
| name | The name of the built-in. |
- Returns
- The declaration node for the built-in, or an empty node if not found.
◆ end()
| std::map< Location, BuiltIn >::const_iterator rego::BuiltInsDef::end |
( |
| ) |
const |
Gets the ending iterator for the built-ins map.
- Returns
- The ending iterator for the built-ins map.
◆ is_builtin()
| bool rego::BuiltInsDef::is_builtin |
( |
const Location & | name | ) |
const |
Determines whether the provided name refers to a built-in.
- Parameters
-
- Returns
- True if the name refers to a built-in, otherwise false.
◆ is_deprecated()
| bool rego::BuiltInsDef::is_deprecated |
( |
const Location & | version, |
|
|
const Location & | name ) const |
Determines whether the provided builtin name is deprecated in the provided version.
- Parameters
-
| version | The version to check. |
| name | The name to check. |
- Returns
- True if the builtin is deprecated in the specified version, otherwise false.
◆ register_builtin()
Registers a built-in.
- Parameters
-
| built_in | The built-in to register. |
- Returns
- A reference to this instance.
◆ register_builtins()
template<typename T >
| BuiltInsDef & rego::BuiltInsDef::register_builtins |
( |
const T & | built_ins | ) |
|
|
inline |
Registers a set of built-ins.
- Parameters
-
| built_ins | The built-ins to register. |
- Returns
- A reference to this instance.
◆ register_standard_builtins()
| BuiltInsDef & rego::BuiltInsDef::register_standard_builtins |
( |
| ) |
|
This registers the "standard library" of built-ins.
There are a number of built-ins which are provided by default. These built-ins are those documented in the OPA docs.
- Returns
- A reference to this instance.
◆ strict_errors() [1/2]
| bool rego::BuiltInsDef::strict_errors |
( |
| ) |
const |
Whether to throw built-in errors.
- Returns
- True if built-in errors will be thrown as exceptions, false otherwise. If true, built-in errors will be thrown as exceptions. If false, built-in errors will result in Undefined nodes.
◆ strict_errors() [2/2]
| BuiltInsDef & rego::BuiltInsDef::strict_errors |
( |
bool | strict_errors | ) |
|
Sets whether to throw built-in errors.
- Parameters
-
| strict_errors | True to throw built-in errors as exceptions, false to return Undefined nodes. |
- Returns
- A reference to this instance.
The documentation for this class was generated from the following file: