added a basic heap inspection utility to the debugger and modified the impl of the buffer object

This commit is contained in:
Francesco Cozzuto
2021-12-07 12:54:55 +01:00
parent f751cbcbd5
commit 51d744ef2e
11 changed files with 653 additions and 75 deletions
+35 -2
View File
@@ -6,8 +6,8 @@
#define MAX_FRAME_STACK 16
#define MAX_FRAMES 16
typedef struct Frame Frame;
struct Frame {
typedef struct xFrame Frame;
struct xFrame {
Frame *prev;
Object *locals;
Object *closure;
@@ -25,6 +25,39 @@ struct xRuntime {
Heap *heap;
};
CallStackScanner *CallStackScanner_New(Runtime *runtime)
{
return runtime->frame;
}
_Bool CallStackScanner_Next(CallStackScanner **scanner, Object **locals, Object **closure, Executable **exe, int *index)
{
assert(scanner != NULL);
if(*scanner == NULL)
return 0;
{
Frame *frame = *scanner;
if(exe)
*exe = frame->exe;
if(index)
*index = frame->index;
if(locals)
*locals = frame->locals;
if(closure)
*closure = frame->closure;
}
(*scanner) = ((Frame*) (*scanner))->prev;
return 1;
}
Stack *Runtime_GetStack(Runtime *runtime)
{
return Stack_Copy(runtime->stack, 1);