Skip to content

Commit 6a8e27a

Browse files
committed
wip
1 parent bd3555c commit 6a8e27a

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

src/sci/impl/analyzer.cljc

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,25 @@
14731473
clazz meth
14741474
^objects (into-array Object args)))
14751475
stack)))))
1476+
#?(:clj
1477+
(comment
1478+
((fn
1479+
([x] (/ 1 x))
1480+
([x y] (. clojure.lang.Numbers (divide x y)))
1481+
([x y & more]
1482+
(reduce / (/ x y) more)))
1483+
##Inf 0.0)
1484+
(defn div [x y]
1485+
(if (double? x)
1486+
(let [x (double x)]
1487+
(. clojure.lang.Numbers (divide x y)))
1488+
(/ x y)))
1489+
(f 0 0)
1490+
(f ##Inf ##Inf)
1491+
(f 1 2)
1492+
(/ 1 2)
1493+
double?
1494+
))
14761495

14771496
(defn analyze-call [ctx expr m top-level?]
14781497
(with-top-level-loc top-level? m
@@ -1619,14 +1638,28 @@
16191638
:else (analyze ctx v top-level?))]
16201639
expanded)
16211640
(if-let [f (:sci.impl/inlined f-meta)]
1622-
(return-call ctx
1623-
expr
1624-
f (analyze-children ctx (rest expr))
1625-
(assoc m
1626-
:ns @utils/current-ns
1627-
:file @utils/current-file
1628-
:sci.impl/f-meta f-meta)
1629-
nil)
1641+
(let [children (analyze-children ctx (rest expr))
1642+
#?@(:clj [f (condp identical? f
1643+
;; double arithmetic, e.g. no divide by zero
1644+
/ (let [div (fn [x y]
1645+
(if (double? x)
1646+
(let [x (double x)]
1647+
(/ x y))
1648+
(/ x y)))]
1649+
(fn
1650+
([x] (div 1 x))
1651+
([x y] (div x y))
1652+
([x y & more]
1653+
(reduce / (div x y) more))))
1654+
f)])]
1655+
(return-call ctx
1656+
expr
1657+
f children
1658+
(assoc m
1659+
:ns @utils/current-ns
1660+
:file @utils/current-file
1661+
:sci.impl/f-meta f-meta)
1662+
nil))
16301663
(if-let [op (:sci.impl/op (meta f))]
16311664
(case op
16321665
:resolve-sym

0 commit comments

Comments
 (0)