NodeManager* nm = NodeManager::currentNM();
size_t index = 0;
std::vector<TypeNode> argTypes;
+ Trace("datatypes-init") << "Initialize constructor " << d_name << std::endl;
for (std::shared_ptr<DTypeSelector> arg : d_args)
{
std::string argName = arg->d_name;
{
// the unresolved type wasn't created here; do name resolution
std::string typeName = argName.substr(argName.find('\0') + 1);
+ Trace("datatypes-init")
+ << " - selector, typeName is " << typeName << std::endl;
argName.resize(argName.find('\0'));
if (typeName == "")
{
+ Trace("datatypes-init") << " ...self selector" << std::endl;
range = self;
arg->d_selector = nm->mkSkolem(
argName,
resolutions.find(typeName);
if (j == resolutions.end())
{
+ Trace("datatypes-init")
+ << " ...failed to resolve selector" << std::endl;
// failed to resolve selector
return false;
}
else
{
+ Trace("datatypes-init") << " ...resolved selector" << std::endl;
range = (*j).second;
arg->d_selector = nm->mkSkolem(
argName,
// the type for the selector already exists; may need
// complex-type substitution
range = arg->d_selector.getType();
+ Trace("datatypes-init")
+ << " - null selector, range = " << range << std::endl;
if (!placeholders.empty())
{
range = range.substitute(placeholders.begin(),
replacements.begin(),
replacements.end());
}
+ Trace("datatypes-init")
+ << " ...range after placeholder replacement " << range << std::endl;
if (!paramTypes.empty())
{
range = doParametricSubstitution(range, paramTypes, paramReplacements);
}
+ Trace("datatypes-init")
+ << " ...range after parametric substitution " << range << std::endl;
arg->d_selector = nm->mkSkolem(
argName,
nm->mkSelectorType(self, range),
}
for (size_t i = 0, psize = paramTypes.size(); i < psize; ++i)
{
- if (paramTypes[i].getNumChildren() + 1 == origChildren.size())
+ if (paramTypes[i].getSortConstructorArity() == origChildren.size())
{
TypeNode tn = paramTypes[i].instantiateSortConstructor(origChildren);
if (range == tn)
return nm->mkTypeNode(kind::PARAMETRIC_DATATYPE, paramsNodes);
}
+uint64_t TypeNode::getSortConstructorArity() const
+{
+ Assert(isSortConstructor() && hasAttribute(expr::SortArityAttr()));
+ return getAttribute(expr::SortArityAttr());
+}
+
TypeNode TypeNode::instantiateSortConstructor(
const std::vector<TypeNode>& params) const
{
+ Assert(isSortConstructor());
return NodeManager::currentNM()->mkSort(*this, params);
}