Balright time to break master again

This commit is contained in:
2026-01-20 21:17:08 +11:00
parent 08b1edd7a7
commit 792aed13ae
2 changed files with 51 additions and 12 deletions

View File

@@ -14,17 +14,6 @@ extern "C" {
struct GroundScope; struct GroundScope;
typedef struct GroundScope 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. // Creates a GroundValue containing (in), with type ERROR.
GroundValue createErrorGroundValue(GroundError in); GroundValue createErrorGroundValue(GroundError in);

View File

@@ -11,6 +11,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <uthash.h>
typedef enum GroundInstType { 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 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; struct GroundValue* values;
} List; } 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. * Stores literal values created in a Ground program.
*/ */
@@ -53,8 +65,10 @@ typedef struct GroundValue {
char charVal; char charVal;
bool boolVal; bool boolVal;
List listVal; List listVal;
GroundError errorVal;
struct GroundFunction* fnVal; struct GroundFunction* fnVal;
void* customVal; struct GroundStruct* structVal;
struct GroundObject* customVal;
} data; } data;
} GroundValue; } GroundValue;
@@ -115,6 +129,39 @@ typedef struct GroundFunction {
size_t startLine; size_t startLine;
} GroundFunction; } 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 #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -133,6 +180,9 @@ GroundValue groundCreateValue(GroundValueType type, ...);
GroundProgram groundParseFile(const char* code); GroundProgram groundParseFile(const char* code);
GroundStruct groundCreateStruct();
void groundAddFieldToStruct(GroundStruct* gstruct, char* name, GroundValue field);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif