Add stubs for MathNumber.
This commit is contained in:
parent
d8b8c223f0
commit
0a2e1b007c
@ -5,6 +5,10 @@ use crate::renderer::errors::WalkError;
|
|||||||
use crate::renderer::DustRenderer;
|
use crate::renderer::DustRenderer;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
use std::ops::Div;
|
||||||
|
use std::ops::Mul;
|
||||||
|
use std::ops::Rem;
|
||||||
|
use std::ops::Sub;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::{cmp::Ordering, fmt::Debug};
|
use std::{cmp::Ordering, fmt::Debug};
|
||||||
|
|
||||||
@ -104,6 +108,38 @@ impl<'a> Add<&'a dyn ContextElement> for &'a dyn ContextElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Sub<&'a dyn ContextElement> for &'a dyn ContextElement {
|
||||||
|
type Output = Option<IceResult<'a>>;
|
||||||
|
|
||||||
|
fn sub(self, other: &'a dyn ContextElement) -> Self::Output {
|
||||||
|
self.math_subtract(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Mul<&'a dyn ContextElement> for &'a dyn ContextElement {
|
||||||
|
type Output = Option<IceResult<'a>>;
|
||||||
|
|
||||||
|
fn mul(self, other: &'a dyn ContextElement) -> Self::Output {
|
||||||
|
self.math_multiply(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Div<&'a dyn ContextElement> for &'a dyn ContextElement {
|
||||||
|
type Output = Option<IceResult<'a>>;
|
||||||
|
|
||||||
|
fn div(self, other: &'a dyn ContextElement) -> Self::Output {
|
||||||
|
self.math_divide(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Rem<&'a dyn ContextElement> for &'a dyn ContextElement {
|
||||||
|
type Output = Option<IceResult<'a>>;
|
||||||
|
|
||||||
|
fn rem(self, other: &'a dyn ContextElement) -> Self::Output {
|
||||||
|
self.math_modulus(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait FromContextElement {
|
pub trait FromContextElement {
|
||||||
fn from_context_element(&self) -> &dyn IntoContextElement;
|
fn from_context_element(&self) -> &dyn IntoContextElement;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
use crate::parser::OwnedLiteral;
|
use crate::parser::OwnedLiteral;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
use std::ops::Div;
|
||||||
|
use std::ops::Mul;
|
||||||
|
use std::ops::Rem;
|
||||||
|
use std::ops::Sub;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum MathNumber {
|
pub enum MathNumber {
|
||||||
@ -44,6 +48,50 @@ impl Add<MathNumber> for MathNumber {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Sub<MathNumber> for MathNumber {
|
||||||
|
type Output = Option<OwnedLiteral>;
|
||||||
|
|
||||||
|
fn sub(self, other: MathNumber) -> Self::Output {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Mul<MathNumber> for MathNumber {
|
||||||
|
type Output = Option<OwnedLiteral>;
|
||||||
|
|
||||||
|
fn mul(self, other: MathNumber) -> Self::Output {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Div<MathNumber> for MathNumber {
|
||||||
|
type Output = Option<OwnedLiteral>;
|
||||||
|
|
||||||
|
fn div(self, other: MathNumber) -> Self::Output {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Rem<MathNumber> for MathNumber {
|
||||||
|
type Output = Option<OwnedLiteral>;
|
||||||
|
|
||||||
|
fn rem(self, other: MathNumber) -> Self::Output {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MathNumber {
|
||||||
|
fn math_abs(&self) -> Option<OwnedLiteral> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn math_floor(&self) -> Option<OwnedLiteral> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn math_ceil(&self) -> Option<OwnedLiteral> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// For math operations that take in integers and return integers
|
/// For math operations that take in integers and return integers
|
||||||
/// (add, subtract, multiply)
|
/// (add, subtract, multiply)
|
||||||
pub fn math_ints<L, R, F>(left: L, right: R, operation: F) -> Option<OwnedLiteral>
|
pub fn math_ints<L, R, F>(left: L, right: R, operation: F) -> Option<OwnedLiteral>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user