Implement module resolvers.

This commit is contained in:
Stephen Chung
2020-05-05 23:57:25 +08:00
parent 036c054ba8
commit 82e1af7acd
6 changed files with 295 additions and 76 deletions

View File

@@ -5,7 +5,7 @@ use crate::module::Module;
use crate::parser::{map_dynamic_to_expr, Expr};
use crate::token::Position;
use crate::stdlib::{borrow::Cow, boxed::Box, iter, vec::Vec};
use crate::stdlib::{borrow::Cow, boxed::Box, iter, vec, vec::Vec};
/// Type of an entry in the Scope.
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
@@ -416,6 +416,11 @@ impl<'a> Scope<'a> {
(&mut entry.value, entry.typ)
}
/// Get an iterator to entries in the Scope.
pub(crate) fn into_iter(self) -> impl Iterator<Item = Entry<'a>> {
self.0.into_iter()
}
/// Get an iterator to entries in the Scope.
pub(crate) fn iter(&self) -> impl Iterator<Item = &Entry> {
self.0.iter().rev() // Always search a Scope in reverse order