Very close to a basic REPL now.
This commit is contained in:
parent
83537391a6
commit
4efe9eab87
23 changed files with 188 additions and 84 deletions
|
|
@ -56,7 +56,7 @@ struct cons_pointer check_exception( struct cons_pointer pointer,
|
|||
fprintf( stderr, "ERROR: Exception at %s: ", location_descriptor );
|
||||
URL_FILE *ustderr = file_to_url_file( stderr );
|
||||
fwide( stderr, 1 );
|
||||
print( ustderr, object->payload.exception.payload );
|
||||
c_print( ustderr, object->payload.exception.payload );
|
||||
free( ustderr );
|
||||
|
||||
dec_ref( pointer );
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ print_list_contents( URL_FILE *output, struct cons_pointer pointer,
|
|||
if ( initial_space ) {
|
||||
url_fputwc( btowc( ' ' ), output );
|
||||
}
|
||||
print( output, cell->payload.cons.car );
|
||||
c_print( output, cell->payload.cons.car );
|
||||
|
||||
print_list_contents( output, cell->payload.cons.cdr, true );
|
||||
break;
|
||||
|
|
@ -80,7 +80,7 @@ print_list_contents( URL_FILE *output, struct cons_pointer pointer,
|
|||
break;
|
||||
default:
|
||||
url_fwprintf( output, L" . " );
|
||||
print( output, pointer );
|
||||
c_print( output, pointer );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,9 +99,9 @@ void print_map( URL_FILE *output, struct cons_pointer map ) {
|
|||
for ( struct cons_pointer ks = hashmap_keys( map ); !nilp( ks );
|
||||
ks = c_cdr( ks ) ) {
|
||||
struct cons_pointer key = c_car( ks );
|
||||
print( output, key );
|
||||
c_print( output, key );
|
||||
url_fputwc( btowc( ' ' ), output );
|
||||
print( output, hashmap_get( map, key, false ) );
|
||||
c_print( output, hashmap_get( map, key, false ) );
|
||||
|
||||
if ( !nilp( c_cdr( ks ) ) ) {
|
||||
url_fputws( L", ", output );
|
||||
|
|
@ -153,7 +153,7 @@ void print_128bit( URL_FILE *output, __int128_t n ) {
|
|||
* Print the cons-space object indicated by `pointer` to the stream indicated
|
||||
* by `output`.
|
||||
*/
|
||||
struct cons_pointer print( URL_FILE *output, struct cons_pointer pointer ) {
|
||||
struct cons_pointer c_print( URL_FILE *output, struct cons_pointer pointer ) {
|
||||
struct cons_space_object cell = pointer2cell( pointer );
|
||||
char *buffer;
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ struct cons_pointer print( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
break;
|
||||
case FUNCTIONTV:
|
||||
url_fputws( L"<Function: ", output );
|
||||
print( output, cell.payload.function.meta );
|
||||
c_print( output, cell.payload.function.meta );
|
||||
url_fputwc( L'>', output );
|
||||
break;
|
||||
case INTEGERTV:
|
||||
|
|
@ -190,7 +190,7 @@ struct cons_pointer print( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
make_cons( cell.payload.lambda.args,
|
||||
cell.payload.lambda.body ) );
|
||||
|
||||
print( output, to_print );
|
||||
c_print( output, to_print );
|
||||
|
||||
dec_ref( to_print );
|
||||
url_fputwc( L'>', output );
|
||||
|
|
@ -206,20 +206,20 @@ struct cons_pointer print( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
make_cons( cell.payload.lambda.args,
|
||||
cell.payload.lambda.body ) );
|
||||
|
||||
print( output, to_print );
|
||||
c_print( output, to_print );
|
||||
|
||||
dec_ref( to_print );
|
||||
url_fputwc( L'>', output );
|
||||
}
|
||||
break;
|
||||
case RATIOTV:
|
||||
print( output, cell.payload.ratio.dividend );
|
||||
c_print( output, cell.payload.ratio.dividend );
|
||||
url_fputws( L"/", output );
|
||||
print( output, cell.payload.ratio.divisor );
|
||||
c_print( output, cell.payload.ratio.divisor );
|
||||
break;
|
||||
case READTV:
|
||||
url_fwprintf( output, L"<Input stream: " );
|
||||
print( output, cell.payload.stream.meta );
|
||||
c_print( output, cell.payload.stream.meta );
|
||||
url_fputwc( L'>', output );
|
||||
break;
|
||||
case REALTV:
|
||||
|
|
@ -246,7 +246,7 @@ struct cons_pointer print( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
break;
|
||||
case SPECIALTV:
|
||||
url_fwprintf( output, L"<Special form: " );
|
||||
print( output, cell.payload.special.meta );
|
||||
c_print( output, cell.payload.special.meta );
|
||||
url_fputwc( L'>', output );
|
||||
break;
|
||||
case TIMETV:
|
||||
|
|
@ -264,7 +264,7 @@ struct cons_pointer print( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
break;
|
||||
case WRITETV:
|
||||
url_fwprintf( output, L"<Output stream: " );
|
||||
print( output, cell.payload.stream.meta );
|
||||
c_print( output, cell.payload.stream.meta );
|
||||
url_fputwc( L'>', output );
|
||||
break;
|
||||
default:
|
||||
|
|
@ -312,7 +312,7 @@ lisp_print( struct stack_frame *frame, struct cons_pointer frame_pointer,
|
|||
debug_print( L"lisp_print: about to print\n", DEBUG_IO );
|
||||
debug_dump_object( frame->arg[0], DEBUG_IO );
|
||||
|
||||
result = print( output, frame->arg[0] );
|
||||
result = c_print( output, frame->arg[0] );
|
||||
|
||||
debug_print( L"lisp_print returning\n", DEBUG_IO );
|
||||
debug_dump_object( result, DEBUG_IO );
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef __print_h
|
||||
#define __print_h
|
||||
|
||||
struct cons_pointer print( URL_FILE * output, struct cons_pointer pointer );
|
||||
struct cons_pointer c_print( URL_FILE * output, struct cons_pointer pointer );
|
||||
void println( URL_FILE * output );
|
||||
|
||||
struct cons_pointer lisp_print( struct stack_frame *frame,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void dump_string_cell( URL_FILE *output, wchar_t *prefix,
|
|||
cell.payload.string.cdr.page,
|
||||
cell.payload.string.cdr.offset, cell.count );
|
||||
url_fwprintf( output, L"\t\t value: " );
|
||||
print( output, pointer );
|
||||
c_print( output, pointer );
|
||||
url_fwprintf( output, L"\n" );
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ void dump_object( URL_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 );
|
||||
c_print( output, pointer );
|
||||
url_fputws( L"\n", output );
|
||||
break;
|
||||
case EXCEPTIONTV:
|
||||
|
|
@ -97,18 +97,18 @@ void dump_object( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
break;
|
||||
case LAMBDATV:
|
||||
url_fwprintf( output, L"\t\t\u03bb cell;\n\t\t args: " );
|
||||
print( output, cell.payload.lambda.args );
|
||||
c_print( output, cell.payload.lambda.args );
|
||||
url_fwprintf( output, L";\n\t\t\tbody: " );
|
||||
print( output, cell.payload.lambda.body );
|
||||
c_print( output, cell.payload.lambda.body );
|
||||
url_fputws( L"\n", output );
|
||||
break;
|
||||
case NILTV:
|
||||
break;
|
||||
case NLAMBDATV:
|
||||
url_fwprintf( output, L"\t\tn\u03bb cell; \n\t\targs: " );
|
||||
print( output, cell.payload.lambda.args );
|
||||
c_print( output, cell.payload.lambda.args );
|
||||
url_fwprintf( output, L";\n\t\t\tbody: " );
|
||||
print( output, cell.payload.lambda.body );
|
||||
c_print( output, cell.payload.lambda.body );
|
||||
url_fputws( L"\n", output );
|
||||
break;
|
||||
case RATIOTV:
|
||||
|
|
@ -121,7 +121,7 @@ void dump_object( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
break;
|
||||
case READTV:
|
||||
url_fputws( L"\t\tInput stream; metadata: ", output );
|
||||
print( output, cell.payload.stream.meta );
|
||||
c_print( output, cell.payload.stream.meta );
|
||||
url_fputws( L"\n", output );
|
||||
break;
|
||||
case REALTV:
|
||||
|
|
@ -159,7 +159,7 @@ void dump_object( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
break;
|
||||
case WRITETV:
|
||||
url_fputws( L"\t\tOutput stream; metadata: ", output );
|
||||
print( output, cell.payload.stream.meta );
|
||||
c_print( output, cell.payload.stream.meta );
|
||||
url_fputws( L"\n", output );
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,13 +140,13 @@ void dump_map( URL_FILE *output, struct cons_pointer pointer ) {
|
|||
&pointer_to_vso( pointer )->payload.hashmap;
|
||||
url_fwprintf( output, L"Hashmap with %d buckets:\n", payload->n_buckets );
|
||||
url_fwprintf( output, L"\tHash function: " );
|
||||
print( output, payload->hash_fn );
|
||||
c_print( output, payload->hash_fn );
|
||||
url_fwprintf( output, L"\n\tWrite ACL: " );
|
||||
print( output, payload->write_acl );
|
||||
c_print( output, payload->write_acl );
|
||||
url_fwprintf( output, L"\n\tBuckets:" );
|
||||
for ( int i = 0; i < payload->n_buckets; i++ ) {
|
||||
url_fwprintf( output, L"\n\t\t[%d]: ", i );
|
||||
print( output, payload->buckets[i] );
|
||||
c_print( output, payload->buckets[i] );
|
||||
}
|
||||
url_fwprintf( output, L"\n" );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ void dump_frame_context_fragment( URL_FILE *output,
|
|||
|
||||
if ( frame != NULL ) {
|
||||
url_fwprintf( output, L" <= " );
|
||||
print( output, frame->arg[0] );
|
||||
c_print( output, frame->arg[0] );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -332,12 +332,12 @@ void dump_frame( URL_FILE *output, struct cons_pointer frame_pointer ) {
|
|||
url_fwprintf( output, L"\tArg %d:\t%4.4s\tcount: %10u\tvalue: ",
|
||||
arg, cell.tag.bytes, cell.count );
|
||||
|
||||
print( output, frame->arg[arg] );
|
||||
c_print( output, frame->arg[arg] );
|
||||
url_fputws( L"\n", output );
|
||||
}
|
||||
if ( !nilp( frame->more ) ) {
|
||||
url_fputws( L"More: \t", output );
|
||||
print( output, frame->more );
|
||||
c_print( output, frame->more );
|
||||
url_fputws( L"\n", output );
|
||||
}
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ void dump_frame( URL_FILE *output, struct cons_pointer frame_pointer ) {
|
|||
|
||||
void dump_stack_trace( URL_FILE *output, struct cons_pointer pointer ) {
|
||||
if ( exceptionp( pointer ) ) {
|
||||
print( output, pointer2cell( pointer ).payload.exception.payload );
|
||||
c_print( output, pointer2cell( pointer ).payload.exception.payload );
|
||||
url_fputws( L"\n", output );
|
||||
dump_stack_trace( output,
|
||||
pointer2cell( pointer ).payload.exception.frame );
|
||||
|
|
|
|||
|
|
@ -1526,7 +1526,7 @@ struct cons_pointer lisp_repl( struct stack_frame *frame,
|
|||
|
||||
struct cons_pointer prompt = c_assoc( prompt_name, new_env );
|
||||
if ( !nilp( prompt ) ) {
|
||||
print( os, prompt );
|
||||
c_print( os, prompt );
|
||||
}
|
||||
|
||||
expr = lisp_read( get_stack_frame( frame_pointer ), frame_pointer,
|
||||
|
|
@ -1541,7 +1541,7 @@ struct cons_pointer lisp_repl( struct stack_frame *frame,
|
|||
|
||||
println( os );
|
||||
|
||||
print( os, eval_form( frame, frame_pointer, expr, new_env ) );
|
||||
c_print( os, eval_form( frame, frame_pointer, expr, new_env ) );
|
||||
|
||||
dec_ref( expr );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue