Move globals out of VM and into a Module struct.

Functions store a reference to the module where they were
defined and load "module" variables from there.

Right now there's only one "main" module, but this is a step
in the right direction. Perf is down, though. :(

binary_trees - wren            ..........  3026  0.33s   88.28% relative to baseline
delta_blue - wren              ..........  7248  0.14s   94.32% relative to baseline
fib - wren                     ..........  2414  0.41s   88.08% relative to baseline
for - wren                     ..........  6753  0.15s   78.79% relative to baseline
method_call - wren             ..........  6624  0.15s  100.03% relative to baseline
This commit is contained in:
Bob Nystrom
2015-01-26 07:45:21 -08:00
parent ed8e595f54
commit b3f556adba
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.