function args

This commit is contained in:
2026-07-04 11:32:36 +10:00
parent d708e2e46f
commit 00428a0bdf

View File

@@ -31,7 +31,7 @@ static inline GroundBytecodeFunction doFunction(GroundFunction* function) {
} }
// Create a state with function paramaters as first things inside state // Create a state with function paramaters as first things inside state
GroundState state = {NULL, NULL, NULL, 0}; GroundState state = {NULL, NULL, NULL, bf.args.count};
for (GroundSize i = 0; i < bf.args.count; i++) { for (GroundSize i = 0; i < bf.args.count; i++) {
GroundVariable* var = malloc(sizeof(GroundVariable)); GroundVariable* var = malloc(sizeof(GroundVariable));
if (var == NULL) { if (var == NULL) {
@@ -40,6 +40,7 @@ static inline GroundBytecodeFunction doFunction(GroundFunction* function) {
return bf; return bf;
} }
snprintf(var->name, 2047, "%s", function->args.at[i].as.id->string); snprintf(var->name, 2047, "%s", function->args.at[i].as.id->string);
var->_offset = i;
HASH_ADD_STR(state.variables, name, var); HASH_ADD_STR(state.variables, name, var);
} }