function calling works in theory (can't test yet)

This commit is contained in:
2026-07-03 15:14:41 +10:00
parent a06d3ba55d
commit ce483dacc2
6 changed files with 169 additions and 71 deletions

View File

@@ -1,18 +1,22 @@
#include "../../../include/ground.h"
#include <stdint.h>
void _GroundBytecodeProgramExecute(GroundBytecodeProgram* program, GroundBytecodeHeap* heap) {
GroundBytecodeValue _GroundBytecodeProgramExecute(GroundBytecodeProgram* program, GroundBytecodeHeap* heap) {
GroundSize i = 0;
while (i < program->len) {
int64_t status = Ground.Bytecode.Instruction.execute(&program->at[i], heap);
struct GroundExecutionResult status = Ground.Bytecode.Instruction.execute(&program->at[i], heap);
if (Ground.Flags.error) {
return;
return Ground.New.BytecodeValue(Ground.New.Value.Int(1));
}
switch (status) {
case -1: i++; break;
case -2: return;
default: i = status; break;
switch (status.type) {
case _GER_CONTINUE: i++; break;
case _GER_RETURN: return status.as.value;
case _GER_JUMP: i = status.as.line; break;
case _GER_END: exit(status.as.end);
}
}
return Ground.New.BytecodeValue(Ground.New.Value.Int(0));
}