"windows-sys 0.48.0",
]
+[[package]]
+name = "dashu"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "51a1b5a00793e3ac2239993ef582603764bcb333a4d04c2a0944639a7e916c85"
+dependencies = [
+ "dashu-base",
+ "dashu-float",
+ "dashu-int",
+ "dashu-macros",
+ "dashu-ratio",
+]
+
+[[package]]
+name = "dashu-base"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f2585452b8ecf7c874045dba02a7914b7e5b2e3cdd5e152573413aa290197aa"
+
+[[package]]
+name = "dashu-float"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a168f338914fab603c31a371207c8b3245ab5ff5e9a0f4fd64a9b5f8a972d1f"
+dependencies = [
+ "dashu-base",
+ "dashu-int",
+ "num-traits",
+ "rand",
+ "static_assertions",
+]
+
+[[package]]
+name = "dashu-int"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57a1009a3ce0c4c64e977c5e7dd8c475278750e145cbb8956d1e28832f557975"
+dependencies = [
+ "cfg-if",
+ "dashu-base",
+ "num-order",
+ "num-traits",
+ "rand",
+ "static_assertions",
+]
+
+[[package]]
+name = "dashu-macros"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6fc2425b6724a7d5bfc8e57044e231803b5fc3a7283d6efbff34bfab6ebe014"
+dependencies = [
+ "dashu-base",
+ "dashu-float",
+ "dashu-int",
+ "dashu-ratio",
+ "proc-macro2",
+ "quote",
+]
+
+[[package]]
+name = "dashu-ratio"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4b57c839e72af6be14e5c55630ffc9429c9970aed48f7db449b2399467336b4"
+dependencies = [
+ "dashu-base",
+ "dashu-float",
+ "dashu-int",
+ "num-traits",
+ "rand",
+]
+
[[package]]
name = "derive_deref"
version = "1.1.1"
"winapi",
]
+[[package]]
+name = "num-integer"
+version = "0.1.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
+dependencies = [
+ "autocfg",
+ "num-traits",
+]
+
+[[package]]
+name = "num-modular"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64a5fe11d4135c3bcdf3a95b18b194afa9608a5f6ff034f5d857bc9a27fb0119"
+dependencies = [
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-order"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e81e321057a0370997b13e6638bba6bd7f6f426e1f8e9a2562490a28eb23e1bc"
+dependencies = [
+ "num-modular",
+ "num-traits",
+]
+
[[package]]
name = "num-traits"
version = "0.2.15"
"crossterm",
"crrl",
"ctrlc",
+ "dashu",
"derive_deref",
"dirs-next",
"divrem",
libffi = "3.1.0"
libloading = "0.7"
derive_deref = "1.1.1"
+dashu = "0.3.0"
[dev-dependencies]
assert_cmd = "1.0.3"
use crate::read::*;
use ordered_float::OrderedFloat;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use std::alloc;
use std::fmt;
self.0.as_ptr()
}
+ #[inline]
+ pub fn to_i64(&self) -> Option<i64> {
+ self.to_i64()
+ }
+
+ #[inline]
+ pub fn to_u32(&self) -> Option<u32> {
+ self.to_u32()
+ }
+
+ #[inline]
+ pub fn to_usize(&self) -> Option<usize> {
+ self.to_usize()
+ }
+
+ #[inline]
+ pub fn to_isize(&self) -> Option<isize> {
+ self.to_isize()
+ }
+
#[inline]
pub fn header_ptr(&self) -> *const ArenaHeader {
let mut ptr = self.as_ptr() as *const u8 as usize;
use crate::machine::partial_string::*;
use ordered_float::OrderedFloat;
- use crate::parser::rug::{Integer, Rational};
+ use crate::parser::dashu::{Integer, Rational};
#[test]
fn float_ptr_cast() {
// rational
- let big_rat = 2 * Rational::from(1u64 << 63);
+ let big_rat = Rational::from(2) * Rational::from(1u64 << 63);
let big_rat_ptr: TypedArenaPtr<Rational> = arena_alloc!(big_rat, &mut wam.machine_st.arena);
assert!(!big_rat_ptr.as_ptr().is_null());
(HeapCellValueTag::Cons, cons_ptr) => {
match_untyped_arena_ptr!(cons_ptr,
(ArenaHeaderTag::Rational, n) => {
- assert_eq!(&*n, &(2 * Rational::from(1u64 << 63)));
+ assert_eq!(&*n, &(Rational::from(2) * Rational::from(1u64 << 63)));
}
_ => unreachable!()
)
use crate::parser::ast::*;
use crate::parser::rug::ops::PowAssign;
-use crate::parser::rug::{Assign, Integer, Rational};
+use crate::parser::rug::{Assign};
+use crate::parser::dashu::{Integer, Rational};
use crate::machine::machine_errors::*;
if I64_MIN_TO_F <= f && f <= I64_MAX_TO_F {
fixnum!(Number, f.into_inner() as i64, arena)
} else {
- Number::Integer(arena_alloc!(Integer::from_f64(f.into_inner()).unwrap(), arena))
+ Number::Integer(arena_alloc!(Integer::from(f.into_inner()).unwrap(), arena))
}
}
&Number::Rational(ref r) => {
let r_ref = r.fract_floor_ref();
- let (mut fract, mut floor) = (Rational::new(), Integer::new());
+ let (mut fract, mut floor) = (Rational::from(0), Integer::from(0));
(&mut fract, &mut floor).assign(r_ref);
if let Some(floor) = floor.to_i64() {
pub(crate) fn rnd_f(n: &Number) -> f64 {
match n {
&Number::Fixnum(n) => n.get_num() as f64,
- &Number::Integer(ref n) => n.to_f64(),
+ &Number::Integer(ref n) => n.to_f64().value(),
&Number::Float(OrderedFloat(f)) => f,
- &Number::Rational(ref r) => r.to_f64(),
+ &Number::Rational(ref r) => r.to_f64().value(),
}
}
use crate::machine::machine_indices::*;
use crate::parser::ast::*;
use crate::parser::parser::CompositeOpDesc;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use crate::types::*;
use fxhash::FxBuildHasher;
pub(crate) fn is_positive(&self) -> bool {
match self {
&Number::Fixnum(n) => n.get_num() > 0,
- &Number::Integer(ref n) => &**n > &0,
+ &Number::Integer(ref n) => &**n > &Integer::from(0),
&Number::Float(f) => f.is_sign_positive(),
- &Number::Rational(ref r) => &**r > &0,
+ &Number::Rational(ref r) => &**r > &Rational::from(0),
}
}
pub(crate) fn is_negative(&self) -> bool {
match self {
&Number::Fixnum(n) => n.get_num() < 0,
- &Number::Integer(ref n) => &**n < &0,
+ &Number::Integer(ref n) => &**n < &Integer::from(0),
&Number::Float(OrderedFloat(f)) => f.is_sign_negative() && OrderedFloat(f) != -0f64,
- &Number::Rational(ref r) => &**r < &0,
+ &Number::Rational(ref r) => &**r < &Rational::from(0),
}
}
pub(crate) fn is_zero(&self) -> bool {
match self {
&Number::Fixnum(n) => n.get_num() == 0,
- &Number::Integer(ref n) => &**n == &0,
+ &Number::Integer(ref n) => &**n == &Integer::from(0),
&Number::Float(f) => f == OrderedFloat(0f64) || f == OrderedFloat(-0f64),
- &Number::Rational(ref r) => &**r == &0,
+ &Number::Rational(ref r) => &**r == &Rational::from(0),
}
}
use crate::arena::*;
use crate::atom_table::*;
use crate::parser::ast::*;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use crate::{
alpha_numeric_char, capital_letter_char, cut_char, decimal_digit_char, graphic_token_char,
is_fx, is_infix, is_postfix, is_prefix, is_xf, is_xfx, is_xfy, is_yfx, semicolon_char,
fn is_negative(&self) -> bool {
match self {
NumberFocus::Unfocused(n) => n.is_negative(),
- NumberFocus::Denominator(r) | NumberFocus::Numerator(r) => **r < 0,
+ NumberFocus::Denominator(r) | NumberFocus::Numerator(r) => **r < Rational::from(0),
}
}
}
&& iter.leftmost_leaf_has_property(op_dir, |addr| match Number::try_from(addr) {
Ok(Number::Fixnum(n)) => n.get_num() > 0,
Ok(Number::Float(f)) => f > OrderedFloat(0f64),
- Ok(Number::Integer(n)) => &*n > &0,
- Ok(Number::Rational(n)) => &*n > &0,
+ Ok(Number::Integer(n)) => &*n > &Integer::from(0),
+ Ok(Number::Rational(n)) => &*n > &Rational::from(0),
_ => false,
})
} else {
let j = n.div_rem_floor(Integer::from(26));
let j = <(Integer, Integer)>::from(j).0;
- if j == 0 {
+ if j == Integer::from(0) {
CHAR_CODES[i].to_string()
} else {
format!("{}{}", CHAR_CODES[i], j)
}
}
Ok(Number::Integer(n)) => {
- if &*n >= &0 {
+ if &*n >= &Integer::from(0) {
Some(numbervar(Integer::from(offset + &*n)))
} else {
None
if self.numbervars && arity == 1 && name == atom!("$VAR") {
!self.iter.immediate_leaf_has_property(|addr| {
match Number::try_from(addr) {
- Ok(Number::Integer(n)) => &*n >= &0,
+ Ok(Number::Integer(n)) => &*n >= &Integer::from(0),
Ok(Number::Fixnum(n)) => n.get_num() >= 0,
Ok(Number::Float(f)) => f >= OrderedFloat(0f64),
- Ok(Number::Rational(r)) => &*r >= &0,
+ Ok(Number::Rational(r)) => &*r >= &Integer::from(0),
_ => false,
}
}) && needs_bracketing(op_desc, op)
use crate::machine::machine_errors::*;
use crate::machine::machine_state::*;
use crate::parser::ast::*;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use crate::types::*;
use crate::fixnum;
(Number::Fixnum(n1), Number::Integer(n2)) => {
let n1_i = n1.get_num();
- if !(n1_i == 1 || n1_i == 0 || n1_i == -1) && &*n2 < &0 {
+ if !(n1_i == 1 || n1_i == 0 || n1_i == -1) && &*n2 < &Integer::from(0) {
let n = Number::Fixnum(n1);
Err(numerical_type_error(ValidType::Float, n, stub_gen))
} else {
(Number::Integer(n1), Number::Fixnum(n2)) => {
let n2_i = n2.get_num();
- if !(&*n1 == &1 || &*n1 == &0 || &*n1 == &-1) && n2_i < 0 {
+ if !(&*n1 == &Integer::from(1) || &*n1 == &Integer::from(0) || &*n1 == &Integer::from(-1)) && n2_i < 0 {
let n = Number::Integer(n1);
Err(numerical_type_error(ValidType::Float, n, stub_gen))
} else {
}
}
(Number::Integer(n1), Number::Integer(n2)) => {
- if !(&*n1 == &1 || &*n1 == &0 || &*n1 == &-1) && &*n2 < &0 {
+ if !(&*n1 == &Integer::from(1) || &*n1 == &Integer::from(0) || &*n1 == &Integer::from(-1)) && &*n2 < &Integer::from(0) {
let n = Number::Integer(n1);
Err(numerical_type_error(ValidType::Float, n, stub_gen))
} else {
use crate::machine::machine_errors::CompilationError;
use crate::machine::preprocessor::*;
use crate::parser::ast::*;
-use crate::parser::rug::Rational;
+use crate::parser::dashu::{Rational, Integer};
use crate::variable_records::*;
use indexmap::{IndexMap, IndexSet};
branch_info.chunks.extend(branch.chunks.drain(..));
}
- branch_info.branch_num.delta *= 2;
+ branch_info.branch_num.delta = branch_info.branch_num.delta * Integer::from(2);
branch_info.branch_num.branch_num -= &branch_info.branch_num.delta;
branch_info
use crate::parser::ast::*;
use crate::types::*;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use std::convert::TryFrom;
.store(self.machine_st.deref(self.machine_st.registers[3]));
let arity = match Number::try_from(arity) {
- Ok(Number::Integer(n)) if &*n >= &0 && &*n <= &MAX_ARITY => Ok(n.to_usize().unwrap()),
+ Ok(Number::Integer(n)) if &*n >= &Integer::from(0) && &*n <= &Integer::from(MAX_ARITY) => Ok(n.to_usize().unwrap()),
Ok(Number::Fixnum(n)) if n.get_num() >= 0 && n.get_num() <= MAX_ARITY as i64 => {
Ok(usize::try_from(n.get_num()).unwrap())
}
use crate::parser::ast::*;
use crate::types::*;
-use crate::parser::rug::Integer;
+use crate::parser::dashu::Integer;
use indexmap::IndexMap;
use crate::machine::stack::*;
use crate::machine::unify::*;
use crate::parser::ast::*;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use indexmap::IndexSet;
use crate::machine::stack::*;
use crate::machine::streams::*;
use crate::parser::ast::*;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use crate::types::*;
use indexmap::IndexMap;
use crate::machine::stack::*;
use crate::machine::streams::*;
use crate::parser::char_reader::*;
-use crate::parser::rug::Integer;
+use crate::parser::dashu::Integer;
use crate::parser::rug::rand::RandState;
use crate::read::*;
use crate::types::*;
use std::rc::Rc;
use std::vec::Vec;
-use crate::parser::rug::{Integer, Rational};
+use crate::parser::dashu::{Integer, Rational};
use fxhash::FxBuildHasher;
use indexmap::IndexMap;
pub use crate::machine::machine_state::*;
use crate::parser::ast::*;
use crate::parser::char_reader::*;
-use crate::parser::rug::Integer;
+use crate::parser::dashu::Integer;
use std::convert::TryFrom;
use std::fmt;
#[cfg(feature = "rug")]
pub use rug;
+pub use dashu;
// #[macro_use]
// extern crate lazy_static;