2007-10-25 16:27:34 -04:00
|
|
|
;;; Ikarus Scheme -- A compiler for R6RS Scheme.
|
2008-01-29 00:34:34 -05:00
|
|
|
;;; Copyright (C) 2006,2007,2008 Abdulaziz Ghuloum
|
2007-10-25 16:27:34 -04:00
|
|
|
;;;
|
|
|
|
;;; This program is free software: you can redistribute it and/or modify
|
|
|
|
;;; it under the terms of the GNU General Public License version 3 as
|
|
|
|
;;; published by the Free Software Foundation.
|
|
|
|
;;;
|
|
|
|
;;; This program is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
;;; General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2006-12-19 12:15:36 -05:00
|
|
|
|
2006-12-24 04:20:16 -05:00
|
|
|
;;; The procedure make-guardian is coped en verbatim
|
|
|
|
;;; from Dybvig et al. Guardians paper.
|
|
|
|
|
2007-04-30 00:33:22 -04:00
|
|
|
(library (ikarus guardians)
|
2007-05-05 03:03:50 -04:00
|
|
|
(export make-guardian)
|
|
|
|
(import (except (ikarus) make-guardian))
|
|
|
|
(define make-guardian
|
2006-12-19 12:15:36 -05:00
|
|
|
(lambda ()
|
|
|
|
(let ([tc
|
|
|
|
(let ([x (cons #f #f)])
|
|
|
|
(cons x x))])
|
|
|
|
(case-lambda
|
|
|
|
[()
|
|
|
|
(and (not (eq? (car tc) (cdr tc)))
|
|
|
|
(let ([x (car tc)])
|
|
|
|
(let ([y (car x)])
|
|
|
|
(set-car! tc (cdr x))
|
|
|
|
(set-car! x #f)
|
|
|
|
(set-cdr! x #f)
|
|
|
|
y)))]
|
|
|
|
[(obj)
|
2007-09-01 01:12:42 -04:00
|
|
|
(foreign-call "ikrt_register_guardian_pair" (cons tc obj))
|
2007-04-30 00:33:22 -04:00
|
|
|
(void)])))))
|