~subsetpark/ec

3f9b6ebe018fde7dfa746291a05a737b6173b35f — Zach Smith 6 months ago 5771c13 big
Support bigints (note: this does not work on account of floats being coerced to big ints)
3 files changed, 11 insertions(+), 3 deletions(-)

M project.janet
M src/calc.janet
M test-support.janet
M project.janet => project.janet +2 -1
@@ 4,7 4,8 @@
  :dependencies ["https://git.sr.ht/~subsetpark/fugue"
                 "https://github.com/janet-lang/argparse.git"
                 "https://github.com/pyrmont/testament"
                 "https://git.sr.ht/~subsetpark/janet-rl"])
                 "https://git.sr.ht/~subsetpark/janet-rl"
                "https://github.com/andrewchambers/janet-big.git" ])

(def *static-build* (= (or (os/getenv "EC_STATIC_BUILD") "0") "1"))


M src/calc.janet => src/calc.janet +7 -1
@@ 1,5 1,7 @@
(use fugue)

(import big)

(defproto Stack ()
  env {}
  data {:default @[]})


@@ 11,7 13,8 @@

(defproto Int Number
  type {:allocate-value :integer}
  value {:init? true})
  value {:init? true}
  _after-init (fn make-big [proto inst] (update inst :value big/int)))

(defproto Float Number
  type {:allocate-value :float}


@@ 101,6 104,8 @@
# TODO: Do we want to do something more sophisticated here?
(defmulti make-element [:number] [n] (:new Float n
                                           :doc (string n)))
(defmulti make-element [:big/int] [i] (:new Int i
                                            :doc (string i)))
(defmulti make-element [_] [v] v)

(defn- inner-apply


@@ 117,6 122,7 @@

(defmethod apply-operation Operation
  [op & args]
  (pp [op args])
  (let [cmpr (comp length get-shape)
        largest (get-shape (extreme |(> (cmpr $0) (cmpr $1)) args))
        filled (map |(fill $ largest) args)]

M test-support.janet => test-support.janet +2 -1
@@ 15,7 15,8 @@

(defn- make-element
  [x]
  (if (number? x) (:new calc/Int x) x))
  (if (or (number? x) (= :big/int (type x)))
    (:new calc/Int x) x))

(defn wrap
  [& args]