Open Mercerenies opened 4 months ago
Current shapes (as of 9de2c93) of the relevant structs:
pub struct CommandContext<'a, 'b> {
pub opts: CommandOptions,
pub simplifier: Box<dyn Simplifier + 'a>,
pub units_parser: &'b dyn UnitParser<Number>,
}
pub struct FunctionContext<'a, 'b, 'c> {
pub errors: &'a mut ErrorList<SimplifierError>,
pub simplifier: &'b dyn Simplifier,
pub function_table: &'c FunctionTable,
_private: (),
}
pub struct ValidationContext<'a, 'b> {
pub units_parser: &'a dyn UnitParser<Number>,
pub language_mode: &'b dyn LanguageMode,
}
pub struct QueryContext<'a> {
pub units_parser: &'a dyn UnitParser<Number>,
}
pub struct SimplifierContext<'a, 'b> {
pub base_simplifier: &'a dyn Simplifier,
pub errors: &'b mut ErrorList<SimplifierError>,
}
And here's where we construct each of them:
CommandContext:
run_math_command
impl Default for CommandContext
FunctionContext:
call
and call_for_graphics
ValidationContext:
validate_value
QueryContext:
query_stack
SimplifierContext:
CommandContext::simplify_expr
ExprFunction
and ExprFunction2
in crate::expr::algebra
We have too many "context" classes.
Consolidate and clarify what each one means.