#| -*-Scheme-*-
-$Id: uenvir.scm,v 14.38 1999/01/02 06:06:43 cph Exp $
+$Id: uenvir.scm,v 14.39 1999/10/23 03:01:29 cph Exp $
Copyright (c) 1988-1999 Massachusetts Institute of Technology
(define (environment-has-parent? environment)
(cond ((system-global-environment? environment)
- false)
+ #f)
((ic-environment? environment)
(ic-environment/has-parent? environment))
((stack-ccenv? environment)
(stack-ccenv/has-parent? environment))
((closure-ccenv? environment)
(closure-ccenv/has-parent? environment))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-HAS-PARENT?))))
(define (environment-parent environment)
(cond ((system-global-environment? environment)
(stack-ccenv/parent environment))
((closure-ccenv? environment)
(closure-ccenv/parent environment))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-PARENT))))
(define (environment-bound-names environment)
(cond ((system-global-environment? environment)
(stack-ccenv/bound-names environment))
((closure-ccenv? environment)
(closure-ccenv/bound-names environment))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-BOUND-NAMES))))
(define (environment-bindings environment)
(map (lambda (name)
((or (system-global-environment? environment)
(closure-ccenv? environment))
'UNKNOWN)
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-ARGUMENTS))))
(define (environment-procedure-name environment)
(let ((scode-lambda (environment-lambda environment)))
(define (environment-lambda environment)
(cond ((system-global-environment? environment)
- false)
+ #f)
((ic-environment? environment)
(ic-environment/lambda environment))
((stack-ccenv? environment)
(stack-ccenv/lambda environment))
((closure-ccenv? environment)
(closure-ccenv/lambda environment))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-LAMBDA))))
(define (environment-bound? environment name)
(cond ((interpreter-environment? environment)
(stack-ccenv/bound? environment name))
((closure-ccenv? environment)
(closure-ccenv/bound? environment name))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-BOUND?))))
(define (environment-lookup environment name)
(cond ((interpreter-environment? environment)
(stack-ccenv/lookup environment name))
((closure-ccenv? environment)
(closure-ccenv/lookup environment name))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-LOOKUP))))
(define (environment-assignable? environment name)
(cond ((interpreter-environment? environment)
- true)
+ #t)
((stack-ccenv? environment)
(stack-ccenv/assignable? environment name))
((closure-ccenv? environment)
(closure-ccenv/assignable? environment name))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-ASSIGNABLE?))))
(define (environment-assign! environment name value)
(cond ((interpreter-environment? environment)
(stack-ccenv/assign! environment name value))
((closure-ccenv? environment)
(closure-ccenv/assign! environment name value))
- (else (error "Illegal environment" environment))))
+ (else
+ (illegal-environment environment 'ENVIRONMENT-ASSIGN!))))
+
+(define (illegal-environment object procedure)
+ (error:wrong-type-argument object "environment" procedure))
\f
;;;; Interpreter Environments
(define (unbound-name? environment name)
(if (eq? name package-name-tag)
- true
+ #t
(lexical-unbound? environment name)))
\f
(define (ic-environment/arguments environment)
(define (ic-environment/remove-parent! environment)
(ic-environment/set-parent! environment null-environment))
-
;; This corresponds to the #defines in sdata.h
(define null-environment
(define (select-lambda environment)
(procedure-lambda (select-procedure environment)))
+
+(define (extend-ic-environment environment)
+ (if (not (ic-environment? environment))
+ (illegal-environment environment 'EXTEND-IC-ENVIRONMENT))
+ (let ((environment (eval '(let () (the-environment)) environment)))
+ (set-environment-syntax-table!
+ environment
+ (make-syntax-table (environment-syntax-table environment)))
+ environment))
\f
;;;; Compiled Code Environments
((ucode-primitive string->symbol)
"#[(runtime environment)stack-ccenv]"))
(conc-name stack-ccenv/))
- (block false read-only true)
- (frame false read-only true)
- (start-index false read-only true))
+ (block #f read-only #t)
+ (frame #f read-only #t)
+ (start-index #f read-only #t))
(define (stack-frame/environment frame default)
(let* ((ret-add (stack-frame/return-address frame))
\f
(define (stack-ccenv/has-parent? environment)
(if (dbg-block/parent (stack-ccenv/block environment))
- true
+ #t
'SIMULATED))
(define (stack-ccenv/parent environment)
((ucode-primitive string->symbol)
"#[(runtime environment)closure-ccenv]"))
(conc-name closure-ccenv/))
- (stack-block false read-only true)
- (closure-block false read-only true)
- (closure false read-only true))
+ (stack-block #f read-only #t)
+ (closure-block #f read-only #t)
+ (closure #f read-only #t))
(define (closure-ccenv/bound-names environment)
(map dbg-variable/name
(let ((parent (dbg-block/parent stack-block)))
(and parent
(case (dbg-block/type parent)
- ((CLOSURE) (and (dbg-block/original-parent stack-block) true))
- ((STACK IC) true)
+ ((CLOSURE) (and (dbg-block/original-parent stack-block) #t))
+ ((STACK IC) #t)
(else (error "Illegal parent block" parent))))))
'SIMULATED))
#| -*-Scheme-*-
-$Id: uenvir.scm,v 14.41 1999/01/02 06:19:10 cph Exp $
+$Id: uenvir.scm,v 14.42 1999/10/23 03:01:24 cph Exp $
Copyright (c) 1988-1999 Massachusetts Institute of Technology
(define (environment-has-parent? environment)
(cond ((system-global-environment? environment)
- false)
+ #f)
((ic-environment? environment)
(ic-environment/has-parent? environment))
((ccenv? environment)
(define (environment-lambda environment)
(cond ((system-global-environment? environment)
- false)
+ #f)
((ic-environment? environment)
(ic-environment/lambda environment))
((ccenv? environment)
(define (environment-assignable? environment name)
(cond ((interpreter-environment? environment)
- true)
+ #t)
((ccenv? environment)
(ccenv/assignable? environment name))
(else (illegal-environment environment 'ENVIRONMENT-ASSIGNABLE?))))
\f
(define (unbound-name? environment name)
(if (eq? name package-name-tag)
- true
+ #t
(lexical-unbound? environment name)))
(define (ic-environment/arguments environment)
(define (ic-environment/remove-parent! environment)
(ic-environment/set-parent! environment null-environment))
-
;; This corresponds to the `#define END_OF_CHAIN ...' in sdata.h
(define null-environment
(define (select-lambda environment)
(procedure-lambda (select-procedure environment)))
+
+(define (extend-ic-environment environment)
+ (if (not (ic-environment? environment))
+ (illegal-environment environment 'EXTEND-IC-ENVIRONMENT))
+ (let ((environment (eval '(let () (the-environment)) environment)))
+ (set-environment-syntax-table!
+ environment
+ (make-syntax-table (environment-syntax-table environment)))
+ environment))
\f
;;;; Compiled Code Environments
"#[(runtime environment)ccenv]"))
(conc-name ccenv/))
;; BLOCK is a block structure description (a DBG-BLOCK).
- (block false read-only true)
+ (block #f read-only #t)
;; ROOT is the object from which to de-reference access paths, usually a
;; STACK-FRAME or a compiled closure.
- (root false read-only true))
+ (root #f read-only #t))
(define (ccenv/has-parent? env)
(let ((block (ccenv/block env)))