当前位置: 首页>>代码示例>>C++>>正文


C++ NodeValue::printAst方法代码示例

本文整理汇总了C++中NodeValue::printAst方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeValue::printAst方法的具体用法?C++ NodeValue::printAst怎么用?C++ NodeValue::printAst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeValue的用法示例。


在下文中一共展示了NodeValue::printAst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reclaimZombies

void NodeManager::reclaimZombies() {
    // FIXME multithreading
    Assert(!d_attrManager->inGarbageCollection());

    Debug("gc") << "reclaiming " << d_zombies.size() << " zombie(s)!\n";

    // during reclamation, reclaimZombies() is never supposed to be called
    Assert(! d_inReclaimZombies, "NodeManager::reclaimZombies() not re-entrant!");

    // whether exit is normal or exceptional, the Reclaim dtor is called
    // and ensures that d_inReclaimZombies is set back to false.
    ScopedBool r(d_inReclaimZombies);

    // We copy the set away and clear the NodeManager's set of zombies.
    // This is because reclaimZombie() decrements the RC of the
    // NodeValue's children, which may (recursively) reclaim them.
    //
    // Let's say we're reclaiming zombie NodeValue "A" and its child "B"
    // then becomes a zombie (NodeManager::markForDeletion(B) is called).
    //
    // One way to handle B's zombification would be simply to put it
    // into d_zombies.  This is what we do.  However, if we were to
    // concurrently process d_zombies in the loop below, such addition
    // may be invisible to us (B is leaked) or even invalidate our
    // iterator, causing a crash.  So we need to copy the set away.

    vector<NodeValue*> zombies;
    zombies.reserve(d_zombies.size());
    remove_copy_if(d_zombies.begin(),
                   d_zombies.end(),
                   back_inserter(zombies),
                   NodeValueReferenceCountNonZero());
    d_zombies.clear();

#ifdef _LIBCPP_VERSION
    NodeValue* last = NULL;
#endif
    for(vector<NodeValue*>::iterator i = zombies.begin();
            i != zombies.end();
            ++i) {
        NodeValue* nv = *i;
#ifdef _LIBCPP_VERSION
        // Work around an apparent bug in libc++'s hash_set<> which can
        // (very occasionally) have an element repeated.
        if(nv == last) {
            continue;
        }
        last = nv;
#endif

        // collect ONLY IF still zero
        if(nv->d_rc == 0) {
            if(Debug.isOn("gc")) {
                Debug("gc") << "deleting node value " << nv
                            << " [" << nv->d_id << "]: ";
                nv->printAst(Debug("gc"));
                Debug("gc") << endl;
            }

            // remove from the pool
            kind::MetaKind mk = nv->getMetaKind();
            if(mk != kind::metakind::VARIABLE) {
                poolRemove(nv);
            }

            // whether exit is normal or exceptional, the NVReclaim dtor is
            // called and ensures that d_nodeUnderDeletion is set back to
            // NULL.
            NVReclaim rc(d_nodeUnderDeletion);
            d_nodeUnderDeletion = nv;

            // remove attributes
            {   // notify listeners of deleted node
                TNode n;
                n.d_nv = nv;
                nv->d_rc = 1; // so that TNode doesn't assert-fail
                for(vector<NodeManagerListener*>::iterator i = d_listeners.begin(); i != d_listeners.end(); ++i) {
                    (*i)->nmNotifyDeleteNode(n);
                }
                // this would mean that one of the listeners stowed away
                // a reference to this node!
                Assert(nv->d_rc == 1);
            }
            nv->d_rc = 0;
            d_attrManager->deleteAllAttributes(nv);

            // decr ref counts of children
            nv->decrRefCounts();
            if(mk == kind::metakind::CONSTANT) {
                // Destroy (call the destructor for) the C++ type representing
                // the constant in this NodeValue.  This is needed for
                // e.g. CVC4::Rational, since it has a gmp internal
                // representation that mallocs memory and should be cleaned
                // up.  (This won't delete a pointer value if used as a
                // constant, but then, you should probably use a smart-pointer
                // type for a constant payload.)
                kind::metakind::deleteNodeValueConstant(nv);
            }
            free(nv);
        }
//.........这里部分代码省略.........
开发者ID:kyledewey,项目名称:CVC4,代码行数:101,代码来源:node_manager.cpp


注:本文中的NodeValue::printAst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。