mirror of
https://github.com/rm-dr/daisy
synced 2025-10-10 20:42:37 -07:00
Cleaned up context argument
This commit is contained in:
@ -9,8 +9,8 @@ use super::function::eval_function;
|
||||
|
||||
|
||||
pub fn evaluate(
|
||||
t: &Expression,
|
||||
context: &mut Context
|
||||
context: &mut Context,
|
||||
t: &Expression
|
||||
) -> Result<
|
||||
Expression,
|
||||
(LineLocation, DaisyError)
|
||||
@ -51,7 +51,7 @@ pub fn evaluate(
|
||||
let new = match g {
|
||||
Expression::Quantity(_, _) => None,
|
||||
Expression::Tuple(_, _) => None,
|
||||
Expression::Constant(_, c) => { Some(evaluate(&c.value(), context).unwrap()) },
|
||||
Expression::Constant(_, c) => { Some(evaluate(context, &c.value()).unwrap()) },
|
||||
Expression::Variable(l, s) => {
|
||||
// Don't move up, re-evaluate
|
||||
// This makes variables containing floating variables work properly
|
||||
@ -64,7 +64,7 @@ pub fn evaluate(
|
||||
context.get_variable(&s)
|
||||
},
|
||||
Expression::Operator(_, Operator::Function(_), _) => { Some(eval_function(g)?) },
|
||||
Expression::Operator(_, _, _) => { eval_operator(g, context)? },
|
||||
Expression::Operator(_, _, _) => { eval_operator(context, g)? },
|
||||
};
|
||||
|
||||
if let Some(mut new) = new {
|
||||
|
@ -7,7 +7,7 @@ use crate::errors::DaisyError;
|
||||
use super::evaluate;
|
||||
|
||||
|
||||
pub fn eval_operator(g: &Expression, context: &mut Context) -> Result<Option<Expression>, (LineLocation, DaisyError)> {
|
||||
pub fn eval_operator(context: &mut Context, g: &Expression) -> Result<Option<Expression>, (LineLocation, DaisyError)> {
|
||||
|
||||
let Expression::Operator(op_loc, op, args) = g else {panic!()};
|
||||
|
||||
@ -52,7 +52,7 @@ pub fn eval_operator(g: &Expression, context: &mut Context) -> Result<Option<Exp
|
||||
}
|
||||
|
||||
|
||||
let r = evaluate(&exp, context)?;
|
||||
let r = evaluate(context, &exp)?;
|
||||
context.clear_shadow();
|
||||
|
||||
return Ok(Some(r));
|
||||
|
Reference in New Issue
Block a user