Whoops! several new files missed from recent commits.

This commit is contained in:
Simon Brooke 2026-04-16 00:24:03 +01:00
parent 25c87aac6e
commit 04aa32bd5a
4 changed files with 253 additions and 0 deletions

72
src/c/ops/list_ops.c Normal file
View file

@ -0,0 +1,72 @@
/**
* ops/list_ops.h
*
* Post Scarcity Software Environment: list_ops.
*
* Operations on cons cells.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_ops_list_ops_h
#define __psse_ops_list_ops_h
#include "memory/pointer.h"
#include "memory/pso.h"
#include "memory/pso4.h"
#include "memory/tags.h"
#include "ops/stack_ops.h"
#include "payloads/cons.h"
#include "payloads/stack.h"
struct pso_pointer car(
#ifndef MANAGED_POINTER_ONLY
struct pso4 *frame,
#endif
struct pso_pointer frame_pointer,
struct pso_pointer env ) {
#ifdef MANAGED_POINTER_ONLY
struct pso4 *frame = pointer_to_pso4( frame_pointer );
#endif
return c_car( fetch_arg( frame, 0 ) );
}
struct pso_pointer cdr(
#ifndef MANAGED_POINTER_ONLY
struct pso4 *frame,
#endif
struct pso_pointer frame_pointer,
struct pso_pointer env ) {
#ifdef MANAGED_POINTER_ONLY
struct pso4 *frame = pointer_to_pso4( frame_pointer );
#endif
return c_cdr( fetch_arg( frame, 0 ) );
}
/**
* @brief allocate a cons cell from the first two args in this frame, and
* return a pointer to it.
*
* Lisp calling conventions.
*
* @return struct pso_pointer a pointer to the newly allocated cons cell.
*/
struct pso_pointer cons(
#ifndef MANAGED_POINTER_ONLY
struct pso4 *frame,
#endif
struct pso_pointer frame_pointer,
struct pso_pointer env ) {
#ifdef MANAGED_POINTER_ONLY
struct pso4 *frame = pointer_to_pso4( frame_pointer );
#endif
return c_cons( fetch_arg( frame, 0 ), fetch_arg( frame, 1 ) );
}
#endif