function calling works in theory (can't test yet)
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user