fix parser info: actually add it to the call
This commit is contained in:
parent
3c33a3f4eb
commit
52ec0c3b1d
|
@ -147,6 +147,7 @@ impl BlockBuilder {
|
|||
Instruction::AppendRest { src } => self.free_register(*src)?,
|
||||
Instruction::PushFlag { name: _ } => (),
|
||||
Instruction::PushNamed { name: _, src } => self.free_register(*src)?,
|
||||
Instruction::PushParserInfo { name: _, info: _ } => (),
|
||||
Instruction::RedirectOut { mode } | Instruction::RedirectErr { mode } => match mode {
|
||||
RedirectMode::File { path, .. } => self.free_register(*path)?,
|
||||
_ => (),
|
||||
|
|
|
@ -119,6 +119,13 @@ pub(crate) fn compile_call(
|
|||
}
|
||||
}
|
||||
|
||||
// Add any parser info from the call
|
||||
for (name, info) in &call.parser_info {
|
||||
let name = builder.data(name)?;
|
||||
let info = Box::new(info.clone());
|
||||
builder.push(Instruction::PushParserInfo { name, info }.into_spanned(call.head))?;
|
||||
}
|
||||
|
||||
if let Some(mode) = redirect_modes.out {
|
||||
builder.push(mode.map(|mode| Instruction::RedirectOut { mode }))?;
|
||||
}
|
||||
|
|
|
@ -319,6 +319,14 @@ fn eval_instruction(
|
|||
});
|
||||
Ok(Continue)
|
||||
}
|
||||
Instruction::PushParserInfo { name, info } => {
|
||||
ctx.stack.arguments.push(Argument::ParserInfo {
|
||||
data: ctx.data.clone(),
|
||||
name: *name,
|
||||
info: info.clone(),
|
||||
});
|
||||
Ok(Continue)
|
||||
}
|
||||
Instruction::RedirectOut { mode } => {
|
||||
let out_dest = eval_redirection(ctx, mode, *span)?;
|
||||
ctx.redirect_out = Some(out_dest);
|
||||
|
|
|
@ -28,7 +28,7 @@ pub enum Argument {
|
|||
name: DataSlice,
|
||||
// TODO: rather than `Expression`, this would probably be best served by a specific enum
|
||||
// type for this purpose.
|
||||
expr: Box<Expression>,
|
||||
info: Box<Expression>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ impl Call {
|
|||
Argument::ParserInfo {
|
||||
data,
|
||||
name: name_slice,
|
||||
expr,
|
||||
info: expr,
|
||||
} if &data[*name_slice] == name.as_bytes() => Some(expr.as_ref()),
|
||||
_ => None,
|
||||
})
|
||||
|
|
|
@ -105,6 +105,10 @@ impl<'a> fmt::Display for FmtInstruction<'a> {
|
|||
let name = FmtData(self.data, *name);
|
||||
write!(f, "{:WIDTH$} {name}, {src}", "push-named")
|
||||
}
|
||||
Instruction::PushParserInfo { name, info } => {
|
||||
let name = FmtData(self.data, *name);
|
||||
write!(f, "{:WIDTH$} {name}, {info:?}", "push-parser-info")
|
||||
}
|
||||
Instruction::RedirectOut { mode } => {
|
||||
write!(f, "{:WIDTH$} {mode}", "redirect-out")
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
ast::{CellPath, Operator, RangeInclusion},
|
||||
ast::{CellPath, Expression, Operator, RangeInclusion},
|
||||
engine::EngineState,
|
||||
BlockId, DeclId, RegId, Span, VarId,
|
||||
};
|
||||
|
@ -90,6 +90,11 @@ pub enum Instruction {
|
|||
PushFlag { name: DataSlice },
|
||||
/// Add a named arg with a value to the next call.
|
||||
PushNamed { name: DataSlice, src: RegId },
|
||||
/// Add parser info to the next call.
|
||||
PushParserInfo {
|
||||
name: DataSlice,
|
||||
info: Box<Expression>,
|
||||
},
|
||||
/// Set the redirection for stdout for the next call (only)
|
||||
RedirectOut { mode: RedirectMode },
|
||||
/// Set the redirection for stderr for the next call (only)
|
||||
|
|
Loading…
Reference in New Issue
Block a user