Added bind; but mainly, tactical commit before changinh lisp calling
convention
This commit is contained in:
parent
9eb0d3c5a0
commit
f3a26bc02e
4 changed files with 75 additions and 5 deletions
45
src/c/ops/bind.c
Normal file
45
src/c/ops/bind.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* ops/bind.c
|
||||
*
|
||||
* Post Scarcity Software Environment: bind.
|
||||
*
|
||||
* Add a binding 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/pso4.h"
|
||||
#include "memory/tags.h"
|
||||
|
||||
#include "ops/stack_ops.h"
|
||||
|
||||
#include "payloads/cons.h"
|
||||
#include "payloads/stack.h"
|
||||
|
||||
struct pso_pointer bind( struct pso_pointer frame_pointer,
|
||||
struct pso_pointer env) {
|
||||
struct pso4 *frame = pointer_to_pso4( frame_pointer);
|
||||
struct pso_pointer key = fetch_arg( frame, 0);
|
||||
struct pso_pointer value = fetch_arg( frame, 1);
|
||||
struct pso_pointer store = fetch_arg( frame, 2);
|
||||
|
||||
return cons( cons(key, value), store);
|
||||
}
|
||||
|
||||
struct pso_pointer c_bind( struct pso_pointer key,
|
||||
struct pso_pointer value,
|
||||
struct pso_pointer store) {
|
||||
struct pso_pointer result = nil;
|
||||
struct pso_pointer next = make_frame( nil, key, value, store);
|
||||
inc_ref( next);
|
||||
result = bind( next, nil);
|
||||
dec_ref( next);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
25
src/c/ops/bind.h
Normal file
25
src/c/ops/bind.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* ops/bind.h
|
||||
*
|
||||
* Post Scarcity Software Environment: bind.
|
||||
*
|
||||
* Test for pointer binduality.
|
||||
*
|
||||
* (c) 2026 Simon Brooke <simon@journeyman.cc>
|
||||
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||
*/
|
||||
|
||||
#ifndef __psse_ops_bind_h
|
||||
#define __psse_ops_bind_h
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "memory/pointer.h"
|
||||
|
||||
struct pso_pointer bind( struct pso_pointer frame_pointer,
|
||||
struct pso_pointer env);
|
||||
|
||||
struct pso_pointer c_bind( struct pso_pointer key,
|
||||
struct pso_pointer value,
|
||||
struct pso_pointer store);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue