Revert logic for building completed definitions
This commit is contained in:
parent
b308847ebd
commit
84031c483b
@ -141,49 +141,20 @@ impl<'p> Translator<'p>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: refactor
|
for predicate_declaration in self.problem.predicate_declarations.borrow().iter()
|
||||||
let predicate_declarations = self.problem.predicate_declarations.borrow();
|
|
||||||
let input_predicate_declarations = self.problem.input_predicate_declarations.borrow();
|
|
||||||
let mut definitions = &mut self.definitions;
|
|
||||||
let problem = &self.problem;
|
|
||||||
|
|
||||||
let completed_definitions = predicate_declarations.iter()
|
|
||||||
.filter_map(
|
|
||||||
|predicate_declaration|
|
|
||||||
{
|
{
|
||||||
// Don’t perform completion for input predicates
|
// Don’t perform completion for input predicates
|
||||||
if input_predicate_declarations.contains(predicate_declaration)
|
if self.problem.input_predicate_declarations.borrow().contains(predicate_declaration)
|
||||||
{
|
{
|
||||||
return None;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let completed_definition = completed_definition(predicate_declaration,
|
|
||||||
&mut definitions, problem);
|
|
||||||
|
|
||||||
Some((std::rc::Rc::clone(predicate_declaration), completed_definition))
|
|
||||||
})
|
|
||||||
.collect::<std::collections::BTreeMap<_, _>>();
|
|
||||||
|
|
||||||
// Replace occurrences of hidden predicates with their completed definitions
|
|
||||||
let output_predicate_declarations = self.problem.output_predicate_declarations.borrow();
|
|
||||||
|
|
||||||
// If no output statements are present, don’t hide any predicates by default
|
|
||||||
if !output_predicate_declarations.is_empty()
|
|
||||||
{
|
|
||||||
let hidden_predicate_declarations =
|
|
||||||
predicate_declarations.difference(&output_predicate_declarations);
|
|
||||||
|
|
||||||
for hidden_predicate_declaration in hidden_predicate_declarations
|
|
||||||
{
|
|
||||||
log::debug!("hidden: {}", hidden_predicate_declaration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (predicate_declaration, completed_definition) in completed_definitions.into_iter()
|
|
||||||
{
|
|
||||||
let statement_kind = crate::problem::StatementKind::CompletedDefinition(
|
let statement_kind = crate::problem::StatementKind::CompletedDefinition(
|
||||||
std::rc::Rc::clone(&predicate_declaration));
|
std::rc::Rc::clone(&predicate_declaration));
|
||||||
|
|
||||||
|
let completed_definition = completed_definition(predicate_declaration,
|
||||||
|
&mut self.definitions, self.problem);
|
||||||
|
|
||||||
let statement = crate::problem::Statement::new(statement_kind, completed_definition)
|
let statement = crate::problem::Statement::new(statement_kind, completed_definition)
|
||||||
.with_name(format!("completed_definition_{}_{}", predicate_declaration.name,
|
.with_name(format!("completed_definition_{}_{}", predicate_declaration.name,
|
||||||
predicate_declaration.arity));
|
predicate_declaration.arity));
|
||||||
|
Loading…
Reference in New Issue
Block a user