diff --git a/mute-interpreter/src/env/core.rs b/mute-interpreter/src/env/core.rs index b497b2c..f17f1ca 100644 --- a/mute-interpreter/src/env/core.rs +++ b/mute-interpreter/src/env/core.rs @@ -1,9 +1,9 @@ use std::borrow::Borrow; use std::collections::HashMap; -use crate::{Error, Node}; use crate::evaluator::{eval, eval_node}; use crate::macros::arg_count; +use crate::{Error, Node}; pub(super) fn core() -> HashMap { [ @@ -92,23 +92,13 @@ pub(super) fn core() -> HashMap { let res = args .into_iter() .reduce(|lhs, rhs| match (lhs, rhs) { - (Node::Int(lhs), Node::Int(rhs)) => match lhs.checked_add(rhs) { - Some(val) => Node::Int(val), - None => Node::Int128(lhs as i128 + rhs as i128), - }, - (Node::Int128(lhs), Node::Int128(rhs)) => Node::Int128(lhs + rhs), - (Node::Int(lhs), Node::Int128(rhs)) => { - Node::Int128(lhs as i128 + rhs as i128) - } - (Node::Int128(lhs), Node::Int(rhs)) => Node::Int128(lhs + rhs as i128), - + (Node::Int(lhs), Node::Int(rhs)) => Node::Int(lhs + rhs), (Node::Float(lhs), Node::Float(rhs)) => Node::Float(lhs + rhs), (Node::Int(lhs), Node::Float(rhs)) => Node::Float(lhs as f64 + rhs), (Node::Float(lhs), Node::Int(rhs)) => Node::Float(lhs + rhs as f64), _ => todo!(), }) .unwrap_or(Node::Int(0)); - Ok(res) }), ), @@ -118,16 +108,7 @@ pub(super) fn core() -> HashMap { let res = args .into_iter() .reduce(|lhs, rhs| match (lhs, rhs) { - (Node::Int(lhs), Node::Int(rhs)) => match lhs.checked_sub(rhs) { - Some(val) => Node::Int(val), - None => Node::Int128(lhs as i128 - rhs as i128), - }, - (Node::Int128(lhs), Node::Int128(rhs)) => Node::Int128(lhs - rhs), - (Node::Int(lhs), Node::Int128(rhs)) => { - Node::Int128(lhs as i128 - rhs as i128) - } - (Node::Int128(lhs), Node::Int(rhs)) => Node::Int128(lhs - rhs as i128), - + (Node::Int(lhs), Node::Int(rhs)) => Node::Int(lhs - rhs), (Node::Float(lhs), Node::Float(rhs)) => Node::Float(lhs - rhs), (Node::Float(lhs), Node::Int(rhs)) => Node::Float(lhs - rhs as f64), (Node::Int(lhs), Node::Float(rhs)) => Node::Float(lhs as f64 - rhs), @@ -144,16 +125,7 @@ pub(super) fn core() -> HashMap { let res = args .into_iter() .reduce(|lhs, rhs| match (lhs, rhs) { - (Node::Int(lhs), Node::Int(rhs)) => match lhs.checked_mul(rhs) { - Some(val) => Node::Int(val), - None => Node::Int128(lhs as i128 * rhs as i128), - }, - (Node::Int128(lhs), Node::Int128(rhs)) => Node::Int128(lhs * rhs), - (Node::Int(lhs), Node::Int128(rhs)) => { - Node::Int128(lhs as i128 * rhs as i128) - } - (Node::Int128(lhs), Node::Int(rhs)) => Node::Int128(lhs * rhs as i128), - + (Node::Int(lhs), Node::Int(rhs)) => Node::Int(lhs * rhs), (Node::Float(lhs), Node::Float(rhs)) => Node::Float(lhs * rhs), (Node::Float(lhs), Node::Int(rhs)) => Node::Float(lhs * rhs as f64), (Node::Int(lhs), Node::Float(rhs)) => Node::Float(lhs as f64 * rhs), @@ -170,16 +142,7 @@ pub(super) fn core() -> HashMap { let res = args .into_iter() .reduce(|lhs, rhs| match (lhs, rhs) { - (Node::Int(lhs), Node::Int(rhs)) => match lhs.checked_div(rhs) { - Some(val) => Node::Int(val), - None => Node::Int128(lhs as i128 / rhs as i128), - }, - (Node::Int128(lhs), Node::Int128(rhs)) => Node::Int128(lhs / rhs), - (Node::Int(lhs), Node::Int128(rhs)) => { - Node::Int128(lhs as i128 / rhs as i128) - } - (Node::Int128(lhs), Node::Int(rhs)) => Node::Int128(lhs / rhs as i128), - + (Node::Int(lhs), Node::Int(rhs)) => Node::Int(lhs / rhs), (Node::Float(lhs), Node::Float(rhs)) => Node::Float(lhs / rhs), (Node::Float(lhs), Node::Int(rhs)) => Node::Float(lhs / rhs as f64), (Node::Int(lhs), Node::Float(rhs)) => Node::Float(lhs as f64 / rhs), diff --git a/mute-interpreter/src/node.rs b/mute-interpreter/src/node.rs index 38fb8a2..5ace2fe 100644 --- a/mute-interpreter/src/node.rs +++ b/mute-interpreter/src/node.rs @@ -10,7 +10,6 @@ pub enum Node { Symbol(String), Keyword(String), Int(i64), - Int128(i128), Float(f64), String(String), Boolean(bool), @@ -36,7 +35,6 @@ impl From for Node { mute_parser::Node::Symbol(symbol) => Node::Symbol(symbol), mute_parser::Node::Keyword(keyword) => Node::Keyword(keyword), mute_parser::Node::Int(int) => Node::Int(int), - mute_parser::Node::Int128(int) => Node::Int128(int), mute_parser::Node::Float(float) => Node::Float(float), mute_parser::Node::String(string) => Node::String(string), mute_parser::Node::Boolean(boolean) => Node::Boolean(boolean), @@ -65,7 +63,6 @@ impl std::fmt::Display for Node { } Node::Int(val) => write!(f, "{}", val), - Node::Int128(val) => write!(f, "{}", val), Node::Float(val) => write!(f, "{}", val), Node::Boolean(true) => write!(f, "true"), Node::Boolean(false) => write!(f, "false"), diff --git a/mute-parser/src/node.rs b/mute-parser/src/node.rs index 8a3aa60..87615c7 100644 --- a/mute-parser/src/node.rs +++ b/mute-parser/src/node.rs @@ -7,7 +7,6 @@ pub enum Node { Symbol(String), Keyword(String), Int(i64), - Int128(i128), Float(f64), String(String), Boolean(bool), @@ -31,7 +30,6 @@ impl std::fmt::Display for Node { } Node::Int(val) => write!(f, "{}", val), - Node::Int128(val) => write!(f, "{}", val), Node::Float(val) => write!(f, "{}", val), Node::Boolean(true) => write!(f, "true"), Node::Boolean(false) => write!(f, "false"),