TypeNode exportTypeInternal(TypeNode n, NodeManager* from, NodeManager* to, ExprManagerMapCollection& vmap) { Debug("export") << "type: " << n << " " << n.getId() << std::endl; if(theory::kindToTheoryId(n.getKind()) == theory::THEORY_DATATYPES) { throw ExportUnsupportedException ("export of types belonging to theory of DATATYPES kinds unsupported"); } if(n.getMetaKind() == kind::metakind::PARAMETERIZED && n.getKind() != kind::SORT_TYPE) { throw ExportUnsupportedException ("export of PARAMETERIZED-kinded types (other than SORT_KIND) not supported"); } if(n.getKind() == kind::TYPE_CONSTANT) { return to->mkTypeConst(n.getConst<TypeConstant>()); } else if(n.getKind() == kind::BITVECTOR_TYPE) { return to->mkBitVectorType(n.getConst<BitVectorSize>()); } else if(n.getKind() == kind::SUBRANGE_TYPE) { return to->mkSubrangeType(n.getSubrangeBounds()); } Type from_t = from->toType(n); Type& to_t = vmap.d_typeMap[from_t]; if(! to_t.isNull()) { Debug("export") << "+ mapped `" << from_t << "' to `" << to_t << "'" << std::endl; return *Type::getTypeNode(to_t); } NodeBuilder<> children(to, n.getKind()); if(n.getKind() == kind::SORT_TYPE) { Debug("export") << "type: operator: " << n.getOperator() << std::endl; // make a new sort tag in target node manager Node sortTag = NodeBuilder<0>(to, kind::SORT_TAG); children << sortTag; } for(TypeNode::iterator i = n.begin(), i_end = n.end(); i != i_end; ++i) { Debug("export") << "type: child: " << *i << std::endl; children << exportTypeInternal(*i, from, to, vmap); } TypeNode out = children.constructTypeNode();// FIXME thread safety to_t = to->toType(out); return out; }/* exportTypeInternal() */
TypeNode NodeManager::mkSort(TypeNode constructor, const std::vector<TypeNode>& children, uint32_t flags) { Assert(constructor.getKind() == kind::SORT_TYPE && constructor.getNumChildren() == 0, "expected a sort constructor"); Assert(children.size() > 0, "expected non-zero # of children"); Assert( hasAttribute(constructor.d_nv, expr::SortArityAttr()) && hasAttribute(constructor.d_nv, expr::VarNameAttr()), "expected a sort constructor" ); std::string name = getAttribute(constructor.d_nv, expr::VarNameAttr()); Assert(getAttribute(constructor.d_nv, expr::SortArityAttr()) == children.size(), "arity mismatch in application of sort constructor"); NodeBuilder<> nb(this, kind::SORT_TYPE); Node sortTag = Node(constructor.d_nv->d_children[0]); nb << sortTag; nb.append(children); TypeNode type = nb.constructTypeNode(); setAttribute(type, expr::VarNameAttr(), name); for(std::vector<NodeManagerListener*>::iterator i = d_listeners.begin(); i != d_listeners.end(); ++i) { (*i)->nmNotifyInstantiateSortConstructor(constructor, type, flags); } return type; }