Bodiless math implementation.

master
Tom Alexander 4 years ago
parent 241f6c04e4
commit 11096d7ece
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -656,9 +656,14 @@ impl<'a> DustRenderer<'a> {
ParametersContext::new(self, breadcrumbs, &parameterized_block.params, None); ParametersContext::new(self, breadcrumbs, &parameterized_block.params, None);
match &parameterized_block.contents { match &parameterized_block.contents {
None => { None => {
// TODO: math without body, calculate the value and render it return self
// Calculate the value .perform_math_operation(breadcrumbs, &param_map)
// Render .map(|final_val| {
final_val
.get_context_element_reference()
.render(&Vec::new())
})
.unwrap_or(Ok("".to_owned()));
} }
Some(_) => { Some(_) => {
// TODO: math with body, calculate the value and use it like a select block // TODO: math with body, calculate the value and use it like a select block
@ -931,7 +936,7 @@ impl<'a> DustRenderer<'a> {
/// Performs a math operation (add, subtract, multiply, divide, /// Performs a math operation (add, subtract, multiply, divide,
/// mod, abs, floor, ceil) and returns the result or None if /// mod, abs, floor, ceil) and returns the result or None if
/// nothing should be rendered. /// nothing should be rendered.
fn performance_math_operation( fn perform_math_operation(
&'a self, &'a self,
breadcrumbs: &'a Vec<BreadcrumbTreeElement<'a>>, breadcrumbs: &'a Vec<BreadcrumbTreeElement<'a>>,
math_parameters: &'a ParametersContext<'a>, math_parameters: &'a ParametersContext<'a>,
@ -959,8 +964,11 @@ impl<'a> DustRenderer<'a> {
.map(|ice| ice.get_context_element_reference()) .map(|ice| ice.get_context_element_reference())
}); });
match method_rendered.as_str() { return match method_rendered.as_str() {
"add" => todo!(), "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),
},
"subtract" => todo!(), "subtract" => todo!(),
"multiply" => todo!(), "multiply" => todo!(),
"divide" => todo!(), "divide" => todo!(),
@ -968,10 +976,8 @@ impl<'a> DustRenderer<'a> {
"abs" => todo!(), "abs" => todo!(),
"floor" => todo!(), "floor" => todo!(),
"ceil" => todo!(), "ceil" => todo!(),
_ => return None, _ => None,
} };
todo!()
} }
} }

Loading…
Cancel
Save