mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 10:38:07 +02:00
Start parsing 'use'; Add Use command
This commit is contained in:
@ -78,6 +78,9 @@ impl EngineState {
|
||||
for item in first.aliases.into_iter() {
|
||||
last.aliases.insert(item.0, item.1);
|
||||
}
|
||||
for item in first.modules.into_iter() {
|
||||
last.modules.insert(item.0, item.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,6 +397,22 @@ impl<'a> StateWorkingSet<'a> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn find_module(&self, name: &[u8]) -> Option<BlockId> {
|
||||
for scope in self.delta.scope.iter().rev() {
|
||||
if let Some(block_id) = scope.modules.get(name) {
|
||||
return Some(*block_id);
|
||||
}
|
||||
}
|
||||
|
||||
for scope in self.permanent_state.scope.iter().rev() {
|
||||
if let Some(block_id) = scope.modules.get(name) {
|
||||
return Some(*block_id);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
// pub fn update_decl(&mut self, decl_id: usize, block: Option<BlockId>) {
|
||||
// let decl = self.get_decl_mut(decl_id);
|
||||
// decl.body = block;
|
||||
|
Reference in New Issue
Block a user