This commit is contained in:
cozis
2022-03-08 21:59:59 +01:00
parent e3afd00da2
commit 4836a9a8c9
3 changed files with 19 additions and 2 deletions
+5
View File
@@ -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);
+1
View File
@@ -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);
+13 -2
View File
@@ -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;
}