De/serialisation
It should be possible to automatically generate the Haxe de/serialisation methods for a coroutine. It should be enough to store:
- the state (CFG position + flags)
- any state-crossing locals (which are already detected anyway)
As an optimisation, only the state-crossing locals which are actually read by reachable states could be stored.
Serialisation of a coroutine that depends on a closure-captured variable should probably be forbidden as well.
but i think the big problem is local var inside they coroutine. the macro must change the mode declaration for save the local vars inside an object state
@francescoagati As I said, state-crossing locals are already detected, e.g.:
co({
var x = foo();
suspend();
trace(x);
});
Here x is declared in a state different from when it is used again. Currently such locals are all declared in a closure surrounding all three internal pecan functions (accept actions, yield actions, "normal" actions), so adding similar functions to dump all the locals into a serializer or load them from a deserializer is an easy change.