diff --git a/src/Bytecode/Instruction/execute.c b/src/Bytecode/Instruction/execute.c index b50b1e2..6555b0d 100644 --- a/src/Bytecode/Instruction/execute.c +++ b/src/Bytecode/Instruction/execute.c @@ -10,7 +10,7 @@ #include #define HEAP_GET(heap, idx) (&(heap)->heap[(idx)]) -#define HEAP_SET(heap, idx, val) ((heap)->heap[(idx)] = (val)) +#define HEAP_SET(heap, idx, val) ({Ground.Free.BytecodeValue(&(heap)->heap[idx]); ((heap)->heap[(idx)] = (val));}) #define CONTINUE (struct GroundExecutionResult) { _GER_CONTINUE } #define JUMP(idx) (struct GroundExecutionResult) { .type = _GER_JUMP, .as.line = idx } @@ -89,7 +89,6 @@ struct GroundExecutionResult _GroundBytecodeInstructionExecute(GroundBytecodeIns SET: { if (instruction->args.at[0] != instruction->args.at[1]) { GroundBytecodeValue copy = Ground.Copy.BytecodeValue(HEAP_GET(heap, instruction->args.at[1])); - Ground.Free.BytecodeValue(&heap->heap[instruction->args.at[0]]); HEAP_SET(heap, instruction->args.at[0], copy); } return CONTINUE;