mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
52 lines
1.4 KiB
Plaintext
52 lines
1.4 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))
|
|
|
|
(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)
|
|
)
|
|
|
|
(defmodule LongRef
|
|
(defn = [a b]
|
|
(Long.= @a @b))
|
|
|
|
(defn < [a b]
|
|
(Long.< @a @b))
|
|
|
|
(defn > [a b]
|
|
(Long.> @a @b))
|
|
)
|