Skip to content

Commit

Permalink
move Hook enum
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Jul 31, 2021
1 parent b957f99 commit 9f8eefb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
14 changes: 0 additions & 14 deletions cps/hooks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ perform a late binding to by name.
]##

type
Hook* = enum ##
## these are hook procedure names; the string value matches the name
## of the symbol we'll call to perform the hook.
Coop = "coop" ## returns control to the dispatcher
Trace = "trace" ## executed at entry to each continuation leg
Alloc = "alloc" ## performs allocation of a new continuation
Dealloc = "dealloc" ## performs deallocation of a continuation
Pass = "pass" ## transfers control-flow between continuations
Boot = "boot" ## prepares a continuation for initial use
Unwind = "unwind" ## controlled "bubble-up" for exception handling
Head = "head" ## invoked when a new continuation has no parent
Tail = "tail" ## invoked when a new continuation has a parent

proc introduce*(hook: Hook; n: NormNode) =
## introduce a hook into the given scope whatfer later use therein
var n = n
Expand Down
13 changes: 13 additions & 0 deletions cps/spec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ type

ContinuationProc*[T] = proc(c: T): T {.nimcall.}

Hook* = enum ##
## these are hook procedure names; the string value matches the name
## of the symbol we'll call to perform the hook.
Coop = "coop" ## returns control to the dispatcher
Trace = "trace" ## executed at entry to each continuation leg
Alloc = "alloc" ## performs allocation of a new continuation
Dealloc = "dealloc" ## performs deallocation of a continuation
Pass = "pass" ## transfers control-flow between continuations
Boot = "boot" ## prepares a continuation for initial use
Unwind = "unwind" ## controlled "bubble-up" for exception handling
Head = "head" ## invoked when a new continuation has no parent
Tail = "tail" ## invoked when a new continuation has a parent

proc filterPragma*(ns: seq[PragmaAtom], liftee: Name): NormNode =
## given a seq of pragmas, omit a match and return Pragma or Empty
newPragmaStmt(filterIt(ns, it.getPragmaName != liftee))
Expand Down
2 changes: 1 addition & 1 deletion tests/thooks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import std/genasts
import std/macros
import std/strutils

from cps/hooks import Hook
from cps/spec import Hook

include preamble
import killer
Expand Down

0 comments on commit 9f8eefb

Please sign in to comment.