From 3112f190db33c0ffa3a3650de6ca2ea40a77e51b Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Thu, 6 Dec 2018 17:55:54 +0000 Subject: [PATCH] Work on the eval-quote bug. I have a really profound misunderstanding here! But, in working on it, I've worked hard on documentation, which is good. --- src/conspage.c | 2 +- src/consspaceobject.c | 2 +- src/equal.c | 6 +++--- src/init.c | 2 +- src/integer.c | 2 +- src/intern.c | 2 +- src/lispops.c | 13 ++++++++++++- src/peano.c | 2 +- src/print.c | 3 +-- src/read.c | 2 +- src/real.c | 9 ++++++--- src/repl.c | 10 +++++++--- src/stack.c | 11 +++++++++-- 13 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/conspage.c b/src/conspage.c index 2d31cf6..6e8ee26 100644 --- a/src/conspage.c +++ b/src/conspage.c @@ -1,4 +1,4 @@ -/** +/* * conspage.c * * Setup and tear down cons pages, and (FOR NOW) do primitive diff --git a/src/consspaceobject.c b/src/consspaceobject.c index 39caac7..3569f5d 100644 --- a/src/consspaceobject.c +++ b/src/consspaceobject.c @@ -1,4 +1,4 @@ -/** +/* * consspaceobject.c * * Structures common to all cons space objects. diff --git a/src/equal.c b/src/equal.c index 3f74d51..2a13257 100644 --- a/src/equal.c +++ b/src/equal.c @@ -1,4 +1,4 @@ -/** +/* * equal.c * * Checks for shallow and deep equality @@ -38,7 +38,7 @@ bool same_type( struct cons_pointer a, struct cons_pointer b ) { } /** - * Some string will be null terminated and some will be NIL terminated... ooops! + * Some strings will be null terminated and some will be NIL terminated... ooops! * @param string the string to test * @return true if it's the end of a string. */ @@ -102,7 +102,7 @@ bool equal( struct cons_pointer a, struct cons_pointer b ) { /* * there's only supposed ever to be one T and one NIL cell, so each * should be caught by eq; equality of vector-space objects is a whole - * other ball game so we won't deal with it now (and indeedmay never). + * other ball game so we won't deal with it now (and indeed may never). * I'm not certain what equality means for read and write streams, so * I'll ignore them, too, for now. */ diff --git a/src/init.c b/src/init.c index d267dec..5ff9f44 100644 --- a/src/init.c +++ b/src/init.c @@ -1,4 +1,4 @@ -/** +/* * init.c * * Start up and initialise the environement - just enough to get working diff --git a/src/integer.c b/src/integer.c index 390594c..6352b34 100644 --- a/src/integer.c +++ b/src/integer.c @@ -1,4 +1,4 @@ -/** +/* * integer.c * * functions for integer cells. diff --git a/src/intern.c b/src/intern.c index 95400ae..8cb3a77 100644 --- a/src/intern.c +++ b/src/intern.c @@ -1,4 +1,4 @@ -/** +/* * intern.c * * For now this implements an oblist and shallow binding; local environments can diff --git a/src/lispops.c b/src/lispops.c index 4606f6a..593e61a 100644 --- a/src/lispops.c +++ b/src/lispops.c @@ -1,4 +1,4 @@ -/** +/* * lispops.c * * List processing operations. @@ -199,6 +199,17 @@ lisp_eval( struct stack_frame *frame, struct cons_pointer env ) { switch ( cell.tag.value ) { case CONSTV: result = c_apply( frame, env ); + /* I have a profound misunderstanding of how quote and eval should interact! + * if ( equal( c_car(frame->arg[0]), c_string_to_lisp_symbol("quote"))) + * /\* car is QUOTE. TODO: It is ABSURDLY expensive to 'equal' each time! *\/ + * { + * /\* we need to eval it again *\/ + * frame->arg[0] = result; + * fputws( L"quote - re-evaling", stderr); + * dump_frame( stderr, frame ); + * result = c_apply(frame, env); + * } */ + break; case SYMBOLTV: diff --git a/src/peano.c b/src/peano.c index 409abf9..8f978b2 100644 --- a/src/peano.c +++ b/src/peano.c @@ -1,4 +1,4 @@ -/** +/* * peano.c * * Basic peano arithmetic diff --git a/src/print.c b/src/print.c index d978bf0..78bc8aa 100644 --- a/src/print.c +++ b/src/print.c @@ -1,9 +1,8 @@ -/** +/* * print.c * * First pass at a printer, for bootstrapping. * - * * (c) 2017 Simon Brooke * Licensed under GPL version 2.0, or, at your option, any later version. */ diff --git a/src/read.c b/src/read.c index b6cf93a..43ff99e 100644 --- a/src/read.c +++ b/src/read.c @@ -1,4 +1,4 @@ -/** +/* * read.c * * First pass at a reader, for bootstrapping. diff --git a/src/real.c b/src/real.c index 5608b86..526dca5 100644 --- a/src/real.c +++ b/src/real.c @@ -1,7 +1,10 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * real.c + * + * functions for real number cells. + * + * (c) 2017 Simon Brooke + * Licensed under GPL version 2.0, or, at your option, any later version. */ #include "conspage.h" diff --git a/src/repl.c b/src/repl.c index 476aebe..3891b4c 100644 --- a/src/repl.c +++ b/src/repl.c @@ -1,8 +1,12 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * repl.c + * + * the read/eval/print loop + * + * (c) 2017 Simon Brooke + * Licensed under GPL version 2.0, or, at your option, any later version. */ + #include #include #include diff --git a/src/stack.c b/src/stack.c index a5a301c..ef9d06a 100644 --- a/src/stack.c +++ b/src/stack.c @@ -1,4 +1,4 @@ -/** +/* * stack.c * * The Lisp evaluation stack. @@ -153,7 +153,14 @@ void free_stack_frame( struct stack_frame *frame ) { void dump_frame( FILE * output, struct stack_frame *frame ) { fputws( L"Dumping stack frame\n", output ); for ( int arg = 0; arg < args_in_frame; arg++ ) { - fwprintf( output, L"Arg %d:", arg ); + struct cons_space_object cell = pointer2cell( frame->arg[arg] ); + + fwprintf( output, L"Arg %d:\t%c%c%c%c\t", arg, + cell.tag.bytes[0], + cell.tag.bytes[1], + cell.tag.bytes[2], + cell.tag.bytes[3]); + print( output, frame->arg[arg] ); fputws( L"\n", output ); }