forked from ground/ground
Closures in Ground
This commit is contained in:
21
src/types.c
21
src/types.c
@@ -709,3 +709,24 @@ bool checkTypes(GroundValue* left, GroundValue* right) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GroundScope copyGroundScope(GroundScope* scope) {
|
||||
GroundScope newScope = {
|
||||
.labels = malloc(sizeof(GroundLabel*)),
|
||||
.variables = malloc(sizeof(GroundVariable*)),
|
||||
.isMainScope = false
|
||||
};
|
||||
*newScope.variables = NULL;
|
||||
*newScope.labels = NULL;
|
||||
|
||||
if (scope == NULL) {
|
||||
printf("oh no scope is null\n");
|
||||
}
|
||||
|
||||
GroundVariable *var, *tmp = NULL;
|
||||
HASH_ITER(hh, *scope->variables, var, tmp) {
|
||||
addVariable(newScope.variables, var->id, var->value);
|
||||
}
|
||||
|
||||
return newScope;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user