bug fixes
This commit is contained in:
@@ -32,12 +32,7 @@ GroundFunction _GroundCopyFunction(GroundFunction* in) {
|
|||||||
return newFunction;
|
return newFunction;
|
||||||
}
|
}
|
||||||
for (GroundSize i = 0; i < in->args.count; i++) {
|
for (GroundSize i = 0; i < in->args.count; i++) {
|
||||||
if (newFunction.args.at == NULL) {
|
newFunction.args.at[i].as.id = Ground.Copy.Identifier(in->args.at[i].as.id);
|
||||||
Ground.Log.Error("malloc failed in Ground.Copy.Function()");
|
|
||||||
Ground.Flags.error = true;
|
|
||||||
return newFunction;
|
|
||||||
}
|
|
||||||
newFunction.args.at->as.id = Ground.Copy.Identifier(in->args.at[i].as.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newFunction;
|
return newFunction;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ void _GroundFreeFunction(GroundFunction* in) {
|
|||||||
free(in->program.ground);
|
free(in->program.ground);
|
||||||
|
|
||||||
for (GroundSize i = 0; i < in->args.count; i++) {
|
for (GroundSize i = 0; i < in->args.count; i++) {
|
||||||
free(in->args.at[i].as.id);
|
Ground.Free.Identifier(in->args.at[i].as.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "../../include/ground.h"
|
#include "../../include/ground.h"
|
||||||
|
|
||||||
void _GroundFunctionAppendArg(GroundFunction* function, GroundIdentifier* argName) {
|
void _GroundFunctionAppendArg(GroundFunction* function, const char* argName) {
|
||||||
if (function->isNativeFunction) {
|
if (function->isNativeFunction) {
|
||||||
Ground.Log.Error("Cannot add arg to native function in Ground.Function.appendArg()");
|
Ground.Log.Error("Cannot add arg to native function in Ground.Function.appendArg()");
|
||||||
Ground.Flags.error = true;
|
Ground.Flags.error = true;
|
||||||
@@ -18,6 +18,6 @@ void _GroundFunctionAppendArg(GroundFunction* function, GroundIdentifier* argNam
|
|||||||
function->args.capacity *= 2;
|
function->args.capacity *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
function->args.at[function->args.count].as.id = Ground.Copy.Identifier(argName);
|
function->args.at[function->args.count].as.id = Ground.New.Identifier(argName);
|
||||||
function->args.count++;
|
function->args.count++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ GroundProgram _GroundProgramPreprocess(GroundProgram* program, GroundState* stat
|
|||||||
GroundInstruction* sig = &program->at[i];
|
GroundInstruction* sig = &program->at[i];
|
||||||
char* id = sig->args.at[0].as.ref->string;
|
char* id = sig->args.at[0].as.ref->string;
|
||||||
|
|
||||||
for (GroundSize j = 1; i < sig->args.len - 1; i++) {
|
for (GroundSize j = 1; j < sig->args.len; j++) {
|
||||||
GroundArg* arg = &sig->args.at[j];
|
GroundArg* arg = &sig->args.at[j];
|
||||||
|
|
||||||
// Ignore type annotations, this can be taken care of in another function
|
// Ignore type annotations, this can be taken care of in another function
|
||||||
@@ -23,6 +23,16 @@ GroundProgram _GroundProgramPreprocess(GroundProgram* program, GroundState* stat
|
|||||||
}
|
}
|
||||||
char* argId = arg->as.ref->string;
|
char* argId = arg->as.ref->string;
|
||||||
Ground.Function.appendArg(&function, argId);
|
Ground.Function.appendArg(&function, argId);
|
||||||
|
|
||||||
|
GroundVariable* argVar = malloc(sizeof(GroundVariable));
|
||||||
|
if (argVar == NULL) {
|
||||||
|
Ground.Flags.error = true;
|
||||||
|
Ground.Log.Error("malloc failed in Ground.Program.Preprocess");
|
||||||
|
return newProgram;
|
||||||
|
}
|
||||||
|
snprintf(argVar->name, 2047, "%s", argId);
|
||||||
|
argVar->value = Ground.New.Value.Int(0);
|
||||||
|
HASH_ADD_STR(function.closure->variables, name, argVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add instructions to function
|
// Add instructions to function
|
||||||
|
|||||||
Reference in New Issue
Block a user