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) |
| | Determines whether the provided name refers to a built-in.
|
| |
| Node | decl (const Location &name) |
| | 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.
|
| |
| BuiltIn | at (const Location &name) |
| | 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 method no longer needs to be called.
|
| |
| template<typename T > |
| BuiltInsDef & | whitelist (const std::initializer_list< T > &allowed) |
| | Sets a whitelist of built-in names that are allowed to be loaded.
|
| |
| template<typename T > |
| BuiltInsDef & | whitelist (T begin, T end) |
| | Sets a whitelist of built-in names that are allowed to be loaded.
|
| |
| template<typename T > |
| BuiltInsDef & | blacklist (const std::initializer_list< T > &forbidden) |
| | Sets a blacklist of built-in names that are forbidden from being loaded.
|
| |
| template<typename T > |
| BuiltInsDef & | blacklist (T begin, T end) |
| | Sets a blacklist of built-in names that are forbidden from being loaded.
|
| |
| BuiltInsDef & | allow_all () |
| | Allow all built-ins to be loaded from the standard library.
|
| |
Manages the set of builtins used by an interpreter to resolve built-in calls.
This object provides all lookup for builtins. Users can add their own custom builtins using BuiltInsDef::register_builtin. Built-ins from the Rego standard library.) will be loaded as needed. Control over what parts of the standard library are available to policies is available via the BuiltInsDef::whitelist and BuiltInsDef::blacklist methods.
◆ allow_all()
Allow all built-ins to be loaded from the standard library.
- Returns
- A reference to this instance
◆ at()
| BuiltIn rego::BuiltInsDef::at |
( |
const Location & | name | ) |
|
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.
◆ blacklist() [1/2]
template<typename T >
| BuiltInsDef & rego::BuiltInsDef::blacklist |
( |
const std::initializer_list< T > & | forbidden | ) |
|
|
inline |
Sets a blacklist of built-in names that are forbidden from being loaded.
Built-ins whose names are in this list will be forbidden. Any previous list and behavior will be overridden.
- Parameters
-
| forbidden | the forbidden built-in names |
- Returns
- A reference to this instance
◆ blacklist() [2/2]
template<typename T >
| BuiltInsDef & rego::BuiltInsDef::blacklist |
( |
T | begin, |
|
|
T | end ) |
|
inline |
Sets a blacklist of built-in names that are forbidden from being loaded.
Built-ins whose names are in this list will be forbidden. Any previous list and behavior will be overridden.
- Parameters
-
| begin | iterator pointing to the beginning of a range of forbidden names |
| end | iterator pointing to the end of a range of forbidden names |
- Returns
- A reference to this instance
◆ 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 | ) |
|
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.
◆ is_builtin()
| bool rego::BuiltInsDef::is_builtin |
( |
const Location & | name | ) |
|
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 method no longer needs to be called.
- Deprecated
- 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.
◆ whitelist() [1/2]
template<typename T >
| BuiltInsDef & rego::BuiltInsDef::whitelist |
( |
const std::initializer_list< T > & | allowed | ) |
|
|
inline |
Sets a whitelist of built-in names that are allowed to be loaded.
Only built-ins whose names are in this list will be allowed. Any previous list and behavior will be overridden.
- Parameters
-
| allowed | the allowed built-in names |
- Returns
- A reference to this instance
◆ whitelist() [2/2]
template<typename T >
| BuiltInsDef & rego::BuiltInsDef::whitelist |
( |
T | begin, |
|
|
T | end ) |
|
inline |
Sets a whitelist of built-in names that are allowed to be loaded.
Only built-ins whose names are in this list will be allowed. Any previous list and behavior will be overridden.
- Parameters
-
| begin | iterator pointing to the beginning of a range of allowed names |
| end | iterator pointing to the end of a range of allowed names |
- Returns
- A reference to this instance
The documentation for this class was generated from the following file: