feat: split core module from main and add implicit core imports for all modules
Extract core module loading into separate `loadIntoCore` function and `getCoreModule` helper, replacing the old `getMainModule`. Implement `loadModule` that automatically imports all core module variables into every newly loaded module, enabling implicit visibility of core types (Bool, Class, Fiber, etc.) across all user modules. Add `wrenImportModule` public API for module loading with circular import detection. Increase `WREN_MAX_TEMP_ROOTS` from 4 to 5 to accommodate additional GC roots during module loading. Add test cases for cyclic imports (a.wren/b.wren) and implicit core imports (implicitly_imports_core.wren/module.wren).
This commit is contained in:
+7
-2
@@ -109,8 +109,13 @@ void wrenFreeVM(WrenVM* vm);
|
||||
// Runs [source], a string of Wren source code in a new fiber in [vm].
|
||||
//
|
||||
// [sourcePath] is a string describing where [source] was located, for use in
|
||||
// debugging stack traces. It must not be `null`. If an empty string, it will
|
||||
// not be shown in a stack trace.
|
||||
// debugging stack traces. It must not be `null`.
|
||||
//
|
||||
// If it's an empty string, then [source] is considered part of the "core"
|
||||
// module. Any module-level names defined in it will be implicitly imported by
|
||||
// another other modules. This also means runtime errors in its code will be
|
||||
// omitted from stack traces (to avoid confusing users with core library
|
||||
// implementation details).
|
||||
WrenInterpretResult wrenInterpret(WrenVM* vm, const char* sourcePath,
|
||||
const char* source);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user