From 9ed0d705c6e8d306303c29b4fc41e8b382a29b01 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sat, 5 Dec 2009 18:13:01 +0900 Subject: [PATCH] adding type checking to disasm Fixes issue #8: http://code.google.com/p/chibi-scheme/issues/detail?id=8 Note disasm is likely to be moved out of the core soon. --- opt/debug.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opt/debug.c b/opt/debug.c index 0df9ea17..6d8b5de6 100644 --- a/opt/debug.c +++ b/opt/debug.c @@ -20,8 +20,14 @@ static const char* reverse_opcode_names[] = static sexp sexp_disasm (sexp ctx, sexp bc, sexp out) { unsigned char *ip, opcode; - if (sexp_procedurep(bc)) + if (sexp_procedurep(bc)) { bc = sexp_procedure_code(bc); + } else if (sexp_opcodep(bc)) { + sexp_printf(ctx, out, "%s is a primitive\n", sexp_opcode_name(bc)); + return SEXP_VOID; + } else if (! sexp_bytecodep(bc)) { + return sexp_type_exception(ctx, "not a procedure", bc); + } ip = sexp_bytecode_data(bc); loop: opcode = *ip++;