Marshal alive fibers in func envs as detached.
This will help with marshaling fibers.
@@ -184,6 +184,13 @@ static void marshal_one_env(MarshalState *st, JanetFuncEnv *env, int flags) {
}
}
janet_v_push(st->seen_envs, env);
+ if (env->offset && (JANET_STATUS_ALIVE == janet_fiber_status(env->as.fiber))) {
+ pushint(st, 0);
+ pushint(st, env->length);
+ Janet *values = env->as.fiber->data + env->offset;
+ for (int32_t i = 0; i < env->length; i++)
+ marshal_one(st, values[i], flags + 1);
+ } else {
janet_env_maybe_detach(env);
pushint(st, env->offset);
pushint(st, env->length);
@@ -196,6 +203,7 @@ static void marshal_one_env(MarshalState *st, JanetFuncEnv *env, int flags) {
marshal_one(st, env->as.values[i], flags + 1);
}
}
+}
/* Add function flags to janet functions */
static void janet_func_addflags(JanetFuncDef *def) {
