Whoops! several new files missed from recent commits.
This commit is contained in:
parent
25c87aac6e
commit
04aa32bd5a
4 changed files with 253 additions and 0 deletions
106
src/c/ops/eval_apply.c
Normal file
106
src/c/ops/eval_apply.c
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
/**
|
||||||
|
* ops/apply.c
|
||||||
|
*
|
||||||
|
* Post Scarcity Software Environment: apply.
|
||||||
|
*
|
||||||
|
* Add a applying for a key/value pair to a store -- at this stage, just an
|
||||||
|
* association list.
|
||||||
|
*
|
||||||
|
* (c) 2026 Simon Brooke <simon@journeyman.cc>
|
||||||
|
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "memory/node.h"
|
||||||
|
#include "memory/pointer.h"
|
||||||
|
#include "memory/pso.h"
|
||||||
|
#include "memory/pso3.h"
|
||||||
|
#include "memory/pso4.h"
|
||||||
|
#include "memory/tags.h"
|
||||||
|
|
||||||
|
#include "ops/assoc.h"
|
||||||
|
#include "ops/stack_ops.h"
|
||||||
|
#include "ops/string_ops.h"
|
||||||
|
#include "ops/truth.h"
|
||||||
|
|
||||||
|
#include "payloads/cons.h"
|
||||||
|
#include "payloads/stack.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Apply a function to arguments in an environment.
|
||||||
|
*
|
||||||
|
* * (apply fn args)
|
||||||
|
*/
|
||||||
|
struct pso_pointer apply(
|
||||||
|
#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
|
||||||
|
|
||||||
|
// TODO.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Evaluate a form, in an environment
|
||||||
|
*
|
||||||
|
* * (eval form)
|
||||||
|
*/
|
||||||
|
struct pso_pointer eval(
|
||||||
|
#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
|
||||||
|
struct pso_pointer result = fetch_arg( frame, 0 );
|
||||||
|
|
||||||
|
switch ( get_tag_value( result ) ) {
|
||||||
|
// case CONSTV:
|
||||||
|
// result = eval_cons( frame, frame_pointer, env);
|
||||||
|
// break;
|
||||||
|
case INTEGERTV:
|
||||||
|
case KEYTV:
|
||||||
|
case STRINGTV:
|
||||||
|
// self evaluating
|
||||||
|
break;
|
||||||
|
case SYMBOLTV:
|
||||||
|
result = c_assoc( result, env );
|
||||||
|
break;
|
||||||
|
// case LAMBDATV:
|
||||||
|
// result = eval_lambda( frame, frame_pointer, env);
|
||||||
|
// break;
|
||||||
|
// case NLAMBDATV:
|
||||||
|
// result = eval_nlambda( frame, frame_pointer, env);
|
||||||
|
// break;
|
||||||
|
// case SPECIALTV:
|
||||||
|
// result = eval_special( frame, frame_pointer, env);
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
result =
|
||||||
|
make_exception( c_cons
|
||||||
|
( c_string_to_lisp_string
|
||||||
|
( L"Can't yet evaluate things of this type: " ),
|
||||||
|
result ), frame_pointer, nil );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( exceptionp( result ) ) {
|
||||||
|
struct pso3 *x =
|
||||||
|
( struct pso3 * ) pointer_to_object_with_tag_value( result,
|
||||||
|
EXCEPTIONTV );
|
||||||
|
|
||||||
|
if ( nilp( x->payload.exception.stack ) ) {
|
||||||
|
inc_ref( result );
|
||||||
|
result =
|
||||||
|
make_exception( x->payload.exception.message, frame_pointer,
|
||||||
|
result );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
36
src/c/ops/eval_apply.h
Normal file
36
src/c/ops/eval_apply.h
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* ops/eval_apply.h
|
||||||
|
*
|
||||||
|
* Post Scarcity Software Environment: eval, apply.
|
||||||
|
*
|
||||||
|
* apply: Apply a function to arguments in an environment.
|
||||||
|
* eval: Evaluate a form in an environment.
|
||||||
|
*
|
||||||
|
* (c) 2026 Simon Brooke <simon@journeyman.cc>
|
||||||
|
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __psse_ops_eval_apply_h
|
||||||
|
#define __psse_ops_eval_apply_h
|
||||||
|
|
||||||
|
#include "memory/pointer.h"
|
||||||
|
#include "memory/pso4.h"
|
||||||
|
#include "payloads/function.h"
|
||||||
|
|
||||||
|
struct pso_pointer apply(
|
||||||
|
#ifndef MANAGED_POINTER_ONLY
|
||||||
|
struct pso4 *frame,
|
||||||
|
#endif
|
||||||
|
struct pso_pointer frame_pointer,
|
||||||
|
struct pso_pointer env );
|
||||||
|
|
||||||
|
|
||||||
|
struct pso_pointer eval(
|
||||||
|
#ifndef MANAGED_POINTER_ONLY
|
||||||
|
struct pso4 *frame,
|
||||||
|
#endif
|
||||||
|
struct pso_pointer frame_pointer,
|
||||||
|
struct pso_pointer env );
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
72
src/c/ops/list_ops.c
Normal file
72
src/c/ops/list_ops.c
Normal 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
|
||||||
39
src/c/ops/list_ops.h
Normal file
39
src/c/ops/list_ops.h
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
* 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/pso4.h"
|
||||||
|
|
||||||
|
struct pso_pointer car(
|
||||||
|
#ifndef MANAGED_POINTER_ONLY
|
||||||
|
struct pso4 *frame,
|
||||||
|
#endif
|
||||||
|
struct pso_pointer frame_pointer,
|
||||||
|
struct pso_pointer env );
|
||||||
|
|
||||||
|
struct pso_pointer cdr(
|
||||||
|
#ifndef MANAGED_POINTER_ONLY
|
||||||
|
struct pso4 *frame,
|
||||||
|
#endif
|
||||||
|
struct pso_pointer frame_pointer,
|
||||||
|
struct pso_pointer env );
|
||||||
|
|
||||||
|
struct pso_pointer cons(
|
||||||
|
#ifndef MANAGED_POINTER_ONLY
|
||||||
|
struct pso4 *frame,
|
||||||
|
#endif
|
||||||
|
struct pso_pointer frame_pointer,
|
||||||
|
struct pso_pointer env );
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue