Fixed! A stupid error which was entirely my fault

This commit is contained in:
Simon Brooke 2018-12-07 22:33:59 +00:00
parent d620542ee5
commit fc960dec20
2 changed files with 10 additions and 6 deletions

View file

@ -46,7 +46,7 @@ struct cons_pointer repl_read( struct cons_pointer stream_pointer ) {
struct cons_pointer repl_eval( struct cons_pointer input ) {
struct stack_frame *frame = make_empty_frame( NULL, oblist );
frame->arg[0] = NIL /* input */ ;
frame->arg[0] = input;
struct cons_pointer result = lisp_eval( frame, oblist );
free_stack_frame( frame );
@ -89,7 +89,7 @@ repl( FILE * in_stream, FILE * out_stream, FILE * error_stream,
struct cons_pointer val = repl_eval( repl_read( input_stream ) );
/* suppress the 'end of stream' exception */
if ( exceptionp( val ) &&
if ( !exceptionp( val ) &&
!feof( pointer2cell( input_stream ).payload.stream.stream ) ) {
repl_print( output_stream, val );
}

View file

@ -69,7 +69,7 @@ struct stack_frame *make_stack_frame( struct stack_frame *previous,
struct cons_pointer env ) {
struct stack_frame *result = make_empty_frame( previous, env );
for ( int i = 0; i < args_in_frame && !nilp( args ); i++ ) {
for ( int i = 0; i < args_in_frame && consp( args ); i++ ) {
/* iterate down the arg list filling in the arg slots in the
* frame. When there are no more slots, if there are still args,
* stash them on more */
@ -81,17 +81,19 @@ struct stack_frame *make_stack_frame( struct stack_frame *previous,
* processor to be evaled in parallel; but see notes here:
* https://github.com/simon-brooke/post-scarcity/wiki/parallelism
*/
struct stack_frame *arg_frame = make_empty_frame( previous, env );
struct stack_frame *arg_frame = make_empty_frame( result, env );
arg_frame->arg[0] = cell.payload.cons.car;
inc_ref( arg_frame->arg[0] );
struct cons_pointer val = lisp_eval( arg_frame, env );
if ( pointer2cell( val ).tag.value == EXCEPTIONTV ) {
if ( exceptionp( val ) ) {
result->arg[0] = val;
break;
} else {
result->arg[i] = val;
}
inc_ref( val );
free_stack_frame( arg_frame );
args = cell.payload.cons.cdr;
@ -147,7 +149,9 @@ void free_stack_frame( struct stack_frame *frame ) {
for ( int i = 0; i < args_in_frame; i++ ) {
dec_ref( frame->arg[i] );
}
if ( !nilp( frame->more ) ) {
dec_ref( frame->more );
}
free( frame );
}