cool stuff

This commit is contained in:
2026-06-15 20:27:50 +10:00
parent 284b08b12a
commit 80140ed798
41 changed files with 470 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ GroundArg _GroundNewArgDirectRef(const char* ref) {
char* copy = malloc(len + 1);
if (copy == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Arg.DirectRef()");
Ground.Flags.error = true;
return (GroundArg) {
.type = GroundArg_DirectRef,

View File

@@ -8,6 +8,7 @@ GroundArg _GroundNewArgFunctionRef(const char* ref) {
char* copy = malloc(len + 1);
if (copy == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Arg.FunctionRef()");
Ground.Flags.error = true;
return (GroundArg) {
.type = GroundArg_DirectRef,

View File

@@ -8,6 +8,7 @@ GroundArg _GroundNewArgLabelRef(const char* ref) {
char* copy = malloc(len + 1);
if (copy == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Arg.LabelRef()");
Ground.Flags.error = true;
return (GroundArg) {
.type = GroundArg_DirectRef,

View File

@@ -8,6 +8,7 @@ GroundArg _GroundNewArgLineRef(const char* ref) {
char* copy = malloc(len + 1);
if (copy == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Arg.LineRef()");
Ground.Flags.error = true;
return (GroundArg) {
.type = GroundArg_DirectRef,

View File

@@ -8,6 +8,7 @@ GroundArg _GroundNewArgTypeRef(const char* ref) {
char* copy = malloc(len + 1);
if (copy == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Arg.TypeRef()");
Ground.Flags.error = true;
return (GroundArg) {
.type = GroundArg_DirectRef,

View File

@@ -2,7 +2,7 @@
GroundArg _GroundNewArgValue(GroundValue value) {
return (GroundArg) {
.type = GroundArg_DirectRef,
.type = GroundArg_Value,
.as.value = Ground.Copy.Value(&value)
};
}

View File

@@ -8,6 +8,7 @@ GroundArg _GroundNewArgValueRef(const char* ref) {
char* copy = malloc(len + 1);
if (copy == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Arg.ValueRef()");
Ground.Flags.error = true;
return (GroundArg) {
.type = GroundArg_DirectRef,

View File

@@ -6,6 +6,7 @@ GroundError _GroundNewError(GroundValue* in) {
};
if (error.value == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Error()");
Ground.Flags.error = true;
return error;
}

View File

@@ -11,6 +11,7 @@ GroundInstruction _GroundNewInstruction(enum GroundInstructionType type) {
};
if (instruction.args.at == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Instruction()");
Ground.Flags.error = true;
}
return instruction;

View File

@@ -8,6 +8,7 @@ GroundList _GroundNewList(size_t len, GroundValue* contents) {
};
if (list.at == NULL) {
Ground.Log.Error("malloc failed in Ground.New.List()");
Ground.Flags.error = true;
}

View File

@@ -16,6 +16,7 @@ GroundFunction _GroundNewNativeFunction(void* function, size_t argc, ...) {
for (size_t i = 0; i < argc; i++) {
GroundType type = va_arg(args, GroundType);
if (type.type == GroundType_Struct) {
Ground.Log.Error("Cannot pass struct to native function in Ground.New.NativeFunction()");
Ground.Flags.error = true;
return gf;
}
@@ -23,6 +24,7 @@ GroundFunction _GroundNewNativeFunction(void* function, size_t argc, ...) {
if (type.type == GroundType_Object) {
// WIP
Ground.Flags.error = true;
Ground.Log.Error("[WIP] Cannot pass object to native function in Ground.New.NativeFunction()");
return gf;
}
@@ -30,6 +32,7 @@ GroundFunction _GroundNewNativeFunction(void* function, size_t argc, ...) {
if (gf.args.count + 1 >= gf.args.capacity) {
GroundFunctionArg* tmp = realloc(gf.args.at, sizeof(GroundFunctionArg) * gf.args.capacity * 2);
if (tmp == NULL) {
Ground.Log.Error("malloc failed in Ground.New.NativeFunction()");
Ground.Flags.error = true;
return gf;
}

View File

@@ -15,6 +15,7 @@ GroundObject _GroundNewObject(GroundStruct* in) {
item = malloc(sizeof(GroundObjectField));
if (item == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Object()");
Ground.Flags.error = true;
return object;
}

View File

@@ -8,6 +8,7 @@ GroundProgram _GroundNewProgram() {
};
if (newProgram.at == NULL) {
Ground.Log.Error("malloc failed in Ground.New.Program()");
Ground.Flags.error = true;
}
return newProgram;

View File

@@ -10,6 +10,7 @@ GroundString _GroundNewString(const char* in) {
};
if (string.cstr == NULL) {
Ground.Log.Error("malloc failed in Ground.New.String()");
Ground.Flags.error = true;
string.len = 0;
return string;