summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/resolve/env.rs
diff options
context:
space:
mode:
authorNadrieril2020-11-01 15:17:42 +0000
committerNadrieril2020-11-01 15:17:42 +0000
commit2c245e7f5ce4019381e0fa47a1e2caf6276106be (patch)
tree26189d7ae5287f406862ef81f001f2fef5a1222a /dhall/src/semantics/resolve/env.rs
parent8a2de7537986b1d60b9e8ce3bc4c08e9ec6c489a (diff)
Store file cache in ImportEnv
Diffstat (limited to 'dhall/src/semantics/resolve/env.rs')
-rw-r--r--dhall/src/semantics/resolve/env.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/dhall/src/semantics/resolve/env.rs b/dhall/src/semantics/resolve/env.rs
index 25d2277..4d502ce 100644
--- a/dhall/src/semantics/resolve/env.rs
+++ b/dhall/src/semantics/resolve/env.rs
@@ -1,7 +1,7 @@
use std::collections::HashMap;
use crate::error::{Error, ImportError};
-use crate::semantics::{AlphaVar, ImportLocation, TypedHir, VarEnv};
+use crate::semantics::{AlphaVar, Cache, ImportLocation, TypedHir, VarEnv};
use crate::syntax::{Label, V};
/// Environment for resolving names.
@@ -10,14 +10,15 @@ pub struct NameEnv {
names: Vec<Label>,
}
-pub type ImportCache = HashMap<ImportLocation, TypedHir>;
-pub type ImportStack = Vec<ImportLocation>;
+pub type MemCache = HashMap<ImportLocation, TypedHir>;
+pub type CyclesStack = Vec<ImportLocation>;
/// Environment for resolving imports
-#[derive(Debug, Clone, Default)]
+#[derive(Debug)]
pub struct ImportEnv {
- cache: ImportCache,
- stack: ImportStack,
+ pub file_cache: Cache,
+ mem_cache: MemCache,
+ stack: CyclesStack,
}
impl NameEnv {
@@ -66,18 +67,22 @@ impl NameEnv {
impl ImportEnv {
pub fn new() -> Self {
- ImportEnv::default()
+ ImportEnv {
+ file_cache: Cache::new(),
+ mem_cache: Default::default(),
+ stack: Default::default(),
+ }
}
pub fn get_from_cache<'a>(
&'a self,
location: &ImportLocation,
) -> Option<&'a TypedHir> {
- self.cache.get(location)
+ self.mem_cache.get(location)
}
pub fn set_cache(&mut self, location: ImportLocation, expr: TypedHir) {
- self.cache.insert(location, expr);
+ self.mem_cache.insert(location, expr);
}
pub fn with_cycle_detection(