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

@@ -336,6 +336,23 @@ struct GroundBytecode {
GroundBytecodeHeap heap;
};
// --- Internal Ground components, avoid use outside of Ground ---
enum GroundExecutionResultType {
_GER_CONTINUE, _GER_JUMP, _GER_RETURN, _GER_END
};
struct GroundExecutionResult {
enum GroundExecutionResultType type;
union {
GroundBytecodeValue value;
GroundSize line;
GroundInt end;
} as;
};
//
// INTERFACE
//
@@ -428,6 +445,8 @@ struct _Ground {
GroundState (*State) (GroundState* in);
GroundIdentifier* (*Identifier) (GroundIdentifier* in);
GroundBytecodeValue (*BytecodeValue) (GroundBytecodeValue* in);
} Copy;
struct {
@@ -481,11 +500,11 @@ struct _Ground {
void (*save) (GroundBytecode* bytecode, const char* path);
GroundBytecode (*load) (const char* path);
struct {
void (*execute) (GroundBytecodeProgram* program, GroundBytecodeHeap* heap);
void (*optimise) (GroundBytecodeProgram* program);
GroundBytecodeValue (*execute) (GroundBytecodeProgram* program, GroundBytecodeHeap* heap);
void (*optimise) (GroundBytecodeProgram* program);
} Program;
struct {
int64_t (*execute) (GroundBytecodeInstruction* instruction, GroundBytecodeHeap* heap);
struct GroundExecutionResult (*execute) (GroundBytecodeInstruction* instruction, GroundBytecodeHeap* heap);
} Instruction;
struct {
void (*set) (GroundBytecodeHeap* heap, GroundSize idx, GroundValue value);