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.
This commit is contained in:
Alex Shinn 2009-12-05 18:13:01 +09:00
parent fa879e183c
commit 9ed0d705c6

View file

@ -20,8 +20,14 @@ static const char* reverse_opcode_names[] =
static sexp sexp_disasm (sexp ctx, sexp bc, sexp out) { static sexp sexp_disasm (sexp ctx, sexp bc, sexp out) {
unsigned char *ip, opcode; unsigned char *ip, opcode;
if (sexp_procedurep(bc)) if (sexp_procedurep(bc)) {
bc = sexp_procedure_code(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); ip = sexp_bytecode_data(bc);
loop: loop:
opcode = *ip++; opcode = *ip++;