diff --git a/src/common/executable.c b/src/common/executable.c index f053cff..5c06200 100644 --- a/src/common/executable.c +++ b/src/common/executable.c @@ -82,6 +82,11 @@ static const InstrInfo instr_table[] = { [OPCODE_JUMP] = {"JUMP", 1, (OperandType[]) {OPTP_INT}}, }; +const char *Executable_GetOpcodeName(Opcode opcode) +{ + return instr_table[opcode].name; +} + Executable *Executable_Copy(Executable *exe) { assert(exe != NULL); diff --git a/src/common/executable.h b/src/common/executable.h index 82c5ff5..320f7ad 100644 --- a/src/common/executable.h +++ b/src/common/executable.h @@ -70,6 +70,7 @@ _Bool Executable_SetSource(Executable *exe, Source *src); Source *Executable_GetSource(Executable *exe); int Executable_GetInstrOffset(Executable *exe, int index); int Executable_GetInstrLength(Executable *exe, int index); +const char *Executable_GetOpcodeName(Opcode opcode); ExeBuilder *ExeBuilder_New(BPAlloc *alloc); _Bool ExeBuilder_Append(ExeBuilder *exeb, Error *error, Opcode opcode, Operand *opv, int opc, int off, int len); diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index a2bd540..e3ca8d3 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -530,7 +530,7 @@ static Object *do_relational_op(Object *lop, Object *rop, Opcode opcode, Heap *h static _Bool step(Runtime *runtime, Error *error) { assert(runtime != NULL); - assert(error->occurred != 0); + assert(error->occurred == 0); Opcode opcode; Operand ops[3]; int opc = sizeof(ops) / sizeof(ops[0]); @@ -815,18 +815,29 @@ static _Bool step(Runtime *runtime, Error *error) if(!Runtime_Pop(runtime, error, 2)) return 0; - Object *val = Object_Select(col, key, runtime->heap, error); + assert(error->occurred == 0); + + Error dummy; + Error_Init(&dummy); // We want to catch the error reported by this Object_Select. + + Object *val = Object_Select(col, key, runtime->heap, &dummy); if(val == NULL) { + Error_Free(&dummy); + val = Object_NewNone(runtime->heap, error); if(val == NULL) return 0; } + assert(error->occurred == 0); + if(!Runtime_Push(runtime, error, val)) return 0; + + assert(error->occurred == 0); return 1; }