Skip to content

Commit

Permalink
Delete extra code. Touch up variables and literals.
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneenders committed Oct 31, 2024
1 parent 378c1b2 commit 6a1714a
Showing 1 changed file with 4 additions and 41 deletions.
45 changes: 4 additions & 41 deletions src/core/localize.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,12 @@
(define expr-batch (progs->batch exprs-list))
(define nodes (batch-nodes expr-batch))
(define roots (batch-roots expr-batch))
(eprintf "exprs:~a\n" (length exprs-list))
(eprintf "~a\n" exprs-list)

; TODO don't ignore the status code from make-real-compiler in eval-progs-real
(define subexprs-fn (eval-progs-real spec-list ctx-list))
(define actual-value-fn (compile-progs exprs-list ctx))

; TODO way too much allocation for what we are doing.
; TODO This is a mess, don't need 4 loops
(define errs
(for/vector #:length (vector-length roots)
([node (in-vector roots)])
Expand All @@ -237,8 +235,6 @@
([node (in-vector roots)])
(make-vector (pcontext-length (*pcontext*)))))

(eprintf "true-errors-out: ~a\n" true-errors-out)

(define exacts-out
(for/vector #:length (vector-length roots)
([node (in-vector roots)])
Expand All @@ -261,19 +257,10 @@
([(pt ex) (in-pcontext (*pcontext*))])
(apply actual-value-fn pt)))

(define diff-expers-per-pcontext
(for/vector #:length (vector-length exacts-from-points)
([exacts (in-vector exacts-from-points)])
(for/list ([exact (in-vector exacts)]
[spec (in-list spec-list)])
`(- ,spec ,exact))))

;; can use ctx list
(define (true-error-for spec exact ctx pt)
; TODO pass in the list of of specs and exacts and ctxs and apply that function to pts
(define s (list `(- ,spec ,exact)))
(define c (list ctx))
(eprintf "true-error-for: ~a, ~a, ~a\n" s c pt)
(first (apply (eval-progs-real s c) pt)))

(define (true-error-from i exact pt)
Expand Down Expand Up @@ -312,8 +299,8 @@
(ulp-difference exact approx repr)]))
(define true-error
(match (vector-ref nodes root)
[(? literal?) exact]
[(? variable?) 1]
[(? literal?) (true-error-for c-spec exact c-ctx pt)]
[(? variable?) 0] ; assuming input is exact
; compare the exact against it's impl substitution.
[(approx _ impl) (true-error-from impl exact pt)]
[`(if ,c ,ift ,iff)
Expand All @@ -333,26 +320,7 @@
(vector-set! (vector-ref actuals-out expr-idx) pt-idx actual)
(vector-set! (vector-ref true-errors-out expr-idx) pt-idx true-error)))

#|
(define s (list (first (vector-ref diff-expers-per-pcontext 0))))
(define p (vector-ref (pcontext-points (*pcontext*)) 0))
(define c (list (first ctx-list)))
(eprintf "spec: ~a, ctx: ~a, pt: ~a\n" s c p)
(eprintf "diff-expers: ~a\n" (apply (eval-progs-real s c) p))
(define diff-funcs
(for/list ([diff-expers (in-vector diff-expers-per-pcontext)])
(eval-progs-real diff-expers ctx-list)))
(eprintf "diffs: ~a\n" diff-funcs)
(define results
(for/list ([(pt ex) (in-pcontext (*pcontext*))]
[func (in-list diff-funcs)])
(eprintf "func: ~a, pt: ~a\n" func pt)
(apply func pt)))
(eprintf "results: ~a\n" results)
|#

; TODO below is also a mess
(define n 0)
(define err-tree
(first (for/list ([subexprs (in-list subexprss)])
Expand All @@ -368,8 +336,6 @@
(vector->list (vector-ref true-errors-out n))))
(set! n (add1 n)))))))

(eprintf "err-tree: ~a\n" err-tree)

(define local-error
(let loop ([expr (test-input test)])
(define expr-info (hash-ref err-tree expr))
Expand Down Expand Up @@ -402,9 +368,6 @@
[(list op args ...) (cons true-error-list (map loop args))]
[_ (list true-error-list)])))

(eprintf "hash: ~a\n" (hash-ref (hash-ref err-tree (test-input test)) 'actual-values))
(eprintf "actual-values: ~a\n" actual-values)

(define tree
(let loop ([expr (prog->fpcore (test-input test) (test-context test))]
[err local-error]
Expand Down

0 comments on commit 6a1714a

Please sign in to comment.