From e9af6a926c530f299a78d0a1345e7e7a1b0a79b3 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 18 Dec 2001 19:35:50 +0000 Subject: [PATCH] Guarantee that source binding of an import is defined. Source binding of an export is always defined by the package description. --- v7/src/runtime/packag.scm | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/v7/src/runtime/packag.scm b/v7/src/runtime/packag.scm index d6bb9f716..3a3fa5e81 100644 --- a/v7/src/runtime/packag.scm +++ b/v7/src/runtime/packag.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: packag.scm,v 14.36 2001/12/17 17:40:59 cph Exp $ +$Id: packag.scm,v 14.37 2001/12/18 19:35:50 cph Exp $ Copyright (c) 1988-1999, 2001 Massachusetts Institute of Technology @@ -379,12 +379,15 @@ USA. (do ((i 0 (fix:+ i 1))) ((fix:= i n)) (let ((binding (vector-ref bindings i))) - (link-variables environment - (vector-ref binding 0) - (find-package-environment (vector-ref binding 1)) - (if (fix:= (vector-length binding) 3) - (vector-ref binding 2) - (vector-ref binding 0))))))))) + (let ((source-environment + (find-package-environment (vector-ref binding 1))) + (source-name + (if (fix:= (vector-length binding) 3) + (vector-ref binding 2) + (vector-ref binding 0)))) + (guarantee-binding source-environment source-name) + (link-variables environment (vector-ref binding 0) + source-environment source-name)))))))) (define (extend-package-environment environment . name-sources) (let ((n @@ -427,8 +430,18 @@ USA. (define (find-package-environment name) (package/environment (find-package name))) +(define (guarantee-binding environment name) + (if (lexical-unbound? environment name) + (local-assignment environment + name + (primitive-object-set-type (ucode-type reference-trap) + 0)))) + (define-primitives - link-variables) + lexical-unbound? + link-variables + local-assignment + primitive-object-set-type) ;; LOAD-PACKAGES-FROM-FILE is called from the cold load and must only ;; use procedures that are inline-coded by the compiler. -- 2.25.1