wip dashu move

This commit is contained in:
Fayeed Pawaskar
2023-07-17 20:40:41 +05:30
parent 5d09449c95
commit cf345d8174
17 changed files with 165 additions and 38 deletions

View File

@@ -8,7 +8,7 @@ use crate::heap_iter::*;
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;
@@ -338,7 +338,7 @@ pub(crate) fn int_pow(n1: Number, n2: Number, arena: &mut Arena) -> Result<Numbe
(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 {
@@ -349,7 +349,7 @@ pub(crate) fn int_pow(n1: Number, n2: Number, arena: &mut Arena) -> Result<Numbe
(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 {
@@ -358,7 +358,7 @@ pub(crate) fn int_pow(n1: Number, n2: Number, arena: &mut Arena) -> Result<Numbe
}
}
(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 {

View File

@@ -6,7 +6,7 @@ use crate::machine::loader::*;
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};
@@ -236,7 +236,7 @@ fn merge_branch_seq<Iter: Iterator<Item = BranchInfo>>(branches: Iter) -> Branch
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

View File

@@ -6,7 +6,7 @@ use crate::machine::partial_string::*;
use crate::parser::ast::*;
use crate::types::*;
use crate::parser::rug::{Integer, Rational};
use crate::parser::dashu::{Integer, Rational};
use std::convert::TryFrom;

View File

@@ -1644,7 +1644,7 @@ impl Machine {
.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())
}

View File

@@ -14,7 +14,7 @@ use crate::machine::streams::*;
use crate::parser::ast::*;
use crate::types::*;
use crate::parser::rug::Integer;
use crate::parser::dashu::Integer;
use indexmap::IndexMap;

View File

@@ -13,7 +13,7 @@ use crate::machine::partial_string::*;
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;

View File

@@ -41,7 +41,7 @@ use crate::machine::machine_state::*;
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;

View File

@@ -24,7 +24,7 @@ use crate::machine::preprocessor::to_op_decl;
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::*;