This commit is contained in:
JT
2021-10-25 17:24:10 +13:00
parent b6d269e90a
commit 397a31e69c
8 changed files with 241 additions and 195 deletions

View File

@ -39,7 +39,7 @@ impl Command for Do {
let block = context.engine_state.get_block(block_id);
let state = context.enter_scope();
let mut state = context.enter_scope();
let params: Vec<_> = block
.signature

View File

@ -62,7 +62,7 @@ impl Command for For {
.map(move |x| {
let block = context.engine_state.get_block(block);
let state = context.enter_scope();
let mut state = context.enter_scope();
state.add_var(var_id, x);
@ -75,6 +75,33 @@ impl Command for For {
}
})
.into_pipeline_data()),
Value::Range { val, span } => Ok(val
.into_range_iter()?
.map(move |x| {
let block = context.engine_state.get_block(block);
let mut state = context.enter_scope();
state.add_var(var_id, x);
match eval_block(&state, block, PipelineData::new()) {
Ok(value) => Value::List {
vals: value.collect(),
span,
},
Err(error) => Value::Error { error },
}
})
.into_pipeline_data()),
x => {
let block = context.engine_state.get_block(block);
let mut state = context.enter_scope();
state.add_var(var_id, x);
eval_block(&state, block, PipelineData::new())
}
}
}