diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-25 13:50:33 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-25 13:59:06 +0200 |
| commit | c010cbc17dcbb2f0d6005d21530143bf57cb5871 (patch) | |
| tree | 937fe79f0c121bcc025480181287fd4a3d0c0f4f /src/eval/array.rs | |
| parent | 6935cf8dfefff3d6cf234f077a7d61661fd5ca57 (diff) | |
Move route from context to VM
Diffstat (limited to 'src/eval/array.rs')
| -rw-r--r-- | src/eval/array.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/eval/array.rs b/src/eval/array.rs index 86347106..840c0aef 100644 --- a/src/eval/array.rs +++ b/src/eval/array.rs @@ -3,11 +3,10 @@ use std::fmt::{self, Debug, Formatter, Write}; use std::ops::{Add, AddAssign}; use std::sync::Arc; -use super::{ops, Args, Func, Value}; +use super::{ops, Args, Func, Machine, Value}; use crate::diag::{At, StrResult, TypResult}; use crate::syntax::Spanned; use crate::util::ArcExt; -use crate::Context; /// Create a new [`Array`] from values. #[allow(unused_macros)] @@ -120,21 +119,21 @@ impl Array { } /// Transform each item in the array with a function. - pub fn map(&self, ctx: &mut Context, f: Spanned<Func>) -> TypResult<Self> { + pub fn map(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<Self> { Ok(self .iter() .cloned() - .map(|item| f.v.call(ctx, Args::from_values(f.span, [item]))) + .map(|item| f.v.call(vm, Args::new(f.span, [item]))) .collect::<TypResult<_>>()?) } /// Return a new array with only those elements for which the function /// return true. - pub fn filter(&self, ctx: &mut Context, f: Spanned<Func>) -> TypResult<Self> { + pub fn filter(&self, vm: &mut Machine, f: Spanned<Func>) -> TypResult<Self> { let mut kept = vec![]; for item in self.iter() { if f.v - .call(ctx, Args::from_values(f.span, [item.clone()]))? + .call(vm, Args::new(f.span, [item.clone()]))? .cast::<bool>() .at(f.span)? { |
