add some debug prints
This commit is contained in:
parent
ff61f8c0f5
commit
346b159e7e
|
@ -709,6 +709,7 @@ print_irep(pic_state *pic, struct pic_irep *irep)
|
|||
printf("## irep %p\n", irep);
|
||||
printf("[clen = %zd, ccapa = %zd, argc = %d, localc = %d]\n", irep->clen, irep->ccapa, irep->argc, irep->localc);
|
||||
for (i = 0; i < irep->clen; ++i) {
|
||||
printf("[%2d] ", irep->code[i].insn);
|
||||
switch (irep->code[i].insn) {
|
||||
case OP_POP:
|
||||
puts("OP_POP");
|
||||
|
|
15
src/expand.c
15
src/expand.c
|
@ -44,6 +44,12 @@ expand(pic_state *pic, pic_value obj, struct syntactic_env *env)
|
|||
{
|
||||
int ai = pic_gc_arena_preserve(pic);
|
||||
|
||||
#if DEBUG
|
||||
printf("expanding...");
|
||||
pic_debug(pic, obj);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
switch (pic_type(obj)) {
|
||||
case PIC_TT_SYMBOL: {
|
||||
return obj;
|
||||
|
@ -147,14 +153,21 @@ pic_expand(pic_state *pic, pic_value obj)
|
|||
|
||||
env.tbl = pic->global_tbl;
|
||||
|
||||
#if DEBUG
|
||||
puts("before expand:");
|
||||
pic_debug(pic, obj);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
v = expand(pic, obj, &env);
|
||||
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
pic_gc_protect(pic, v);
|
||||
|
||||
#if DEBUG
|
||||
puts("expanded:");
|
||||
puts("after expand:");
|
||||
pic_debug(pic, v);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
return v;
|
||||
|
|
21
src/vm.c
21
src/vm.c
|
@ -157,9 +157,15 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
|||
return i;
|
||||
}
|
||||
|
||||
#if VM_DEBUG
|
||||
# define OPCODE_EXEC_HOOK printf("OP = %d\n", c.insn)
|
||||
#else
|
||||
# define OPCODE_EXEC_HOOK ((void)0)
|
||||
#endif
|
||||
|
||||
#if PIC_DIRECT_THREADED_VM
|
||||
# define VM_LOOP JUMP;
|
||||
# define CASE(x) L_##x:
|
||||
# define CASE(x) L_##x: OPCODE_EXEC_HOOK;
|
||||
# define NEXT c = *++pc; JUMP;
|
||||
# define JUMP c = *pc; goto *oplabels[pc->insn];
|
||||
# define VM_LOOP_END
|
||||
|
@ -207,6 +213,19 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
|
|||
|
||||
argc = pic_length(pic, argv) + 1;
|
||||
|
||||
#if VM_DEBUG
|
||||
puts("== booting VM...");
|
||||
printf(" proc = ");
|
||||
pic_debug(pic, pic_obj_value(proc));
|
||||
puts("");
|
||||
printf(" argv = ");
|
||||
pic_debug(pic, argv);
|
||||
puts("");
|
||||
printf(" irep = ");
|
||||
print_irep(pic, proc->u.irep);
|
||||
puts("\nLet's go!");
|
||||
#endif
|
||||
|
||||
PUSH(pic_obj_value(proc));
|
||||
for (i = 1; i < argc; ++i) {
|
||||
PUSH(pic_car(pic, argv));
|
||||
|
|
Loading…
Reference in New Issue