mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
19 lines
447 B
Swift
19 lines
447 B
Swift
// FIXME: Function types don't work yet as generic parameters
|
|
struct REPLExitHandler {
|
|
var f : () -> ()
|
|
}
|
|
|
|
var replExitHandlers : Vector<REPLExitHandler> = Vector<REPLExitHandler>()
|
|
|
|
func atREPLExit(handler:() -> ()) {
|
|
replExitHandlers.append(REPLExitHandler(handler))
|
|
}
|
|
|
|
func replExit() {
|
|
while replExitHandlers.length > 0 {
|
|
var handler = replExitHandlers[replExitHandlers.length-1]
|
|
replExitHandlers.popBack()
|
|
handler.f()
|
|
}
|
|
}
|