Started to try to get back into this; work on exceptions and loops.
This commit is contained in:
parent
16f78f4077
commit
d2101dbd47
9 changed files with 101 additions and 10 deletions
|
|
@ -148,7 +148,7 @@ void free_cell( struct cons_pointer pointer ) {
|
|||
dec_ref( cell->payload.cons.cdr );
|
||||
break;
|
||||
case EXCEPTIONTV:
|
||||
dec_ref( cell->payload.exception.message );
|
||||
dec_ref( cell->payload.exception.payload );
|
||||
dec_ref( cell->payload.exception.frame );
|
||||
break;
|
||||
case FUNCTIONTV:
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ struct cons_pointer make_exception( struct cons_pointer message,
|
|||
|
||||
inc_ref( message );
|
||||
inc_ref( frame_pointer );
|
||||
cell->payload.exception.message = message;
|
||||
cell->payload.exception.payload = message;
|
||||
cell->payload.exception.frame = frame_pointer;
|
||||
|
||||
result = pointer;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@
|
|||
#define CONSTV 1397641027
|
||||
|
||||
/**
|
||||
* An exception.
|
||||
* An exception. TODO: we need a means of dealing with different classes of
|
||||
* exception, and we don't have one yet.
|
||||
*/
|
||||
#define EXCEPTIONTAG "EXEP"
|
||||
|
||||
|
|
@ -108,6 +109,17 @@
|
|||
*/
|
||||
#define LAMBDATV 1094995276
|
||||
|
||||
/**
|
||||
* A loop exit is a special kind of exception which has exactly the same
|
||||
* payload as an exception.
|
||||
*/
|
||||
#define LOOPXTAG "LOOX"
|
||||
|
||||
/**
|
||||
* The string `LOOX`, considered as an `unsigned int`.
|
||||
*/
|
||||
#define LOOPXTV 1481592652
|
||||
|
||||
/**
|
||||
* The special cons cell at address {0,0} whose car and cdr both point to
|
||||
* itself.
|
||||
|
|
@ -286,10 +298,15 @@
|
|||
#define keywordp(conspoint) (check_tag(conspoint,KEYTAG))
|
||||
|
||||
/**
|
||||
* true if `conspoint` points to a special Lambda cell, else false
|
||||
* true if `conspoint` points to a Lambda binding cell, else false
|
||||
*/
|
||||
#define lambdap(conspoint) (check_tag(conspoint,LAMBDATAG))
|
||||
|
||||
/**
|
||||
* true if `conspoint` points to a loop exit exception, else false.
|
||||
*/
|
||||
#define loopexitp(conspoint) (check_tag(conspoint,LOOPXTAG))
|
||||
|
||||
/**
|
||||
* true if `conspoint` points to a special form cell, else false
|
||||
*/
|
||||
|
|
@ -414,8 +431,8 @@ struct cons_payload {
|
|||
* Message should be a Lisp string; frame should be a pointer to an (unfreed) stack frame.
|
||||
*/
|
||||
struct exception_payload {
|
||||
/** The message: should be a Lisp string but in practice anything printable will do. */
|
||||
struct cons_pointer message;
|
||||
/** The payload: usually a Lisp string but in practice anything printable will do. */
|
||||
struct cons_pointer payload;
|
||||
/** pointer to the (unfreed) stack frame in which the exception was thrown. */
|
||||
struct cons_pointer frame;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -267,7 +267,8 @@ 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.message );
|
||||
// todo: if the payload isn't a message, we maybe shouldn't print it?
|
||||
print( output, pointer2cell( pointer ).payload.exception.payload );
|
||||
url_fputws( L"\n", output );
|
||||
dump_stack_trace( output,
|
||||
pointer2cell( pointer ).payload.exception.frame );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue