The Env(ironment) tracks continuation types and the variables of which they are comprised.
Procs
proc createContinuation(e: Env; name: Name; goto: NimNode): NimNode {. ...raises: [], tags: [], forbids: [].}
- allocate a continuation as name and maybe aim it at the leg goto Source Edit
proc createRecover(env: Env; exported = false): NimNode {....raises: [ValueError], tags: [], forbids: [].}
-
define procedures for retrieving the result of a continuation
exported determines whether these procedures will be exported
Source Edit proc genException(e: var Env): NimNode {....raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
-
generates a new symbol of type ref Exception, then put it in the env.
returns the access to the exception symbol from the env.
Source Edit proc localSection(e: var Env; n: IdentDef; into: NimNode = nil) {. ...raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
- consume nnkIdentDefs and populate into with assignments, even if into is nil, the n will be cached locally Source Edit
proc localSection(e: var Env; n: RoutineParam; into: NimNode = nil) {.borrow, ...raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
- consume proc definition params and yield name, node pairs representing assignments to local scope. Source Edit
proc localSection(e: var Env; n: VarLet; into: NimNode = nil) {. ...raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
- consume a var|let section and yield name, node pairs representing assignments to local scope Source Edit
proc newEnv(c: Name; store: var NormNode; via: Name; rs: NormNode; procedure: string): Env {....raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
- the initial version of the environment; c names the first parameter of continuations, store is where we add types and procedures, via is the type from which we inherit, rs is the return type (if not nnkEmpty) of the continuation. Source Edit