Still in progress. Nothing workds.
This commit is contained in:
parent
aa5b34368e
commit
ef59563e25
14 changed files with 206 additions and 180 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* ops/list_ops.h
|
||||
* ops/list_ops.c
|
||||
*
|
||||
* Post Scarcity Software Environment: list_ops.
|
||||
*
|
||||
|
|
@ -8,65 +8,22 @@
|
|||
* (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/pso2.h"
|
||||
#include "memory/pso4.h"
|
||||
#include "memory/tags.h"
|
||||
|
||||
#include "ops/stack_ops.h"
|
||||
|
||||
#include "payloads/cons.h"
|
||||
#include "payloads/stack.h"
|
||||
|
||||
#include "ops/truth.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 length( struct pso_pointer frame_pointer) {
|
||||
struct pso_pointer list = fetch_arg( frame_pointer, 0);
|
||||
int count = 0;
|
||||
|
||||
for ( struct pso_pointer cursor = list; !nilp( cursor);
|
||||
cursor = cdr( make_frame( 1, frame_pointer, list))) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return make_integer( pointer_to_pso4(frame_pointer), count);
|
||||
}
|
||||
|
||||
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( frame, 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 make_cons( frame, fetch_arg( frame, 0 ), fetch_arg( frame, 1 ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue