Bodiless math is now working in the simple cases.

This commit is contained in:
Tom Alexander 2020-06-13 20:02:48 -04:00
parent dcbf8e83f6
commit e6c17fb603
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -957,24 +957,29 @@ impl<'a> DustRenderer<'a> {
maybe_ice
.as_ref()
.map(|ice| ice.get_context_element_reference())
.map(|ce| ce.cast_to_type("number"))
});
let right_side_ce = right_side.as_ref().map(|maybe_ice| {
maybe_ice
.as_ref()
.map(|ice| ice.get_context_element_reference())
.map(|ce| ce.cast_to_type("number"))
});
// TODO convert string to number or render NaN
println!(
"Doing {:?} {:?} {:?}",
left_side, method_rendered, right_side
);
// println!(
// "Doing {:?} {:?} {:?}",
// left_side, method_rendered, right_side
// );
return match method_rendered.as_str() {
"add" => match (left_side_ce, right_side_ce) {
(None, _) | (Some(Err(_)), _) | (_, None) | (_, Some(Err(_))) => None,
(Some(Ok(l)), Some(Ok(r))) => l.math_add(r),
(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_add(r.get_context_element_reference()),
},
"subtract" => todo!(),
"multiply" => todo!(),