Carp/core/StdInt.carp

380 lines
12 KiB
Plaintext
Raw Permalink Normal View History

2020-05-08 22:16:12 +03:00
(system-include "carp_stdint.h")
2020-02-17 12:42:07 +03:00
(register-type Uint8)
(register-type Uint16)
(register-type Uint32)
(register-type Uint64)
(register-type Int8)
(register-type Int16)
(register-type Int32)
(register-type Int64)
2021-07-05 15:48:35 +03:00
(doc Int8 "is a thin wrapper around the `int8_t` C data type, a signed 8-bit
integer.")
2020-02-17 12:42:07 +03:00
(defmodule Int8
(register = (λ [Int8 Int8] Bool))
(register > (λ [Int8 Int8] Bool))
(register < (λ [Int8 Int8] Bool))
(register + (λ [Int8 Int8] Int8))
(register - (λ [Int8 Int8] Int8))
(register * (λ [Int8 Int8] Int8))
(register / (λ [Int8 Int8] Int8))
(register bit-shift-left (λ [Int8 Int8] Int8))
(register bit-shift-right (λ [Int8 Int8] Int8))
(register bit-or (λ [Int8 Int8] Int8))
(register bit-and (λ [Int8 Int8] Int8))
(register bit-not (λ [Int8] Int8))
(register bit-xor (λ [Int8 Int8] Int8))
(register to-long (λ [Int8] Long))
(register from-long (λ [Long] Int8))
(register copy (Fn [&Int8] Int8))
2020-02-21 07:39:25 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Int8)))
(implements + Int8.+)
(implements - Int8.-)
(implements * Int8.*)
(implements / Int8./)
(implements < Int8.<)
(implements > Int8.>)
(implements = Int8.=)
(implements copy Int8.copy)
(implements zero Int8.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Int8.bit-shift-left)
(implements bit-shift-right Int8.bit-shift-right)
(implements bit-and Int8.bit-and)
(implements bit-or Int8.bit-or)
(implements bit-xor Int8.bit-xor)
(implements bit-not Int8.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Int8Extra
(defn = [a b] (Int8.= @a @b))
(implements = Int8Extra.=)
2020-02-17 12:42:07 +03:00
)
2021-07-05 15:48:35 +03:00
(doc Int16 "is a thin wrapper around the `int16_t` C data type, a signed 16-bit
integer.")
2020-02-17 12:42:07 +03:00
(defmodule Int16
(register = (λ [Int16 Int16] Bool))
(register > (λ [Int16 Int16] Bool))
(register < (λ [Int16 Int16] Bool))
(register + (λ [Int16 Int16] Int16))
(register - (λ [Int16 Int16] Int16))
(register * (λ [Int16 Int16] Int16))
(register / (λ [Int16 Int16] Int16))
(register bit-shift-left (λ [Int16 Int16] Int16))
(register bit-shift-right (λ [Int16 Int16] Int16))
(register bit-or (λ [Int16 Int16] Int16))
(register bit-and (λ [Int16 Int16] Int16))
(register bit-not (λ [Int16] Int16))
(register bit-xor (λ [Int16 Int16] Int16))
(register to-long (λ [Int16] Long))
(register from-long (λ [Long] Int16))
(register copy (Fn [&Int16] Int16))
2020-02-21 07:39:25 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Int16)))
(implements + Int16.+)
(implements - Int16.-)
(implements * Int16.*)
(implements / Int16./)
(implements < Int16.<)
(implements > Int16.>)
(implements = Int16.=)
(implements copy Int16.copy)
(implements zero Int16.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Int16.bit-shift-left)
(implements bit-shift-right Int16.bit-shift-right)
(implements bit-and Int16.bit-and)
(implements bit-or Int16.bit-or)
(implements bit-xor Int16.bit-xor)
(implements bit-not Int16.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Int16Extra
(defn = [a b] (Int16.= @a @b))
(implements = Int16Extra.=)
2020-02-17 12:42:07 +03:00
)
2021-07-05 15:48:35 +03:00
(doc Int32 "is a thin wrapper around the `int32_t` C data type, a signed 32-bit
integer.")
2020-02-17 12:42:07 +03:00
(defmodule Int32
(register = (λ [Int32 Int32] Bool))
(register > (λ [Int32 Int32] Bool))
(register < (λ [Int32 Int32] Bool))
(register + (λ [Int32 Int32] Int32))
(register - (λ [Int32 Int32] Int32))
(register * (λ [Int32 Int32] Int32))
(register / (λ [Int32 Int32] Int32))
(register bit-shift-left (λ [Int32 Int32] Int32))
(register bit-shift-right (λ [Int32 Int32] Int32))
(register bit-or (λ [Int32 Int32] Int32))
(register bit-and (λ [Int32 Int32] Int32))
(register bit-not (λ [Int32] Int32))
(register bit-xor (λ [Int32 Int32] Int32))
(register to-long (λ [Int32] Long))
(register from-long (λ [Long] Int32))
(register copy (Fn [&Int32] Int32))
2020-02-21 07:39:25 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Int32)))
(implements + Int32.+)
(implements - Int32.-)
(implements * Int32.*)
(implements / Int32./)
(implements < Int32.<)
(implements > Int32.>)
(implements = Int32.=)
(implements copy Int32.copy)
(implements zero Int32.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Int32.bit-shift-left)
(implements bit-shift-right Int32.bit-shift-right)
(implements bit-and Int32.bit-and)
(implements bit-or Int32.bit-or)
(implements bit-xor Int32.bit-xor)
(implements bit-not Int32.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Int32Extra
(defn = [a b] (Int32.= @a @b))
(implements = Int32Extra.=)
2020-02-17 12:42:07 +03:00
)
2021-07-05 15:48:35 +03:00
(doc Int64 "is a thin wrapper around the `int64_t` C data type, a signed 64-bit
integer.")
2020-02-17 12:42:07 +03:00
(defmodule Int64
(register = (λ [Int64 Int64] Bool))
(register > (λ [Int64 Int64] Bool))
(register < (λ [Int64 Int64] Bool))
(register + (λ [Int64 Int64] Int64))
(register - (λ [Int64 Int64] Int64))
(register * (λ [Int64 Int64] Int64))
(register / (λ [Int64 Int64] Int64))
(register bit-shift-left (λ [Int64 Int64] Int64))
(register bit-shift-right (λ [Int64 Int64] Int64))
(register bit-or (λ [Int64 Int64] Int64))
(register bit-and (λ [Int64 Int64] Int64))
(register bit-not (λ [Int64] Int64))
(register bit-xor (λ [Int64 Int64] Int64))
(register to-long (λ [Int64] Long))
(register from-long (λ [Long] Int64))
(register copy (Fn [&Int64] Int64))
2020-02-21 07:39:25 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Int64)))
(implements + Int64.+)
(implements - Int64.-)
(implements * Int64.*)
(implements / Int64./)
(implements < Int64.<)
(implements > Int64.>)
(implements = Int64.=)
(implements copy Int64.copy)
(implements zero Int64.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Int64.bit-shift-left)
(implements bit-shift-right Int64.bit-shift-right)
(implements bit-and Int64.bit-and)
(implements bit-or Int64.bit-or)
(implements bit-xor Int64.bit-xor)
(implements bit-not Int64.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Int64Extra
(defn = [a b] (Int64.= @a @b))
(implements = Int64Extra.=)
2020-02-17 12:42:07 +03:00
)
2021-07-05 15:48:35 +03:00
(doc Uint8 "is a thin wrapper around the `uint8_t` C data type, an unsigned
8-bit integer.")
2020-02-17 12:42:07 +03:00
(defmodule Uint8
(register = (λ [Uint8 Uint8] Bool))
(register > (λ [Uint8 Uint8] Bool))
(register < (λ [Uint8 Uint8] Bool))
(register + (λ [Uint8 Uint8] Uint8))
(register - (λ [Uint8 Uint8] Uint8))
(register * (λ [Uint8 Uint8] Uint8))
(register / (λ [Uint8 Uint8] Uint8))
(register bit-shift-left (λ [Uint8 Uint8] Uint8))
(register bit-shift-right (λ [Uint8 Uint8] Uint8))
(register bit-or (λ [Uint8 Uint8] Uint8))
(register bit-and (λ [Uint8 Uint8] Uint8))
(register bit-not (λ [Uint8] Uint8))
(register bit-xor (λ [Uint8 Uint8] Uint8))
(register to-long (λ [Uint8] Long))
(register from-long (λ [Long] Uint8))
(register copy (Fn [&Uint8] Uint8))
2020-02-21 07:39:25 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Uint8)))
(implements + Uint8.+)
(implements - Uint8.-)
(implements * Uint8.*)
(implements / Uint8./)
(implements < Uint8.<)
(implements > Uint8.>)
(implements = Uint8.=)
(implements copy Uint8.copy)
(implements zero Uint8.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Uint8.bit-shift-left)
(implements bit-shift-right Uint8.bit-shift-right)
(implements bit-and Uint8.bit-and)
(implements bit-or Uint8.bit-or)
(implements bit-xor Uint8.bit-xor)
(implements bit-not Uint8.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Uint8Extra
(defn = [a b] (Uint8.= @a @b))
(implements = Uint8Extra.=)
2020-02-17 12:42:07 +03:00
)
2021-07-05 15:48:35 +03:00
(doc Uint16 "is a thin wrapper around the `uint16_t` C data type, an unsigned
16-bit integer.")
2020-02-17 12:42:07 +03:00
(defmodule Uint16
(register = (λ [Uint16 Uint16] Bool))
(register > (λ [Uint16 Uint16] Bool))
(register < (λ [Uint16 Uint16] Bool))
(register + (λ [Uint16 Uint16] Uint16))
(register - (λ [Uint16 Uint16] Uint16))
(register * (λ [Uint16 Uint16] Uint16))
(register / (λ [Uint16 Uint16] Uint16))
(register bit-shift-left (λ [Uint16 Uint16] Uint16))
(register bit-shift-right (λ [Uint16 Uint16] Uint16))
(register bit-or (λ [Uint16 Uint16] Uint16))
(register bit-and (λ [Uint16 Uint16] Uint16))
(register bit-not (λ [Uint16] Uint16))
(register bit-xor (λ [Uint16 Uint16] Uint16))
(register to-long (λ [Uint16] Long))
(register from-long (λ [Long] Uint16))
(register copy (Fn [&Uint16] Uint16))
2020-02-20 22:12:14 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Uint16)))
(implements + Uint16.+)
(implements - Uint16.-)
(implements * Uint16.*)
(implements / Uint16./)
(implements < Uint16.<)
(implements > Uint16.>)
(implements = Uint16.=)
(implements copy Uint16.copy)
(implements zero Uint16.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Uint16.bit-shift-left)
(implements bit-shift-right Uint16.bit-shift-right)
(implements bit-and Uint16.bit-and)
(implements bit-or Uint16.bit-or)
(implements bit-xor Uint16.bit-xor)
(implements bit-not Uint16.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Uint16Extra
(defn = [a b] (Uint16.= @a @b))
(implements = Uint16Extra.=)
2020-02-17 12:42:07 +03:00
)
2021-07-05 15:48:35 +03:00
(doc Uint32 "is a thin wrapper around the `uint32_t` C data type, an unsigned
32-bit integer.")
2020-02-17 12:42:07 +03:00
(defmodule Uint32
(register = (λ [Uint32 Uint32] Bool))
(register > (λ [Uint32 Uint32] Bool))
(register < (λ [Uint32 Uint32] Bool))
(register + (λ [Uint32 Uint32] Uint32))
(register - (λ [Uint32 Uint32] Uint32))
(register * (λ [Uint32 Uint32] Uint32))
(register / (λ [Uint32 Uint32] Uint32))
(register bit-shift-left (λ [Uint32 Uint32] Uint32))
(register bit-shift-right (λ [Uint32 Uint32] Uint32))
(register bit-or (λ [Uint32 Uint32] Uint32))
(register bit-and (λ [Uint32 Uint32] Uint32))
(register bit-not (λ [Uint32] Uint32))
(register bit-xor (λ [Uint32 Uint32] Uint32))
(register to-long (λ [Uint32] Long))
(register from-long (λ [Long] Uint32))
(register copy (Fn [&Uint32] Uint32))
2020-02-20 22:12:14 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Uint32)))
(implements + Uint32.+)
(implements - Uint32.-)
(implements * Uint32.*)
(implements / Uint32./)
(implements < Uint32.<)
(implements > Uint32.>)
(implements = Uint32.=)
(implements copy Uint32.copy)
(implements zero Uint32.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Uint32.bit-shift-left)
(implements bit-shift-right Uint32.bit-shift-right)
(implements bit-and Uint32.bit-and)
(implements bit-or Uint32.bit-or)
(implements bit-xor Uint32.bit-xor)
(implements bit-not Uint32.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Uint32Extra
(defn = [a b] (Uint32.= @a @b))
(implements = Uint32Extra.=)
2020-02-17 12:42:07 +03:00
)
2021-07-05 15:48:35 +03:00
(doc Uint64 "is a thin wrapper around the `uint64_t` C data type, an unsigned
64-bit integer.")
2020-02-17 12:42:07 +03:00
(defmodule Uint64
(register = (λ [Uint64 Uint64] Bool))
(register > (λ [Uint64 Uint64] Bool))
(register < (λ [Uint64 Uint64] Bool))
(register + (λ [Uint64 Uint64] Uint64))
(register - (λ [Uint64 Uint64] Uint64))
(register * (λ [Uint64 Uint64] Uint64))
(register / (λ [Uint64 Uint64] Uint64))
(register bit-shift-left (λ [Uint64 Uint64] Uint64))
(register bit-shift-right (λ [Uint64 Uint64] Uint64))
(register bit-or (λ [Uint64 Uint64] Uint64))
(register bit-and (λ [Uint64 Uint64] Uint64))
(register bit-not (λ [Uint64] Uint64))
(register bit-xor (λ [Uint64 Uint64] Uint64))
(register to-long (λ [Uint64] Long))
(register from-long (λ [Long] Uint64))
(register copy (Fn [&Uint64] Uint64))
2020-02-20 22:12:14 +03:00
(defn zero [] (from-long 0l))
2020-02-17 12:42:07 +03:00
(register from-bytes (Fn [&(Array Byte)] (Array Uint64)))
(implements + Uint64.+)
(implements - Uint64.-)
(implements * Uint64.*)
(implements / Uint64./)
(implements < Uint64.<)
(implements > Uint64.>)
(implements = Uint64.=)
(implements copy Uint64.copy)
(implements zero Uint64.zero)
2020-07-08 22:11:13 +03:00
(implements bit-shift-left Uint64.bit-shift-left)
(implements bit-shift-right Uint64.bit-shift-right)
(implements bit-and Uint64.bit-and)
(implements bit-or Uint64.bit-or)
(implements bit-xor Uint64.bit-xor)
(implements bit-not Uint64.bit-not)
2020-02-17 12:42:07 +03:00
)
(defmodule Uint64Extra
(defn = [a b] (Uint64.= @a @b))
(implements = Uint64Extra.=)
2020-02-17 12:42:07 +03:00
)