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

@@ -11,6 +11,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#include <uthash.h>
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