forked from Mirror/wren
Move running the module fiber into C.
This commit is contained in:
@ -60,9 +60,7 @@ class Sequence {
|
||||
|
||||
class String is Sequence {
|
||||
import_(variable) {
|
||||
var result = loadModule_
|
||||
if (result != null) result.call
|
||||
|
||||
loadModule_
|
||||
return lookUpVariable_(variable)
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,9 +103,7 @@ static const char* libSource =
|
||||
"\n"
|
||||
"class String is Sequence {\n"
|
||||
" import_(variable) {\n"
|
||||
" var result = loadModule_\n"
|
||||
" if (result != null) result.call\n"
|
||||
"\n"
|
||||
" loadModule_\n"
|
||||
" return lookUpVariable_(variable)\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
@ -1308,6 +1306,13 @@ DEF_NATIVE(string_loadModule)
|
||||
// If it returned a string, it was an error message.
|
||||
if (IS_STRING(args[0])) return PRIM_ERROR;
|
||||
|
||||
// If it returned a fiber, we want to call it.
|
||||
if (IS_FIBER(args[0]))
|
||||
{
|
||||
AS_FIBER(args[0])->caller = fiber;
|
||||
return PRIM_RUN_FIBER;
|
||||
}
|
||||
|
||||
return PRIM_VALUE;
|
||||
}
|
||||
|
||||
|
||||
@ -455,6 +455,9 @@ typedef struct
|
||||
// Returns true if [value] is a closure.
|
||||
#define IS_CLOSURE(value) (wrenIsObjType(value, OBJ_CLOSURE))
|
||||
|
||||
// Returns true if [value] is a fiber.
|
||||
#define IS_FIBER(value) (wrenIsObjType(value, OBJ_FIBER))
|
||||
|
||||
// Returns true if [value] is a function object.
|
||||
#define IS_FN(value) (wrenIsObjType(value, OBJ_FN))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user