Initial commit
This commit is contained in:
29
src/Function/appendArg.c
Normal file
29
src/Function/appendArg.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "../../include/ground.h"
|
||||
#include <string.h>
|
||||
|
||||
void _GroundFunctionAppendArg(GroundFunction* function, const char* argName) {
|
||||
if (function->isNativeFunction) {
|
||||
Ground.Flags.error = true;
|
||||
return;
|
||||
}
|
||||
if (function->args.count + 1 >= function->args.capacity) {
|
||||
GroundFunctionArg* tmp = realloc(function->args.at, sizeof(GroundFunctionArg) * function->args.capacity * 2);
|
||||
if (tmp == NULL) {
|
||||
Ground.Flags.error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
function->args.at = tmp;
|
||||
function->args.capacity *= 2;
|
||||
}
|
||||
|
||||
size_t len = strlen(argName);
|
||||
function->args.at[function->args.count].as.id = malloc(sizeof(char) * (len + 1));
|
||||
if (function->args.at[function->args.count].as.id == NULL) {
|
||||
Ground.Flags.error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(function->args.at[function->args.count].as.id, argName);
|
||||
function->args.count++;
|
||||
}
|
||||
9
src/Function/appendInstruction.c
Normal file
9
src/Function/appendInstruction.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundFunctionAppendInstruction(GroundFunction* function, GroundInstruction instruction) {
|
||||
if (function->isNativeFunction) {
|
||||
Ground.Flags.error = true;
|
||||
return;
|
||||
}
|
||||
Ground.Program.append(function->program.ground, instruction);
|
||||
}
|
||||
Reference in New Issue
Block a user