Improved error reports in records.procedural as per Derick

Eddington's suggestions and removed the record-name check for
non-generative records.
This commit is contained in:
Abdulaziz Ghuloum 2007-12-01 22:32:19 -05:00
parent fc3f347830
commit 113add26ac
6 changed files with 73 additions and 68 deletions

Binary file not shown.

View File

@ -820,7 +820,7 @@ you need to specify that explicitly as in the following example.
This definition gives us, in addition to the constructor, predicate, This definition gives us, in addition to the constructor, predicate,
and accessors, two additional procedures: and accessors, two additional procedures:
\begin{itemize} \begin{itemize}
\item The mutators \texttt{set-point-x!} and \texttt{set-point-y!} that, \item The mutators \texttt{point-x-set!} and \texttt{point-y-set!} that,
given a record of type point, and a new value, sets the value stored in the given a record of type point, and a new value, sets the value stored in the
\texttt{x} field or \texttt{y} field to the new value. \texttt{x} field or \texttt{y} field to the new value.
\end{itemize} \end{itemize}

View File

@ -54,16 +54,14 @@
(not (rtd-opaque? rtd)))))) (not (rtd-opaque? rtd))))))
(define (record-rtd x) (define (record-rtd x)
(define (err x)
(error 'record-rtd "not a record" x))
(if ($struct? x) (if ($struct? x)
(let ([rtd ($struct-rtd x)]) (let ([rtd ($struct-rtd x)])
(if (rtd? rtd) (if (rtd? rtd)
(if (not (rtd-opaque? rtd)) (if (not (rtd-opaque? rtd))
rtd rtd
(err x)) (error 'record-rtd "record is opaque"))
(err x))) (error 'record-rtd "not a record" x)))
(err x))) (error 'record-rtd "not a record" x)))
(define (record-type-name x) (define (record-type-name x)
(if (rtd? x) (if (rtd? x)
@ -179,7 +177,8 @@
[(lookup-rtd uid) => [(lookup-rtd uid) =>
(lambda (rtd) (lambda (rtd)
(unless (unless
(and (eqv? name (rtd-name rtd)) (and ; must not check name!
; (eqv? name (rtd-name rtd))
(eqv? parent (rtd-parent rtd)) (eqv? parent (rtd-parent rtd))
(eqv? sealed? (rtd-sealed? rtd)) (eqv? sealed? (rtd-sealed? rtd))
(eqv? opaque? (rtd-opaque? rtd)) (eqv? opaque? (rtd-opaque? rtd))

View File

@ -20,7 +20,7 @@
(ikarus system $fx) (ikarus system $fx)
(except (ikarus) list-sort vector-sort vector-sort!)) (except (ikarus) list-sort vector-sort vector-sort!))
(module (sort-tail)
(define (merge1 <? a1 ls1 ls2) (define (merge1 <? a1 ls1 ls2)
(cond (cond
[(null? ls2) ls1] [(null? ls2) ls1]
@ -72,13 +72,16 @@
[else [else
(let-values ([(sorted-head tail) (let-values ([(sorted-head tail)
(sort-head <? ls ($fxsra n 1))]) (sort-head <? ls ($fxsra n 1))])
(merge <? sorted-head (sort-tail <? tail ($fx- n ($fxsra n 1)))))])) (merge <? sorted-head
(sort-tail <? tail ($fx- n ($fxsra n 1)))))])))
(define (list-sort <? ls) (define (list-sort <? ls)
(unless (procedure? <?) (unless (procedure? <?)
(error 'list-sort "not a procedure" <?)) (error 'list-sort "not a procedure" <?))
(sort-tail <? ls (length ls))) (sort-tail <? ls (length ls)))
(define (vector-sort <? v) (define (vector-sort <? v)
;;; FIXME: improve ;;; FIXME: improve
(unless (procedure? <?) (unless (procedure? <?)
@ -89,6 +92,8 @@
(sort-tail <? (vector->list v) (vector-length v)))) (sort-tail <? (vector->list v) (vector-length v))))
(define (vector-sort! <? v) (define (vector-sort! <? v)
(import (ikarus system $vectors))
(import (ikarus system $pairs))
(unless (procedure? <?) (unless (procedure? <?)
(error 'vector-sort! "not a procedure" <?)) (error 'vector-sort! "not a procedure" <?))
(unless (vector? v) (unless (vector? v)
@ -96,8 +101,8 @@
(let f ([i 0] [v v] (let f ([i 0] [v v]
[ls (sort-tail <? (vector->list v) (vector-length v))]) [ls (sort-tail <? (vector->list v) (vector-length v))])
(unless (null? ls) (unless (null? ls)
(vector-set! v i (car ls)) ($vector-set! v i ($car ls))
(f (fx+ i 1) v (cdr ls))))) (f ($fx+ i 1) v ($cdr ls)))))
) )

View File

@ -1 +1 @@
1160 1162

View File

@ -60,19 +60,20 @@
(dirty-vector-set addr))] (dirty-vector-set addr))]
[else (dirty-vector-set addr)])) [else (dirty-vector-set addr)]))
(define (mem-assign v x i)
(define (slow-mem-assign v x i)
(with-tmp ([t (prm 'int+ x (K i))]) (with-tmp ([t (prm 'int+ x (K i))])
(make-seq (make-seq
(prm 'mset t (K 0) (T v)) (prm 'mset t (K 0) (T v))
(dirty-vector-set t)))) (dirty-vector-set t))))
(define (smart-mem-assign what v x i) (define (mem-assign v x i)
(struct-case what (struct-case v
[(constant t) [(constant t)
(if (or (fixnum? t) (immediate? t)) (if (or (fixnum? t) (immediate? t))
(prm 'mset x (K i) v) (prm 'mset x (K i) (T v))
(mem-assign v x i))] (slow-mem-assign v x i))]
[else (mem-assign v x i)])) [else (slow-mem-assign v x i)]))
(define (align-code unknown-amt known-amt) (define (align-code unknown-amt known-amt)
(prm 'sll (prm 'sll