now variables can access the global scope
This commit is contained in:
@@ -9,6 +9,7 @@ typedef struct {
|
||||
Runtime *runtime;
|
||||
Executable *exe;
|
||||
int index, argc;
|
||||
Object *globals;
|
||||
} FunctionObject;
|
||||
|
||||
static Object *call(Object *self, Object **argv, unsigned int argc, Heap *heap, Error *error);
|
||||
@@ -73,7 +74,7 @@ static Object *call(Object *self, Object **argv, unsigned int argc, Heap *heap,
|
||||
// The right amount of arguments was provided.
|
||||
argv2 = argv;
|
||||
|
||||
Object *result = run(func->runtime, error, func->exe, func->index, argv2, expected_argc);
|
||||
Object *result = run(func->runtime, error, func->exe, func->index, func->globals, 0, argv2, expected_argc);
|
||||
|
||||
if(argv2 != argv)
|
||||
free(argv2);
|
||||
@@ -81,7 +82,7 @@ static Object *call(Object *self, Object **argv, unsigned int argc, Heap *heap,
|
||||
return result;
|
||||
}
|
||||
|
||||
Object *Object_FromNojaFunction(Runtime *runtime, Executable *exe, int index, int argc, Heap *heap, Error *error)
|
||||
Object *Object_FromNojaFunction(Runtime *runtime, Executable *exe, int index, int argc, Object *globals, Heap *heap, Error *error)
|
||||
{
|
||||
assert(runtime != NULL);
|
||||
assert(exe != NULL);
|
||||
@@ -107,6 +108,7 @@ Object *Object_FromNojaFunction(Runtime *runtime, Executable *exe, int index, in
|
||||
func->exe = exe_copy;
|
||||
func->index = index;
|
||||
func->argc = argc;
|
||||
func->globals = globals;
|
||||
|
||||
return (Object*) func;
|
||||
}
|
||||
Reference in New Issue
Block a user