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


C++ ASTNode::IsDefined方法代码示例

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


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

示例1: C_Print1

// helper function for printing C code (copied from PL_Print1())
void C_Print1(ostream& os, const ASTNode n, int indentation, bool letize)
{

  unsigned int upper, lower, num_bytes;
  Kind LHSkind, RHSkind;

  // os << spaces(indentation);
  // os << endl << spaces(indentation);
  if (!n.IsDefined())
  {
    os << "<undefined>";
    return;
  }

  // if this node is present in the letvar Map, then print the letvar
  STPMgr* bm = n.GetSTPMgr();

  // this is to print letvars for shared subterms inside the printing
  // of "(LET v0 = term1, [email protected],...
  if ((bm->NodeLetVarMap1.find(n) != bm->NodeLetVarMap1.end()) && !letize)
  {
    C_Print1(os, (bm->NodeLetVarMap1[n]), indentation, letize);
    return;
  }

  // this is to print letvars for shared subterms inside the actual
  // term to be printed
  if ((bm->NodeLetVarMap.find(n) != bm->NodeLetVarMap.end()) && letize)
  {
    C_Print1(os, (bm->NodeLetVarMap[n]), indentation, letize);
    return;
  }

  // otherwise print it normally
  Kind kind = n.GetKind();
  const ASTVec& c = n.GetChildren();
  switch (kind)
  {
    case BOOLEXTRACT:
      FatalError("C_Print1: printing not implemented for this kind: ", n);
      C_Print1(os, c[0], indentation, letize);
      os << "{";
      C_Print1(os, c[1], indentation, letize);
      os << "}";
      break;
    case BITVECTOR:
      FatalError("C_Print1: printing not implemented for this kind: ", n);
      os << "BITVECTOR(";
      unsigned char* str;
      str = CONSTANTBV::BitVector_to_Hex(c[0].GetBVConst());
      os << str << ")";
      CONSTANTBV::BitVector_Dispose(str);
      break;
    case BOOLEAN:
      FatalError("C_Print1: printing not implemented for this kind: ", n);
      os << "BOOLEAN";
      break;
    case FALSE:
      os << "0";
      break;
    case TRUE:
      os << "1";
      break;
    case BVCONST:
    case SYMBOL:
      // print in C friendly format:
      n.nodeprint(os, true);
      break;
    case READ:
      C_Print1(os, c[0], indentation, letize);
      os << "[";
      C_Print1(os, c[1], indentation, letize);
      os << "]";
      break;
    case WRITE:
      os << "(";
      C_Print1(os, c[0], indentation, letize);
      os << " WITH [";
      C_Print1(os, c[1], indentation, letize);
      os << "] := ";
      C_Print1(os, c[2], indentation, letize);
      os << ")";
      os << endl;
      break;
    case BVUMINUS:
      os << kind << "( ";
      C_Print1(os, c[0], indentation, letize);
      os << ")";
      break;
    case NOT:
      os << "!(";
      C_Print1(os, c[0], indentation, letize);
      os << ") " << endl;
      break;
    case BVNEG:
      os << " ~(";
      C_Print1(os, c[0], indentation, letize);
      os << ")";
      break;
//.........这里部分代码省略.........
开发者ID:delcypher,项目名称:stp,代码行数:101,代码来源:CPrinter.cpp

示例2: FatalError

  void SMTLIB2_Print1(ostream& os, const ASTNode n, int indentation, bool letize)
  {
    //os << spaces(indentation);
    //os << endl << spaces(indentation);
    if (!n.IsDefined())
      {
        FatalError("<undefined>");
        return;
      }

    //if this node is present in the letvar Map, then print the letvar
    //this is to print letvars for shared subterms inside the printing
    //of "(LET v0 = term1, [email protected],...
	if ((NodeLetVarMap1.find(n) != NodeLetVarMap1.end()) && !letize)
      {
		SMTLIB2_Print1(os, (NodeLetVarMap1[n]), indentation, letize);
        return;
      }

    //this is to print letvars for shared subterms inside the actual
    //term to be printed
	if ((NodeLetVarMap.find(n) != NodeLetVarMap.end()) && letize)
      {
		SMTLIB2_Print1(os, (NodeLetVarMap[n]), indentation, letize);
        return;
      }

    //otherwise print it normally
	const Kind kind = n.GetKind();
    const ASTVec &c = n.GetChildren();
    switch (kind)
      {
      case BITVECTOR:
      case BVCONST:
    	  outputBitVecSMTLIB2(n, os);
        break;
      case SYMBOL:
        os << "|";
        n.nodeprint(os);
        os << "|";
        break;
      case FALSE:
        os << "false";
        break;
      case NAND: // No NAND, NOR in smtlib format.
      case NOR:
    	  assert(c.size() ==2);
    	  os << "(" << "not ";
    	  if (NAND == kind )
    		  os << "(" << "and ";
    	  else
    		  os << "(" << "or ";
    	  SMTLIB2_Print1(os, c[0], 0, letize);
    	  os << " " ;
    	  SMTLIB2_Print1(os, c[1], 0, letize);
    	  os << "))";
    	  break;
      case TRUE:
        os << "true";
        break;
      case BVSX:
      case BVZX:
        {
          unsigned int amount = c[1].GetUnsignedConst();
          if (BVZX == kind)
            os << "((_ zero_extend ";
          else
            os << "((_ sign_extend ";

          os << (amount - c[0].GetValueWidth()) << ") ";
          SMTLIB2_Print1(os, c[0], indentation, letize);
          os << ")";
        }
        break;
      case BVEXTRACT:
        {
          unsigned int upper = c[1].GetUnsignedConst();
          unsigned int lower = c[2].GetUnsignedConst();
          assert(upper >= lower);
          os << "((_ extract " << upper << " " << lower << ") ";
          SMTLIB2_Print1(os, c[0], indentation, letize);
          os << ")";
        }
        break;
  	default:
  	{
  	    if ((kind == AND  || kind == OR|| kind == XOR) && n.Degree() == 1)
  	    {
  	    	FatalError("Wrong number of arguments to operation (must be >1).", n);
  	    }

  		// SMT-LIB only allows these functions to have two parameters.
  		if ((kind == AND  || kind == OR|| kind == XOR || BVPLUS == kind || kind == BVOR || kind == BVAND)  && n.Degree() > 2)
  		{
  			string close = "";

  			for (long int i =0; i < (long int)c.size()-1; i++)
  			{
  				os << "(" << functionToSMTLIBName(kind,false);
  				os << " ";
//.........这里部分代码省略.........
开发者ID:DidwardFrenkel,项目名称:stp,代码行数:101,代码来源:SMTLIB2Printer.cpp


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