mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 04:44:12 +03:00
81 lines
2.2 KiB
Plaintext
81 lines
2.2 KiB
Plaintext
(system-include "carp_long.h")
|
|
|
|
(defmodule Long
|
|
(register MAX Long "LONG_MAX")
|
|
(register MIN Long "LONG_MIN")
|
|
(register + (λ [Long Long] Long))
|
|
(register - (λ [Long Long] Long))
|
|
(register * (λ [Long Long] Long))
|
|
(register / (λ [Long Long] Long))
|
|
(register < (λ [Long Long] Bool))
|
|
(register > (λ [Long Long] Bool))
|
|
(register = (λ [Long Long] Bool))
|
|
(register neg (λ [Long] Long))
|
|
(register mod (λ [Long Long] Long))
|
|
(register seed (λ [Long] ()))
|
|
(register bit-shift-left (λ [Long Long] Long))
|
|
(register bit-shift-right (λ [Long Long] Long))
|
|
(register bit-and (λ [Long Long] Long))
|
|
(register bit-or (λ [Long Long] Long))
|
|
(register bit-xor (λ [Long Long] Long))
|
|
(register bit-not (λ [Long] Long))
|
|
(register inc (λ [Long] Long))
|
|
(register dec (λ [Long] Long))
|
|
(register to-int (λ [Long] Int))
|
|
(register from-int (λ [Int] Long))
|
|
(todo copy "Should not be needed when refs to value types are auto-converted
|
|
to non-refs.")
|
|
(register copy (λ [&Long] Long))
|
|
|
|
(implements + Long.+)
|
|
(implements - Long.-)
|
|
(implements * Long.*)
|
|
(implements / Long./)
|
|
(implements < Long.<)
|
|
(implements > Long.>)
|
|
(implements = Long.=)
|
|
(implements copy Long.copy)
|
|
(implements inc Long.inc)
|
|
(implements dec Long.dec)
|
|
(implements neg Long.neg)
|
|
(implements mod Long.mod)
|
|
(implements to-int Long.to-int)
|
|
(implements from-int Long.from-int)
|
|
(implements bit-shift-left Long.bit-shift-left)
|
|
(implements bit-shift-right Long.bit-shift-right)
|
|
(implements bit-and Long.bit-and)
|
|
(implements bit-or Long.bit-or)
|
|
(implements bit-xor Long.bit-xor)
|
|
(implements bit-not Long.bit-not)
|
|
|
|
(posix-only ; this seems to generate invalid code on some windows machines
|
|
(register safe-add (λ [Long Long (Ref Long)] Bool))
|
|
(register safe-sub (λ [Long Long (Ref Long)] Bool))
|
|
(register safe-mul (λ [Long Long (Ref Long)] Bool))
|
|
)
|
|
|
|
(register abs (λ [Long] Long))
|
|
|
|
(defn even? [a] (= (mod a 2l) 0l))
|
|
(defn odd? [a] (not (even? a)))
|
|
|
|
(defn zero [] 0l)
|
|
|
|
(implements abs Long.abs)
|
|
(implements zero Long.zero)
|
|
)
|
|
|
|
(defmodule LongRef
|
|
(defn = [a b]
|
|
(Long.= @a @b))
|
|
(implements = LongRef.=)
|
|
|
|
(defn < [a b]
|
|
(Long.< @a @b))
|
|
(implements < LongRef.<)
|
|
|
|
(defn > [a b]
|
|
(Long.> @a @b))
|
|
(implements > LongRef.>)
|
|
)
|