Wire up the math functions to the renderer.

This commit is contained in:
Tom Alexander 2020-06-13 23:01:29 -04:00
parent cdd10576e8
commit c5a0ad6786
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -1043,13 +1043,63 @@ impl<'a> DustRenderer<'a> {
.get_context_element_reference()
.math_add(r.get_context_element_reference()),
},
"subtract" => todo!(),
"multiply" => todo!(),
"divide" => todo!(),
"mod" => todo!(),
"abs" => todo!(),
"floor" => todo!(),
"ceil" => todo!(),
"subtract" => match (left_side_ce, right_side_ce) {
(None, _) | (Some(Err(_)), _) | (_, None) | (_, Some(Err(_))) => None,
(Some(Ok(None)), _) | (_, Some(Ok(None))) => Some(IceResult::from_owned(
OwnedLiteral::LString("NaN".to_owned()),
)),
(Some(Ok(Some(l))), Some(Ok(Some(r)))) => l
.get_context_element_reference()
.math_subtract(r.get_context_element_reference()),
},
"multiply" => match (left_side_ce, right_side_ce) {
(None, _) | (Some(Err(_)), _) | (_, None) | (_, Some(Err(_))) => None,
(Some(Ok(None)), _) | (_, Some(Ok(None))) => Some(IceResult::from_owned(
OwnedLiteral::LString("NaN".to_owned()),
)),
(Some(Ok(Some(l))), Some(Ok(Some(r)))) => l
.get_context_element_reference()
.math_multiply(r.get_context_element_reference()),
},
"divide" => match (left_side_ce, right_side_ce) {
(None, _) | (Some(Err(_)), _) | (_, None) | (_, Some(Err(_))) => None,
(Some(Ok(None)), _) | (_, Some(Ok(None))) => Some(IceResult::from_owned(
OwnedLiteral::LString("NaN".to_owned()),
)),
(Some(Ok(Some(l))), Some(Ok(Some(r)))) => l
.get_context_element_reference()
.math_divide(r.get_context_element_reference()),
},
"mod" => match (left_side_ce, right_side_ce) {
(None, _) | (Some(Err(_)), _) | (_, None) | (_, Some(Err(_))) => None,
(Some(Ok(None)), _) | (_, Some(Ok(None))) => Some(IceResult::from_owned(
OwnedLiteral::LString("NaN".to_owned()),
)),
(Some(Ok(Some(l))), Some(Ok(Some(r)))) => l
.get_context_element_reference()
.math_modulus(r.get_context_element_reference()),
},
"abs" => match left_side_ce {
None | Some(Err(_)) => None,
Some(Ok(None)) => Some(IceResult::from_owned(OwnedLiteral::LString(
"NaN".to_owned(),
))),
Some(Ok(Some(num))) => num.get_context_element_reference().math_abs(),
},
"floor" => match left_side_ce {
None | Some(Err(_)) => None,
Some(Ok(None)) => Some(IceResult::from_owned(OwnedLiteral::LString(
"NaN".to_owned(),
))),
Some(Ok(Some(num))) => num.get_context_element_reference().math_floor(),
},
"ceil" => match left_side_ce {
None | Some(Err(_)) => None,
Some(Ok(None)) => Some(IceResult::from_owned(OwnedLiteral::LString(
"NaN".to_owned(),
))),
Some(Ok(Some(num))) => num.get_context_element_reference().math_ceil(),
},
_ => None,
};
}