This commit is contained in:
2026-06-21 14:35:48 +10:00
parent f97cec4567
commit ff98aa63b4
11 changed files with 903 additions and 760 deletions

View File

@@ -23,6 +23,7 @@ typedef struct GroundState GroundState;
typedef struct GroundBytecodeProgram GroundBytecodeProgram;
typedef struct GroundBytecodeInstruction GroundBytecodeInstruction;
typedef struct GroundBytecodeHeap GroundBytecodeHeap;
typedef struct GroundBytecode GroundBytecode;
// --- Literal types ---
@@ -267,7 +268,7 @@ struct GroundBytecodeProgram {
};
struct GroundBytecodeInstruction {
GroundInstruction instruction;
enum GroundInstructionType type;
struct {
GroundSize* at;
GroundSize capacity;
@@ -278,9 +279,13 @@ struct GroundBytecodeInstruction {
struct GroundBytecodeHeap {
GroundValue* heap;
GroundSize capacity;
GroundSize count;
GroundSize len;
};
struct GroundBytecode {
GroundBytecodeProgram program;
GroundBytecodeHeap heap;
};
//
// INTERFACE
@@ -335,6 +340,8 @@ struct _Ground {
GroundIdentifier* (*Identifier) (const char* id);
GroundBytecode (*Bytecode) (GroundProgram* program, GroundState* state);
} New;
// Frees the memory held by the specified struct
@@ -406,7 +413,7 @@ struct _Ground {
} Internal;
struct {
void (*Error) (const char* message);
void (*Error) (const char* message);
void (*Warning) (const char* message);
void (*printErrors)();
@@ -422,8 +429,13 @@ struct _Ground {
void (*execute) (GroundBytecodeProgram* program, GroundBytecodeHeap* heap);
void (*optimise) (GroundBytecodeProgram* program);
} Program;
struct {} Instruction;
struct {} Heap;
struct {
int64_t (*execute) (GroundBytecodeInstruction* instruction, GroundBytecodeHeap* heap);
} Instruction;
struct {
void (*set) (GroundBytecodeHeap* heap, GroundSize idx, GroundValue value);
GroundValue* (*get) (GroundBytecodeHeap* heap, GroundSize idx);
} Heap;
} Bytecode;
};