Print typing formulas for integer parameters
For every integer parameter of the visible predicates, this prints a formula to the output that makes the integer type of that parameter explicit.
This commit is contained in:
parent
a2c4d87852
commit
a70b1fb726
@ -126,6 +126,38 @@ void translate(const char *fileName, std::istream &stream, Context &context)
|
||||
ast::print(context.logger.outputStream(), completedFormula, printContext);
|
||||
context.logger.outputStream() << std::endl;
|
||||
}
|
||||
|
||||
// Print specifiers for integer predicate parameters
|
||||
for (auto &predicateDeclaration : context.predicateDeclarations)
|
||||
{
|
||||
// Check that the predicate is used and not declared #external
|
||||
if (!predicateDeclaration->isUsed || predicateDeclaration->isExternal)
|
||||
continue;
|
||||
|
||||
const auto isPredicateVisible =
|
||||
(predicateDeclaration->visibility == ast::PredicateDeclaration::Visibility::Visible)
|
||||
|| (predicateDeclaration->visibility == ast::PredicateDeclaration::Visibility::Default
|
||||
&& context.defaultPredicateVisibility == ast::PredicateDeclaration::Visibility::Visible);
|
||||
|
||||
// If the predicate ought to be visible, don’t eliminate it
|
||||
if (!isPredicateVisible)
|
||||
continue;
|
||||
|
||||
for (size_t i = 0; i < predicateDeclaration->parameters.size(); i++)
|
||||
{
|
||||
auto ¶meter = predicateDeclaration->parameters[i];
|
||||
|
||||
if (parameter.domain != Domain::Integer)
|
||||
continue;
|
||||
|
||||
context.logger.outputStream()
|
||||
<< output::Keyword("int")
|
||||
<< "(" << predicateDeclaration->name
|
||||
<< "/" << output::Number(predicateDeclaration->arity())
|
||||
<< "@" << output::Number(i + 1)
|
||||
<< ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user