Initialisation almost succeeds. nil and t are successfully instantiated.
We then go into a mess of exceptions which trigger exceptions until we run out of allocatable memory, but all those exceptions and stack frames are correctly allocated and torn down again afterwards, so.... sort of good?
This commit is contained in:
commit
ba985474f6
31 changed files with 869 additions and 199 deletions
|
|
@ -18,6 +18,8 @@
|
|||
#include "memory/pso4.h"
|
||||
#include "memory/tags.h"
|
||||
|
||||
#include "payloads/cons.h"
|
||||
|
||||
/**
|
||||
* @brief Construct a stack frame with this `previous` pointer, and arguments
|
||||
* taken from the remaining arguments to this function, which should all be
|
||||
|
|
@ -50,7 +52,8 @@ struct pso_pointer make_frame( struct pso_pointer previous, ... ) {
|
|||
struct pso_pointer more_args = nil;
|
||||
|
||||
for ( ; cursor < count; cursor++ ) {
|
||||
more_args = cons( va_arg( args, struct pso_pointer ), more_args );
|
||||
more_args =
|
||||
c_cons( va_arg( args, struct pso_pointer ), more_args );
|
||||
}
|
||||
|
||||
// should be frame->payload.stack_frame.more = reverse( more_args), but
|
||||
|
|
@ -75,19 +78,17 @@ struct pso_pointer destroy_stack_frame( struct pso_pointer fp,
|
|||
struct pso_pointer env ) {
|
||||
if ( stackp( fp ) ) {
|
||||
struct pso4 *frame = pointer_to_pso4( fp );
|
||||
struct pso4 *casualty =
|
||||
pointer_to_pso4( frame->payload.stack_frame.arg[0] );
|
||||
|
||||
dec_ref( casualty->payload.stack_frame.previous );
|
||||
dec_ref( casualty->payload.stack_frame.function );
|
||||
dec_ref( casualty->payload.stack_frame.more );
|
||||
dec_ref( frame->payload.stack_frame.previous );
|
||||
dec_ref( frame->payload.stack_frame.function );
|
||||
dec_ref( frame->payload.stack_frame.more );
|
||||
|
||||
for ( int i = 0; i < args_in_frame; i++ ) {
|
||||
dec_ref( casualty->payload.stack_frame.arg[0] );
|
||||
dec_ref( frame->payload.stack_frame.arg[i] );
|
||||
}
|
||||
|
||||
casualty->payload.stack_frame.args = 0;
|
||||
casualty->payload.stack_frame.depth = 0;
|
||||
frame->payload.stack_frame.args = 0;
|
||||
frame->payload.stack_frame.depth = 0;
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue