Skip to content

Commit 8027e3b

Browse files
author
varun10p
committed
More fixes
1 parent 09c9ffc commit 8027e3b

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/syntax/platform.rkt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,15 @@
552552

553553
(define (expr-otype expr)
554554
(match expr
555-
[(? literal?) #f]
555+
[(? number?) #f]
556556
[(? variable?) #f]
557557
[(list 'if cond ift iff) (expr-otype ift)]
558558
[(list op args ...) (impl-info op 'otype)]))
559559

560560
(define (type-verify expr otype)
561561
(match expr
562-
[(? literal?) '()]
563-
[(? variable?) '((cons expr otype))]
562+
[(? number?) '()]
563+
[(? variable?) (list (cons expr otype))]
564564
[(list 'if cond ift iff)
565565
(define bool-repr (get-representation 'bool))
566566
(define combined
@@ -584,11 +584,16 @@
584584

585585
(define (expr->prog expr repr)
586586
(match expr
587-
[(? literal?) (literal (get-representation repr) expr)]
587+
[(? number?) (literal (representation-name repr) expr)]
588588
[(? variable?) expr]
589589
[`(if ,cond ,ift ,iff)
590-
`(if ,(expr->prog cond repr) ,(expr->prog ift repr) ,(expr->prog iff repr))]
591-
[`(,impl ,args ...) `(impl ,@(map (λ (arg) (expr->prog arg (impl-info impl 'itype))) args))]))
590+
`(if ,(expr->prog cond (get-representation 'bool))
591+
,(expr->prog ift repr)
592+
,(expr->prog iff repr))]
593+
[`(,impl ,args ...)
594+
`(,impl ,@(for/list ([arg (in-list args)]
595+
[itype (in-list (impl-info impl 'itype))])
596+
(expr->prog arg itype)))]))
592597

593598
(define (*fp-safe-simplify-rules*)
594599
(reap [sow]
@@ -613,13 +618,14 @@
613618
[(list 'commutes name expr rev-expr)
614619
(define vars (impl-info impl 'vars))
615620
(define itype (car (impl-info impl 'itype)))
621+
(define otype (impl-info impl 'otype))
616622
(define r
617623
(rule name
618-
(expr->prog expr)
619-
(expr->prog rev-expr)
624+
(expr->prog expr otype)
625+
(expr->prog rev-expr otype)
620626
(for/hash ([v (in-list vars)])
621627
(values v itype))
622-
(impl-info impl 'otype))) ; Commutes by definition the types are matching
628+
otype)) ; Commutes by definition the types are matching
623629
(sow r)]
624630
[(list 'directed name lhs rhs)
625631
(define lotype (expr-otype lhs))
@@ -635,8 +641,8 @@
635641
(define var-types (merge-bindings (type-verify lhs lotype) (type-verify rhs rotype)))
636642
(define r
637643
(rule name
638-
(expr->prog lhs)
639-
(expr->prog rhs)
644+
(expr->prog lhs lotype)
645+
(expr->prog rhs rotype)
640646
(for/hash ([binding (in-list var-types)])
641647
(values (car binding) (cdr binding)))
642648
(impl-info impl 'otype)))

0 commit comments

Comments
 (0)