microcad_lang/eval/
init.rs1use crate::{eval::*, model::*, syntax::*};
5
6impl InitDefinition {
7 pub fn eval(&self, args: Tuple, context: &mut Context) -> EvalResult<()> {
9 context.grant(self)?;
10 let model = context.get_model()?;
11 context.scope(StackFrame::Init(args.into()), |context| {
12 let _: Value = self.body.statements.eval(context)?;
13
14 if let Some(properties) = model.borrow().get_properties() {
15 let missing: IdentifierList = properties
16 .iter()
17 .filter(|(_, value)| value.is_invalid())
18 .map(|(id, _)| id.clone())
19 .collect();
20
21 if !missing.is_empty() {
22 context.error(self, EvalError::BuildingPlanIncomplete(missing))?;
23 }
24 }
25
26 Ok(())
27 })
28 }
29}