|
26 | 26 |
|
27 | 27 | (struct alt-table (point-idx->alts alt->point-idxs alt->done? alt->cost pcontext all) #:prefab) |
28 | 28 |
|
29 | | -(define (alt-batch-cost batch repr) |
| 29 | +(define (alt-batch-cost batch brfs repr) |
30 | 30 | (define node-cost-proc (platform-node-cost-proc (*active-platform*))) |
31 | | - (define costs (make-vector (batch-length batch) 0)) |
32 | | - (for ([node (in-batch batch)] |
33 | | - [i (in-naturals)]) |
34 | | - (define cost |
35 | | - (match node |
36 | | - [(? literal?) ((node-cost-proc node repr))] |
37 | | - [(? symbol?) ((node-cost-proc node repr))] |
38 | | - [(? number?) 0] ; specs |
39 | | - [(approx _ impl) (vector-ref costs impl)] |
40 | | - [(list (? (negate impl-exists?) impl) args ...) 0] ; specs |
41 | | - [(list impl args ...) |
42 | | - (define cost-proc (node-cost-proc node repr)) |
43 | | - (define itypes (impl-info impl 'itype)) |
44 | | - (apply cost-proc (map (curry vector-ref costs) args))])) |
45 | | - (vector-set! costs i cost)) |
46 | | - (for/list ([root (in-vector (batch-roots batch))]) |
47 | | - (vector-ref costs root))) |
| 31 | + (define costs |
| 32 | + (batch-map batch |
| 33 | + (λ (get-args-costs node) |
| 34 | + (match node |
| 35 | + [(? literal?) ((node-cost-proc node repr))] |
| 36 | + [(? symbol?) ((node-cost-proc node repr))] |
| 37 | + [(? number?) 0] ; specs |
| 38 | + [(approx _ impl) (get-args-costs impl)] |
| 39 | + [(list (? (negate impl-exists?) impl) args ...) 0] ; specs |
| 40 | + [(list impl args ...) |
| 41 | + (define cost-proc (node-cost-proc node repr)) |
| 42 | + (define itypes (impl-info impl 'itype)) |
| 43 | + (apply cost-proc (map get-args-costs args))])))) |
| 44 | + (map costs brfs)) |
48 | 45 |
|
49 | 46 | (define (make-alt-table pcontext initial-alt ctx) |
50 | 47 | (define cost (alt-cost initial-alt (context-repr ctx))) |
|
184 | 181 | [alt->cost (hash-remove* alt->cost altns)])) |
185 | 182 |
|
186 | 183 | (define (atab-eval-altns atab altns ctx) |
187 | | - (define batch (progs->batch (map alt-expr altns) #:vars (context-vars ctx))) |
188 | | - (define errss (batch-errors batch (alt-table-pcontext atab) ctx)) |
189 | | - (define costs (alt-batch-cost batch (context-repr ctx))) |
| 184 | + (define-values (batch brfs) (progs->batch (map alt-expr altns) #:vars (context-vars ctx))) |
| 185 | + (define errss (batch-errors batch brfs (alt-table-pcontext atab) ctx)) |
| 186 | + (define costs (alt-batch-cost batch brfs (context-repr ctx))) |
190 | 187 | (values errss costs)) |
191 | 188 |
|
192 | 189 | (define (atab-add-altns atab altns errss costs ctx) |
|
0 commit comments