Thomas /kits/scc/scc-specific.sc

Language Lisp Lines 218
MD5 Hash 170b36eebd4b246e034dd7fbc4f48d21 Estimated Cost $2,738 (why?)
Repository git://github.com/pablomarx/Thomas.git View Raw File View Project SPDX
  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
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
;*              Copyright 1992 Digital Equipment Corporation
;*                         All Rights Reserved
;*
;* Permission to use, copy, and modify this software and its documentation is
;* hereby granted only under the following terms and conditions.  Both the
;* above copyright notice and this permission notice must appear in all copies
;* of the software, derivative works or modified versions, and any portions
;* thereof, and both notices must appear in supporting documentation.
;*
;* Users of this software agree to the terms and conditions set forth herein,
;* and hereby grant back to Digital a non-exclusive, unrestricted, royalty-free
;* right and license under any changes, enhancements or extensions made to the
;* core functions of the software, including but not limited to those affording
;* compatibility with other hardware or software environments, but excluding
;* applications which incorporate this software.  Users further agree to use
;* their best efforts to return to Digital any such changes, enhancements or
;* extensions that they make and inform Digital of noteworthy uses of this
;* software.  Correspondence should be provided to Digital at:
;*
;*			Director, Cambridge Research Lab
;*			Digital Equipment Corp
;*			One Kendall Square, Bldg 700
;*			Cambridge MA 02139
;*
;* This software may be distributed (but not offered for sale or transferred
;* for compensation) to third parties, provided such third parties agree to
;* abide by the terms and conditions of this notice.
;*
;* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
;* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
;* MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
;* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
;* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
;* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
;* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
;* SOFTWARE.

; $Id: scc-specific.scm,v 1.16 1992/09/23 15:35:25 birkholz Exp $

;;; This file contains the definitions of all functions used in the
;;; implementation of Dylan which aren't part of R4RS.

(module sccspecific)

;;;; Populations

;(load "aftergc.sc")
;(load "poplat.sc")

;;;; Hash tables that use weak links for objects

;(load "hash.sc")

;;;; Record package

;(load "record.sc")

;;;; Compiler's error procedure.

(define (dylan::error string . args)
  (error 'dylan::error (string-append string ": ~A") args))

;;;; Load-up

(define (dylan::load string)
  (load (string-append string ".scm")))

(define (implementation-specific:generate-file in-exprs out-expr)
  (define (print x) (newline) (display x))
  (print ";;;; Compiled output:")
  (print "")
  (print "(module dylan-compiled-code)")
  (print "")
  (pp out-expr)
  (newline))

;;;; Eval

(define (implementation-specific:eval expression)
  (eval expression))

;;;; Interface between Dylan condition system (runtime-exceptions.scm) and
;;;; native condition system.

(define *dylan-handlers* (list))
(define *scc-error-handler* *error-handler*)
(define scc-error-tag (list 'scc 'error))

(define (implementation-specific:push-handler
	 type function test description thunk)
  (dynamic-wind
   (lambda ()
     (set! *dylan-handlers* (cons (list type function test description)
				  *dylan-handlers*)))
   thunk
   (lambda ()
     (set! *dylan-handlers* (cdr *dylan-handlers*)))))

(define (implementation-specific:get-dylan-handler-frames)
  *dylan-handlers*)

(define (implementation-specific:enter-debugger dylan-condition)
  (*scc-error-handler*
   'enter-debugger "Dylan condition ~A" dylan-condition))

(define (implementation-specific:induce-error format-string format-args)
  (*scc-error-handler* 'induce-error
		       (string-append format-string ": ~A")
		       format-args))

(define (implementation-specific:induce-type-error value class-name)
  (*scc-error-handler*
   'induce-type-error "Type error. ~A not of type ~A."
   value class-name))

(define (implementation-specific:signal-unhandled-dylan-condition
	 dylan-condition)
  (*scc-error-handler*
   'signal-unhandled-dylan-condition "Dylan condition ~A" dylan-condition))

(define (implementation-specific:warning format-string format-args)
  (apply *scc-error-handler* 'warning format-string format-args))

(define (implementation-specific:catch-all-errors handler thunk)
  (let ((old-handler 'xxx))
    (dynamic-wind
     (lambda ()
       (set! old-handler *error-handler*)
       (set! *error-handler*
	     (lambda (procedure-name format-string . args)
	       (handler `(,scc-error-tag
			  ,procedure-name
			  ,format-string
			  ,@args)))))
     thunk
     (lambda ()
       (set! *error-handler* old-handler)))))

(define (implementation-specific:get-error-message scheme-condition)
  (if (and (pair? scheme-condition)
	   (eq? (car scheme-condition) scc-error-tag))
      (string-append (symbol->string (cadr scheme-condition))
		     (caddr scheme-condition))
      (*scc-error-handler* 'get-error-message
			   "Not a Scheme error: ~A"
			   scheme-condition)))

(define (implementation-specific:get-error-arguments scheme-condition)
  (if (and (pair? scheme-condition)
	   (eq? (car scheme-condition) scc-error-tag))
      (cdddr scheme-condition)
      (*scc-error-handler* 'get-error-arguments
			   "Not a Scheme error: ~A"
			   scheme-condition)))

(define (implementation-specific:is-reflected-error? f-string f-args)
  #F)

(define (implementation-specific:let-scheme-handle-it serious)
  ;; This can't happen if is-reflected-error? is returning #F  
  (car 34))

;;;; Additional Dylan bindings

(define (dylan:scheme-variable-ref mv nm variable-name)
  (eval variable-name))

(define (dylan:scheme-procedure-ref mv nm variable-name)
  (make-dylan-callable (eval variable-name)))

(define (dylan:pp mv nm obj)
  mv nm					; Ignored
  (pp obj))

(define implementation-specific:additional-dylan-bindings
  `((pp dylan:pp)
    (scheme-variable dylan:scheme-variable-ref)
    (scheme-procedure dylan:scheme-procedure-ref)))

;;;; Other things

;;; For conversion from strings to symbols, we need a function that
;;; canonicalizes the case of the string.

(define (canonicalize-string-for-symbol string)
  (list->string (map char-upcase (string->list string))))

;(load "msort.sc")

(define (write-line x)
  (write x)
  (newline))

;; pp -- already provided

;(load "dynwnd.sc")

;;; Imaginary numbers aren't supported by all implementations
(define (get-+i)
  (error 'get-+i "Complex numbers aren't supported"))

(define (numerator x) x)
(define (denominator x) 1)
(define (angle x) 0)
(define (magnitude x) x)
(define (real-part x) x)
(define (imag-part x) 0)
(define (make-polar mag angle)
  (if (zero? angle)
      mag
      (get-+i)))
(define (make-rectangular x y)
  (if (zero? y)
      x
      (get-+i)))
(define (rationalize x . y)
  (error 'rationalize "We aren't rational"))
Back to Top