function calls work
This commit is contained in:
@@ -705,7 +705,30 @@ struct GroundExecutionResult _GroundBytecodeInstructionExecute(GroundBytecodeIns
|
|||||||
// make a copy of the current state and attach it to the function
|
// make a copy of the current state and attach it to the function
|
||||||
GroundBytecodeFunction* function = &HEAP_GET(heap, instruction->args.at[0])->as.Function;
|
GroundBytecodeFunction* function = &HEAP_GET(heap, instruction->args.at[0])->as.Function;
|
||||||
|
|
||||||
if (function->closure == NULL) {}
|
if (function->closure == NULL) {
|
||||||
|
function->closure = malloc(sizeof(GroundBytecodeHeap));
|
||||||
|
if (function->closure == NULL) {
|
||||||
|
Ground.Log.Error("malloc failed in Ground.Bytecode.Instruction.execute");
|
||||||
|
Ground.Flags.error = true;
|
||||||
|
return CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GroundBytecodeHeap newHeap = {
|
||||||
|
.capacity = heap->capacity,
|
||||||
|
.len = heap->len,
|
||||||
|
.heap = malloc(sizeof(GroundBytecodeValue) * heap->capacity)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (newHeap.heap == NULL) {
|
||||||
|
Ground.Log.Error("malloc failed in Ground.Bytecode.Instruction.execute");
|
||||||
|
Ground.Flags.error = true;
|
||||||
|
return CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (GroundSize i = 0; i < heap->len; i++) {
|
||||||
|
newHeap.heap[i] = Ground.Copy.BytecodeValue(&heap->heap[i]);
|
||||||
|
}
|
||||||
|
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,6 +201,8 @@ struct _Ground Ground = {
|
|||||||
.State = _GroundCopyState,
|
.State = _GroundCopyState,
|
||||||
|
|
||||||
.Identifier = _GroundCopyIdentifier,
|
.Identifier = _GroundCopyIdentifier,
|
||||||
|
|
||||||
|
.BytecodeValue = _GroundCopyBytecodeValue,
|
||||||
},
|
},
|
||||||
|
|
||||||
.List = {
|
.List = {
|
||||||
|
|||||||
Reference in New Issue
Block a user