From 792aed13ae317e0c8afa05dfd4b64435639f1946 Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Tue, 20 Jan 2026 21:17:08 +1100 Subject: [PATCH] Balright time to break master again --- include/groundext.h | 11 ---------- include/groundvm.h | 52 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/include/groundext.h b/include/groundext.h index 735b9b7..d3c76b5 100644 --- a/include/groundext.h +++ b/include/groundext.h @@ -14,17 +14,6 @@ extern "C" { struct GroundScope; typedef struct GroundScope GroundScope; -/* - * Stores data associated with an error thrown during Ground execution. - */ -typedef struct GroundError { - char* what; - char* type; - struct GroundInstruction* where; - size_t line; - bool hasLine; -} GroundError; - // Creates a GroundValue containing (in), with type ERROR. GroundValue createErrorGroundValue(GroundError in); diff --git a/include/groundvm.h b/include/groundvm.h index 8c403d1..58bb07a 100644 --- a/include/groundvm.h +++ b/include/groundvm.h @@ -11,6 +11,7 @@ #include #include #include +#include typedef enum GroundInstType { IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND, GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, STOI, STOD, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, STRUCT, ENDSTRUCT, INIT, USE, EXTERN, CREATELABEL, PAUSE, DROP, ERRORCMD @@ -41,6 +42,17 @@ typedef struct List { struct GroundValue* values; } List; +/* + * Stores data associated with an error thrown during Ground execution. + */ +typedef struct GroundError { + char* what; + char* type; + struct GroundInstruction* where; + size_t line; + bool hasLine; +} GroundError; + /* * Stores literal values created in a Ground program. */ @@ -53,8 +65,10 @@ typedef struct GroundValue { char charVal; bool boolVal; List listVal; + GroundError errorVal; struct GroundFunction* fnVal; - void* customVal; + struct GroundStruct* structVal; + struct GroundObject* customVal; } data; } GroundValue; @@ -115,6 +129,39 @@ typedef struct GroundFunction { size_t startLine; } GroundFunction; +/* + * Field for a GroundStruct + */ +typedef struct GroundStructField { + char id[64]; + GroundValue value; + UT_hash_handle hh; +} GroundStructField; + +/* + * Represents a Ground struct. + */ +typedef struct GroundStruct { + GroundStructField* fields; + size_t size; +} GroundStruct; + +/* + * Field for a GroundObject + */ +typedef struct GroundObjectField { + char id[64]; + GroundValue value; + UT_hash_handle hh; +} GroundObjectField; + +/* + * Represents an initialised Ground struct. + */ +typedef struct GroundObject { + GroundObjectField* fields; +} GroundObject; + #ifdef __cplusplus extern "C" { #endif @@ -133,6 +180,9 @@ GroundValue groundCreateValue(GroundValueType type, ...); GroundProgram groundParseFile(const char* code); +GroundStruct groundCreateStruct(); +void groundAddFieldToStruct(GroundStruct* gstruct, char* name, GroundValue field); + #ifdef __cplusplus } #endif