mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:36:08 +02:00
Block params
This commit is contained in:
@ -13,7 +13,7 @@ pub struct EngineState {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct ScopeFrame {
|
||||
pub struct ScopeFrame {
|
||||
vars: HashMap<Vec<u8>, VarId>,
|
||||
decls: HashMap<Vec<u8>, DeclId>,
|
||||
aliases: HashMap<Vec<u8>, Vec<Span>>,
|
||||
@ -27,6 +27,16 @@ impl ScopeFrame {
|
||||
aliases: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_var(&self, var_name: &[u8]) -> Option<&VarId> {
|
||||
self.vars.get(var_name)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ScopeFrame {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EngineState {
|
||||
@ -188,7 +198,7 @@ pub struct StateDelta {
|
||||
vars: Vec<Type>, // indexed by VarId
|
||||
decls: Vec<Box<dyn Command>>, // indexed by DeclId
|
||||
blocks: Vec<Block>, // indexed by BlockId
|
||||
scope: Vec<ScopeFrame>,
|
||||
pub scope: Vec<ScopeFrame>,
|
||||
}
|
||||
|
||||
impl StateDelta {
|
||||
|
@ -13,7 +13,7 @@ pub enum ShellError {
|
||||
UnknownOperator(String, Span),
|
||||
ExternalNotSupported(Span),
|
||||
InternalError(String),
|
||||
VariableNotFound(Span),
|
||||
VariableNotFoundAtRuntime(Span),
|
||||
CantConvert(String, Span),
|
||||
DivisionByZero(Span),
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ impl Command for BlockCommand {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
panic!("Internal error: can't get signature with 'signature', use block_id");
|
||||
self.signature.clone()
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
Reference in New Issue
Block a user