OperatorRegistry
class OperatorRegistry
Central registry for operator definitions
Manages: - Registration of new operators - Lookup by name - Batch registration of operator categories - Dynamic operator injection (from Python)
Used by SEval to dispatch function calls and special forms. Typically one registry per evaluator instance.
- See
- SEval for usage context
Functions
| Name | Description |
|---|---|
| register_operator | @name Registration @{ Register a new operator Once registered, the operator is available for dispatch in eval(). |
| get_operator | @name Lookup @{ Get an operator if it exists Used by evaluator to dispatch function calls: cpp auto op = registry.get_operator("+"); if (op) { result = op.value()(evaluator, arguments); } name : The operator name to look up Return : Optional containing the operator function, or nullopt if not found |
| has_operator | Check if an operator exists Faster than get_operator() if you only need existence check. |
| get_all_operators | @} @name Introspection @{ Get all registered operator names Useful for listing available operators or debugging. |
| size | Get number of registered operators Return : Count of registered operators |
| clear | @} @name Maintenance @{ Clear all registered operators Use with caution - removes all operators including builtins. |
| register_math_operators | @} @name Batch Registration Helpers @{ Register standard math operators (+, -, *, /, **, %) |
| register_bitwise_operators | Register bitwise operators (band, bor, bxor, lshift, rshift) |
| register_list_operators | Register list operators (car, cdr, cons, length, list) |
| register_array_operators | Register array operators (arange, array, extend) |
| register_core_operators | Register core operators (define, lambda, if, etc.) |
| register_type_operators | Register type operators (type, is?, etc.) |
| register_waveform_operators | Register waveform operators (signal, step, load, etc.) |
| register_special_operators | Register special forms (quote, eval, etc.) |
| register_virtual_operators | Register virtual signal operators |
Function Details
clear
void clear()
@} @name Maintenance @{ Clear all registered operators
Use with caution - removes all operators including builtins. Typically only used in testing or extreme reset scenarios.
get_all_operators
std::vector<std::string> get_all_operators() const
@} @name Introspection @{ Get all registered operator names
Useful for listing available operators or debugging.
- Return
- Vector of operator names
get_operator
std::optional<OperatorFunc> get_operator(const std::string& name) const
@name Lookup @{ Get an operator if it exists
Used by evaluator to dispatch function calls:
-
name - The operator name to look up
- Return
- Optional containing the operator function, or nullopt if not found
has_operator
bool has_operator(const std::string& name) const
Check if an operator exists
Faster than get_operator() if you only need existence check.
-
name - The operator name
- Return
- true if operator is registered, false otherwise
register_array_operators
void register_array_operators()
Register array operators (arange, array, extend)
register_bitwise_operators
void register_bitwise_operators()
Register bitwise operators (band, bor, bxor, lshift, rshift)
register_core_operators
void register_core_operators()
Register core operators (define, lambda, if, etc.)
register_list_operators
void register_list_operators()
Register list operators (car, cdr, cons, length, list)
register_math_operators
void register_math_operators()
@} @name Batch Registration Helpers @{ Register standard math operators (+, -, *, /, **, %)
register_operator
void register_operator(const std::string& name, OperatorFunc func)
@name Registration @{ Register a new operator
Once registered, the operator is available for dispatch in eval(). If operator already exists, replaces it.
Example - Simple math operator:
Example - Special form:
-
name - The operator name (e.g., "+", "my-op", "special-form")
-
func - The implementation function (callable with OperatorFunc signature)
- See
- for architecture overview
register_special_operators
void register_special_operators()
Register special forms (quote, eval, etc.)
register_type_operators
void register_type_operators()
Register type operators (type, is?, etc.)
register_virtual_operators
void register_virtual_operators()
Register virtual signal operators
register_waveform_operators
void register_waveform_operators()
Register waveform operators (signal, step, load, etc.)
size
size_t size() const
Get number of registered operators
- Return
- Count of registered operators