Thu Jan 9 09:36:36 CET 2020


Go through the steps manually.  There are two problems: collecting the
current stack frame, and resuming it.

Resuming should probably be implemented by letting the code do
explicit pointer chasing.  E.g.  e->var1, e->var2, ....

This should probably be extended to extending environment for closures.

e->var     is current stack frame, while
e->p->var  is a variable in the parent frame

So from the point of application it is straightforward: just use
nested C structures/unions.

The trick is then to convert suspension points into nested unions.

The difference between doing this statically and dynamically is that
all continuations need to be known at compile time.  This is a serious
control flow analysis problem, and for sure doesn't work for all
programs.  What are the restrictions?

( Note: only blocking functions need to be considered here.
Non-blocking functions are treated as primitives. )

The algorithm is straightforward

- enumerate all call sites
- for each call site:
  - collect stack frame
  - recurse

This way it is ensured that recursion cannot represent loops.

Note that nested unions/structs aren't necessary because memory is
stored linearly.  The only time two pointers are needed is for
(downward) closures, but we are probably not going to use those much
because iterators probably eliminate them completely.