testcases for instructions INSERT, INSERT2, SELECT and ASS

This commit is contained in:
Francesco Cozzuto
2023-01-23 21:36:44 +01:00
parent 31d0c100c1
commit 5234fc73a8
17 changed files with 359 additions and 10 deletions
+1 -1
View File
@@ -463,7 +463,7 @@ Executable *assemble(Source *src, Error *error, int *error_offset)
goto done;
}
}
size_t unresolved_count = LabelList_GetUnresolvedCount(list);
if(unresolved_count > 0) {
*error_offset = -1;
+5 -6
View File
@@ -497,8 +497,7 @@ static _Bool runInstruction(Runtime *runtime, Error *error)
ASSERT(runtime != NULL);
ASSERT(error->occurred == 0);
Stack *stack = Runtime_GetStack(runtime);
Heap *heap = Runtime_GetHeap(runtime);
Heap *heap = Runtime_GetHeap(runtime);
Executable *exe = Runtime_GetCurrentExecutable(runtime);
ASSERT(exe != NULL);
int index = Runtime_GetCurrentIndex(runtime);
@@ -855,14 +854,14 @@ static _Bool runInstruction(Runtime *runtime, Error *error)
return Object_Insert(col, key, val, heap, error);
}
case OPCODE_INSERT2:
{
ASSERT(opc == 0);
Object *val = Stack_Top(stack, -2);
Object *col = Stack_Top(stack, -1);
Object *key = Stack_Top(stack, 0);
Object *val = Runtime_Top(runtime, -2);
Object *col = Runtime_Top(runtime, -1);
Object *key = Runtime_Top(runtime, 0);
if (val == NULL || col == NULL || key == NULL) {
Error_Report(error, ErrorType_INTERNAL, "Frame has not enough values on the stack to run INSERT2 instruction");
return 0;
-2
View File
@@ -35,7 +35,6 @@
#include "timing.h"
#include "executable.h"
#include "utils/error.h"
#include "utils/stack.h"
#include "objects/objects.h"
typedef struct xRuntime Runtime;
@@ -90,7 +89,6 @@ bool Runtime_CollectGarbage(Runtime *runtime, Error *error);
void Runtime_PrintStackTrace(Runtime *runtime, FILE *stream);
void Runtime_Interrupt(Runtime *runtime);
Heap* Runtime_GetHeap(Runtime *runtime);
Stack* Runtime_GetStack(Runtime *runtime);
int Runtime_GetCurrentIndex(Runtime *runtime);
Executable *Runtime_GetCurrentExecutable(Runtime *runtime);
Executable *Runtime_GetMostRecentExecutable(Runtime *runtime);