microcad_lang/eval/
source_file.rs1use crate::{eval::*, model::*, syntax::*};
5
6impl Eval for std::rc::Rc<SourceFile> {
7 fn eval(&self, context: &mut EvalContext) -> EvalResult<Value> {
8 context.scope(
9 StackFrame::Source(self.id(), SymbolMap::default()),
10 |context| self.statements.eval(context),
11 )
12 }
13}
14
15impl Eval<Model> for std::rc::Rc<SourceFile> {
16 fn eval(&self, context: &mut EvalContext) -> EvalResult<Model> {
17 context.scope(
18 StackFrame::Source(self.id(), SymbolMap::default()),
19 |context| {
20 let model = ModelBuilder::new(Element::Group, self.src_ref())
21 .add_children(self.statements.eval(context)?)?
22 .attributes(self.statements.eval(context)?)
23 .build();
24 Ok(model)
25 },
26 )
27 }
28}