Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::PrimitiveExpeditor Class Reference

#include <PrimitiveExpeditor.h>

Public Member Functions

RegisterManagerProxygetAssignedRegister ()
 Gets the register proxy assigned to this expeditor.
 
int getArgsLength ()
 Gets the number of arguments in the current function call.
 
bool checkType (Object param, Lisp::Type expectedType)
 Checks if a parameter matches an expected Lisp type.
 
Object evalList ()
 Evaluates the argument list if not already evaluated.
 
Object list ()
 Gets the argument list (evaluated or not).
 
Object evalObj (VarObject obj)
 Evaluates a single object in the current environment.
 
void terminate (const char *msg)
 Terminates execution with an error message.
 
void assertArgsCount (int length)
 Asserts that the function was called with the expected number of arguments.
 
void assertArgs (uint8_t length, const Lisp::Type *types)
 Asserts that arguments match the expected types.
 
void assertArgs (uint8_t length,...)
 Variadic version of assertArgs.
 
void assertDescribedArgs ()
 Asserts arguments against the primitive's description.
 
Object getArg (int idx)
 Gets an argument at the specified index.
 
bool getArgBool (int idx, bool acceptsInt=true)
 Gets a boolean value from an argument.
 
int getArgInt (int idx, bool acceptsBool=true)
 Gets an integer value from an argument.
 
const char * getArgSymbol (int idx)
 Gets a symbol value from an argument.
 
Object makeBool (bool value)
 Creates a boolean Lisp object.
 
Object makeInt (int value)
 Creates an integer Lisp object.
 
Object makeSymbol (const char *value)
 Creates a symbol Lisp object.
 

Static Public Member Functions

static RegisterManagergetRegisterManager ()
 Gets the static register manager instance.
 
static PrimitiveExpeditorInitializer describe (const String &name, Lisp::Type returnType, int argsCount,...)
 Describes a primitive function by setting up its metadata.
 
static PrimitiveDescription extractDescription (Primitive *primitive)
 Extracts description metadata from a primitive function.
 

Member Function Documentation

◆ assertArgs() [1/2]

void uniot::PrimitiveExpeditor::assertArgs ( uint8_t length,
const Lisp::Type * types )
inline

Asserts that arguments match the expected types.

Parameters
lengthExpected number of arguments
typesArray of expected argument types
Exceptions
Errorif arguments don't match expected types or count

◆ assertArgs() [2/2]

void uniot::PrimitiveExpeditor::assertArgs ( uint8_t length,
... )
inline

Variadic version of assertArgs.

Parameters
lengthExpected number of arguments
...Expected argument types (variadic)
Exceptions
Errorif arguments don't match expected types or count

◆ assertArgsCount()

void uniot::PrimitiveExpeditor::assertArgsCount ( int length)
inline

Asserts that the function was called with the expected number of arguments.

Parameters
lengthExpected number of arguments
Exceptions
Errorif the argument count doesn't match

◆ assertDescribedArgs()

void uniot::PrimitiveExpeditor::assertDescribedArgs ( )
inline

Asserts arguments against the primitive's description.

Exceptions
Errorif arguments don't match the description

◆ checkType()

bool uniot::PrimitiveExpeditor::checkType ( Object param,
Lisp::Type expectedType )
inline

Checks if a parameter matches an expected Lisp type.

Parameters
paramObject to check
expectedTypeExpected type of the object
Return values
trueParameter matches the expected type
falseParameter does not match the expected type

◆ describe()

static PrimitiveExpeditorInitializer uniot::PrimitiveExpeditor::describe ( const String & name,
Lisp::Type returnType,
int argsCount,
... )
inlinestatic

Describes a primitive function by setting up its metadata.

Parameters
nameName of the primitive function
returnTypeReturn type of the function
argsCountNumber of arguments the function expects
...Types of each argument (variadic)
Return values
initializerPrimitiveExpeditorInitializer object

◆ evalList()

Object uniot::PrimitiveExpeditor::evalList ( )
inline

Evaluates the argument list if not already evaluated.

Return values
listThe evaluated list of arguments

◆ evalObj()

Object uniot::PrimitiveExpeditor::evalObj ( VarObject obj)
inline

Evaluates a single object in the current environment.

Parameters
objObject to evaluate
Return values
ObjectThe evaluated object

◆ extractDescription()

static PrimitiveDescription uniot::PrimitiveExpeditor::extractDescription ( Primitive * primitive)
inlinestatic

Extracts description metadata from a primitive function.

Uses setjmp/longjmp to capture the description information when the primitive is executed in description mode.

Parameters
primitivePointer to the primitive function
Return values
descriptionPrimitiveDescription object with the function's metadata

◆ getArg()

Object uniot::PrimitiveExpeditor::getArg ( int idx)
inline

Gets an argument at the specified index.

Parameters
idxZero-based index of the argument to retrieve
Return values
ObjectThe argument object
Exceptions
Errorif index is out of bounds

◆ getArgBool()

bool uniot::PrimitiveExpeditor::getArgBool ( int idx,
bool acceptsInt = true )
inline

Gets a boolean value from an argument.

Parameters
idxZero-based index of the argument
acceptsIntWhether to accept integer values as booleans
Return values
boolThe boolan value of the argument
Exceptions
Errorif argument doesn't have a compatible type

◆ getArgInt()

int uniot::PrimitiveExpeditor::getArgInt ( int idx,
bool acceptsBool = true )
inline

Gets an integer value from an argument.

Parameters
idxZero-based index of the argument
acceptsBoolWhether to accept boolean values as integers
Return values
intThe integer value of the argument
Exceptions
Errorif argument doesn't have a compatible type

◆ getArgsLength()

int uniot::PrimitiveExpeditor::getArgsLength ( )
inline

Gets the number of arguments in the current function call.

Return values
intThe number of arguments in the list

◆ getArgSymbol()

const char * uniot::PrimitiveExpeditor::getArgSymbol ( int idx)
inline

Gets a symbol value from an argument.

Parameters
idxZero-based index of the argument
Return values
symbolThe symbol value of the argument
Exceptions
Errorif argument is not a symbol

◆ getAssignedRegister()

RegisterManagerProxy & uniot::PrimitiveExpeditor::getAssignedRegister ( )
inline

Gets the register proxy assigned to this expeditor.

Return values
RegisterManagerProxy&The register manager proxy

◆ getRegisterManager()

static RegisterManager & uniot::PrimitiveExpeditor::getRegisterManager ( )
inlinestatic

Gets the static register manager instance.

Return values
RegisterManager&The register manager instance.

◆ list()

Object uniot::PrimitiveExpeditor::list ( )
inline

Gets the argument list (evaluated or not).

Return values
listThe list of arguments

◆ makeBool()

Object uniot::PrimitiveExpeditor::makeBool ( bool value)
inline

Creates a boolean Lisp object.

Parameters
valueBoolean value
Return values
ObjectLisp object representing the boolean value
NilIf value is false

◆ makeInt()

Object uniot::PrimitiveExpeditor::makeInt ( int value)
inline

Creates an integer Lisp object.

Parameters
valueInteger value
Return values
ObjectLisp object representing the integer value

◆ makeSymbol()

Object uniot::PrimitiveExpeditor::makeSymbol ( const char * value)
inline

Creates a symbol Lisp object.

Parameters
valueSymbol name
Return values
ObjectLisp object representing the symbol

◆ terminate()

void uniot::PrimitiveExpeditor::terminate ( const char * msg)
inline

Terminates execution with an error message.

Parameters
msgError message to display

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