示例#1
0
//////////////////////////////////////////////////////////////////////////
//attach to one file, create one package information
void fileHandler::attach(std::string path)
{
	clearResult();
	packageInfo* pack = new packageInfo();
	pack->addFileName(path);
	results[path] = pack;
}
示例#2
0
PatchResult::PatchResult()
    :   valType_("None"),
      valPtr_(NULL),
      isPoint_(false)
{
    clearResult();
}
示例#3
0
	MStatus StrandLengthCount::doIt(const MArgList & args) {
		std::list<MObject> targets;
		MStatus status = ArgList_GetModelObjects(args, syntax(), "-b", targets);
		if (status != MStatus::kNotFound && status != MStatus::kSuccess) {
			HMEVALUATE_RETURN_DESCRIPTION("ArgList_GetModelObjects", status);
		}

		clearResult();
		if (!targets.empty()) {
			for (std::list<MObject>::const_iterator it(targets.begin()); it != targets.end(); ++it) {
				Model::Base base(*it);
				Model::Strand strand(base);
				HPRINT("Calling with base: %s", base.getDagPath(status).fullPathName().asChar());
				appendToResult(int(m_operation.length(strand)));
			}
		} else {
			MObjectArray objects;
			HMEVALUATE_RETURN(status = Model::Base::AllSelected(objects), status);

			for (unsigned int i = 0; i < objects.length(); ++i) {
				Model::Base base(objects[i]);
				Model::Strand strand(base);
				HPRINT("Calling with base: %s", base.getDagPath(status).fullPathName().asChar());
				appendToResult(int(m_operation.length(strand)));
			}
		}

		return MStatus::kSuccess;
	}
void CUIAuctionNew::updateFavoriteList()
{
	if (m_pListFavorite == NULL)
		return;

	int		i;
	int		nMax = m_pAuction->getFavoriteCount();

	m_pTxtFavCount->SetText( CTString(0, "%d/%d", nMax, MAX_LIKE_REG_COUNT) );

	TradeAgentItem* pItem;	
	int			nListItemCnt;
	CUIManager* pUIMgr = CUIManager::getSingleton();	
	
	nListItemCnt = m_pListFavorite->getListItemCount();

	m_pListFavorite->SetItemShowNum(nMax);

	CUIListItem*	pListItem; 
	CUIListItem*	pTmpItem;

	pListItem = m_pListFavorite->GetListItemTemplate();

	for (i = 0; i < MAX_LIKE_REG_COUNT; ++i)
	{
		if (i >= nListItemCnt)
			m_pListFavorite->AddListItem((CUIListItem*)pListItem->Clone());

		pTmpItem = (CUIListItem*)m_pListFavorite->GetListItem(i);

		if (pTmpItem == NULL)
			continue;

		if (i >= nMax)
		{
			clearResult(eRESULT_TYPE_FAVORITE, pTmpItem);
			continue;
		}

		pItem = m_pAuction->getFavoriteItem(i);

		if (pItem == NULL)
		{
			continue;
		}

		updateResult(eRESULT_TYPE_FAVORITE, pItem, pTmpItem);
	}

	m_pListFavorite->setCurSel(-1);
	m_pListFavorite->UpdateList();

	//관심물품이 바뀌게 되면, 검색 갱신
	updateSearchList();

	if (nMax >= MAX_LIKE_REG_COUNT)
	{
		m_pBtnRegFav->SetEnable(FALSE);
	}
}
SGameResult PauseScene::onPauseMenu(sf::RenderWindow & window) 
{	
	clearResult();
	checkEvents(window);
	render(window);
	window.display();
	return m_result;
}
示例#6
0
MStatus cvPos::redoIt()
{
    clearResult();
    appendToResult( point.x );
    appendToResult( point.y );
    appendToResult( point.z );

    return MS::kSuccess;
}
示例#7
0
void FilterEffect::addAbsolutePaintRect(const FloatRect& paintRect)
{
    IntRect intPaintRect(enclosingIntRect(paintRect));
    if (m_absolutePaintRect.contains(intPaintRect))
        return;
    intPaintRect.unite(m_absolutePaintRect);
    // Make sure we are not holding on to a smaller rendering.
    clearResult();
    m_absolutePaintRect = intPaintRect;
}
示例#8
0
bool SyncroDB::CreateDatabase()
{
	runInsert( FOLDERS_TABLE_CREATE );
	runInsert( SERVER_ID_TABLE_CREATE );
	runInsert( USERS_TABLE_CREATE );
	runInsert( FILES_TABLE_CREATE );
	runInsert( UPLOAD_HISTORY_CREATE );
	runInsert( DEFAULT_USER_CREATE );
	clearResult();
	return true;
}
示例#9
0
void FilterEffect::clearResultsRecursive()
{
    // Clear all results, regardless that the current effect has
    // a result. Can be used if an effect is in an erroneous state.
    if (hasResult())
        clearResult();

    unsigned size = m_inputEffects.size();
    for (unsigned i = 0; i < size; ++i)
        m_inputEffects.at(i).get()->clearResultsRecursive();
}
示例#10
0
void TriangulationWidget::receiveInputUpdate(int id, bool valid)
{
	if (valid)
		validBitmap |= (1 << id);
	else
		validBitmap &= ~(1 << id);
	if (validBitmap + 1 == (1 << N_INPUTS))
		calculateResult();
	else
		clearResult();
}
示例#11
0
void FECustomFilter::clearShaderResult()
{
    clearResult();
    Uint8ClampedArray* dstPixelArray = createUnmultipliedImageResult();
    if (!dstPixelArray)
        return;

    FilterEffect* in = inputEffect(0);
    setIsAlphaImage(in->isAlphaImage());
    IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
    in->copyUnmultipliedImage(dstPixelArray, effectDrawingRect);
}
示例#12
0
void ObjectFinderWidget::setModel(ModelWidget *model_wgt)
{
	bool enable=model_wgt!=nullptr;

	clearResult();
	this->model_wgt=model_wgt;
	filter_btn->setEnabled(enable);
	pattern_edt->setEnabled(enable);
	filter_frm->setEnabled(enable);
	pattern_lbl->setEnabled(enable);
	find_btn->setEnabled(enable);
	result_tbw->setEnabled(enable);
	highlight_btn->setEnabled(enable);
}
示例#13
0
MStatus iffPixel::redoIt()
{
    clearResult();
	if (useDepth) {
		appendToResult (d);
	} else {
		appendToResult( r );
		appendToResult( g );
		appendToResult( b );
		appendToResult( a );
	}

    return MS::kSuccess;
}
示例#14
0
文件: pyvis.cpp 项目: b3sigma/fourd
bool PyVisInterface::PathIntegralSingleStep(NumberList& output) {
    Timer slowness("python time");
    if(!g_PyVis || !g_PyVis->scriptStep)
        return false;

    PyObject* result = PyObject_CallObject(g_PyVis->scriptStep, /* args */ NULL);
    ScopePyDecRef clearResult(result);
    if(!result || !PyList_Check(result) || PyList_Size(result) <= 0) {
        printf("Python script step didn't return a valid list\n");
        return false;
    }

    PyObject* list = PyList_GetItem(result, 0);
    return g_PyVis->CollectNumberList(list, output);
}
示例#15
0
void fileHandler::attach(int argc, char* argv[])
{

	if (!getCommands(argc,argv))
	{
		std::cout<<"The command line is not formated.\n";
		std::cout<<"Please enter command line as:\n";
		std::cout<<"[path] [pattern](*.*){0,2} (/r)?:\n";
		return;
	}

	clearResult();
	getFiles();
	if (results.size() == 0)
	std::cout<<"\n\nNo file found!!!\n";
}
示例#16
0
bool SyncroDB::UpgradeDatabase( int nCurrentVersion )
{
	if( nCurrentVersion == 1 )
		runInsert( SERVER_ID_TABLE_CREATE );
	if( nCurrentVersion == 2 )
	{
		runInsert( "DROP TABLE " + SERVER_ID_TABLE_NAME + ";" );
		runInsert( SERVER_ID_TABLE_CREATE );
	}
	if( nCurrentVersion < 5 )
	{
		runInsert( USERS_TABLE_CREATE );
	}
	if( nCurrentVersion < 6 )
	{
		runInsert( "DROP TABLE " + USERS_TABLE_NAME + ";" );
		runInsert( USERS_TABLE_CREATE );
	}
	if( nCurrentVersion < 7 )
	{
		runInsert( FILES_TABLE_CREATE );
	}
	if( nCurrentVersion < 8 )
	{
		runInsert( "DROP TABLE " + FOLDERS_TABLE_NAME + ";" );
		runInsert( FOLDERS_TABLE_CREATE );
	}
	if( nCurrentVersion < 9 )
	{
		runInsert( UPLOAD_HISTORY_CREATE );
	}
	if( nCurrentVersion < 11 )
	{
		runInsert( "DELETE FROM " + USERS_TABLE_NAME + ";" );
		runInsert( DEFAULT_USER_CREATE );
	}
	if( nCurrentVersion < 12 )
	{
		runInsert( FILES_TABLE_UPGRADE_V11_V12 );
	}
	clearResult();
	return true;
}
示例#17
0
MStatus lockEvent::doIt( const MArgList &args ) 
//
// Description: 
//  Entry point 
//
{
	MStatus status; 
	int result = 0;
	
	// First check our arguments 
	//
	if ( !parseArgs( args ) ) { 
		return MS::kFailure; 
	}

	if ( fAttach ) { 
		MItSelectionList iter( theList, MFn::kDependencyNode, &status ); 
		for ( ; status && !iter.isDone(); iter.next() ) { 
			MCallbackId id = installCallback( iter ); 
			if ( id ) { 
				result ++; 
			} else { 
				status = MS::kFailure; 
			}
		}
	} else if ( fOverrideFlag ) { 
		// What to do when callback occurs. 
		overrideMode = fOverrideVal; 
	} else if ( fClearCB ) { 
		clearCallbackIds(); 
		result++; 
	}	 

	clearResult(); 
	// Let the caller know if the operation was successful. 
	// We just use an integer value here.  Anything > 0 is 
	// a success. 
	//
	setResult( result ); 

	return status; 
}
示例#18
0
文件: pyvis.cpp 项目: b3sigma/fourd
bool PyVisInterface::PathIntegralSingleStep(QuaxolChunk& output) {
    // Timer slowness("python time");
    if(!g_PyVis || !g_PyVis->scriptStep)
        return false;

    PyErr_Print();

    PyObject* result = PyObject_CallObject(g_PyVis->scriptStep, /* args */ NULL);
    ScopePyDecRef clearResult(result);
    if(!result || !PyList_Check(result) || PyList_Size(result) <= 0) {
        //printf("Python script step didn't return a valid list\n");
        return false;
    }
    PyObject* list = PyList_GetItem(result, 0);
    PyErr_Print();

    NumberList nums;
    bool success = g_PyVis->CollectNumberList(list, nums);
    // printf("Got %d nums!\n", (int)nums.size());
    QuaxolSpec pos(0,0,0,0);
    for(int i = 0;
            i < (int)nums.size() && i < (int)QuaxolChunk::c_mxSz; 
            i++) {
        double val = nums[i];
        // printf(" val %f ", val); 
        static double max = 10.0f;
        static double min = 0.0f;
        int numFilled = (int)((val - min) / (max - min) * (double)QuaxolChunk::c_mxSz);
        pos.x = i;
        for(int j = 0;
                j < numFilled && j < (int)QuaxolChunk::c_mxSz;
                j++) {
            pos.z = j;
            output.SetAt(pos, true);
        }
    }
    PyErr_Print();

    return success;
}
示例#19
0
MStatus tm_polyExtract::doIt( const MArgList& args )
{
	MStatus stat = MS::kSuccess;
	clearResult();

	MArgDatabase argData( syntax(), args);

//	if(argData.isFlagSet( extractFaces_Flag))
	{
		MSelectionList selectionList;
		argData.getObjects( selectionList);
		MStringArray node_names;
		bool result = extractFaces_Func( selectionList, node_names);
		if(!result)
		{
			MGlobal::displayError("tm_polyExtract: extractFaces function call failed.");
			return MStatus::kFailure;
		}
		setResult( node_names);
		return stat;
	}
}
示例#20
0
void ObjectFinderWidget::findObjects(void)
{
	if(model_wgt)
	{
		vector<BaseObject *> objs;
		vector<ObjectType> types;

		clearResult();

		//Getting the selected object types
		for(int i=0; i < obj_types_lst->count(); i++)
		{
			if(obj_types_lst->item(i)->checkState()==Qt::Checked)
				types.push_back(static_cast<ObjectType>(obj_types_lst->item(i)->data(Qt::UserRole).toUInt()));
		}

		//Search the objects on model
		objs=model_wgt->getDatabaseModel()->findObjects(pattern_edt->text(), types, true,
																										case_sensitive_chk->isChecked(), regexp_chk->isChecked(), exact_match_chk->isChecked());

		//Show the found objects on the result table
		updateObjectTable(result_tbw, objs);
		found_lbl->setVisible(true);

		//Show a message indicating the number of found objects
		if(!objs.empty())
		{
			found_lbl->setText(trUtf8("Found <strong>%1</strong> object(s).").arg(objs.size()));
			result_tbw->resizeColumnsToContents();
			result_tbw->horizontalHeader()->setStretchLastSection(true);
		}
		else
			found_lbl->setText(trUtf8("No objects found."));

		clear_res_btn->setEnabled(!objs.empty());
	}
}
MStatus exportJointClusterData::redoIt()
{
    clearResult();
	setResult( (int) 1);
    return MS::kSuccess;
}
示例#22
0
void RunVisitorT<T>::visitprivate(const LogicalOpExp &e)
{
    try
    {
        InternalType *pITR = NULL; //assign only in non shortcut operations.

        /*getting what to assign*/
        e.getLeft().accept(*this);
        InternalType *pITL = getResult();
        if (isSingleResult() == false)
        {
            std::wostringstream os;
            os << _W("Incompatible output argument.\n");
            //os << ((Location)e.right_get().getLocation()).getLocationString() << std::endl;
            throw ast::InternalError(os.str(), 999, e.getRight().getLocation());
        }

        setResult(NULL);

        if (pITL->getType() == GenericType::ScilabImplicitList)
        {
            ImplicitList* pIL = pITL->getAs<ImplicitList>();
            if (pIL->isComputable())
            {
                pITL = pIL->extractFullMatrix();
                pIL->killMe();
            }
        }

        InternalType *pResult   = NULL;

        switch (e.getOper())
        {
            case LogicalOpExp::logicalShortCutAnd :
            {
                pResult = GenericShortcutAnd(pITL);
                if (pResult)
                {
                    break;
                }

                //Continue to logicalAnd
            }
            case LogicalOpExp::logicalAnd :
            {
                /*getting what to assign*/
                e.getRight().accept(*this);
                pITR = getResult();
                if (isSingleResult() == false)
                {
                    std::wostringstream os;
                    os << _W("Incompatible output argument.\n");
                    //os << ((Location)e.right_get().getLocation()).getLocationString() << std::endl;
                    throw ast::InternalError(os.str(), 999, e.getRight().getLocation());
                }

                if (pITR->getType() == GenericType::ScilabImplicitList)
                {
                    ImplicitList* pIR = pITR->getAs<ImplicitList>();
                    if (pIR->isComputable())
                    {
                        pITR = pIR->extractFullMatrix();
                        pIR->killMe();
                    }
                }
                pResult = GenericLogicalAnd(pITL, pITR);
                break;
            }
            case LogicalOpExp::logicalShortCutOr :
            {
                pResult = GenericShortcutOr(pITL);
                if (pResult)
                {
                    break;
                }

                //Continue to logicalAnd
            }
            case LogicalOpExp::logicalOr :
            {
                /*getting what to assign*/
                e.getRight().accept(*this);
                pITR = getResult();
                if (isSingleResult() == false)
                {
                    std::wostringstream os;
                    os << _W("Incompatible output argument.\n");
                    //os << ((Location)e.right_get().getLocation()).getLocationString() << std::endl;
                    throw ast::InternalError(os.str(), 999, e.getRight().getLocation());
                }

                if (pITR->getType() == GenericType::ScilabImplicitList)
                {
                    ImplicitList* pIR = pITR->getAs<ImplicitList>();
                    if (pIR->isComputable())
                    {
                        pITR = pIR->extractFullMatrix();
                    }
                }
                pResult = GenericLogicalOr(pITL, pITR);
                break;
            }

            default :
                break;
        }
        //overloading
        if (pResult == NULL)
        {
            // We did not have any algorithm matching, so we try to call OverLoad
            pResult = callOverloadOpExp(e.getOper(), pITL, pITR);
        }

        setResult(pResult);

        // protect pResult in case where pITL or pITR equal pResult
        pResult->IncreaseRef();

        //clear left and/or right operands
        pITL->killMe();
        if (pITR)
        {
            pITR->killMe();
        }

        // unprotect pResult
        pResult->DecreaseRef();
    }
    catch (ast::InternalError& error)
    {
        clearResult();
        error.SetErrorLocation(e.getLocation());
        throw error;
    }

}
示例#23
0
void
V3SVrfIPDR::startVerify2(const uint32_t& p) {
   // Initialize Parameters
   cerr << "Multi-Step PDR\n";
   uint32_t proved = V3NtkUD, fired = V3NtkUD;
   struct timeval inittime, curtime; gettimeofday(&inittime, NULL);
   clearResult(p); if (profileON()) _totalStat->start(); assert (!_constr.size());
   const string flushSpace = string(100, ' ');
   setEndline(true);
   _maxTime = 900;
   // Clear Verification Results

   if(_tem_decomp == false) _decompDepth = 1;
   if (!reportUnsupportedInitialState()) return;
   //printNetlist(_vrfNtk);
   V3NtkExpand2* const pNtk = new V3NtkExpand2(_handler, _decompDepth+1, true); assert (pNtk);
   _handler->_ntk = pNtk->getNtk();
   _vrfNtk = pNtk->getNtk();
   //_handler->_latchMap = V3NetTable(_cycle, V3NetVec(parentNets, V3NetUD));
   _handler->_latchMap = &(pNtk->_latchMap);
   if(_decompDepth >1) _handler->_decDep = _decompDepth;
   v3Handler.pushAndSetCurHandler(_handler);
   //printNetlist(pNtk->getNtk());

   /*for (unsigned i = 0; i < 3; ++i){
      for (unsigned j = 0; j < 6; ++j){
          cout << _handler->_latchMap->at(i)[j].id << ":" << _handler->_latchMap->at(i)[j].cp << endl;
      }
   }*/
   _pdrGen = new V3AlgAigGeneralize(_handler); assert (_pdrGen);
   _pdrSim = dynamic_cast<V3AlgAigSimulate*>(_pdrGen); assert (_pdrSim);
   V3NetVec simTargets(1, _vrfNtk->getOutput(p)); _pdrSim->reset2(simTargets);
   // Initialize Pattern Input Size
   assert (p < _result.size()); assert (p < _vrfNtk->getOutputSize());
   const V3NetId& pId = _vrfNtk->getOutput(p); assert (V3NetUD != pId);

   _pdrSize = _vrfNtk->getInputSize() + _vrfNtk->getInoutSize();


   // Initialize Signal Priority List
   if (_pdrPriority.size() != _vrfNtk->getLatchSize()) _pdrPriority.resize(_vrfNtk->getLatchSize());

   // Initialize Bad Cube
   _pdrBad = new V3SIPDRCube(0); assert (_pdrBad); _pdrBad->setState(V3NetVec(1, pId));

   // Initialize Frame 0, Solver 0
   _pdrFrame.push_back(new V3SIPDRFrame()); assert (_pdrFrame.size() == 1);
   initializeSolver2(0);

   assert (_pdrSvr.size() == 1); assert (_pdrSvr.back());
   if (_vrfNtk->getLatchSize()) _pdrSvr.back()->assertInit();  // R0 = I0


   // Start PDR Based Verification
   V3SIPDRCube* badCube = 0;
   while (true) {
      // Check Time Bounds
      gettimeofday(&curtime, NULL);
      if (_maxTime < getTimeUsed(inittime, curtime)) break;

      // Find a Bad Cube as Initial Proof Obligation
      badCube = getInitialObligation();  // SAT(R ^ T ^ !p)
      if(heavy_debug){
         if(!badCube) cerr << "the Cube is NULL\n";
         if(badCube){
            cerr << "the Cube is NOT NULL\n";
            printState(badCube->getState());
         }
      }
      if (!badCube) {
         if (!isIncKeepSilent() && intactON() && frame_info ) {
            if (!endLineON()) Msg(MSG_IFO) << "\r" + flushSpace + "\r";
            Msg(MSG_IFO) << setw(3) << left << getPDRDepth() << " :";
            const uint32_t j = (_pdrFrame.size() > 25) ? _pdrFrame.size() - 25 : 0; if (j) Msg(MSG_IFO) << " ...";
            for (uint32_t i = j; i < _pdrFrame.size(); ++i) 
               Msg(MSG_IFO) << " " << _pdrFrame[i]->getCubeList().size();
            Msg(MSG_IFO) << endl;  // Always Endline At the End of Each Frame
         }
         // Set p to the Last Frame
         _pdrSvr.back()->assertProperty(pId, true, 0);
         // Push New Frame
         _pdrFrame.push_back(new V3SIPDRFrame());
         initializeSolver2(getPDRDepth());
         assert (_pdrSvr.back()); assert (_pdrSvr.size() == _pdrFrame.size());

         if (propagateCubes()) {
            proved = getPDRDepth(); break;
         }

      }
      else {
         badCube = recursiveBlockCube2(badCube);
         if (badCube) { fired = getPDRDepth(); break; }
         // Interactively Show the Number of Bad Cubes in Frames
         if (!isIncKeepSilent() && intactON() && frame_info) {
            if (!endLineON()) Msg(MSG_IFO) << "\r" + flushSpace + "\r";
            Msg(MSG_IFO) << setw(3) << left << getPDRDepth() << " :";
            const uint32_t j = (_pdrFrame.size() > 25) ? _pdrFrame.size() - 25 : 0; if (j) Msg(MSG_IFO) << " ...";
            for (uint32_t i = j; i < _pdrFrame.size(); ++i)
               Msg(MSG_IFO) << " " << _pdrFrame[i]->getCubeList().size();
            if (endLineON()) Msg(MSG_IFO) << endl; else Msg(MSG_IFO) << flush;
         }
      }
   }

   // Report Verification Result
   if (!isIncKeepSilent() && reportON()) {
      uint32_t c_size = 0;
      for (uint32_t i = 0; i < _pdrFrame.size(); ++i)
         c_size += _pdrFrame[i]->getCubeList().size();
      cout << "CubeSize : " << c_size << endl;
      if (intactON()) {
         if (endLineON()) Msg(MSG_IFO) << endl;
         else Msg(MSG_IFO) << "\r" << flushSpace << "\r";
      }
      if (V3NtkUD != proved) Msg(MSG_IFO) << "Inductive Invariant found at depth = " << ++proved;
      else if (V3NtkUD != fired) Msg(MSG_IFO) << "Counter-example found at depth = " << ++fired;
      else Msg(MSG_IFO) << "UNDECIDED at depth = " << _maxDepth;
      if (usageON()) {
         gettimeofday(&curtime, NULL);
         Msg(MSG_IFO) << "  (time = " << setprecision(5) << getTimeUsed(inittime, curtime) << "  sec)" << endl;
      }
      if (profileON()) {
         _totalStat->end();
         Msg(MSG_IFO) << *_initSvrStat << endl;
         Msg(MSG_IFO) << *_solveStat << endl;
         Msg(MSG_IFO) << *_BMCStat << endl;
         Msg(MSG_IFO) << *_generalStat << endl;
         Msg(MSG_IFO) << *_propagateStat << endl;
         Msg(MSG_IFO) << *_ternaryStat << endl;
         Msg(MSG_IFO) << *_totalStat << endl;
      }
   }

   // Record CounterExample Trace or Invariant
   if (V3NtkUD != fired) {  // Record Counter-Example
      // Compute PatternCount
      const V3SIPDRCube* traceCube = badCube; assert (traceCube);
      uint32_t patternCount = 0; while (_pdrBad != traceCube) { traceCube = traceCube->getNextCube(); ++patternCount; }
      V3CexTrace* const cex = new V3CexTrace(patternCount); assert (cex);
      _result[p].setCexTrace(cex); assert (_result[p].isCex());
      // Set Pattern Value
      traceCube = badCube; assert (traceCube); assert (existInitial2(traceCube->getState()));
      while (_pdrBad != traceCube) {
         if (_pdrSize) cex->pushData(traceCube->getInputData());
         traceCube = traceCube->getNextCube(); assert (traceCube);
      }
      const V3SIPDRCube* lastCube; traceCube = badCube;
      while (_pdrBad != traceCube) { lastCube = traceCube->getNextCube(); delete traceCube; traceCube = lastCube; }

   }
   else if (V3NtkUD != proved) {  // Record Inductive Invariant
      _result[p].setIndInv(_vrfNtk); assert (_result[p].isInv());
      // Put the Inductive Invariant to the Last Frame
      uint32_t f = 1; for (; f < getPDRDepth(); ++f) if (!_pdrFrame[f]->getCubeList().size()) break;
      assert (f < getPDRDepth());
      for (uint32_t i = 1 + f; i < getPDRDepth(); ++i) {
         const V3SIPDRCubeList& cubeList = _pdrFrame[i]->getCubeList(); V3SIPDRCubeList::const_iterator it;
         for (it = cubeList.begin(); it != cubeList.end(); ++it) _pdrFrame.back()->pushCube(*it);
         _pdrFrame[i]->clearCubeList(); delete _pdrFrame[i]; delete _pdrSvr[i];
      }
      // Remove Empty Frames
      _pdrFrame[f] = _pdrFrame.back(); while ((1 + f) != _pdrFrame.size()) _pdrFrame.pop_back();
      _pdrFrame.back()->removeSelfSubsumed(); delete _pdrSvr.back(); while ((1 + f) != _pdrSvr.size()) _pdrSvr.pop_back();
   }
}
示例#24
0
/* ---------------------------------------------------------------------------------------------------- *\
isIncKeepLastReachability(): If the last result is unsat, put the inductive invariant into the last frame.
isIncContinueOnLastSolver(): Reset the solver.
\* ---------------------------------------------------------------------------------------------------- */
void
V3VrfMPDR::startVerify(const uint32_t& p) {
vrfRestart: 
   // Check Shared Results
   if (_sharedBound && V3NtkUD == _sharedBound->getBound(p)) return;
   
   // Clear Verification Results
   clearResult(p); if (profileON()) _totalStat->start();
   
   // Consistency Check
   consistencyCheck(); assert (!_constr.size());
   if (!reportUnsupportedInitialState()) return;
   
   // Initialize Backup Frames
   for (uint32_t i = 0; i < _pdrBackup.size(); ++i) delete _pdrBackup[i]; _pdrBackup.clear();
   if (_pdrFrame.size()) {
      if (isIncKeepLastReachability()) {
         // Backup frames in the order: ..., 2, 1, INF
         assert (_pdrFrame.size() > 1); _pdrBackup.reserve(_pdrFrame.size() - 1);
         for (uint32_t i = _pdrFrame.size() - 2; i > 0; --i) _pdrBackup.push_back(_pdrFrame[i]);
         _pdrBackup.push_back(_pdrFrame.back()); delete _pdrFrame[0];
      }
      else { for (uint32_t i = 0; i < _pdrFrame.size(); ++i) delete _pdrFrame[i]; } _pdrFrame.clear();
   }

   // Initialize Other Members
   if (!isIncKeepLastReachability()) _pdrPriority.clear(); _pdrActCount = 0;
   if (_pdrBad) delete _pdrBad; _pdrBad = 0; if (_pdrGen) delete _pdrGen; _pdrGen = 0;
   if (dynamic_cast<V3BvNtk*>(_vrfNtk)) {
      _pdrGen = new V3AlgBvGeneralize(_handler); assert (_pdrGen);
      _pdrSim = dynamic_cast<V3AlgBvSimulate*>(_pdrGen); assert (_pdrSim);
   }
   else {
      _pdrGen = new V3AlgAigGeneralize(_handler); assert (_pdrGen);
      _pdrSim = dynamic_cast<V3AlgAigSimulate*>(_pdrGen); assert (_pdrSim);
   }
   V3NetVec simTargets(1, _vrfNtk->getOutput(p)); _pdrSim->reset(simTargets);

   // Initialize Pattern Input Size
   assert (p < _result.size()); assert (p < _vrfNtk->getOutputSize());
   const V3NetId& pId = _vrfNtk->getOutput(p); assert (V3NetUD != pId);
   _pdrSize = _vrfNtk->getInputSize() + _vrfNtk->getInoutSize();

   // Initialize Parameters
   const string flushSpace = string(100, ' ');
   uint32_t proved = V3NtkUD, fired = V3NtkUD;
   struct timeval inittime, curtime; gettimeofday(&inittime, NULL);
   
   // Initialize Signal Priority List
   if (_pdrPriority.size() != _vrfNtk->getLatchSize()) _pdrPriority.resize(_vrfNtk->getLatchSize(), 0);

   // Initialize Solver
   if (_pdrSvr && !isIncContinueOnLastSolver()) { delete _pdrSvr; _pdrSvr = 0; } initializeSolver();

   // Initialize Bad Cube
   _pdrBad = new V3MPDRCube(0); assert (_pdrBad); _pdrBad->setState(V3NetVec(1, pId));

   // Initialize Frame 0
   if (_vrfNtk->getLatchSize()) _pdrFrame.push_back(new V3MPDRFrame(_pdrSvr->setImplyInit()));  // R0 = I0
   else _pdrFrame.push_back(new V3MPDRFrame(_pdrSvr->reserveFormula()));
   assert (_pdrFrame.back()->getActivator()); assert (_pdrFrame.size() == 1);

   // Initialize Frame INF
   if (_pdrBackup.size()) { _pdrFrame.push_back(_pdrBackup.back()); _pdrBackup.pop_back(); addFrameInfoToSolver(1); }
   else _pdrFrame.push_back(new V3MPDRFrame(_pdrSvr->reserveFormula()));
   assert (_pdrFrame.back()->getActivator()); assert (_pdrFrame.size() == 2);

   // Check Shared Invariants
   if (_sharedInv) {
      V3NetTable sharedInv; _sharedInv->getInv(sharedInv);
      for (uint32_t i = 0; i < sharedInv.size(); ++i) {
         V3MPDRCube* const inv = new V3MPDRCube(0); assert (inv);
         inv->setState(sharedInv[i]); addBlockedCube(make_pair(getPDRFrame(), inv));
      }
   }

   // Continue on the Last Depth
   while (_pdrBackup.size() && (getIncLastDepthToKeepGoing() > getPDRFrame())) {
      _pdrFrame.push_back(_pdrFrame.back());  // Keep frame INF the last frame
      _pdrFrame[_pdrFrame.size() - 2] = _pdrBackup.back(); _pdrBackup.pop_back();
      addFrameInfoToSolver(_pdrFrame.size() - 2);
   }

   // Start PDR Based Verification
   V3MPDRCube* badCube = 0;
   while (true) {
      // Check Time Bounds
      gettimeofday(&curtime, NULL);
      if (_maxTime < getTimeUsed(inittime, curtime)) break;
      // Check Shared Results
      if (_sharedBound && (V3NtkUD == _sharedBound->getBound(p))) break;
      // Check Shared Networks
      if (_sharedNtk) {
         V3NtkHandler* const sharedNtk = _sharedNtk->getNtk(_handler);
         if (sharedNtk) {
            setIncKeepLastReachability(true); setIncContinueOnLastSolver(false); setIncLastDepthToKeepGoing(getPDRDepth());
            _handler = sharedNtk; _vrfNtk = sharedNtk->getNtk(); goto vrfRestart;
         }
      }
      // Find a Bad Cube as Initial Proof Obligation
      badCube = getInitialObligation();  // SAT(R ^ T ^ !p)
      if (!badCube) {
         if (!isIncKeepSilent() && intactON()) {
            if (!endLineON()) Msg(MSG_IFO) << "\r" + flushSpace + "\r";
            Msg(MSG_IFO) << setw(3) << left << getPDRDepth() << " :";
            const uint32_t j = (_pdrFrame.size() > 25) ? _pdrFrame.size() - 25 : 0; if (j) Msg(MSG_IFO) << " ...";
            for (uint32_t i = j; i < _pdrFrame.size(); ++i) 
               Msg(MSG_IFO) << " " << _pdrFrame[i]->getCubeList().size();
            if (svrInfoON()) { Msg(MSG_IFO) << "  ("; _pdrSvr->printInfo(); Msg(MSG_IFO) << ")"; }
            Msg(MSG_IFO) << endl;  // Always Endline At the End of Each Frame
         }
         if (_sharedBound) _sharedBound->updateBound(p, getPDRFrame());
         // Push New Frame
         _pdrFrame.push_back(_pdrFrame.back());  // Renders F Infinity to be the last in _pdrFrame
         if (_pdrBackup.size()) {
            _pdrFrame[_pdrFrame.size() - 2] = _pdrBackup.back(); _pdrBackup.pop_back();
            addFrameInfoToSolver(_pdrFrame.size() - 2);
         }
         else _pdrFrame[_pdrFrame.size() - 2] = new V3MPDRFrame(_pdrSvr->reserveFormula());  // New Frame
         if (propagateCubes()) { proved = getPDRDepth(); break; }
         if (_maxDepth <= (getPDRFrame() - 1)) break;
      }
      else {
         badCube = recursiveBlockCube(badCube);
         if (badCube) { fired = getPDRDepth(); break; }
         // Interactively Show the Number of Bad Cubes in Frames
         if (!isIncKeepSilent() && intactON()) {
            if (!endLineON()) Msg(MSG_IFO) << "\r" + flushSpace + "\r";
            Msg(MSG_IFO) << setw(3) << left << getPDRDepth() << " :";
            const uint32_t j = (_pdrFrame.size() > 25) ? _pdrFrame.size() - 25 : 0; if (j) Msg(MSG_IFO) << " ...";
            for (uint32_t i = j; i < _pdrFrame.size(); ++i) 
               Msg(MSG_IFO) << " " << _pdrFrame[i]->getCubeList().size();
            if (svrInfoON()) { Msg(MSG_IFO) << "  ("; _pdrSvr->printInfo(); Msg(MSG_IFO) << ")"; }
            if (endLineON()) Msg(MSG_IFO) << endl; else Msg(MSG_IFO) << flush;
         }
      }
   }

   // Report Verification Result
   if (!isIncKeepSilent() && reportON()) {
      if (intactON()) {
         if (endLineON()) Msg(MSG_IFO) << endl;
         else Msg(MSG_IFO) << "\r" << flushSpace << "\r";
      }
      if (V3NtkUD != proved) Msg(MSG_IFO) << "Inductive Invariant found at depth = " << ++proved;
      else if (V3NtkUD != fired) Msg(MSG_IFO) << "Counter-example found at depth = " << ++fired;
      else Msg(MSG_IFO) << "UNDECIDED at depth = " << _maxDepth;
      if (usageON()) {
         gettimeofday(&curtime, NULL);
         Msg(MSG_IFO) << "  (time = " << setprecision(5) << getTimeUsed(inittime, curtime) << "  sec)" << endl;
      }
      if (profileON()) {
         _totalStat->end();
         Msg(MSG_IFO) << *_initSvrStat << endl;
         Msg(MSG_IFO) << *_solveStat << endl;
         Msg(MSG_IFO) << *_generalStat << endl;
         Msg(MSG_IFO) << *_propagateStat << endl;
         Msg(MSG_IFO) << *_ternaryStat << endl;
         Msg(MSG_IFO) << *_totalStat << endl;
      }
   }

   // Record CounterExample Trace or Invariant
   if (V3NtkUD != fired) {  // Record Counter-Example
      // Compute PatternCount
      const V3MPDRCube* traceCube = badCube; assert (traceCube); assert (existInitial(traceCube->getState()));
      uint32_t patternCount = 0; while (_pdrBad != traceCube) { traceCube = traceCube->getNextCube(); ++patternCount; }
      V3CexTrace* const cex = new V3CexTrace(patternCount); assert (cex);
      _result[p].setCexTrace(cex); assert (_result[p].isCex());
      // Set Pattern Value
      traceCube = badCube; assert (traceCube); assert (existInitial(traceCube->getState()));
      while (_pdrBad != traceCube) {
         if (_pdrSize) cex->pushData(traceCube->getInputData());
         traceCube = traceCube->getNextCube(); assert (traceCube);
      }
      // Set Initial State Value
      if (_pdrInitValue.size()) {
         V3BitVecX initValue(_pdrInitValue.size());
         for (uint32_t i = 0; i < badCube->getState().size(); ++i) {
            assert (initValue.size() > badCube->getState()[i].id);
            if (badCube->getState()[i].cp) initValue.set0(badCube->getState()[i].id);
            else initValue.set1(badCube->getState()[i].id);
         }
         for (uint32_t i = 0; i < _pdrInitValue.size(); ++i)
            if (_pdrInitConst[i]) { if (_pdrInitValue[i]) initValue.set0(i); else initValue.set1(i); }
         cex->setInit(initValue);
      }
      // Delete Cubes on the Trace
      const V3MPDRCube* lastCube; traceCube = badCube;
      while (_pdrBad != traceCube) { lastCube = traceCube->getNextCube(); delete traceCube; traceCube = lastCube; }
      // Check Common Results
      if (isIncVerifyUsingCurResult()) checkCommonCounterexample(p, *cex);
   }
   else if (V3NtkUD != proved) {  // Record Inductive Invariant
      _result[p].setIndInv(_vrfNtk); assert (_result[p].isInv());
      // Put the Inductive Invariant to Frame INF
      uint32_t f = 1; for (; f < getPDRDepth(); ++f) if (!_pdrFrame[f]->getCubeList().size()) break;
      assert (f < getPDRDepth());
      for (uint32_t i = 1 + f; i < getPDRFrame(); ++i) {
         const V3MPDRCubeList& cubeList = _pdrFrame[i]->getCubeList(); V3MPDRCubeList::const_iterator it;
         for (it = cubeList.begin(); it != cubeList.end(); ++it) addBlockedCube(make_pair(getPDRFrame(), *it));
         _pdrFrame[i]->clearCubeList(); delete _pdrFrame[i];
      }
      // Remove Empty Frames
      _pdrFrame.back()->removeSelfSubsumed();
      _pdrFrame[f] = _pdrFrame.back(); while ((1 + f) != _pdrFrame.size()) _pdrFrame.pop_back();
      // Check Common Results
      if (isIncVerifyUsingCurResult()) {
         const V3MPDRCubeList& invCubeList = _pdrFrame.back()->getCubeList();
         V3NetTable invList; invList.clear(); invList.reserve(invCubeList.size());
         for (V3MPDRCubeList::const_iterator it = invCubeList.begin(); it != invCubeList.end(); ++it)
            invList.push_back((*it)->getState()); checkCommonProof(p, invList, false);
      }
   }
}
示例#25
0
MStatus blindComplexDataCmd::redoIt()
{
	MStatus     stat;				// Status code
	MObject 	dependNode;		// Selected dependency node

	// Iterate over all selected dependency nodes
	//
	for ( ; !iter->isDone(); iter->next() ) 
	{
		// Get the selected dependency node and create
		// a function set for it
		//
		if ( MS::kSuccess != iter->getDependNode( dependNode ) ) {
			cerr << "Error getting the dependency node" << endl;
			continue;
		}
		
		MFnDependencyNode fnDN( dependNode, &stat );
		if ( MS::kSuccess != stat ) {
			cerr << "Error creating MFnDependencyNode" << endl;
			continue;
		}

		// Create a new attribute for our blind data
		//
		// cout << "Creating attr..." << endl;
		
		MFnTypedAttribute fnAttr;
		const MString fullName( "blindComplexData" );
		const MString briefName( "BCD" );
		MObject newAttr = fnAttr.create( fullName, briefName,
										 blindComplexData::id );

		// Now add the new attribute to the current dependency node
		//
		// cout << "Adding attr..." << endl;
		fnDN.addAttribute( newAttr, MFnDependencyNode::kLocalDynamicAttr );
		
		//
		// now we will demonstrate setting the value by using a plug.
		MPlug plug( dependNode, newAttr );  

		//
		// create an instance of the blind data with an initial array size of
		// 5.
		blindComplexData * newData = new blindComplexData( 5 );

		//
		// initialized 
		// cout << "setting data values..." << endl;
		unsigned int i;
		for ( i= 0; i < newData->length(); i++ ) {
			(*newData)[i]._intData = 10 + i;
			(*newData)[i]._doubleData = 20.02 + i;
		}

		// 
		// setting the value for the plug.
		stat = plug.setValue( newData );

		//
		// The following code demonstrates the retrieving of data from the 
		// plug.
		MObject sData;
		stat = plug.getValue( sData );

		if ( stat != MS::kSuccess ) {
			cerr << "error getting value off plug" << endl;
			continue;
		}

		// 
		// Convert the data from an MObject back to a pointer to MPxData, then
		// cast it back to a pointer to blindComplexData.
		MFnPluginData pdFn( sData ); 
		blindComplexData* data =
							( blindComplexData* ) pdFn.constData( &stat );
		//
		// read the data, and set the result to the values set.
		
		clearResult();

		if ( NULL != data ) {
			// cout << "retrieving data values..." << endl;
			for ( i = 0; i < data->length(); i++ ) {
				// cout << "rec #" << i << ": " << (*data)[i]._intData << ", "; 
				// cout << (*data)[i]._doubleData << endl;
				appendToResult((double) ((*data)[i]._intData));
				appendToResult((*data)[i]._doubleData);
			}
		} else {
			// cout << "Null data" << endl;
		}

	}
	return MS::kSuccess;
}
示例#26
0
MStatus dagPoseInfo::redoIt()
{
    clearResult();
    setResult( (int) 1);
    return MS::kSuccess;
}
 void PThreadProcessingDevice::clear() { // delete?
   clearCache();
   clearResult();
 }
示例#28
0
void RunVisitorT<T>::visitprivate(const CallExp &e)
{
    CoverageInstance::invokeAndStartChrono((void*)&e);
    types::typed_list outTmp;
    types::typed_list inTmp;
    std::vector<std::wstring> vectOptName;
    std::vector<int> vectNbResult;

    int iRetCount = getExpectedSize();
    int iSaveExpectedSize = iRetCount;

    //get function arguments
    exps_t args = e.getArgs();
    try
    {
        for (auto& arg : args)
        {
            int iSize = getExpectedSize();
            if (arg->isAssignExp())
            {
                AssignExp* pAssign = static_cast<AssignExp*>(arg);
                //optional parameter
                Exp* pL = &pAssign->getLeftExp();
                if (!pL->isSimpleVar())
                {
                    std::wostringstream os;
                    os << _W("left side of optional parameter must be a variable") << std::endl;
                    CoverageInstance::stopChrono((void*)&e);
                    throw ast::InternalError(os.str(), 999, e.getLocation());
                }

                SimpleVar* pVar = pL->getAs<SimpleVar>();
                Exp* pR = &pAssign->getRightExp();
                // optional parameter have only one output argument
                setExpectedSize(1);
                try
                {
                    pR->accept(*this);
                }
                catch (ScilabException &)
                {
                    CoverageInstance::stopChrono((void*)&e);
                    throw;
                }
                setExpectedSize(iSize);
                types::InternalType* pITR = getResult();
                // IncreaseRef to protect opt argument of scope_end delete
                // It will be deleted by clear_opt
                pITR->IncreaseRef();

                vectOptName.push_back(pVar->getSymbol().getName());
                inTmp.push_back(pITR);
                vectNbResult.push_back(1);

                clearResult();
                continue;
            }

            setExpectedSize(-1);
            try
            {
                arg->accept(*this);
            }
            catch (ScilabException &)
            {
                CoverageInstance::stopChrono((void*)&e);
                throw;
            }
            setExpectedSize(iSize);

            if (getResult() == NULL)
            {
                //special case for empty extraction of list ( list()(:) )
                vectNbResult.push_back(0);
                continue;
            }

            if (isSingleResult())
            {
                inTmp.push_back(getResult());
                getResult()->IncreaseRef();
            }
            else
            {
                for (int i = 0; i < getResultSize(); i++)
                {
                    types::InternalType * pITArg = getResult(i);
                    pITArg->IncreaseRef();
                    inTmp.push_back(pITArg);
                }
            }

            vectNbResult.push_back(getResultSize());
            clearResult();
        }
    }
    catch (const InternalError& ie)
    {
        clearResult();
        cleanIn(inTmp, outTmp);
        CoverageInstance::stopChrono((void*)&e);
        throw ie;
    }

    // get function/variable
    try
    {
        e.getName().accept(*this);
    }
    catch (ScilabException &)
    {
        CoverageInstance::stopChrono((void*)&e);
        throw;
    }
    types::InternalType* pIT = getResult();

    // pIT can be NULL if one of call return nothing. foo()(1) with foo return nothing.
    if(pIT == NULL)
    {
        clearResult();
        std::wostringstream os;
        os << _W("Cannot extract from nothing.") << std::endl;
        CoverageInstance::stopChrono((void*)&e);
        throw ast::InternalError(os.str(), 999, e.getLocation());
    }

    types::typed_list out;
    types::typed_list in;
    types::optional_list opt;

    // manage case [a,b]=foo() where foo is defined as a=foo()
    if (pIT->getInvokeNbOut() != -1 && pIT->getInvokeNbOut() < iRetCount)
    {
        clearResult();
        std::wostringstream os;
        os << _W("Wrong number of output arguments.\n") << std::endl;
        CoverageInstance::stopChrono((void*)&e);
        throw ast::InternalError(os.str(), 999, e.getLocation());
    }

    if (pIT->isCallable())
    {
        CoverageInstance::invoke(static_cast<types::Callable *>(pIT));
    }

    // manage input according the function/variable
    int iLoop = -1;
    int iterIn = 0;
    int iterOptName = 0;
    for (auto& arg : args)
    {
        iLoop++;

        //special case for empty extraction of list ( list()(:) )
        if (vectNbResult[iLoop] == 0)
        {
            continue;
        }

        //extract implicit list for call()
        if (pIT->isCallable() || pIT->isUserType())
        {
            if (inTmp[iterIn]->isImplicitList())
            {
                types::ImplicitList* pIL = inTmp[iterIn]->getAs<types::ImplicitList>();
                if (pIL->isComputable())
                {
                    types::InternalType* pITExtract = pIL->extractFullMatrix();
                    pITExtract->IncreaseRef();
                    inTmp[iterIn] = pITExtract;
                    pIL->DecreaseRef();
                    pIL->killMe();
                }
            }
        }

        // management of optional input
        if (arg->isAssignExp())
        {
            if (pIT->hasInvokeOption())
            {
                opt[vectOptName[iterOptName++]] = inTmp[iterIn++];

                //in case of macro/macrofile, we have to shift input param
                //so add NULL item in in list to keep initial order
                if (pIT->isMacro() || pIT->isMacroFile())
                {
                    in.push_back(NULL);
                }
            }
            else
            {
                in.push_back(inTmp[iterIn++]);
            }

            continue;
        }

        // default case
        for (int i = 0; i < vectNbResult[iLoop]; i++, iterIn++)
        {
            in.push_back(inTmp[iterIn]);
        }
    }

    try
    {
        // Extraction with a List in input argument.
        // This extraction must be a recursive extract.
        int iLoopSize = 1;
        types::List* pListArg = NULL;
        if (pIT->isCallable() == false && in.size() == 1 && in[0]->isList())
        {
            pListArg = in[0]->getAs<types::List>();
            iLoopSize = pListArg->getSize();
            cleanOpt(opt, out);
        }

        setExpectedSize(iSaveExpectedSize);
        iRetCount = std::max(1, iRetCount);

        for (int i = 0; i < iLoopSize; i++)
        {
            if (pListArg)
            {
                in[0] = pListArg->get(i);

                if (in[0]->isList())
                {
                    if (pIT->isCallable())
                    {
                        // list used like "varargin"
                        types::List* pLFuncArgs = in[0]->getAs<types::List>();
                        types::typed_list input;
                        for (int j = 0; j < pLFuncArgs->getSize(); j++)
                        {
                            input.push_back(pLFuncArgs->get(j));
                            input.back()->IncreaseRef();
                        }

                        in = input;
                    }
                    else
                    {
                        pListArg->DecreaseRef();
                        pListArg->killMe();

                        std::wostringstream os;
                        os << _W("Invalid index.\n");
                        throw ast::InternalError(os.str(), 999, e.getFirstLocation());
                    }
                }
                else
                {
                    in[0]->IncreaseRef();
                }
            }

            bool ret = false;
            if (pIT->isInvokable() == false)
            {
                // call overload
                ret = Overload::call(L"%" + pIT->getShortTypeStr() + L"_e", in, iRetCount, out, true);
            }
            else
            {
                ret = pIT->invoke(in, opt, iRetCount, out, e);
                if (ret == false && pIT->isUserType())
                {
                    // call overload
                    ret = Overload::call(L"%" + pIT->getShortTypeStr() + L"_e", in, iRetCount, out, true);
                }
            }

            if (ret)
            {
                if (iSaveExpectedSize != -1 && iSaveExpectedSize > out.size())
                {
                    char szError[bsiz];
                    if (pIT->isCallable())
                    {
                        char* strFName = wide_string_to_UTF8(pIT->getAs<types::Callable>()->getName().c_str());
                        os_sprintf(szError, _("%s: Wrong number of output argument(s): %d expected.\n"), strFName, out.size());
                        FREE(strFName);
                    }
                    else
                    {
                        os_sprintf(szError, _("%s: Wrong number of output argument(s): %d expected.\n"), "extract", out.size());
                    }

                    wchar_t* wError = to_wide_string(szError);
                    std::wstring err(wError);
                    FREE(wError);
                    throw InternalError(err, 999, e.getLocation());
                }

                setExpectedSize(iSaveExpectedSize);
                setResult(out);
                cleanIn(in, out);
                cleanOpt(opt, out);

                // In case a.b(), getResult contain pIT ("b").
                // If out == pIT, do not delete it.
                if (getResult() != pIT)
                {
                    // protect element of out in case where
                    // out contain elements of pIT
                    for (int i = 0; i < out.size(); i++)
                    {
                        out[i]->IncreaseRef();
                    }

                    pIT->killMe();

                    // unprotect
                    for (int i = 0; i < out.size(); i++)
                    {
                        out[i]->DecreaseRef();
                    }
                }

                if (pListArg && i + 1 != iLoopSize)
                {
                    pIT = out[0];
                    out.clear();
                    setResult(NULL);
                }
            }
            else
            {
                std::wostringstream os;
                os << _W("Invalid index.\n");
                throw ast::InternalError(os.str(), 999, e.getFirstLocation());
            }
        }

        if (pListArg)
        {
            pListArg->DecreaseRef();
            pListArg->killMe();
        }
    }
    catch (InternalAbort & ia)
    {
        setExpectedSize(iSaveExpectedSize);
        if (pIT != getResult())
        {
            pIT->killMe();
        }

        clearResult();
        cleanInOut(in, out);
        cleanOpt(opt, out);
        CoverageInstance::stopChrono((void*)&e);

        throw ia;
    }
    catch (const InternalError& ie)
    {
        setExpectedSize(iSaveExpectedSize);
        if (pIT != getResult())
        {
            pIT->killMe();
        }

        clearResult();
        cleanInOut(in, out);
        cleanOpt(opt, out);
        CoverageInstance::stopChrono((void*)&e);

        throw ie;
    }

    CoverageInstance::stopChrono((void*)&e);
}
void ExpressionResult::resetInternal() {
    clearResult();
}
void ExpressionResult::operator=(const ExpressionResult& rhs)
{
    Pbug << "operator=(const ExpressionResult& rhs)"
        << endl;
    Pbug << "Rhs: " << rhs << endl;

    // Check for assignment to self
    if (this == &rhs)
    {
        FatalErrorIn("ExpressionResult::operator=(const ExpressionResult&)")
            << "Attempted assignment to self"
            << exit(FatalError);
    }

    clearResult();

    valType_=rhs.valType_;
    isPoint_=rhs.isPoint_;
    isSingleValue_=rhs.isSingleValue_;
    objectSize_=-1;

    if( rhs.valPtr_ ) {
        if(valType_==pTraits<scalar>::typeName) {
            valPtr_=new scalarField(*static_cast<scalarField*>(rhs.valPtr_));
        } else if(valType_==pTraits<vector>::typeName) {
            valPtr_=new Field<vector>(
                *static_cast<Field<vector>*>(
                    rhs.valPtr_
                )
            );
        } else if(valType_==pTraits<tensor>::typeName) {
            valPtr_=new Field<tensor>(
                *static_cast<Field<tensor>*>(
                    rhs.valPtr_
                )
            );
        } else if(valType_==pTraits<symmTensor>::typeName) {
            valPtr_=new Field<symmTensor>(
                *static_cast<Field<symmTensor>*>(
                    rhs.valPtr_
                )
            );
        } else if(valType_==pTraits<sphericalTensor>::typeName) {
            valPtr_=new Field<sphericalTensor>(
                *static_cast<Field<sphericalTensor>*>(
                    rhs.valPtr_
                )
            );
        } else if(valType_==pTraits<bool>::typeName) {
            valPtr_=new Field<bool>(
                *static_cast<Field<bool>*>(
                    rhs.valPtr_
                )
            );
        } else {
            FatalErrorIn("ExpressionResult::operator=(const ExpressionResult& rhs)")
                << " Type " << valType_ << " can not be copied"
                    << endl
                    << exit(FatalError);
        }
    } else {
        valPtr_=rhs.valPtr_;
        if(generalContent_.valid()) {
            FatalErrorIn("ExpressionResult::operator=(const ExpressionResult& rhs)")
                << "Assignment with general content not possible"
                    << endl
                    << exit(FatalError);

        }
    }

//     const_cast<ExpressionResult &>(rhs).valPtr_=NULL;
//     const_cast<ExpressionResult &>(rhs).clearResult();
}