refactor: move global variable storage from VM into Module struct

Functions now hold a reference to the module where they were defined and load module-level variables from there instead of from the VM's global table. This introduces a new Module struct with its own variable buffer and symbol table, replacing the VM-level globals and globalNames. The main module is stored directly in the VM as a temporary measure. Performance regresses slightly due to the indirection through the function's module pointer.
This commit is contained in:
Bob Nystrom
2015-01-26 15:45:21 +00:00
parent bee26d2ab2
commit a794ce4ee1
9 changed files with 175 additions and 132 deletions
+2
View File
@@ -93,6 +93,8 @@ void wrenFreeVM(WrenVM* vm);
WrenInterpretResult wrenInterpret(WrenVM* vm, const char* sourcePath,
const char* source);
// TODO: Figure out how these interact with modules.
// Defines a foreign method implemented by the host application. Looks for a
// global class named [className] to bind the method to. If not found, it will
// be created automatically.