refactor: change wrenCompileSource to return ObjClosure instead of ObjFiber and inline import execution

The compileInModule function now returns a closure directly instead of wrapping it in a fiber, simplifying the compilation pipeline and removing unnecessary fiber overhead for module imports. The wrenImportModule function is moved into wren_vm.c and rewritten to execute the imported module's closure immediately rather than returning a fiber for deferred execution. This change also adds a test for yielding from an imported module to verify correct behavior with the new execution model.
This commit is contained in:
Bob Nystrom
2018-03-17 16:33:33 +00:00
parent 2bbd385f69
commit cf05cd7c8c
7 changed files with 105 additions and 104 deletions
+14
View File
@@ -0,0 +1,14 @@
var fiber = Fiber.new {
System.print("fiber 1")
import "yield_from_import_module"
System.print("fiber 2")
}
fiber.call() // expect: fiber 1
// expect: module 1
System.print("main 1") // expect: main 1
fiber.call() // expect: module 2
// expect: fiber 2
System.print("main 2") // expect: main 2
@@ -0,0 +1,4 @@
// nontest
System.print("module 1")
Fiber.yield()
System.print("module 2")