read isn't written yet, but I think all the building blocks I need for it are.

Compiles and runs; does nothing yet.
This commit is contained in:
Simon Brooke 2026-03-31 20:01:01 +01:00
parent 364d7d2c7b
commit 1196b3eb1d
21 changed files with 84 additions and 3347 deletions

View file

@ -14,7 +14,11 @@
#include "memory/pso.h"
#include "memory/pso2.h"
#include "memory/tags.h"
#include "payloads/cons.h"
#include "payloads/exception.h"
#include "ops/string_ops.h"
/**
* @brief allocate a cons cell with this car and this cdr, and return a pointer
@ -58,19 +62,29 @@ struct pso_pointer car( struct pso_pointer cons ) {
}
/**
* @brief return the cdr of this cons cell.
* @brief return the cdr of this cons (or other sequence) cell.
*
* @param cons a pointer to the cell.
* @return the cdr of the indicated cell.
* @exception if the pointer does not indicate a cons cell.
*/
struct pso_pointer cdr( struct pso_pointer cons ) {
struct pso_pointer cdr( struct pso_pointer p ) {
struct pso_pointer result = nil;
struct pso2 *object = pointer_to_object( result );
if ( consp( cons ) ) {
result = object->payload.cons.cdr;
switch (get_tag_value( p)) {
case CONSTV : result = object->payload.cons.cdr; break;
case KEYTV :
case STRINGTV :
case SYMBOLTV :
result = object->payload.string.cdr; break;
default :
result = make_exception(
cons(c_string_to_lisp_string(L"Invalid type for cdr"), p),
nil, nil);
break;
}
// TODO: else throw an exception
return result;

View file

@ -24,6 +24,7 @@ struct exception_payload {
struct pso_pointer cause;
};
struct pso_pointer make_exception( struct pso_pointer message, struct pso_pointer frame_pointer, struct pso_pointer cause);
struct pso_pointer make_exception( struct pso_pointer message,
struct pso_pointer frame_pointer, struct pso_pointer cause);
#endif

View file

@ -37,4 +37,6 @@ struct stack_frame_payload {
uint32_t depth;
};
struct pso_pointer make_frame( struct pso_pointer previous, ...);
#endif