mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-11 23:17:34 +02:00
obiwan error: supporting showing labels at offset 0
This commit is contained in:
parent
9c0bf42077
commit
6eafdd1bb4
1 changed files with 6 additions and 2 deletions
|
@ -54,6 +54,7 @@ static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) {
|
|||
sexp_write_pointer(ctx, bc, out);
|
||||
sexp_newline(ctx, out);
|
||||
|
||||
/* build a table of labels that are jumped to */
|
||||
labels = calloc(sexp_bytecode_length(bc), sizeof(sexp_sint_t));
|
||||
ip = sexp_bytecode_data(bc);
|
||||
while (ip - sexp_bytecode_data(bc) < sexp_bytecode_length(bc)) {
|
||||
|
@ -61,7 +62,7 @@ static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) {
|
|||
case SEXP_OP_JUMP:
|
||||
case SEXP_OP_JUMP_UNLESS:
|
||||
off = ip - sexp_bytecode_data(bc) + ((sexp_sint_t*)ip)[0];
|
||||
if (off > 0 && off < sexp_bytecode_length(bc) && labels[off] == 0)
|
||||
if (off >= 0 && off < sexp_bytecode_length(bc) && labels[off] == 0)
|
||||
labels[off] = label++;
|
||||
case SEXP_OP_CALL:
|
||||
case SEXP_OP_CLOSURE_REF:
|
||||
|
@ -85,6 +86,9 @@ static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) {
|
|||
case SEXP_OP_MAKE_PROCEDURE:
|
||||
ip += sizeof(sexp)*3;
|
||||
break;
|
||||
default:
|
||||
/* opcode takes no additional instruction args */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +129,7 @@ static sexp disasm (sexp ctx, sexp self, sexp bc, sexp out, int depth) {
|
|||
case SEXP_OP_JUMP_UNLESS:
|
||||
sexp_write_integer(ctx, ((sexp_sint_t*)ip)[0], out);
|
||||
off = ip - sexp_bytecode_data(bc) + ((sexp_sint_t*)ip)[0];
|
||||
if (off > 0 && off < sexp_bytecode_length(bc) && labels[off] > 0) {
|
||||
if (off >= 0 && off < sexp_bytecode_length(bc) && labels[off] > 0) {
|
||||
sexp_write_string(ctx, " L", out);
|
||||
sexp_write_integer(ctx, labels[off], out);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue