Skip to content

Commit

Permalink
make compile-reference and compile-binder work with symbol tables, us…
Browse files Browse the repository at this point in the history
…ed in staged mk
  • Loading branch information
michaelballantyne committed Jun 29, 2024
1 parent 8b04ad7 commit 550afd3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions private/ee-lib/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@
((make-syntax-introducer) (datum->syntax #f (syntax-e id) id id)))


(define-persistent-free-id-table compiled-ids)

(define (table-ref table id fail)
(if (persistent-free-id-table? table)
(persistent-free-id-table-ref
Expand All @@ -428,13 +426,11 @@
val)))

(define/who (compile-binder! id #:table [table compiled-ids] #:reuse? [reuse? #f])
(check who (lambda (v) (or (mutable-free-id-table? v) (persistent-free-id-table? v)))
#:contract "(or/c mutable-free-id-table? persistent-free-id-table?)"
table)
(check who symbol-table? table)
(check who identifier? id)
(check who boolean? reuse?)

(define ref-result (table-ref table id #f))
(define ref-result (table-ref (mutable-symbol-table-id-table table) id #f))

(define renamed
(if (and ref-result
Expand All @@ -444,7 +440,7 @@
(flip-intro-scope ref-result)
(error 'compile-binder! "compiled binder already recorded for identifier ~v" id))
(let ([result (syntax-local-get-shadower/including-module (generate-same-name-temporary id))])
(table-set! table id result)
(table-set! (mutable-symbol-table-id-table table) id result)
(flip-intro-scope result))))

(define annotated
Expand All @@ -459,13 +455,11 @@
ids)))

(define/who (compile-reference id #:table [table compiled-ids])
(check who (lambda (v) (or (mutable-free-id-table? v) (persistent-free-id-table? v)))
#:contract "(or/c mutable-free-id-table? persistent-free-id-table?)"
table)
(check who symbol-table? table)
(check who identifier? id)

(define table-val
(table-ref table id (lambda () (error 'compile-reference "no compiled name in table for ~v" id))))
(table-ref (mutable-symbol-table-id-table table) id (lambda () (error 'compile-reference "no compiled name in table for ~v" id))))

(define renamed
(syntax-local-get-shadower/including-module
Expand Down Expand Up @@ -500,6 +494,8 @@
(begin (define-persistent-free-id-table id-table)
(define id (mutable-symbol-table id-table))))

(define-persistent-symbol-table compiled-ids)

; deprecated
(define-syntax-rule
(define-local-symbol-table id)
Expand Down

0 comments on commit 550afd3

Please sign in to comment.