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


C++ ASTNodeSet::insert方法代码示例

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


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

示例1: ASTNodeSet

ASTNodeSet * VariablesInExpression::SetofVarsSeenInTerm(Symbols* symbol, bool& destruct)
{
	assert(symbol != NULL);

	SymbolPtrToNode::iterator it = TermsAlreadySeenMap.find(symbol);

	if ( it != TermsAlreadySeenMap.end())
		{
		destruct = false;
		return it->second;
		}

	SymbolPtrSet visited;

	ASTNodeSet *symbols = new ASTNodeSet();
	vector<Symbols*> av;
	VarSeenInTerm(symbol,visited,*symbols,av);

	for (size_t i =0; i < av.size();i++)
	{
		const ASTNodeSet& sym = *TermsAlreadySeenMap.find(av[i])->second;
		symbols->insert(sym.begin(), sym.end());
	}

	destruct = true;
	//TermsAlreadySeenMap.insert(make_pair(symbol,symbols));

	return symbols;
}
开发者ID:AmesianX,项目名称:stp,代码行数:29,代码来源:VariablesInExpression.cpp

示例2: LetizeNode

void LetizeNode(const ASTNode& n, ASTNodeSet& PLPrintNodeSet, bool smtlib1)
{
  const Kind kind = n.GetKind();

  if (kind == SYMBOL || kind == BVCONST || kind == FALSE || kind == TRUE)
    return;

  const ASTVec& c = n.GetChildren();
  for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend;
       it++)
  {
    const ASTNode& ccc = *it;

    const Kind k = ccc.GetKind();
    if (k == SYMBOL || k == BVCONST || k == FALSE || k == TRUE)
      continue;

    if (PLPrintNodeSet.find(ccc) == PLPrintNodeSet.end())
    {
      // If branch: if *it is not in NodeSet then,
      //
      // 1. add it to NodeSet
      //
      // 2. Letize its childNodes
      PLPrintNodeSet.insert(ccc);
      LetizeNode(ccc, PLPrintNodeSet, smtlib1);
    }
    else
    {
      // 0. Else branch: Node has been seen before
      //
      // 1. Check if the node has a corresponding letvar in the
      // 1. NodeLetVarMap.
      //
      // 2. if no, then create a new var and add it to the
      // 2. NodeLetVarMap
      if ((!smtlib1 || ccc.GetType() == BITVECTOR_TYPE) &&
          NodeLetVarMap.find(ccc) == NodeLetVarMap.end())
      {
        // Create a new symbol. Get some name. if it conflicts with a
        // declared name, too bad.
        int sz = NodeLetVarMap.size();
        std::ostringstream oss;
        oss << "?let_k_" << sz;

        ASTNode CurrentSymbol = n.GetSTPMgr()->CreateSymbol(
            oss.str().c_str(), n.GetIndexWidth(), n.GetValueWidth());
        /* If for some reason the variable being created here is
         * already declared by the user then the printed output will
         * not be a legal input to the system. too bad. I refuse to
         * check for this.  [Vijay is the author of this comment.]
         */

        NodeLetVarMap[ccc] = CurrentSymbol;
        std::pair<ASTNode, ASTNode> node_letvar_pair(CurrentSymbol, ccc);
        NodeLetVarVec.push_back(node_letvar_pair);
      }
    }
  }
} // end of LetizeNode()
开发者ID:delcypher,项目名称:stp,代码行数:60,代码来源:SMTLIBPrinter.cpp

示例3: VarSeenInTerm

// Builds a set of the SYMBOLS that were found under the "term". The symbols are the union of "found" and
// all the sets : TermsAlreadySeen(av[0]) union ... TermsAlreadySeen(av[n])".
void VariablesInExpression::VarSeenInTerm(Symbols* term, SymbolPtrSet& visited,
		ASTNodeSet& found, vector<Symbols*>& av) {
	if (visited.find(term) != visited.end()) {
		return;
	}

	if (term->isLeaf()) {
		found.insert(term->found);
		return;
	}

	visited.insert(term);

	SymbolPtrToNode::const_iterator it;
	if ((it = TermsAlreadySeenMap.find(term)) != TermsAlreadySeenMap.end()) {
		// We've previously built the set of variables below this "symbols".
		// It's not added into "found" because its sometimes 70k variables
		// big, and if there are no other symbols discovered it's a terrible
		// waste to create a copy of the set. Instead we store (in effect)
		// a pointer to the set.
		av.push_back(term);
		return;
	}

	for (vector<Symbols*>::const_iterator it = term->children.begin(), itend =
			term->children.end(); it != itend; it++) {
		VarSeenInTerm(*it, visited, found, av);
	}

	return;
}//End of VarSeenInTerm
开发者ID:AmesianX,项目名称:stp,代码行数:33,代码来源:VariablesInExpression.cpp

示例4: buildListOfSymbols

  void buildListOfSymbols(const ASTNode& n, ASTNodeSet& visited,
  		ASTNodeSet& symbols)
  {
  	if (visited.find(n) != visited.end())
  		return; // already visited.

  	visited.insert(n);

  	if (n.GetKind() == SYMBOL)
  	{
  		symbols.insert(n);
  	}

  	for (unsigned i = 0; i < n.GetChildren().size(); i++)
  		buildListOfSymbols(n[i], visited, symbols);
  }
开发者ID:chubbymaggie,项目名称:Tac-Symbolic-Executor,代码行数:16,代码来源:ASTmisc.cpp

示例5: assertTransformPostConditions

// Check that the transformations have occurred.
void ArrayTransformer::assertTransformPostConditions(const ASTNode& term,
                                                     ASTNodeSet& visited)
{

  // I haven't measure whether this is the quickest way to do it?
  std::pair<ASTNodeSet::iterator, bool> p = visited.insert(term);
  if (!p.second)
    return;

  const Kind k = term.GetKind();

  // Check the array reads / writes have been removed
  assert(READ != k);
  assert(WRITE != k);

  // There should be no nodes left of type array.
  assert(0 == term.GetIndexWidth());

  const ASTVec& c = term.GetChildren();
  ASTVec::const_iterator it = c.begin();
  const ASTVec::const_iterator itend = c.end();
  for (; it != itend; it++)
  {
    assertTransformPostConditions(*it, visited);
  }
} 
开发者ID:jamella,项目名称:stp,代码行数:27,代码来源:ArrayTransformer.cpp

示例6: containsArrayOps

bool containsArrayOps(const ASTNode& n, ASTNodeSet& visited)
{
	if (visited.find(n) != visited.end())
		return false;
	if (n.GetType() == ARRAY_TYPE)
		return true;

	for (int i =0; i < n.Degree();i++)
		if (containsArrayOps(n[i],visited))
			return true;

	visited.insert(n);
	return false;
}
开发者ID:Esail,项目名称:CourseProject,代码行数:14,代码来源:ASTmisc.cpp

示例7: assert

    bool
    ConstantBitPropagation::checkAtFixedPoint(const ASTNode& n, ASTNodeSet & visited)
    {
      if (status == CONFLICT)
        return true; // can't do anything.

      if (visited.find(n) != visited.end())
        return true;

      visited.insert(n);

      // get the current for the children.
      vector<FixedBits> childrenFixedBits;
      childrenFixedBits.reserve(n.GetChildren().size());

      // get a copy of the current fixing from the cache.
      for (unsigned i = 0; i < n.GetChildren().size(); i++)
        {
          childrenFixedBits.push_back(*getCurrentFixedBits(n[i]));
        }
      FixedBits current = *getCurrentFixedBits(n);
      FixedBits newBits = *getUpdatedFixedBits(n);

      assert(FixedBits::equals(newBits, current));

      for (int i = 0; i < n.Degree(); i++)
        {
          if (!FixedBits::equals(*getUpdatedFixedBits(n[i]),
              childrenFixedBits[i]))
            {
              cerr << "Not fixed point";
              assert(false);
            }

          checkAtFixedPoint(n[i], visited);
        }
      return true;
    }
开发者ID:bengheng,项目名称:Expose,代码行数:38,代码来源:ConstantBitPropagation.cpp

示例8: FlattenKindNoDuplicates

/* Maintains a set of nodes that have already been seen. So that deeply shared
 * AND,OR operations are not
 * flattened multiple times.
 */
void FlattenKindNoDuplicates(const Kind k, const ASTVec& children,
                             ASTVec& flat_children,
                             ASTNodeSet& alreadyFlattened)
{
  const ASTVec::const_iterator ch_end = children.end();
  for (ASTVec::const_iterator it = children.begin(); it != ch_end; it++)
  {
    const Kind ck = it->GetKind();
    if (k == ck)
    {
      if (alreadyFlattened.find(*it) == alreadyFlattened.end())
      {
        alreadyFlattened.insert(*it);
        FlattenKindNoDuplicates(k, it->GetChildren(), flat_children,
                                alreadyFlattened);
      }
    }
    else
    {
      flat_children.push_back(*it);
    }
  }
}
开发者ID:cambridgehackers,项目名称:stp,代码行数:27,代码来源:ASTmisc.cpp

示例9: if

/** Internal function to print in lisp format.  Assume newline
    and indentation printed already before first line.  Recursive
    calls will have newline & indent, though */
ostream& Lisp_Print1(ostream& os, const ASTNode& n, int indentation)
{
  if (!n.IsDefined())
  {
    os << "<undefined>";
    return os;
  }
  Kind kind = n.GetKind();
  // FIXME: figure out how to avoid symbols with same names as kinds.
  //    if (kind == READ) {
  //      const ASTVec &children = GetChildren();
  //      children[0].LispPrint1(os, indentation);
  //  os << "[" << children[1] << "]";
  //    } else
  if (kind == BOOLEXTRACT)
  {
    const ASTVec& children = n.GetChildren();
    // child 0 is a symbol.  Print without the NodeNum.
    os << n.GetNodeNum() << ":";

    children[0].nodeprint(os, true);
    os << "{";
    children[1].nodeprint(os, true);
    os << "}";
  }
  else if (kind == NOT)
  {
    const ASTVec& children = n.GetChildren();
    os << n.GetNodeNum() << ":";
    os << "(NOT ";
    Lisp_Print1(os, children[0], indentation);
    os << ")";
  }
  else if (n.Degree() == 0)
  {
    // Symbol or a kind with no children print as index:NAME if shared,
    // even if they have been printed before.
    os << n.GetNodeNum() << ":";
    n.nodeprint(os, true);
    // os << "(" << _int_node_ptr->_ref_count << ")";
    // os << "{" << GetValueWidth() << "}";
  }
  else if (Lisp_AlreadyPrintedSet.find(n) != Lisp_AlreadyPrintedSet.end())
  {
    // print non-symbols as "[index]" if seen before.
    os << "[" << n.GetNodeNum() << "]";
    //         << "(" << _int_node_ptr->_ref_count << ")";
  }
  else
  {
    Lisp_AlreadyPrintedSet.insert(n);
    const ASTVec& children = n.GetChildren();
    os << n.GetNodeNum() << ":"
       //<< "(" << _int_node_ptr->_ref_count << ")"
       << "(" << kind << " ";
    // os << "{" << GetValueWidth() << "}";
    ASTVec::const_iterator iend = children.end();
    for (ASTVec::const_iterator i = children.begin(); i != iend; i++)
    {
      Lisp_Print_indent(os, *i, indentation + 2);
    }
    os << ")";
  }
  return os;
}
开发者ID:delcypher,项目名称:stp,代码行数:68,代码来源:LispPrinter.cpp

示例10: if


//.........这里部分代码省略.........
              }
            else if (children[0] == var && children[1].isConstant())
              {
                if (children[1] == c1)
                  continue; // always false. Or always false.

                ASTNode v =replaceParentWithFresh(muteParent, variable_array);

                ASTNode rhs = nf->CreateTerm(ITE, width, v,biggestNumber, smallestNumber);
                replace(var, rhs);
              }
            else if (children[1] == var && children[0].isConstant())
              {
                if (children[0] == c2)
                  continue;  // always false. Or always false.

                ASTNode v =replaceParentWithFresh(muteParent, variable_array);

                ASTNode rhs = nf->CreateTerm(ITE, width, v, smallestNumber, biggestNumber);
                replace(var, rhs);
              }
            else // One side is a variable. The other is anything.
              {
            	 bool varOnLHS = (var == children[0]);

                // All the ASTNode vars need to map to their existing MutableASTNodes. So we collect all the variables
                vector<MutableASTNode*> vars;
                set<MutableASTNode*> visited;
                muteOther->getAllVariablesRecursively(vars, visited);
                visited.clear();

                map<ASTNode, MutableASTNode *> create;
                for (vector<MutableASTNode*>::iterator it = vars.begin(); it != vars.end();it++)
                  create.insert(make_pair((*it)->n, *it));
                vars.clear();

                ASTNode v= bm.CreateFreshVariable(0, 0, "STP_INTERNAL_comparison");

                ASTNode rhs;
                ASTNode n;
                if (varOnLHS)
                  {
                    rhs = nf->CreateTerm(ITE, width, v, biggestNumber, smallestNumber);

                    if (kind == BVSGE || kind == BVGE)
                      n= nf->CreateNode(OR, v, nf->CreateNode(EQ, mutable_children[1]->toASTNode(nf), c1));
                    else
                      n= nf->CreateNode(AND, v, nf->CreateNode(NOT,nf->CreateNode(EQ, mutable_children[1]->toASTNode(nf), c1)));
                  }
                else
                  {
                    rhs = nf->CreateTerm(ITE, width, v, smallestNumber, biggestNumber);

                    if (kind == BVSGE || kind == BVGE)
                      n= nf->CreateNode(OR, v, nf->CreateNode(EQ, mutable_children[0]->toASTNode(nf), c2));
                    else
                      n= nf->CreateNode(AND, v, nf->CreateNode(NOT,nf->CreateNode(EQ, mutable_children[0]->toASTNode(nf), c2)));
                  }
                replace(var, rhs);
                MutableASTNode *newN = MutableASTNode::build(n,create);
                muteParent.replaceWithAnotherNode(newN);
                //assert(muteParent.checkInvariant());
              }
          }
          break;
开发者ID:arsenm,项目名称:stp,代码行数:66,代码来源:RemoveUnconstrained.cpp

示例11: GDL_Print1

void GDL_Print1(ostream& os, const ASTNode& n, hash_set<int>* alreadyOutput,
                string (*annotate)(const ASTNode&))
{
  // check if this node has already been printed. If so return.
  if (alreadyOutput->find(n.GetNodeNum()) != alreadyOutput->end())
    return;

  alreadyOutput->insert(n.GetNodeNum());

  os << "node: { title:\"n" << n.GetNodeNum() << "\" label: \"";
  switch (n.GetKind())
  {
    case SYMBOL:
      n.nodeprint(os);
      break;

    case BITVECTOR:
    case BVCONST:
      outputBitVec(n, os);
      break;

    default:
      os << _kind_names[n.GetKind()];
  }

  os << annotate(n);
  os << "\"}" << endl;

  // print the edges to each child.
  const ASTVec ch = n.GetChildren();
  const ASTVec::const_iterator itend = ch.end();

  // If a node has the child 'TRUE' twice, we only want to output one TRUE node.
  ASTNodeSet constantOutput;

  int i = 0;
  for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
  {
    std::stringstream label;

    if (!isCommutative(n.GetKind()))
      label << " label:\"" << i << "\"";

    if (it->isConstant())
    {
      std::stringstream ss;
      ss << n.GetNodeNum() << "_" << it->GetNodeNum();

      if (constantOutput.end() == constantOutput.find(*it))
      {
        os << "node: { title:\"n";

        os << ss.str() << "\" label: \"";
        if (it->GetType() == BEEV::BOOLEAN_TYPE)
          os << _kind_names[it->GetKind()];
        else
          outputBitVec(*it, os);
        os << "\"}" << endl;
        constantOutput.insert(*it);
      }

      os << "edge: { source:\"n" << n.GetNodeNum() << "\" target: \""
         << "n" << ss.str() << "\"" << label.str() << "}" << endl;
    }
    else
      os << "edge: { source:\"n" << n.GetNodeNum() << "\" target: \""
         << "n" << it->GetNodeNum() << "\"" << label.str() << "}" << endl;
    i++;
  }

  // print each of the children.
  for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
  {
    if (!it->isConstant())
      GDL_Print1(os, *it, alreadyOutput, annotate);
  }
}
开发者ID:delcypher,项目名称:stp,代码行数:77,代码来源:GDLPrinter.cpp


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