refactor: move module load failure handling from Wren to C with error string return

The loadModule_ primitive now returns NULL for already-loaded modules and an error string for missing modules, shifting the error handling from Wren's Fiber.abort to C's native string return. The Wren import_ method simplifies to only call the result when non-null, removing the false/true branching logic.
This commit is contained in:
Bob Nystrom
2015-02-16 18:12:41 +00:00
parent ea958deeef
commit f2424f029e
3 changed files with 14 additions and 13 deletions
+1 -5
View File
@@ -61,11 +61,7 @@ class Sequence {
class String is Sequence {
import_(variable) {
var result = loadModule_
if (result == false) {
Fiber.abort("Could not find module '" + this + "'.")
} else if (result != true) {
result.call
}
if (result != null) result.call
return lookUpVariable_(variable)
}