diff options
author | David Thompson <dthompson2@worcester.edu> | 2023-02-04 21:34:06 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2023-06-08 08:14:41 -0400 |
commit | 8978b504678dfd1f979259681b82bf5a611f69f2 (patch) | |
tree | ef53885f0cdd136e6e93f8cde9ab56730361f727 | |
parent | 92213b149739fc98a209d7cb3c329fbd5ce901df (diff) |
Emitting overloaded functions seems to work!
-rw-r--r-- | chickadee/graphics/seagull.scm | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm index 6b8073d..dcddfb9 100644 --- a/chickadee/graphics/seagull.scm +++ b/chickadee/graphics/seagull.scm @@ -1956,6 +1956,17 @@ ;; of non-quantified function type specifications, one for each unique ;; type of call in the program. +;; Check if the substitutions in a and b do not contain +;; contradictions. +(define (consistent? a b) + (every (match-lambda + ((from . to) + (let ((other (assq-ref b from))) + (or (not other) (equal? to other))))) + a)) + +;; Compute all the valid permutations of substitutions that a +;; predicate could produce. (define (possible-substitutions pred) (match pred (#t '()) @@ -1974,17 +1985,12 @@ (append-map (lambda (a) (if (null? rest-options) (list a) - (map (lambda (b) - (compose-substitutions a b)) - rest-options))) + (filter-map (lambda (b) + (and (consistent? a b) + (compose-substitutions a b))) + rest-options))) options))))))) -(define (possible-signatures type) - (define type* (for-all-type-ref type)) - (map (lambda (subs) - (apply-substitutions-to-type type* subs)) - (possible-substitutions (for-all-type-predicate type)))) - (define (resolve-overloads program) (match program (('t types ('top-level bindings body)) |