core: Fill out missing functions for basic types
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#[doc = "Operations and constants constants for `f32`"];
|
#[doc = "Operations and constants for `f32`"];
|
||||||
|
|
||||||
// PORT
|
// PORT
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#[doc = "Operations and constants constants for `f64`"];
|
#[doc = "Operations and constants for `f64`"];
|
||||||
|
|
||||||
// PORT
|
// PORT
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#[doc = "Operations and constants constants for `float`"];
|
#[doc = "Operations and constants for `float`"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Module: float
|
Module: float
|
||||||
|
|||||||
@@ -1 +1,28 @@
|
|||||||
#[doc = "Operations and constants constants for `i16`"];
|
#[doc = "Operations and constants for `i16`"];
|
||||||
|
|
||||||
|
const min_value: i16 = -1i16 << 15i16;
|
||||||
|
const max_value: i16 = (-1i16 << 15i16) - 1i16;
|
||||||
|
|
||||||
|
pure fn add(x: i16, y: i16) -> i16 { x + y }
|
||||||
|
pure fn sub(x: i16, y: i16) -> i16 { x - y }
|
||||||
|
pure fn mul(x: i16, y: i16) -> i16 { x * y }
|
||||||
|
pure fn div(x: i16, y: i16) -> i16 { x / y }
|
||||||
|
pure fn rem(x: i16, y: i16) -> i16 { x % y }
|
||||||
|
|
||||||
|
pure fn lt(x: i16, y: i16) -> bool { x < y }
|
||||||
|
pure fn le(x: i16, y: i16) -> bool { x <= y }
|
||||||
|
pure fn eq(x: i16, y: i16) -> bool { x == y }
|
||||||
|
pure fn ne(x: i16, y: i16) -> bool { x != y }
|
||||||
|
pure fn ge(x: i16, y: i16) -> bool { x >= y }
|
||||||
|
pure fn gt(x: i16, y: i16) -> bool { x > y }
|
||||||
|
|
||||||
|
pure fn positive(x: i16) -> bool { x > 0i16 }
|
||||||
|
pure fn negative(x: i16) -> bool { x < 0i16 }
|
||||||
|
pure fn nonpositive(x: i16) -> bool { x <= 0i16 }
|
||||||
|
pure fn nonnegative(x: i16) -> bool { x >= 0i16 }
|
||||||
|
|
||||||
|
#[doc = "Iterate over the range [`lo`..`hi`)"]
|
||||||
|
fn range(lo: i16, hi: i16, it: fn(i16)) {
|
||||||
|
let i = lo;
|
||||||
|
while i < hi { it(i); i += 1i16; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1,28 @@
|
|||||||
#[doc = "Operations and constants constants for `i32`"];
|
#[doc = "Operations and constants for `i32`"];
|
||||||
|
|
||||||
|
const min_value: i32 = -1i32 << 31i32;
|
||||||
|
const max_value: i32 = (-1i32 << 31i32) - 1i32;
|
||||||
|
|
||||||
|
pure fn add(x: i32, y: i32) -> i32 { x + y }
|
||||||
|
pure fn sub(x: i32, y: i32) -> i32 { x - y }
|
||||||
|
pure fn mul(x: i32, y: i32) -> i32 { x * y }
|
||||||
|
pure fn div(x: i32, y: i32) -> i32 { x / y }
|
||||||
|
pure fn rem(x: i32, y: i32) -> i32 { x % y }
|
||||||
|
|
||||||
|
pure fn lt(x: i32, y: i32) -> bool { x < y }
|
||||||
|
pure fn le(x: i32, y: i32) -> bool { x <= y }
|
||||||
|
pure fn eq(x: i32, y: i32) -> bool { x == y }
|
||||||
|
pure fn ne(x: i32, y: i32) -> bool { x != y }
|
||||||
|
pure fn ge(x: i32, y: i32) -> bool { x >= y }
|
||||||
|
pure fn gt(x: i32, y: i32) -> bool { x > y }
|
||||||
|
|
||||||
|
pure fn positive(x: i32) -> bool { x > 0i32 }
|
||||||
|
pure fn negative(x: i32) -> bool { x < 0i32 }
|
||||||
|
pure fn nonpositive(x: i32) -> bool { x <= 0i32 }
|
||||||
|
pure fn nonnegative(x: i32) -> bool { x >= 0i32 }
|
||||||
|
|
||||||
|
#[doc = "Iterate over the range [`lo`..`hi`)"]
|
||||||
|
fn range(lo: i32, hi: i32, it: fn(i32)) {
|
||||||
|
let i = lo;
|
||||||
|
while i < hi { it(i); i += 1i32; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1,28 @@
|
|||||||
#[doc = "Operations and constants constants for `i64`"];
|
#[doc = "Operations and constants constants for `i64`"];
|
||||||
|
|
||||||
|
const min_value: i64 = -1i64 << 63i64;
|
||||||
|
const max_value: i64 = (-1i64 << 63i64) - 1i64;
|
||||||
|
|
||||||
|
pure fn add(x: i64, y: i64) -> i64 { x + y }
|
||||||
|
pure fn sub(x: i64, y: i64) -> i64 { x - y }
|
||||||
|
pure fn mul(x: i64, y: i64) -> i64 { x * y }
|
||||||
|
pure fn div(x: i64, y: i64) -> i64 { x / y }
|
||||||
|
pure fn rem(x: i64, y: i64) -> i64 { x % y }
|
||||||
|
|
||||||
|
pure fn lt(x: i64, y: i64) -> bool { x < y }
|
||||||
|
pure fn le(x: i64, y: i64) -> bool { x <= y }
|
||||||
|
pure fn eq(x: i64, y: i64) -> bool { x == y }
|
||||||
|
pure fn ne(x: i64, y: i64) -> bool { x != y }
|
||||||
|
pure fn ge(x: i64, y: i64) -> bool { x >= y }
|
||||||
|
pure fn gt(x: i64, y: i64) -> bool { x > y }
|
||||||
|
|
||||||
|
pure fn positive(x: i64) -> bool { x > 0i64 }
|
||||||
|
pure fn negative(x: i64) -> bool { x < 0i64 }
|
||||||
|
pure fn nonpositive(x: i64) -> bool { x <= 0i64 }
|
||||||
|
pure fn nonnegative(x: i64) -> bool { x >= 0i64 }
|
||||||
|
|
||||||
|
#[doc = "Iterate over the range [`lo`..`hi`)"]
|
||||||
|
fn range(lo: i64, hi: i64, it: fn(i64)) {
|
||||||
|
let i = lo;
|
||||||
|
while i < hi { it(i); i += 1i64; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1 +1,28 @@
|
|||||||
#[doc = "Operations and constants constants for `i8`"];
|
#[doc = "Operations and constants for `i8`"];
|
||||||
|
|
||||||
|
const min_value: i8 = -1i8 << 7i8;
|
||||||
|
const max_value: i8 = (-1i8 << 7i8) - 1i8;
|
||||||
|
|
||||||
|
pure fn add(x: i8, y: i8) -> i8 { x + y }
|
||||||
|
pure fn sub(x: i8, y: i8) -> i8 { x - y }
|
||||||
|
pure fn mul(x: i8, y: i8) -> i8 { x * y }
|
||||||
|
pure fn div(x: i8, y: i8) -> i8 { x / y }
|
||||||
|
pure fn rem(x: i8, y: i8) -> i8 { x % y }
|
||||||
|
|
||||||
|
pure fn lt(x: i8, y: i8) -> bool { x < y }
|
||||||
|
pure fn le(x: i8, y: i8) -> bool { x <= y }
|
||||||
|
pure fn eq(x: i8, y: i8) -> bool { x == y }
|
||||||
|
pure fn ne(x: i8, y: i8) -> bool { x != y }
|
||||||
|
pure fn ge(x: i8, y: i8) -> bool { x >= y }
|
||||||
|
pure fn gt(x: i8, y: i8) -> bool { x > y }
|
||||||
|
|
||||||
|
pure fn positive(x: i8) -> bool { x > 0i8 }
|
||||||
|
pure fn negative(x: i8) -> bool { x < 0i8 }
|
||||||
|
pure fn nonpositive(x: i8) -> bool { x <= 0i8 }
|
||||||
|
pure fn nonnegative(x: i8) -> bool { x >= 0i8 }
|
||||||
|
|
||||||
|
#[doc = "Iterate over the range [`lo`..`hi`)"]
|
||||||
|
fn range(lo: i8, hi: i8, it: fn(i8)) {
|
||||||
|
let i = lo;
|
||||||
|
while i < hi { it(i); i += 1i8; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
#[doc = "Operations and constants constants for `int`"];
|
#[doc = "Operations and constants for `int`"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Module: int
|
Module: int
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Const: min_value
|
||||||
|
|
||||||
|
The minumum value of an integer
|
||||||
|
*/
|
||||||
|
#[cfg(target_arch="x86")]
|
||||||
|
const min_value: int = -1 << 31;
|
||||||
|
|
||||||
|
#[cfg(target_arch="x86_64")]
|
||||||
|
const min_value: int = -1 << 63;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Const: max_value
|
Const: max_value
|
||||||
|
|
||||||
@@ -16,17 +27,6 @@ const max_value: int = (-1 << 31)-1;
|
|||||||
#[cfg(target_arch="x86_64")]
|
#[cfg(target_arch="x86_64")]
|
||||||
const max_value: int = (-1 << 63)-1;
|
const max_value: int = (-1 << 63)-1;
|
||||||
|
|
||||||
/*
|
|
||||||
Const: min_value
|
|
||||||
|
|
||||||
The minumum value of an integer
|
|
||||||
*/
|
|
||||||
#[cfg(target_arch="x86")]
|
|
||||||
const min_value: int = -1 << 31;
|
|
||||||
|
|
||||||
#[cfg(target_arch="x86_64")]
|
|
||||||
const min_value: int = -1 << 63;
|
|
||||||
|
|
||||||
/* Function: add */
|
/* Function: add */
|
||||||
pure fn add(x: int, y: int) -> int { ret x + y; }
|
pure fn add(x: int, y: int) -> int { ret x + y; }
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,28 @@
|
|||||||
#[doc = "Operations and constants constants for `u16`"];
|
#[doc = "Operations and constants for `u16`"];
|
||||||
|
|
||||||
|
const min_value: u16 = 0u16;
|
||||||
|
const max_value: u16 = 0u16 - 1u16;
|
||||||
|
|
||||||
|
pure fn add(x: u16, y: u16) -> u16 { x + y }
|
||||||
|
pure fn sub(x: u16, y: u16) -> u16 { x - y }
|
||||||
|
pure fn mul(x: u16, y: u16) -> u16 { x * y }
|
||||||
|
pure fn div(x: u16, y: u16) -> u16 { x / y }
|
||||||
|
pure fn rem(x: u16, y: u16) -> u16 { x % y }
|
||||||
|
|
||||||
|
pure fn lt(x: u16, y: u16) -> bool { x < y }
|
||||||
|
pure fn le(x: u16, y: u16) -> bool { x <= y }
|
||||||
|
pure fn eq(x: u16, y: u16) -> bool { x == y }
|
||||||
|
pure fn ne(x: u16, y: u16) -> bool { x != y }
|
||||||
|
pure fn ge(x: u16, y: u16) -> bool { x >= y }
|
||||||
|
pure fn gt(x: u16, y: u16) -> bool { x > y }
|
||||||
|
|
||||||
|
pure fn positive(x: u16) -> bool { x > 0u16 }
|
||||||
|
pure fn negative(x: u16) -> bool { x < 0u16 }
|
||||||
|
pure fn nonpositive(x: u16) -> bool { x <= 0u16 }
|
||||||
|
pure fn nonnegative(x: u16) -> bool { x >= 0u16 }
|
||||||
|
|
||||||
|
#[doc = "Iterate over the range [`lo`..`hi`)"]
|
||||||
|
fn range(lo: u16, hi: u16, it: fn(u16)) {
|
||||||
|
let i = lo;
|
||||||
|
while i < hi { it(i); i += 1u16; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#[doc = "Operations and constants constants for `u32`"];
|
#[doc = "Operations and constants for `u32`"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Module: u32
|
Module: u32
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#[doc = "Operations and constants constants for `u64`"];
|
#[doc = "Operations and constants for `u64`"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Module: u64
|
Module: u64
|
||||||
|
|||||||
@@ -1,16 +1,9 @@
|
|||||||
#[doc = "Operations and constants constants for `u8`"];
|
#[doc = "Operations and constants for `u8`"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Module: u8
|
Module: u8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
Const: max_value
|
|
||||||
|
|
||||||
The maximum value of a u8.
|
|
||||||
*/
|
|
||||||
const max_value: u8 = 255u8;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Const: min_value
|
Const: min_value
|
||||||
|
|
||||||
@@ -18,6 +11,13 @@ The minumum value of a u8.
|
|||||||
*/
|
*/
|
||||||
const min_value: u8 = 0u8;
|
const min_value: u8 = 0u8;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Const: max_value
|
||||||
|
|
||||||
|
The maximum value of a u8.
|
||||||
|
*/
|
||||||
|
const max_value: u8 = 255u8;
|
||||||
|
|
||||||
/* Function: add */
|
/* Function: add */
|
||||||
pure fn add(x: u8, y: u8) -> u8 { ret x + y; }
|
pure fn add(x: u8, y: u8) -> u8 { ret x + y; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#[doc = "Operations and constants constants for `uint`"];
|
#[doc = "Operations and constants for `uint`"];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Module: uint
|
Module: uint
|
||||||
|
|||||||
Reference in New Issue
Block a user