I *think* that's all the bootstrap functions being bound in the environment.

This commit is contained in:
Simon Brooke 2026-05-04 18:23:46 +01:00
parent efa6a3246d
commit fcfdb43b05
8 changed files with 184 additions and 54 deletions

View file

@ -11,6 +11,7 @@
#include "debug.h"
#include "environment/function_bindings.h"
#include "memory/memory.h"
#include "memory/node.h"
#include "memory/pointer.h"
@ -21,11 +22,11 @@
#include "ops/bind.h"
#include "ops/string_ops.h"
#include "payloads/cons.h"
#include "payloads/exception.h"
#include "payloads/psse_string.h"
#include "ops/stack_ops.h"
#include "ops/truth.h"
#include "payloads/stack.h"
/**
* @brief Flag to prevent re-initialisation.
@ -44,7 +45,7 @@ struct pso_pointer initialise_environment( uint32_t node ) {
struct pso_pointer frame_pointer = nil; // can't have a frame pointer before we've initialised nil and t
if ( c_truep( result ) ) {
debug_print( L"Initialising `nil`... ", DEBUG_BOOTSTRAP, 0 );
debug_print( U"Initialising `nil`... ", DEBUG_BOOTSTRAP, 0 );
struct pso_pointer n = allocate( frame_pointer, NILTAG, 2 );
if ( ( n.page == 0 ) && ( n.offset == 0 ) ) {
@ -54,14 +55,14 @@ struct pso_pointer initialise_environment( uint32_t node ) {
nil = n;
lock_object( nil );
debug_print( L"success\n", DEBUG_BOOTSTRAP, 0 );
debug_print( U"success\n", DEBUG_BOOTSTRAP, 0 );
} else {
result = nil;
debug_print( L"fail\n", DEBUG_BOOTSTRAP, 0 );
debug_print( U"fail\n", DEBUG_BOOTSTRAP, 0 );
}
}
if ( !c_nilp( result ) ) {
debug_print( L"Initialising `t`... ", DEBUG_BOOTSTRAP, 0 );
debug_print( U"Initialising `t`... ", DEBUG_BOOTSTRAP, 0 );
struct pso_pointer n = allocate( frame_pointer, TRUETAG, 2 );
// offset is in words, and size of a pso2 is four words
@ -72,36 +73,39 @@ struct pso_pointer initialise_environment( uint32_t node ) {
t = n;
lock_object( t );
debug_print( L"success\n", DEBUG_BOOTSTRAP, 0 );
debug_print( U"success\n", DEBUG_BOOTSTRAP, 0 );
} else {
result = nil;
debug_print( L"fail\n", DEBUG_BOOTSTRAP, 0 );
debug_print( U"fail\n", DEBUG_BOOTSTRAP, 0 );
}
}
if ( !exceptionp( result ) ) {
result =
lisp_bind( make_frame
( 3, frame_pointer,
c_string_to_lisp_symbol( frame_pointer, L"nil" ), nil,
c_string_to_lisp_symbol( frame_pointer, U"niU" ), nil,
nil ) );
debug_print( L"Environment after binding `nil`: ", DEBUG_BOOTSTRAP,
debug_print( U"Environment after binding `nil`: ", DEBUG_BOOTSTRAP,
0 );
debug_print_object( result, DEBUG_BOOTSTRAP, 0 );
result =
lisp_bind( make_frame
( 3, frame_pointer,
c_string_to_lisp_symbol( frame_pointer, L"t" ), t,
c_string_to_lisp_symbol( frame_pointer, U"t" ), t,
result ) );
environment_initialised = true;
debug_print( L"Environment after binding `t`: ", DEBUG_BOOTSTRAP, 0 );
debug_print( U"Environment after binding `t`: ", DEBUG_BOOTSTRAP, 0 );
debug_print_object( result, DEBUG_BOOTSTRAP, 0 );
debug_print( L"\nEnvironment initialised successfully.\n",
debug_print( U"\nEnvironment initialised successfully.\n",
DEBUG_BOOTSTRAP, 0 );
}
dec_ref( frame_pointer );
result = initialise_function_bindings(push_local(
frame_pointer, make_frame_with_env(0, frame_pointer, result)));
return result;
dec_ref(frame_pointer);
return result;
}