diff options
Diffstat (limited to 'src/library')
| -rw-r--r-- | src/library/utility/mod.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/library/utility/mod.rs b/src/library/utility/mod.rs index c4e847c3..6f0f9a4c 100644 --- a/src/library/utility/mod.rs +++ b/src/library/utility/mod.rs @@ -10,7 +10,7 @@ pub use string::*; use std::mem; -use crate::eval::{Eval, Scopes}; +use crate::eval::{Eval, Machine, Scopes}; use crate::library::prelude::*; use crate::source::SourceFile; @@ -33,22 +33,24 @@ pub fn eval(ctx: &mut Context, args: &mut Args) -> TypResult<Value> { let Spanned { v: src, span } = args.expect::<Spanned<String>>("source")?; // Parse the source and set a synthetic span for all nodes. - let mut source = SourceFile::detached(src); - source.synthesize(span); + let source = SourceFile::synthesized(src, span); let ast = source.ast()?; - // Save the old context, then detach it. - let prev_flow = ctx.flow.take(); + // Save the old route, then detach it. let prev_route = mem::take(&mut ctx.route); // Evaluate the source. let std = ctx.config.std.clone(); - let mut scp = Scopes::new(Some(&std)); - let result = ast.eval(ctx, &mut scp); + let scopes = Scopes::new(Some(&std)); + let mut vm = Machine::new(ctx, scopes); + let result = ast.eval(&mut vm); + let flow = vm.flow; - // Restore the old context and handle control flow. + // Restore the old route. ctx.route = prev_route; - if let Some(flow) = mem::replace(&mut ctx.flow, prev_flow) { + + // Handle control flow. + if let Some(flow) = flow { return Err(flow.forbidden()); } |
