forked from ground/cground
Fix bug for functions inside functions
This commit is contained in:
@@ -272,7 +272,7 @@ GroundFunction* parseFunction(GroundProgram* in, size_t errorOffset) {
|
||||
}
|
||||
}
|
||||
i++;
|
||||
while (in->instructions[i].type != ENDFUN) {
|
||||
while (i < in->size) {
|
||||
addInstructionToProgram(&function->program, in->instructions[i]);
|
||||
i++;
|
||||
}
|
||||
@@ -445,37 +445,6 @@ GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope) {
|
||||
GroundValue gv = createFunctionGroundValue(parseFunction(&gp, errorOffset));
|
||||
|
||||
addVariable(scope.variables, name, gv);
|
||||
/*
|
||||
char* functionName = in->instructions[i].args.args[0].value.refName;
|
||||
if (in->instructions[i].args.length < 2) {
|
||||
function->returnType = NONE;
|
||||
} else {
|
||||
if (in->instructions[i].args.args[1].type != TYPEREF) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a TypeRef for arg 2", &in->instructions[i], i);
|
||||
}
|
||||
GroundArg* args = in->instructions[i].args.args;
|
||||
function->returnType = stringToValueType(args[1].value.refName);
|
||||
size_t length = in->instructions[i].args.length;
|
||||
for (size_t j = 2; j < length; j += 2) {
|
||||
if (args[j].type != TYPEREF) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a TypeRef", &in->instructions[i], i);
|
||||
}
|
||||
if (j + 1 >= length) {
|
||||
runtimeError(TOO_FEW_ARGS, "Expecting a DirectRef after a TypeRef", &in->instructions[i], i);
|
||||
}
|
||||
if (args[j + 1].type != DIRREF) {
|
||||
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef after a TypeRef", &in->instructions[i], i);
|
||||
}
|
||||
addArgsToGroundFunction(function, stringToValueType(args[j].value.refName), args[j + 1].value.refName);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
while (in->instructions[i].type != ENDFUN) {
|
||||
addInstructionToProgram(&function->program, in->instructions[i]);
|
||||
i++;
|
||||
}
|
||||
addVariable(scope.variables, functionName, createFunctionGroundValue(function));
|
||||
*/
|
||||
}
|
||||
if (in->instructions[i].type == STRUCT) {
|
||||
if (in->instructions[i].args.length < 1) {
|
||||
|
||||
Reference in New Issue
Block a user