remove operators declared at user-level from files when reloading

This commit is contained in:
Mark Thom
2021-03-16 13:47:30 -06:00
parent 51424aed32
commit 5f7abda22d
4 changed files with 85 additions and 56 deletions

View File

@@ -718,6 +718,16 @@ impl<'a> LoadState<'a> {
pub(super) fn add_op_decl(&mut self, op_decl: &OpDecl) {
match &self.compilation_target {
CompilationTarget::User => {
if let Some(filename) = self.listing_src_file_name() {
match self.wam.indices.modules.get_mut(&filename) {
Some(ref mut module) => {
op_decl.insert_into_op_dir(&mut module.op_dir);
}
None => {
}
}
}
add_op_decl(
&mut self.retraction_info,
&self.compilation_target,
@@ -949,6 +959,15 @@ impl<'a> LoadState<'a> {
}
if &self.compilation_target == compilation_target {
if let CompilationTarget::User = &self.compilation_target {
match (key.0.as_str(), key.1) {
("term_expansion", 2) | ("goal_expansion", 2) => {
continue;
}
_ => {}
}
}
let skeleton_opt = self.wam.indices.remove_predicate_skeleton(
compilation_target,
&key,

View File

@@ -1474,16 +1474,29 @@ impl Machine {
exports: vec![],
};
if !loader.load_state.wam.indices.modules.contains_key(&module_decl.name) {
let module_name = module_decl.name.clone();
let module = Module::new(module_decl, ListingSource::DynamicallyGenerated);
let module_name = module_decl.name.clone();
if !loader.load_state.wam.indices.modules.contains_key(&module_decl.name) {
let module = Module::new_in_situ(module_decl);
loader.load_state.wam.indices.modules.insert(module_name, module);
} else {
loader.load_state.reset_in_situ_module(
module_decl.clone(),
&ListingSource::DynamicallyGenerated,
);
match loader.load_state.wam.indices.modules.get_mut(&module_name) {
Some(module) => {
for (key, value) in module.op_dir.drain(0 ..) {
let (prec, spec) = value.shared_op_desc().get();
let mut op_decl = OpDecl::new(prec, spec, key.0);
op_decl.remove(&mut loader.load_state.wam.indices.op_dir);
}
}
None => {
}
}
}
}

View File

@@ -702,7 +702,7 @@ impl IndexStore {
key: &PredicateKey,
) -> Option<&mut PredicateSkeleton> {
match (key.0.as_str(), key.1) {
("term_expansion", 2) => self.extensible_predicates.get_mut(key),
// ("term_expansion", 2) => self.extensible_predicates.get_mut(key),
_ => match compilation_target {
CompilationTarget::User => self.extensible_predicates.get_mut(key),
CompilationTarget::Module(ref module_name) => {
@@ -722,24 +722,19 @@ impl IndexStore {
local_compilation_target: CompilationTarget,
key: PredicateKey,
) -> Option<&mut PredicateSkeleton> {
match (key.0.as_str(), key.1) {
("term_expansion", 2) => self
match src_compilation_target {
CompilationTarget::User => self
.local_extensible_predicates
.get_mut(&(local_compilation_target, key)),
_ => match src_compilation_target {
CompilationTarget::User => self
.local_extensible_predicates
.get_mut(&(local_compilation_target, key)),
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get_mut(module_name) {
module
.local_extensible_predicates
.get_mut(&(local_compilation_target, key))
} else {
None
}
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get_mut(module_name) {
module
.local_extensible_predicates
.get_mut(&(local_compilation_target, key))
} else {
None
}
},
}
}
}
@@ -749,24 +744,19 @@ impl IndexStore {
local_compilation_target: CompilationTarget,
key: PredicateKey,
) -> Option<&PredicateSkeleton> {
match (key.0.as_str(), key.1) {
("term_expansion", 2) => self
match src_compilation_target {
CompilationTarget::User => self
.local_extensible_predicates
.get(&(local_compilation_target, key)),
_ => match src_compilation_target {
CompilationTarget::User => self
.local_extensible_predicates
.get(&(local_compilation_target, key)),
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get(module_name) {
module
.local_extensible_predicates
.get(&(local_compilation_target, key))
} else {
None
}
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get(module_name) {
module
.local_extensible_predicates
.get(&(local_compilation_target, key))
} else {
None
}
},
}
}
}
@@ -775,18 +765,15 @@ impl IndexStore {
compilation_target: &CompilationTarget,
key: &PredicateKey,
) -> Option<&PredicateSkeleton> {
match (key.0.as_str(), key.1) {
("term_expansion", 2) => self.extensible_predicates.get(key),
_ => match compilation_target {
CompilationTarget::User => self.extensible_predicates.get(key),
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get(module_name) {
module.extensible_predicates.get(key)
} else {
None
}
match compilation_target {
CompilationTarget::User => self.extensible_predicates.get(key),
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get(module_name) {
module.extensible_predicates.get(key)
} else {
None
}
},
}
}
}
@@ -795,18 +782,15 @@ impl IndexStore {
compilation_target: &CompilationTarget,
key: &PredicateKey,
) -> Option<PredicateSkeleton> {
match (key.0.as_str(), key.1) {
("term_expansion", 2) => self.extensible_predicates.remove(key),
_ => match compilation_target {
CompilationTarget::User => self.extensible_predicates.remove(key),
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get_mut(module_name) {
module.extensible_predicates.remove(key)
} else {
None
}
match compilation_target {
CompilationTarget::User => self.extensible_predicates.remove(key),
CompilationTarget::Module(ref module_name) => {
if let Some(module) = self.modules.get_mut(module_name) {
module.extensible_predicates.remove(key)
} else {
None
}
},
}
}
}