1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
;; -*-theme-d-*-
;; Copyright (C) 2018, 2020, 2021 Tommi Höynälänmaa
;; Distributed under GNU Lesser General Public License version 3,
;; see file doc/LGPL-3.
;; This module is imported by the core interface so we can't import it here.
(define-interface (standard-library platform-specific-impl)
(import (standard-library core-forms))
(declare raise (:simple-proc (<object>) <none> (pure never-returns)))
(define-syntax guard-general
(syntax-rules ()
((_ variable handler body)
(call/cc
(lambda-automatic
(((jump (:procedure
((static-type-of
(let ((variable (static-cast <object> null)))
handler)))
<none> (pure never-returns))))
(pure))
(with-exception-handler
(lambda (((variable <object>)) <none> (pure never-returns))
(jump handler))
(lambda-automatic (() pure)
body)))))))
(define-syntax guard-general-nonpure
(syntax-rules ()
((_ variable handler body)
(call/cc-nonpure
(lambda-automatic
(((jump (:procedure
((static-type-of
(let ((variable (static-cast <object> null)))
handler)))
<none> (pure never-returns))))
(nonpure))
(with-exception-handler-nonpure
(lambda (((variable <object>)) <none> (nonpure never-returns))
(jump handler))
(lambda-automatic (() nonpure)
body)))))))
(define-syntax guard-general-without-result
(syntax-rules ()
((_ variable handler body)
(call/cc-without-result
(lambda-automatic
(((jump (:procedure () <none> (pure never-returns))))
(nonpure))
(with-exception-handler-nonpure
(lambda (((variable <object>)) <none> (nonpure never-returns))
handler
(jump))
(lambda (() <none> nonpure)
body))))))))
|