More code, closer to working, still builds.
This commit is contained in:
parent
c9f50572ab
commit
f751fc8a09
14 changed files with 138 additions and 133 deletions
|
|
@ -9,8 +9,19 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "memory/memory.h"
|
||||
#include "memory/node.h"
|
||||
#include "memory/pointer.h"
|
||||
#include "memory/pso.h"
|
||||
#include "memory/pso2.h"
|
||||
#include "memory/tags.h"
|
||||
|
||||
#include "ops/bind.h"
|
||||
#include "ops/string_ops.h"
|
||||
|
||||
#include "payloads/cons.h"
|
||||
#include "payloads/exception.h"
|
||||
#include "payloads/psse_string.h"
|
||||
|
||||
/**
|
||||
* @brief Flag to prevent re-initialisation.
|
||||
|
|
@ -25,11 +36,45 @@ bool environment_initialised = false;
|
|||
*/
|
||||
|
||||
struct pso_pointer initialise_environment( uint32_t node ) {
|
||||
struct pso_pointer result = t;
|
||||
if ( environment_initialised ) {
|
||||
// TODO: throw an exception "Attempt to reinitialise environment"
|
||||
} else {
|
||||
// TODO: actually initialise it.
|
||||
struct pso_pointer result = initialise_memory( node );
|
||||
|
||||
if ( !exceptionp( result ) ) {
|
||||
struct pso_pointer n = allocate( NILTAG, 2 );
|
||||
|
||||
if ( ( n.page == 0 ) && ( n.offset == 0 ) ) {
|
||||
struct pso2 *object = pointer_to_object( n );
|
||||
object->payload.cons.car = nil;
|
||||
object->payload.cons.cdr = nil;
|
||||
|
||||
nil = n;
|
||||
} else {
|
||||
result =
|
||||
make_exception( c_string_to_lisp_string
|
||||
( L"Unexpected cell while allocating `nil`." ),
|
||||
nil, n );
|
||||
}
|
||||
}
|
||||
if ( !exceptionp( result ) ) {
|
||||
struct pso_pointer n = allocate( TRUETAG, 2 );
|
||||
|
||||
if ( ( n.page == 0 ) && ( n.offset == 1 ) ) {
|
||||
struct pso2 *object = pointer_to_object( n );
|
||||
object->payload.string.character = L't';
|
||||
object->payload.cons.cdr = t;
|
||||
|
||||
t = n;
|
||||
} else {
|
||||
result =
|
||||
make_exception( c_string_to_lisp_string
|
||||
( L"Unexpected cell while allocating `t`." ),
|
||||
nil, n );
|
||||
}
|
||||
}
|
||||
if ( !exceptionp( result ) ) {
|
||||
result = c_bind( c_string_to_lisp_symbol( L"nil" ), nil, nil );
|
||||
result = c_bind( c_string_to_lisp_symbol( L"t" ), t, result );
|
||||
|
||||
environment_initialised = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue