From cdd59dee8834331aded27913e0ce2e85461c4d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 6 Sep 2020 01:46:23 +0200 Subject: Add filter-stack. --- module/calp/util/exceptions.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/module/calp/util/exceptions.scm b/module/calp/util/exceptions.scm index 29e1472c..53d9475d 100644 --- a/module/calp/util/exceptions.scm +++ b/module/calp/util/exceptions.scm @@ -3,6 +3,10 @@ #:use-module (calp util) #:use-module (calp util config) #:use-module (ice-9 format) + + #:use-module ((system vm frame) + :select (frame-bindings binding-ref)) + #:export (throw-returnable catch-multiple assert)) @@ -93,3 +97,9 @@ (lambda () body ...) (lambda _ default)))))) + + +(define-public (filter-stack pred? stk) + (concatenate + (for i in (iota (stack-length stk)) + (filter pred? (map binding-ref (frame-bindings (stack-ref stk i))))))) -- cgit v1.2.3