Whitespace only changes
This commit is contained in:
parent
8231c74bae
commit
40e1f3ca64
|
@ -412,8 +412,8 @@ struct cons_pointer inverse( struct cons_pointer frame,
|
||||||
case RATIOTV:
|
case RATIOTV:
|
||||||
result = make_ratio( frame,
|
result = make_ratio( frame,
|
||||||
make_integer( 0 -
|
make_integer( 0 -
|
||||||
to_long_int( cell.payload.
|
to_long_int( cell.payload.ratio.
|
||||||
ratio.dividend ) ),
|
dividend ) ),
|
||||||
cell.payload.ratio.divisor );
|
cell.payload.ratio.divisor );
|
||||||
break;
|
break;
|
||||||
case REALTV:
|
case REALTV:
|
||||||
|
|
|
@ -61,10 +61,10 @@ struct cons_pointer simplify_ratio( struct cons_pointer frame_pointer,
|
||||||
|
|
||||||
if ( ratiop( arg ) ) {
|
if ( ratiop( arg ) ) {
|
||||||
int64_t ddrv =
|
int64_t ddrv =
|
||||||
pointer2cell( pointer2cell( arg ).payload.ratio.dividend ).
|
pointer2cell( pointer2cell( arg ).payload.ratio.dividend ).payload.
|
||||||
payload.integer.value, drrv =
|
integer.value, drrv =
|
||||||
pointer2cell( pointer2cell( arg ).payload.ratio.divisor ).
|
pointer2cell( pointer2cell( arg ).payload.ratio.divisor ).payload.
|
||||||
payload.integer.value, gcd = greatest_common_divisor( ddrv, drrv );
|
integer.value, gcd = greatest_common_divisor( ddrv, drrv );
|
||||||
|
|
||||||
if ( gcd > 1 ) {
|
if ( gcd > 1 ) {
|
||||||
if ( drrv / gcd == 1 ) {
|
if ( drrv / gcd == 1 ) {
|
||||||
|
@ -117,7 +117,8 @@ struct cons_pointer add_ratio_ratio( struct cons_pointer frame_pointer,
|
||||||
lcm = least_common_multiple( dr1v, dr2v ),
|
lcm = least_common_multiple( dr1v, dr2v ),
|
||||||
m1 = lcm / dr1v, m2 = lcm / dr2v;
|
m1 = lcm / dr1v, m2 = lcm / dr2v;
|
||||||
|
|
||||||
debug_printf( DEBUG_ARITH, L"); lcm = %ld; m1 = %ld; m2 = %ld", lcm, m1, m2 );
|
debug_printf( DEBUG_ARITH, L"); lcm = %ld; m1 = %ld; m2 = %ld", lcm,
|
||||||
|
m1, m2 );
|
||||||
|
|
||||||
if ( dr1v == dr2v ) {
|
if ( dr1v == dr2v ) {
|
||||||
r = make_ratio( frame_pointer,
|
r = make_ratio( frame_pointer,
|
||||||
|
@ -201,11 +202,10 @@ struct cons_pointer divide_ratio_ratio( struct cons_pointer frame_pointer,
|
||||||
struct cons_pointer arg1,
|
struct cons_pointer arg1,
|
||||||
struct cons_pointer arg2 ) {
|
struct cons_pointer arg2 ) {
|
||||||
struct cons_pointer i = make_ratio( frame_pointer,
|
struct cons_pointer i = make_ratio( frame_pointer,
|
||||||
pointer2cell( arg2 ).payload.
|
pointer2cell( arg2 ).payload.ratio.
|
||||||
ratio.divisor,
|
divisor,
|
||||||
pointer2cell( arg2 ).payload.
|
pointer2cell( arg2 ).payload.ratio.
|
||||||
ratio.dividend ),
|
dividend ), result =
|
||||||
result =
|
|
||||||
multiply_ratio_ratio( frame_pointer, arg1, i );
|
multiply_ratio_ratio( frame_pointer, arg1, i );
|
||||||
|
|
||||||
dec_ref( i );
|
dec_ref( i );
|
||||||
|
|
12
src/debug.c
12
src/debug.c
|
@ -61,15 +61,15 @@ void debug_println( int level ) {
|
||||||
* `wprintf` adapted for the debug logging system. Print to stderr only
|
* `wprintf` adapted for the debug logging system. Print to stderr only
|
||||||
* `verbosity` matches `level`. All other arguments as for `wprintf`.
|
* `verbosity` matches `level`. All other arguments as for `wprintf`.
|
||||||
*/
|
*/
|
||||||
void debug_printf( int level, wchar_t * format, ...) {
|
void debug_printf( int level, wchar_t *format, ... ) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if ( level & verbosity ) {
|
if ( level & verbosity ) {
|
||||||
fwide( stderr, 1 );
|
fwide( stderr, 1 );
|
||||||
va_list(args);
|
va_list( args );
|
||||||
va_start(args, format);
|
va_start( args, format );
|
||||||
vfwprintf(stderr, format, args);
|
vfwprintf( stderr, format, args );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern int verbosity;
|
||||||
|
|
||||||
void debug_print( wchar_t *message, int level );
|
void debug_print( wchar_t *message, int level );
|
||||||
void debug_println( int level );
|
void debug_println( int level );
|
||||||
void debug_printf( int level, wchar_t * format, ...);
|
void debug_printf( int level, wchar_t *format, ... );
|
||||||
void debug_print_object( struct cons_pointer pointer, int level );
|
void debug_print_object( struct cons_pointer pointer, int level );
|
||||||
void debug_dump_object( struct cons_pointer pointer, int level );
|
void debug_dump_object( struct cons_pointer pointer, int level );
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,8 @@ void make_cons_page( ) {
|
||||||
cell->count = MAXREFERENCE;
|
cell->count = MAXREFERENCE;
|
||||||
cell->payload.free.car = NIL;
|
cell->payload.free.car = NIL;
|
||||||
cell->payload.free.cdr = NIL;
|
cell->payload.free.cdr = NIL;
|
||||||
debug_printf( DEBUG_ALLOC, L"Allocated special cell NIL\n" );
|
debug_printf( DEBUG_ALLOC,
|
||||||
|
L"Allocated special cell NIL\n" );
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/*
|
/*
|
||||||
|
@ -80,7 +81,8 @@ void make_cons_page( ) {
|
||||||
cell->payload.free.cdr = ( struct cons_pointer ) {
|
cell->payload.free.cdr = ( struct cons_pointer ) {
|
||||||
0, 1
|
0, 1
|
||||||
};
|
};
|
||||||
debug_printf( DEBUG_ALLOC, L"Allocated special cell T\n" );
|
debug_printf( DEBUG_ALLOC,
|
||||||
|
L"Allocated special cell T\n" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -164,7 +166,8 @@ void free_cell( struct cons_pointer pointer ) {
|
||||||
case VECTORPOINTTV:
|
case VECTORPOINTTV:
|
||||||
/* for vector space pointers, free the actual vector-space
|
/* for vector space pointers, free the actual vector-space
|
||||||
* object. Dangerous! */
|
* object. Dangerous! */
|
||||||
debug_printf( DEBUG_ALLOC, L"About to free vector-space object at %ld\n",
|
debug_printf( DEBUG_ALLOC,
|
||||||
|
L"About to free vector-space object at %ld\n",
|
||||||
cell->payload.vectorp.address );
|
cell->payload.vectorp.address );
|
||||||
//free( ( void * ) cell->payload.vectorp.address );
|
//free( ( void * ) cell->payload.vectorp.address );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -67,8 +67,8 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
|
||||||
cell.payload.cons.car.offset,
|
cell.payload.cons.car.offset,
|
||||||
cell.payload.cons.cdr.page,
|
cell.payload.cons.cdr.page,
|
||||||
cell.payload.cons.cdr.offset, cell.count );
|
cell.payload.cons.cdr.offset, cell.count );
|
||||||
print( output, pointer);
|
print( output, pointer );
|
||||||
fputws( L"\n", output);
|
fputws( L"\n", output );
|
||||||
break;
|
break;
|
||||||
case EXCEPTIONTV:
|
case EXCEPTIONTV:
|
||||||
fwprintf( output, L"\t\tException cell: " );
|
fwprintf( output, L"\t\tException cell: " );
|
||||||
|
@ -89,7 +89,7 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
|
||||||
print( output, cell.payload.lambda.args );
|
print( output, cell.payload.lambda.args );
|
||||||
fwprintf( output, L";\n\t\t\tbody: " );
|
fwprintf( output, L";\n\t\t\tbody: " );
|
||||||
print( output, cell.payload.lambda.body );
|
print( output, cell.payload.lambda.body );
|
||||||
fputws( L"\n", output);
|
fputws( L"\n", output );
|
||||||
break;
|
break;
|
||||||
case NILTV:
|
case NILTV:
|
||||||
break;
|
break;
|
||||||
|
@ -98,15 +98,15 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
|
||||||
print( output, cell.payload.lambda.args );
|
print( output, cell.payload.lambda.args );
|
||||||
fwprintf( output, L";\n\t\t\tbody: " );
|
fwprintf( output, L";\n\t\t\tbody: " );
|
||||||
print( output, cell.payload.lambda.body );
|
print( output, cell.payload.lambda.body );
|
||||||
fputws( L"\n", output);
|
fputws( L"\n", output );
|
||||||
break;
|
break;
|
||||||
case RATIOTV:
|
case RATIOTV:
|
||||||
fwprintf( output,
|
fwprintf( output,
|
||||||
L"\t\tRational cell: value %ld/%ld, count %u\n",
|
L"\t\tRational cell: value %ld/%ld, count %u\n",
|
||||||
pointer2cell( cell.payload.ratio.dividend ).
|
pointer2cell( cell.payload.ratio.dividend ).payload.
|
||||||
payload.integer.value,
|
integer.value,
|
||||||
pointer2cell( cell.payload.ratio.divisor ).
|
pointer2cell( cell.payload.ratio.divisor ).payload.
|
||||||
payload.integer.value, cell.count );
|
integer.value, cell.count );
|
||||||
break;
|
break;
|
||||||
case READTV:
|
case READTV:
|
||||||
fwprintf( output, L"\t\tInput stream\n" );
|
fwprintf( output, L"\t\tInput stream\n" );
|
||||||
|
@ -130,9 +130,10 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
|
||||||
struct vector_space_object *vso = cell.payload.vectorp.address;
|
struct vector_space_object *vso = cell.payload.vectorp.address;
|
||||||
fwprintf( output,
|
fwprintf( output,
|
||||||
L"\t\tVector space object of type %4.4s (%d), payload size %d bytes\n",
|
L"\t\tVector space object of type %4.4s (%d), payload size %d bytes\n",
|
||||||
&vso->header.tag.bytes, vso->header.tag.value, vso->header.size );
|
&vso->header.tag.bytes, vso->header.tag.value,
|
||||||
if (stackframep(vso)) {
|
vso->header.size );
|
||||||
dump_frame(output, pointer);
|
if ( stackframep( vso ) ) {
|
||||||
|
dump_frame( output, pointer );
|
||||||
}
|
}
|
||||||
switch ( vso->header.tag.value ) {
|
switch ( vso->header.tag.value ) {
|
||||||
case STACKFRAMETV:
|
case STACKFRAMETV:
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
#include "vectorspace.h"
|
#include "vectorspace.h"
|
||||||
|
|
||||||
void set_reg(struct stack_frame * frame, int reg, struct cons_pointer value) {
|
void set_reg( struct stack_frame *frame, int reg, struct cons_pointer value ) {
|
||||||
debug_printf(DEBUG_STACK, L"Setting register %d to ", reg);
|
debug_printf( DEBUG_STACK, L"Setting register %d to ", reg );
|
||||||
debug_print_object(value, DEBUG_STACK);
|
debug_print_object( value, DEBUG_STACK );
|
||||||
debug_println(DEBUG_STACK);
|
debug_println( DEBUG_STACK );
|
||||||
frame->arg[reg++] = value;
|
frame->arg[reg++] = value;
|
||||||
inc_ref(value);
|
inc_ref( value );
|
||||||
if (reg > frame->args) {
|
if ( reg > frame->args ) {
|
||||||
frame->args = reg;
|
frame->args = reg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ struct stack_frame *get_stack_frame( struct cons_pointer pointer ) {
|
||||||
|
|
||||||
if ( vectorpointp( pointer ) && stackframep( vso ) ) {
|
if ( vectorpointp( pointer ) && stackframep( vso ) ) {
|
||||||
result = ( struct stack_frame * ) &( vso->payload );
|
result = ( struct stack_frame * ) &( vso->payload );
|
||||||
debug_printf( DEBUG_STACK, L"get_stack_frame: all good, returning %p\n",
|
debug_printf( DEBUG_STACK,
|
||||||
result );
|
L"get_stack_frame: all good, returning %p\n", result );
|
||||||
} else {
|
} else {
|
||||||
debug_print( L"get_stack_frame: fail, returning NULL\n", DEBUG_STACK );
|
debug_print( L"get_stack_frame: fail, returning NULL\n", DEBUG_STACK );
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ struct cons_pointer make_empty_frame( struct cons_pointer previous ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug_print( L"Leaving make_empty_frame\n", DEBUG_ALLOC );
|
debug_print( L"Leaving make_empty_frame\n", DEBUG_ALLOC );
|
||||||
debug_dump_object( result, DEBUG_ALLOC);
|
debug_dump_object( result, DEBUG_ALLOC );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ struct cons_pointer make_stack_frame( struct cons_pointer previous,
|
||||||
} else {
|
} else {
|
||||||
struct stack_frame *frame = get_stack_frame( result );
|
struct stack_frame *frame = get_stack_frame( result );
|
||||||
|
|
||||||
while ( frame->args < args_in_frame && consp( args )) {
|
while ( frame->args < args_in_frame && consp( args ) ) {
|
||||||
/* iterate down the arg list filling in the arg slots in the
|
/* iterate down the arg list filling in the arg slots in the
|
||||||
* frame. When there are no more slots, if there are still args,
|
* frame. When there are no more slots, if there are still args,
|
||||||
* stash them on more */
|
* stash them on more */
|
||||||
|
@ -136,13 +136,15 @@ struct cons_pointer make_stack_frame( struct cons_pointer previous,
|
||||||
* processor to be evaled in parallel; but see notes here:
|
* processor to be evaled in parallel; but see notes here:
|
||||||
* https://github.com/simon-brooke/post-scarcity/wiki/parallelism
|
* https://github.com/simon-brooke/post-scarcity/wiki/parallelism
|
||||||
*/
|
*/
|
||||||
struct cons_pointer val = eval_form(frame, result, cell.payload.cons.car, env);
|
struct cons_pointer val =
|
||||||
|
eval_form( frame, result, cell.payload.cons.car, env );
|
||||||
if ( exceptionp( val ) ) {
|
if ( exceptionp( val ) ) {
|
||||||
result = val;
|
result = val;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
debug_printf( DEBUG_STACK, L"Setting argument %d to ", frame->args);
|
debug_printf( DEBUG_STACK, L"Setting argument %d to ",
|
||||||
debug_print_object(cell.payload.cons.car, DEBUG_STACK);
|
frame->args );
|
||||||
|
debug_print_object( cell.payload.cons.car, DEBUG_STACK );
|
||||||
set_reg( frame, frame->args, val );
|
set_reg( frame, frame->args, val );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +192,7 @@ struct cons_pointer make_special_frame( struct cons_pointer previous,
|
||||||
} else {
|
} else {
|
||||||
struct stack_frame *frame = get_stack_frame( result );
|
struct stack_frame *frame = get_stack_frame( result );
|
||||||
|
|
||||||
while ( frame->args < args_in_frame && !nilp( args )) {
|
while ( frame->args < args_in_frame && !nilp( args ) ) {
|
||||||
/* iterate down the arg list filling in the arg slots in the
|
/* iterate down the arg list filling in the arg slots in the
|
||||||
* frame. When there are no more slots, if there are still args,
|
* frame. When there are no more slots, if there are still args,
|
||||||
* stash them on more */
|
* stash them on more */
|
||||||
|
@ -240,7 +242,7 @@ void dump_frame( FILE * output, struct cons_pointer frame_pointer ) {
|
||||||
struct stack_frame *frame = get_stack_frame( frame_pointer );
|
struct stack_frame *frame = get_stack_frame( frame_pointer );
|
||||||
|
|
||||||
if ( frame != NULL ) {
|
if ( frame != NULL ) {
|
||||||
fwprintf( output, L"Stack frame with %d arguments:\n", frame->args);
|
fwprintf( output, L"Stack frame with %d arguments:\n", frame->args );
|
||||||
for ( int arg = 0; arg < frame->args; arg++ ) {
|
for ( int arg = 0; arg < frame->args; arg++ ) {
|
||||||
struct cons_space_object cell = pointer2cell( frame->arg[arg] );
|
struct cons_space_object cell = pointer2cell( frame->arg[arg] );
|
||||||
|
|
||||||
|
@ -252,8 +254,7 @@ void dump_frame( FILE * output, struct cons_pointer frame_pointer ) {
|
||||||
print( output, frame->arg[arg] );
|
print( output, frame->arg[arg] );
|
||||||
fputws( L"\n", output );
|
fputws( L"\n", output );
|
||||||
}
|
}
|
||||||
if (!nilp(frame->more))
|
if ( !nilp( frame->more ) ) {
|
||||||
{
|
|
||||||
fputws( L"More: \t", output );
|
fputws( L"More: \t", output );
|
||||||
print( output, frame->more );
|
print( output, frame->more );
|
||||||
fputws( L"\n", output );
|
fputws( L"\n", output );
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
*/
|
*/
|
||||||
//#define set_reg(frame,register,value){frame->arg[register]=value; inc_ref(value);}
|
//#define set_reg(frame,register,value){frame->arg[register]=value; inc_ref(value);}
|
||||||
|
|
||||||
void set_reg(struct stack_frame * frame, int reg, struct cons_pointer value);
|
void set_reg( struct stack_frame *frame, int reg, struct cons_pointer value );
|
||||||
|
|
||||||
struct stack_frame *get_stack_frame( struct cons_pointer pointer );
|
struct stack_frame *get_stack_frame( struct cons_pointer pointer );
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ struct cons_pointer make_vec_pointer( struct vector_space_object *address ) {
|
||||||
L"make_vec_pointer: tag written, about to set pointer address to %p\n",
|
L"make_vec_pointer: tag written, about to set pointer address to %p\n",
|
||||||
address );
|
address );
|
||||||
cell->payload.vectorp.address = address;
|
cell->payload.vectorp.address = address;
|
||||||
debug_printf( DEBUG_ALLOC, L"make_vec_pointer: all good, returning pointer to %p\n",
|
debug_printf( DEBUG_ALLOC,
|
||||||
|
L"make_vec_pointer: all good, returning pointer to %p\n",
|
||||||
cell->payload.vectorp.address );
|
cell->payload.vectorp.address );
|
||||||
|
|
||||||
debug_dump_object( pointer, DEBUG_ALLOC );
|
debug_dump_object( pointer, DEBUG_ALLOC );
|
||||||
|
@ -67,8 +68,8 @@ struct cons_pointer make_vso( char *tag, uint64_t payload_size ) {
|
||||||
|
|
||||||
if ( vso != NULL ) {
|
if ( vso != NULL ) {
|
||||||
debug_printf( DEBUG_ALLOC,
|
debug_printf( DEBUG_ALLOC,
|
||||||
L"make_vso: about to write tag '%s' into vso at %p\n", tag,
|
L"make_vso: about to write tag '%s' into vso at %p\n",
|
||||||
vso );
|
tag, vso );
|
||||||
strncpy( &vso->header.tag.bytes[0], tag, TAGLENGTH );
|
strncpy( &vso->header.tag.bytes[0], tag, TAGLENGTH );
|
||||||
result = make_vec_pointer( vso );
|
result = make_vec_pointer( vso );
|
||||||
debug_dump_object( result, DEBUG_ALLOC );
|
debug_dump_object( result, DEBUG_ALLOC );
|
||||||
|
@ -80,8 +81,8 @@ struct cons_pointer make_vso( char *tag, uint64_t payload_size ) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug_printf( DEBUG_ALLOC,
|
debug_printf( DEBUG_ALLOC,
|
||||||
L"Allocated vector-space object of type %4.4s, total size %ld, payload size %ld, at address %p, payload address %p\n",
|
L"Allocated vector-space object of type %4.4s, total size %ld, payload size %ld, at address %p, payload address %p\n",
|
||||||
&vso->header.tag.bytes, total_size, vso->header.size, vso,
|
&vso->header.tag.bytes, total_size, vso->header.size,
|
||||||
&vso->payload );
|
vso, &vso->payload );
|
||||||
if ( padded != total_size ) {
|
if ( padded != total_size ) {
|
||||||
debug_printf( DEBUG_ALLOC, L"\t\tPadded from %d to %d\n",
|
debug_printf( DEBUG_ALLOC, L"\t\tPadded from %d to %d\n",
|
||||||
total_size, padded );
|
total_size, padded );
|
||||||
|
@ -89,7 +90,8 @@ struct cons_pointer make_vso( char *tag, uint64_t payload_size ) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug_printf( DEBUG_ALLOC, L"make_vso: all good, returning pointer to %p\n",
|
debug_printf( DEBUG_ALLOC,
|
||||||
|
L"make_vso: all good, returning pointer to %p\n",
|
||||||
pointer2cell( result ).payload.vectorp.address );
|
pointer2cell( result ).payload.vectorp.address );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,8 @@ bool equal( struct cons_pointer a, struct cons_pointer b ) {
|
||||||
&& ( equal( cell_a->payload.string.cdr,
|
&& ( equal( cell_a->payload.string.cdr,
|
||||||
cell_b->payload.string.cdr )
|
cell_b->payload.string.cdr )
|
||||||
|| ( end_of_string( cell_a->payload.string.cdr )
|
|| ( end_of_string( cell_a->payload.string.cdr )
|
||||||
&& end_of_string( cell_b->payload.
|
&& end_of_string( cell_b->payload.string.
|
||||||
string.cdr ) ) );
|
cdr ) ) );
|
||||||
break;
|
break;
|
||||||
case INTEGERTV:
|
case INTEGERTV:
|
||||||
result =
|
result =
|
||||||
|
|
|
@ -111,11 +111,11 @@ struct cons_pointer c_assoc( struct cons_pointer key,
|
||||||
struct cons_pointer
|
struct cons_pointer
|
||||||
bind( struct cons_pointer key, struct cons_pointer value,
|
bind( struct cons_pointer key, struct cons_pointer value,
|
||||||
struct cons_pointer store ) {
|
struct cons_pointer store ) {
|
||||||
debug_print(L"Binding ", DEBUG_BIND);
|
debug_print( L"Binding ", DEBUG_BIND );
|
||||||
debug_print_object(key, DEBUG_BIND);
|
debug_print_object( key, DEBUG_BIND );
|
||||||
debug_print(L" to ", DEBUG_BIND);
|
debug_print( L" to ", DEBUG_BIND );
|
||||||
debug_print_object(value, DEBUG_BIND);
|
debug_print_object( value, DEBUG_BIND );
|
||||||
debug_println( DEBUG_BIND);
|
debug_println( DEBUG_BIND );
|
||||||
|
|
||||||
return make_cons( make_cons( key, value ), store );
|
return make_cons( make_cons( key, value ), store );
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ eval_lambda( struct cons_space_object cell, struct stack_frame *frame,
|
||||||
struct cons_pointer
|
struct cons_pointer
|
||||||
c_apply( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
c_apply( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
||||||
struct cons_pointer env ) {
|
struct cons_pointer env ) {
|
||||||
debug_print(L"Entering c_apply\n", DEBUG_EVAL);
|
debug_print( L"Entering c_apply\n", DEBUG_EVAL );
|
||||||
struct cons_pointer result = NIL;
|
struct cons_pointer result = NIL;
|
||||||
|
|
||||||
struct cons_pointer fn_pointer =
|
struct cons_pointer fn_pointer =
|
||||||
|
@ -281,7 +281,8 @@ c_apply( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
||||||
if ( exceptionp( next_pointer ) ) {
|
if ( exceptionp( next_pointer ) ) {
|
||||||
result = next_pointer;
|
result = next_pointer;
|
||||||
} else {
|
} else {
|
||||||
struct stack_frame *next = get_stack_frame( next_pointer );
|
struct stack_frame *next =
|
||||||
|
get_stack_frame( next_pointer );
|
||||||
|
|
||||||
result =
|
result =
|
||||||
( *fn_cell.payload.function.executable ) ( next,
|
( *fn_cell.payload.function.executable ) ( next,
|
||||||
|
@ -300,8 +301,10 @@ c_apply( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
||||||
if ( exceptionp( next_pointer ) ) {
|
if ( exceptionp( next_pointer ) ) {
|
||||||
result = next_pointer;
|
result = next_pointer;
|
||||||
} else {
|
} else {
|
||||||
struct stack_frame *next = get_stack_frame( next_pointer );
|
struct stack_frame *next =
|
||||||
result = eval_lambda( fn_cell, next, next_pointer, env );
|
get_stack_frame( next_pointer );
|
||||||
|
result =
|
||||||
|
eval_lambda( fn_cell, next, next_pointer, env );
|
||||||
if ( !exceptionp( result ) ) {
|
if ( !exceptionp( result ) ) {
|
||||||
dec_ref( next_pointer );
|
dec_ref( next_pointer );
|
||||||
}
|
}
|
||||||
|
@ -318,7 +321,8 @@ c_apply( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
||||||
} else {
|
} else {
|
||||||
struct stack_frame *next =
|
struct stack_frame *next =
|
||||||
get_stack_frame( next_pointer );
|
get_stack_frame( next_pointer );
|
||||||
result = eval_lambda( fn_cell, next, next_pointer, env );
|
result =
|
||||||
|
eval_lambda( fn_cell, next, next_pointer, env );
|
||||||
dec_ref( next_pointer );
|
dec_ref( next_pointer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,19 +336,19 @@ c_apply( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
||||||
result = next_pointer;
|
result = next_pointer;
|
||||||
} else {
|
} else {
|
||||||
result =
|
result =
|
||||||
( *fn_cell.payload.special.executable ) ( get_stack_frame( next_pointer ),
|
( *fn_cell.payload.special.
|
||||||
next_pointer,
|
executable ) ( get_stack_frame( next_pointer ),
|
||||||
env );
|
next_pointer, env );
|
||||||
debug_print(L"Special form returning: ", DEBUG_EVAL);
|
debug_print( L"Special form returning: ", DEBUG_EVAL );
|
||||||
debug_print_object(result, DEBUG_EVAL);
|
debug_print_object( result, DEBUG_EVAL );
|
||||||
debug_println(DEBUG_EVAL);
|
debug_println( DEBUG_EVAL );
|
||||||
dec_ref( next_pointer );
|
dec_ref( next_pointer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
int bs = sizeof(wchar_t) * 1024;
|
int bs = sizeof( wchar_t ) * 1024;
|
||||||
wchar_t *buffer = malloc( bs );
|
wchar_t *buffer = malloc( bs );
|
||||||
memset( buffer, '\0', bs );
|
memset( buffer, '\0', bs );
|
||||||
swprintf( buffer, bs,
|
swprintf( buffer, bs,
|
||||||
|
@ -358,9 +362,9 @@ c_apply( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_print(L"c_apply: returning: ", DEBUG_EVAL);
|
debug_print( L"c_apply: returning: ", DEBUG_EVAL );
|
||||||
debug_print_object(result, DEBUG_EVAL);
|
debug_print_object( result, DEBUG_EVAL );
|
||||||
debug_println(DEBUG_EVAL);
|
debug_println( DEBUG_EVAL );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -375,9 +379,8 @@ struct cons_pointer c_type( struct cons_pointer pointer ) {
|
||||||
struct cons_pointer result = NIL;
|
struct cons_pointer result = NIL;
|
||||||
struct cons_space_object cell = pointer2cell( pointer );
|
struct cons_space_object cell = pointer2cell( pointer );
|
||||||
|
|
||||||
for (int i = TAGLENGTH -1; i >= 0; i--)
|
for ( int i = TAGLENGTH - 1; i >= 0; i-- ) {
|
||||||
{
|
result = make_string( ( wchar_t ) cell.tag.bytes[i], result );
|
||||||
result = make_string((wchar_t)cell.tag.bytes[i], result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -133,8 +133,8 @@ struct cons_pointer print( FILE * output, struct cons_pointer pointer ) {
|
||||||
case LAMBDATV:
|
case LAMBDATV:
|
||||||
print( output, make_cons( c_string_to_lisp_symbol( L"lambda" ),
|
print( output, make_cons( c_string_to_lisp_symbol( L"lambda" ),
|
||||||
make_cons( cell.payload.lambda.args,
|
make_cons( cell.payload.lambda.args,
|
||||||
cell.payload.lambda.
|
cell.payload.
|
||||||
body ) ) );
|
lambda.body ) ) );
|
||||||
break;
|
break;
|
||||||
case NILTV:
|
case NILTV:
|
||||||
fwprintf( output, L"nil" );
|
fwprintf( output, L"nil" );
|
||||||
|
@ -142,8 +142,8 @@ struct cons_pointer print( FILE * output, struct cons_pointer pointer ) {
|
||||||
case NLAMBDATV:
|
case NLAMBDATV:
|
||||||
print( output, make_cons( c_string_to_lisp_symbol( L"nlambda" ),
|
print( output, make_cons( c_string_to_lisp_symbol( L"nlambda" ),
|
||||||
make_cons( cell.payload.lambda.args,
|
make_cons( cell.payload.lambda.args,
|
||||||
cell.payload.lambda.
|
cell.payload.
|
||||||
body ) ) );
|
lambda.body ) ) );
|
||||||
break;
|
break;
|
||||||
case RATIOTV:
|
case RATIOTV:
|
||||||
print( output, cell.payload.ratio.dividend );
|
print( output, cell.payload.ratio.dividend );
|
||||||
|
|
|
@ -171,7 +171,8 @@ struct cons_pointer read_number( struct stack_frame *frame,
|
||||||
initial = fgetwc( input );
|
initial = fgetwc( input );
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_printf( DEBUG_IO, L"read_number starting '%c' (%d)\n", initial, initial );
|
debug_printf( DEBUG_IO, L"read_number starting '%c' (%d)\n", initial,
|
||||||
|
initial );
|
||||||
|
|
||||||
for ( c = initial; iswdigit( c )
|
for ( c = initial; iswdigit( c )
|
||||||
|| c == btowc( '.' ) || c == btowc( '/' ); c = fgetwc( input ) ) {
|
|| c == btowc( '.' ) || c == btowc( '/' ); c = fgetwc( input ) ) {
|
||||||
|
|
|
@ -34,12 +34,15 @@
|
||||||
struct cons_pointer repl_read( struct cons_pointer stream_pointer ) {
|
struct cons_pointer repl_read( struct cons_pointer stream_pointer ) {
|
||||||
struct cons_pointer result = NIL;
|
struct cons_pointer result = NIL;
|
||||||
debug_print( L"Entered repl_read\n", DEBUG_REPL );
|
debug_print( L"Entered repl_read\n", DEBUG_REPL );
|
||||||
struct cons_pointer frame_pointer = make_stack_frame( NIL, make_cons(stream_pointer, NIL), oblist );
|
struct cons_pointer frame_pointer =
|
||||||
|
make_stack_frame( NIL, make_cons( stream_pointer, NIL ), oblist );
|
||||||
debug_print( L"repl_read: got stack_frame pointer\n", DEBUG_REPL );
|
debug_print( L"repl_read: got stack_frame pointer\n", DEBUG_REPL );
|
||||||
debug_dump_object( frame_pointer, DEBUG_REPL );
|
debug_dump_object( frame_pointer, DEBUG_REPL );
|
||||||
if ( !nilp( frame_pointer ) ) {
|
if ( !nilp( frame_pointer ) ) {
|
||||||
inc_ref( frame_pointer );
|
inc_ref( frame_pointer );
|
||||||
result = lisp_read( get_stack_frame( frame_pointer ), frame_pointer, oblist );
|
result =
|
||||||
|
lisp_read( get_stack_frame( frame_pointer ), frame_pointer,
|
||||||
|
oblist );
|
||||||
dec_ref( frame_pointer );
|
dec_ref( frame_pointer );
|
||||||
}
|
}
|
||||||
debug_print( L"repl_read: returning\n", DEBUG_REPL );
|
debug_print( L"repl_read: returning\n", DEBUG_REPL );
|
||||||
|
|
Loading…
Reference in a new issue