Whitespace only changes

This commit is contained in:
Simon Brooke 2018-12-29 07:40:01 +00:00
parent 8231c74bae
commit 40e1f3ca64
17 changed files with 283 additions and 269 deletions

View file

@ -66,7 +66,8 @@ void make_cons_page( ) {
cell->count = MAXREFERENCE;
cell->payload.free.car = 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;
case 1:
/*
@ -80,7 +81,8 @@ void make_cons_page( ) {
cell->payload.free.cdr = ( struct cons_pointer ) {
0, 1
};
debug_printf( DEBUG_ALLOC, L"Allocated special cell T\n" );
debug_printf( DEBUG_ALLOC,
L"Allocated special cell T\n" );
break;
}
} else {
@ -98,8 +100,8 @@ void make_cons_page( ) {
initialised_cons_pages++;
} else {
debug_printf( DEBUG_ALLOC,
L"FATAL: Failed to allocate memory for cons page %d\n",
initialised_cons_pages );
L"FATAL: Failed to allocate memory for cons page %d\n",
initialised_cons_pages );
exit( 1 );
}
@ -164,8 +166,9 @@ void free_cell( struct cons_pointer pointer ) {
case VECTORPOINTTV:
/* for vector space pointers, free the actual vector-space
* object. Dangerous! */
debug_printf( DEBUG_ALLOC, L"About to free vector-space object at %ld\n",
cell->payload.vectorp.address );
debug_printf( DEBUG_ALLOC,
L"About to free vector-space object at %ld\n",
cell->payload.vectorp.address );
//free( ( void * ) cell->payload.vectorp.address );
break;
@ -179,13 +182,13 @@ void free_cell( struct cons_pointer pointer ) {
freelist = pointer;
} else {
debug_printf( DEBUG_ALLOC,
L"ERROR: Attempt to free cell with %d dangling references at page %d, offset %d\n",
cell->count, pointer.page, pointer.offset );
L"ERROR: Attempt to free cell with %d dangling references at page %d, offset %d\n",
cell->count, pointer.page, pointer.offset );
}
} else {
debug_printf( DEBUG_ALLOC,
L"ERROR: Attempt to free cell which is already FREE at page %d, offset %d\n",
pointer.page, pointer.offset );
L"ERROR: Attempt to free cell which is already FREE at page %d, offset %d\n",
pointer.page, pointer.offset );
}
}
@ -216,8 +219,8 @@ struct cons_pointer allocate_cell( char *tag ) {
cell->payload.cons.cdr = NIL;
debug_printf( DEBUG_ALLOC,
L"Allocated cell of type '%s' at %d, %d \n", tag,
result.page, result.offset );
L"Allocated cell of type '%s' at %d, %d \n", tag,
result.page, result.offset );
} else {
debug_printf( DEBUG_ALLOC, L"WARNING: Allocating non-free cell!" );
}
@ -239,6 +242,6 @@ void initialise_cons_pages( ) {
conspageinitihasbeencalled = true;
} else {
debug_printf( DEBUG_ALLOC,
L"WARNING: initialise_cons_pages() called a second or subsequent time\n" );
L"WARNING: initialise_cons_pages() called a second or subsequent time\n" );
}
}

View file

@ -183,10 +183,10 @@ make_string_like_thing( wint_t c, struct cons_pointer tail, char *tag ) {
* cell->payload.string.cdr = tsil */
cell->payload.string.cdr.offset = tail.offset;
} else {
// TODO: should throw an exception!
// TODO: should throw an exception!
debug_printf( DEBUG_ALLOC,
L"Warning: only NIL and %s can be prepended to %s\n",
tag, tag );
L"Warning: only NIL and %s can be prepended to %s\n",
tag, tag );
}
return pointer;

View file

@ -67,8 +67,8 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
cell.payload.cons.car.offset,
cell.payload.cons.cdr.page,
cell.payload.cons.cdr.offset, cell.count );
print( output, pointer);
fputws( L"\n", output);
print( output, pointer );
fputws( L"\n", output );
break;
case EXCEPTIONTV:
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 );
fwprintf( output, L";\n\t\t\tbody: " );
print( output, cell.payload.lambda.body );
fputws( L"\n", output);
fputws( L"\n", output );
break;
case NILTV:
break;
@ -98,15 +98,15 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
print( output, cell.payload.lambda.args );
fwprintf( output, L";\n\t\t\tbody: " );
print( output, cell.payload.lambda.body );
fputws( L"\n", output);
fputws( L"\n", output );
break;
case RATIOTV:
fwprintf( output,
L"\t\tRational cell: value %ld/%ld, count %u\n",
pointer2cell( cell.payload.ratio.dividend ).
payload.integer.value,
pointer2cell( cell.payload.ratio.divisor ).
payload.integer.value, cell.count );
pointer2cell( cell.payload.ratio.dividend ).payload.
integer.value,
pointer2cell( cell.payload.ratio.divisor ).payload.
integer.value, cell.count );
break;
case READTV:
fwprintf( output, L"\t\tInput stream\n" );
@ -130,10 +130,11 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
struct vector_space_object *vso = cell.payload.vectorp.address;
fwprintf( output,
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 );
if (stackframep(vso)) {
dump_frame(output, pointer);
}
&vso->header.tag.bytes, vso->header.tag.value,
vso->header.size );
if ( stackframep( vso ) ) {
dump_frame( output, pointer );
}
switch ( vso->header.tag.value ) {
case STACKFRAMETV:
dump_frame( output, pointer );

View file

@ -26,15 +26,15 @@
#include "stack.h"
#include "vectorspace.h"
void set_reg(struct stack_frame * frame, int reg, struct cons_pointer value) {
debug_printf(DEBUG_STACK, L"Setting register %d to ", reg);
debug_print_object(value, DEBUG_STACK);
debug_println(DEBUG_STACK);
frame->arg[reg++] = value;
inc_ref(value);
if (reg > frame->args) {
frame->args = reg;
}
void set_reg( struct stack_frame *frame, int reg, struct cons_pointer value ) {
debug_printf( DEBUG_STACK, L"Setting register %d to ", reg );
debug_print_object( value, DEBUG_STACK );
debug_println( DEBUG_STACK );
frame->arg[reg++] = value;
inc_ref( value );
if ( reg > frame->args ) {
frame->args = reg;
}
}
@ -49,8 +49,8 @@ struct stack_frame *get_stack_frame( struct cons_pointer pointer ) {
if ( vectorpointp( pointer ) && stackframep( vso ) ) {
result = ( struct stack_frame * ) &( vso->payload );
debug_printf( DEBUG_STACK, L"get_stack_frame: all good, returning %p\n",
result );
debug_printf( DEBUG_STACK,
L"get_stack_frame: all good, returning %p\n", result );
} else {
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_dump_object( result, DEBUG_ALLOC);
debug_dump_object( result, DEBUG_ALLOC );
return result;
}
@ -124,7 +124,7 @@ struct cons_pointer make_stack_frame( struct cons_pointer previous,
} else {
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
* frame. When there are no more slots, if there are still args,
* stash them on more */
@ -136,19 +136,21 @@ struct cons_pointer make_stack_frame( struct cons_pointer previous,
* processor to be evaled in parallel; but see notes here:
* https://github.com/simon-brooke/post-scarcity/wiki/parallelism
*/
struct cons_pointer val = eval_form(frame, result, cell.payload.cons.car, env);
if ( exceptionp( val ) ) {
result = val;
break;
} else {
debug_printf( DEBUG_STACK, L"Setting argument %d to ", frame->args);
debug_print_object(cell.payload.cons.car, DEBUG_STACK);
set_reg( frame, frame->args, val );
}
args = cell.payload.cons.cdr;
struct cons_pointer val =
eval_form( frame, result, cell.payload.cons.car, env );
if ( exceptionp( val ) ) {
result = val;
break;
} else {
debug_printf( DEBUG_STACK, L"Setting argument %d to ",
frame->args );
debug_print_object( cell.payload.cons.car, DEBUG_STACK );
set_reg( frame, frame->args, val );
}
args = cell.payload.cons.cdr;
}
if ( !exceptionp( result ) ) {
if ( consp( args ) ) {
/* if we still have args, eval them and stick the values on `more` */
@ -190,7 +192,7 @@ struct cons_pointer make_special_frame( struct cons_pointer previous,
} else {
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
* frame. When there are no more slots, if there are still args,
* 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 );
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++ ) {
struct cons_space_object cell = pointer2cell( frame->arg[arg] );
@ -252,12 +254,11 @@ void dump_frame( FILE * output, struct cons_pointer frame_pointer ) {
print( output, frame->arg[arg] );
fputws( L"\n", output );
}
if (!nilp(frame->more))
{
fputws( L"More: \t", output );
print( output, frame->more );
fputws( L"\n", output );
}
if ( !nilp( frame->more ) ) {
fputws( L"More: \t", output );
print( output, frame->more );
fputws( L"\n", output );
}
}
}

View file

@ -41,7 +41,7 @@
*/
//#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 );

View file

@ -36,11 +36,12 @@ struct cons_pointer make_vec_pointer( struct vector_space_object *address ) {
struct cons_pointer pointer = allocate_cell( VECTORPOINTTAG );
struct cons_space_object *cell = &pointer2cell( pointer );
debug_printf( DEBUG_ALLOC,
L"make_vec_pointer: tag written, about to set pointer address to %p\n",
address );
L"make_vec_pointer: tag written, about to set pointer address to %p\n",
address );
cell->payload.vectorp.address = address;
debug_printf( DEBUG_ALLOC, L"make_vec_pointer: all good, returning pointer to %p\n",
cell->payload.vectorp.address );
debug_printf( DEBUG_ALLOC,
L"make_vec_pointer: all good, returning pointer to %p\n",
cell->payload.vectorp.address );
debug_dump_object( pointer, DEBUG_ALLOC );
@ -67,8 +68,8 @@ struct cons_pointer make_vso( char *tag, uint64_t payload_size ) {
if ( vso != NULL ) {
debug_printf( DEBUG_ALLOC,
L"make_vso: about to write tag '%s' into vso at %p\n", tag,
vso );
L"make_vso: about to write tag '%s' into vso at %p\n",
tag, vso );
strncpy( &vso->header.tag.bytes[0], tag, TAGLENGTH );
result = make_vec_pointer( vso );
debug_dump_object( result, DEBUG_ALLOC );
@ -79,18 +80,19 @@ struct cons_pointer make_vso( char *tag, uint64_t payload_size ) {
#ifdef DEBUG
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",
&vso->header.tag.bytes, total_size, vso->header.size, vso,
&vso->payload );
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->payload );
if ( padded != total_size ) {
debug_printf( DEBUG_ALLOC, L"\t\tPadded from %d to %d\n",
total_size, padded );
total_size, padded );
}
#endif
}
#ifdef DEBUG
debug_printf( DEBUG_ALLOC, L"make_vso: all good, returning pointer to %p\n",
pointer2cell( result ).payload.vectorp.address );
debug_printf( DEBUG_ALLOC,
L"make_vso: all good, returning pointer to %p\n",
pointer2cell( result ).payload.vectorp.address );
#endif
return result;