Many more ops written, and it compiles. Nothing works yet.
This commit is contained in:
parent
f5f8e38b91
commit
c9f50572ab
17 changed files with 290 additions and 71 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#include "payloads/cons.h"
|
||||
|
||||
#include "ops/eq.h"
|
||||
#include "ops/stack_ops.h"
|
||||
#include "ops/truth.h"
|
||||
|
||||
/**
|
||||
|
|
@ -40,12 +41,12 @@ struct pso_pointer search( struct pso_pointer key,
|
|||
|
||||
if ( consp( store ) ) {
|
||||
for ( struct pso_pointer cursor = store;
|
||||
consp( store ) && found == false; cursor = cdr( cursor ) ) {
|
||||
struct pso_pointer pair = car( cursor );
|
||||
consp( store ) && found == false; cursor = c_cdr( cursor ) ) {
|
||||
struct pso_pointer pair = c_car( cursor );
|
||||
|
||||
if ( consp( pair ) && c_equal( car( pair ), key ) ) {
|
||||
if ( consp( pair ) && c_equal( c_car( pair ), key ) ) {
|
||||
found = true;
|
||||
result = return_key ? car( pair ) : cdr( pair );
|
||||
result = return_key ? c_car( pair ) : c_cdr( pair );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -61,7 +62,7 @@ struct pso_pointer search( struct pso_pointer key,
|
|||
*
|
||||
* @return a pointer to the value of the key in the store, or nil if not found
|
||||
*/
|
||||
struct pso_pointer assoc( struct pso_pointer key, struct pso_pointer store ) {
|
||||
struct pso_pointer c_assoc( struct pso_pointer key, struct pso_pointer store ) {
|
||||
return search( key, store, false );
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +74,7 @@ struct pso_pointer assoc( struct pso_pointer key, struct pso_pointer store ) {
|
|||
*
|
||||
* @return a pointer to the copy of the key in the store, or nil if not found.
|
||||
*/
|
||||
struct pso_pointer interned( struct pso_pointer key, struct pso_pointer store ) {
|
||||
struct pso_pointer c_interned( struct pso_pointer key, struct pso_pointer store ) {
|
||||
return search( key, store, true );
|
||||
}
|
||||
|
||||
|
|
@ -85,6 +86,63 @@ struct pso_pointer interned( struct pso_pointer key, struct pso_pointer store )
|
|||
*
|
||||
* @return `true` if a pointer the key was found in the store..
|
||||
*/
|
||||
bool internedp( struct pso_pointer key, struct pso_pointer store ) {
|
||||
bool c_internedp( struct pso_pointer key, struct pso_pointer store ) {
|
||||
return !nilp( search( key, store, true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @prief: bootstap layer assoc; Lisp calling signature.
|
||||
*
|
||||
* @return a pointer to the value of the key in the store, or nil if not found
|
||||
*/
|
||||
struct pso_pointer assoc(
|
||||
#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 key = fetch_arg( frame, 0 );
|
||||
struct pso_pointer store = fetch_arg( frame, 1 );
|
||||
|
||||
return c_assoc( key, store );
|
||||
}
|
||||
|
||||
/**
|
||||
* @prief: bootstap layer interned; Lisp calling signature.
|
||||
*
|
||||
* @return a pointer to the copy of the key in the store, or nil if not found.
|
||||
*/
|
||||
struct pso_pointer interned(
|
||||
#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 key = fetch_arg( frame, 0 );
|
||||
struct pso_pointer store = fetch_arg( frame, 1 );
|
||||
|
||||
return c_interned( key, store );
|
||||
}
|
||||
|
||||
/**
|
||||
* @prief: bootstap layer interned?; Lisp calling signature.
|
||||
*
|
||||
* @return `t` if a pointer to a copy of `key` is found in the store, or `nil` if not found.
|
||||
*/
|
||||
struct pso_pointer internedp(
|
||||
#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 key = fetch_arg( frame, 0 );
|
||||
struct pso_pointer store = fetch_arg( frame, 1 );
|
||||
|
||||
return c_interned( key, store );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue