Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (def test-block
- '((:constant :c 10)
- (:div :d :i :c)
- (:mod :r :i :c)
- (:store :p1 :d)
- (:store :p2 :r)
- (:add :x :y :z)
- (:jmp :next-block)))
- (defn test-matcher
- [block typemap]
- (run* [q]
- (conde
- [(fresh [?types ?idiv ?imod ?a ?b ?c ?d]
- (membero ?idiv block)
- (membero ?imod block)
- (== ?idiv `(:div ~?a ~?c ~?d))
- (== ?imod `(:mod ~?b ~?c ~?d))
- (== q `((~?idiv ~?imod)
- ((:divmod32 ~?a ~?b ~?c ~?d)))))]
- [(fresh [?types ?idiv ?a ?b ?c]
- (membero ?idiv block)
- (== ?idiv `(:div ~?a ~?b ~?c))
- (== q `(((~?idiv))
- ((:div32 ~?a ~?b ~?c)))))]
- )))
Advertisement
Add Comment
Please, Sign In to add comment