(skint repl) library is built at init time

This commit is contained in:
ESL 2024-05-31 23:28:29 -04:00
parent 639a2d54bd
commit 7b4b3bc2b1
2 changed files with 30 additions and 16 deletions

View file

@ -1227,14 +1227,17 @@
(define (get-env-vec! lib) (define (get-env-vec! lib)
(cond (cond
[(assoc lib *std-lib->env*) => cdr] [(assoc lib *std-lib->env*) => cdr]
[else (let* ([n 37] ; use prime number [else (let* ([n (if (eq? lib '(skint repl)) 101 37)] ; use prime number
[env (make-vector n '())]) [env (make-vector n '())])
(set! *std-lib->env* (cons (cons lib env) *std-lib->env*)) (set! *std-lib->env* (cons (cons lib env) *std-lib->env*))
env)])) env)]))
(let loop ([name (car r)] [keys (cdr r)]) (let loop ([name (car r)] [keys (cdr r)])
(unless (null? keys) (cond
[(null? keys)
(put-loc! (get-env-vec! '(skint repl)) name (root-environment name 'ref))]
[else
(put-loc! (get-env-vec! (key->lib (car keys))) name (root-environment name 'ref)) (put-loc! (get-env-vec! (key->lib (car keys))) name (root-environment name 'ref))
(loop name (cdr keys))))) (loop name (cdr keys))])))
'((* v b) (+ v b) (- v b) (... v u b) (/ v b) (< v b) '((* v b) (+ v b) (- v b) (... v u b) (/ v b) (< v b)
(<= v b) (= v b) (=> v u b) (> v b) (>= v b) (_ b) (abs v b) (<= v b) (= v b) (=> v u b) (> v b) (>= v b) (_ b) (abs v b)
(and v u b) (append v b) (apply v b) (assoc v b) (assq v b) (and v u b) (append v b) (apply v b) (assoc v b) (assq v b)
@ -1342,10 +1345,17 @@
(cond [(assoc lib *std-lib->env*) => (cond [(assoc lib *std-lib->env*) =>
(lambda (lv) (lambda (lv)
(let* ([v (cdr lv)] [n (vector-length v)]) (let* ([v (cdr lv)] [n (vector-length v)])
(if (eq? lib '(skint repl))
(lambda (id at)
(let* ([i (immediate-hash id n)] [al (vector-ref v i)] [p (assq id al)])
(if p (cdr p)
(let ([loc (make-location (list 'ref id))])
(vector-set! v i (cons (cons id loc) al))
loc))))
(lambda (id at) (lambda (id at)
(and (eq? at 'ref) (and (eq? at 'ref)
(let* ([i (immediate-hash id n)] [al (vector-ref v i)] [p (assq id al)]) (let* ([i (immediate-hash id n)] [al (vector-ref v i)] [p (assq id al)])
(if p (cdr p) #f))))))] (if p (cdr p) #f)))))))]
[else #f])) [else #f]))

16
t.c
View file

@ -715,14 +715,18 @@ char *t_code[] = {
"h),.1v?{'(l2:y6:scheme;y4:char;)]2}'(y1:l),.1v?{'(l2:y6:scheme;y11:cas" "h),.1v?{'(l2:y6:scheme;y4:char;)]2}'(y1:l),.1v?{'(l2:y6:scheme;y11:cas"
"e-lambda;)]2}'(y1:b),.1v?{'(l2:y6:scheme;y4:base;)]2}]2}.!0&0{%3.0V3,." "e-lambda;)]2}'(y1:b),.1v?{'(l2:y6:scheme;y4:base;)]2}]2}.!0&0{%3.0V3,."
"0,.3H2,.0,.3V4,.0,.5A3,.0?{.6,.1sd]7}.1,.7,.7cc,.3,.6V5]7}.!1&0{%1@(y1" "0,.3H2,.0,.3V4,.0,.5A3,.0?{.6,.1sd]7}.1,.7,.7cc,.3,.6V5]7}.!1&0{%1@(y1"
"4:*std-lib->env*),.1A5,.0?{.0d]2}'(i37),n,.1V2,@(y14:*std-lib->env*),." "4:*std-lib->env*),.1A5,.0?{.0d]2}'(l2:y5:skint;y4:repl;),.2q?{'(i101)}"
"1,.5cc@!(y14:*std-lib->env*).0]4}.!2.3d,.4a,,#0.5,.4,.6,.3,&4{%2.1u~?{" "{'(i37)},n,.1V2,@(y14:*std-lib->env*),.1,.5cc@!(y14:*std-lib->env*).0]"
"${${'(y3:ref),.5,@(y16:root-environment)[02},.3,${${.9a,:2^[01},:3^[01" "4}.!2.3d,.4a,,#0.0,.5,.5,.8,&4{%2.1u?{${'(y3:ref),.3,@(y16:root-enviro"
"},:1^[03}.1d,.1,:0^[22}]2}.!0.0^_1[42},@(y10:%25for-each1)[02}", "nment)[02},.1,${'(l2:y5:skint;y4:repl;),:0^[01},:2^[23}${${'(y3:ref),."
"5,@(y16:root-environment)[02},.3,${${.9a,:1^[01},:0^[01},:2^[03}.1d,.1"
",:3^[22}.!0.0^_1[42},@(y10:%25for-each1)[02}",
"P", "std-lib->env", "P", "std-lib->env",
"%1@(y14:*std-lib->env*),.1A5,.0?{.0,.0d,.0V3,.1,.1,&2{%2'(y3:ref),.2q?" "%1@(y14:*std-lib->env*),.1A5,.0?{.0,.0d,.0V3,'(l2:y5:skint;y4:repl;),."
"{:0,.1H2,.0,:1V4,.0,.3A3,.0?{.0d]5}f]5}f]2}]5}f]2", "5q?{.0,.2,&2{%2:1,.1H2,.0,:0V4,.0,.3A3,.0?{.0d]5}.3,'(y3:ref),l2b,.2,."
"1,.6cc,.4,:0V5.0]6}]5}.1,.1,&2{%2'(y3:ref),.2q?{:0,.1H2,.0,:1V4,.0,.3A"
"3,.0?{.0d]5}f]5}f]2}]5}f]2",
"C", 0, "C", 0,
"f@!(y7:*reset*)", "f@!(y7:*reset*)",