From 9f8eefbdb24ec0760f4fd0b1b461bdf49247b340 Mon Sep 17 00:00:00 2001 From: Andy Davidoff Date: Sat, 31 Jul 2021 15:26:46 -0400 Subject: [PATCH] move Hook enum --- cps/hooks.nim | 14 -------------- cps/spec.nim | 13 +++++++++++++ tests/thooks.nim | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cps/hooks.nim b/cps/hooks.nim index 4f02481e..42370882 100644 --- a/cps/hooks.nim +++ b/cps/hooks.nim @@ -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 diff --git a/cps/spec.nim b/cps/spec.nim index 15ca88a5..4708d9eb 100644 --- a/cps/spec.nim +++ b/cps/spec.nim @@ -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)) diff --git a/tests/thooks.nim b/tests/thooks.nim index 1cbcc578..ffc6bc7a 100644 --- a/tests/thooks.nim +++ b/tests/thooks.nim @@ -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