Progress towards deterministic TR compilation.
Traverse many dictionaries in sorted order when generating residual code. Closes racket/racket#1138.
This commit is contained in:
parent
4af7c9d10e
commit
71b6fc456c
|
@ -5,6 +5,7 @@
|
|||
|
||||
(require "../types/tc-error.rkt"
|
||||
"../utils/tc-utils.rkt"
|
||||
"env-utils.rkt"
|
||||
syntax/parse
|
||||
syntax/id-table
|
||||
racket/lazy-require)
|
||||
|
@ -102,4 +103,4 @@
|
|||
;; map over the-mapping, producing a list
|
||||
;; (id type -> T) -> listof[T]
|
||||
(define (type-env-map f)
|
||||
(free-id-table-map the-mapping f))
|
||||
(sorted-dict-map the-mapping f id<))
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
racket/match
|
||||
racket/promise
|
||||
(for-syntax syntax/parse racket/base)
|
||||
"env-utils.rkt"
|
||||
"../utils/utils.rkt"
|
||||
(utils tc-utils)
|
||||
(rep type-rep))
|
||||
|
@ -66,4 +67,4 @@
|
|||
(free-id-table-ref (signature-env) id #f))
|
||||
|
||||
(define (signature-env-map f)
|
||||
(free-id-table-map (signature-env) f))
|
||||
(sorted-dict-map (signature-env) f id<))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#lang racket/base
|
||||
|
||||
(require "../utils/utils.rkt"
|
||||
"env-utils.rkt"
|
||||
syntax/id-table racket/dict
|
||||
(utils tc-utils)
|
||||
(typecheck renamer)
|
||||
|
@ -61,6 +62,6 @@
|
|||
;; map over the-mapping, producing a list
|
||||
;; (id type -> T) -> listof[T]
|
||||
(define (type-alias-env-map f)
|
||||
(for/list ([(id t) (in-dict the-mapping)]
|
||||
(for/list ([(id t) (in-sorted-dict the-mapping id<)]
|
||||
#:when (resolved? t))
|
||||
(f id (resolved-ty t))))
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
;; Environment for type names
|
||||
|
||||
(require "../utils/utils.rkt")
|
||||
(require "../utils/utils.rkt"
|
||||
"env-utils.rkt")
|
||||
|
||||
(require syntax/id-table
|
||||
(contract-req)
|
||||
|
@ -58,7 +59,7 @@
|
|||
;; map over the-mapping, producing a list
|
||||
;; (id type -> T) -> listof[T]
|
||||
(define (type-name-env-map f)
|
||||
(free-id-table-map the-mapping f))
|
||||
(sorted-dict-map the-mapping f id<))
|
||||
|
||||
(define (add-alias from to)
|
||||
(when (lookup-type-name to (lambda () #f))
|
||||
|
@ -83,7 +84,7 @@
|
|||
;; map over the-mapping, producing a list
|
||||
;; (id variance -> T) -> listof[T]
|
||||
(define (type-variance-env-map f)
|
||||
(free-id-table-map variance-mapping f))
|
||||
(sorted-dict-map variance-mapping f id<))
|
||||
|
||||
;; Refines the variance of a type in the name environment
|
||||
(define (refine-variance! names types tvarss)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
(private syntax-properties)
|
||||
(typecheck renamer def-binding)
|
||||
(utils tc-utils)
|
||||
(env env-utils)
|
||||
(for-syntax racket/base)
|
||||
(for-template racket/base))
|
||||
|
||||
|
@ -186,9 +187,10 @@
|
|||
new-id
|
||||
null)))
|
||||
|
||||
|
||||
;; Build the final provide with auxilliary definitions
|
||||
(for/lists (defs export-defs provides aliases) ([(internal-id external-ids) (in-dict provs)])
|
||||
(for/lists (defs export-defs provides aliases)
|
||||
;; sort provs to generate deterministic output
|
||||
([(internal-id external-ids) (in-sorted-dict provs id<)])
|
||||
(define-values (defs export-def id alias) (mk internal-id))
|
||||
(define provide-forms
|
||||
(for/list ([external-id (in-list external-ids)])
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
(prefix-in c: (contract-req))
|
||||
(rep type-rep filter-rep object-rep)
|
||||
(utils tc-utils)
|
||||
(env init-envs))
|
||||
(env init-envs env-utils))
|
||||
|
||||
(define struct-fn-table (make-free-id-table))
|
||||
(define struct-constructor-table (make-free-id-table))
|
||||
|
@ -33,7 +33,7 @@
|
|||
(parameterize ([current-print-convert-hook converter]
|
||||
[show-sharing #f])
|
||||
(define/with-syntax (adds ...)
|
||||
(for/list ([(k v) (in-dict struct-fn-table)]
|
||||
(for/list ([(k v) (in-sorted-dict struct-fn-table id<)]
|
||||
#:when (bound-in-this-module k))
|
||||
(match v
|
||||
[(list pe mut?)
|
||||
|
|
Loading…
Reference in New Issue
Block a user