示例#1
0
PredicateSymbol* LiftedAlgsConvertor::createPredicateSymbol(Predicate* pred)
{
	int predicateId = pred->getId();
	vector<int> var_types(pred->getNumTerms());
	string symbolName(pred->getName());
	PredicateSymbol* pSymbol = new PredicateSymbol(predicateId,symbolName,var_types,LogDouble(1,false),LogDouble(1,false),predicateId);
	return pSymbol;
}
示例#2
0
const QString& ExpressionStatement::symbolName() const
{
	static QString nullString;

	//TODO What should the const usage be here?
	auto e = (const_cast<ExpressionStatement*>(this))->expression();
	return e ? e->symbolName() : nullString;
}
示例#3
0
FrFrame *FrSymbol::lockFrame()
{
   FrFrame *fr = find_vframe_inline(this) ;

   if (fr && !fr->isLocked() && VFrame_Info)
      {
      if (VFrame_Info->lockFrame(this))
         fr->setLock(true) ;
      else
         {
	 FrWarningVA("unable to lock frame %s",symbolName()) ;
         return 0 ;
         }
      }
   return fr ;
}
示例#4
0
void CodeProfile::report()
{
    dataLog("<CodeProfiling %s:%d>\n", m_file.data(), m_lineNo);

    // How many frames of C-code to print - 0, if not verbose, 1 if verbose, up to 1024 if very verbose.
    unsigned recursionLimit = CodeProfiling::beVeryVerbose() ? 1024 : CodeProfiling::beVerbose();

    ProfileTreeNode profile;

    // Walk through the sample buffer.
    size_t trace = 0;
    while (trace < m_samples.size()) {

        // All traces are zero or more 'EngineFrame's, followed by a non-'EngineFrame'.
        // Scan to find the last sample in the trace.
        size_t lastInTrace = trace;
        while (m_samples[lastInTrace].type == EngineFrame)
            ++lastInTrace;

        // We use the last sample type to look up a name (used as a bucket in the profiler).
        ProfileTreeNode* callbacks = profile.sampleChild(s_codeTypeNames[m_samples[lastInTrace].type]);

        // If there are any samples in C-code, add up to recursionLimit of them into the profile tree.
        size_t lastEngineFrame = lastInTrace;
        for (unsigned count = 0; lastEngineFrame > trace && count < recursionLimit; ++count) {
            --lastEngineFrame;
            ASSERT(m_samples[lastEngineFrame].type == EngineFrame);
            const char* name = symbolName(m_samples[lastEngineFrame].pc);
            callbacks = callbacks->sampleChild(name);
            if (truncateTrace(name))
                break;
        }

        // Move on to the next trace.
        trace = lastInTrace + 1;
        ASSERT(trace <= m_samples.size());
    }

    // Output the profile tree.
    dataLog("Total samples: %lld\n", static_cast<long long>(profile.childCount()));
    profile.dump();
    
    for (size_t i = 0 ; i < m_children.size(); ++i)
        m_children[i]->report();

    dataLog("</CodeProfiling %s:%d>\n", m_file.data(), m_lineNo);
}
示例#5
0
Model::Node* Project::navigateTo(Model::Node* source, QString path)
{
	QString symbol = extractFrontSymbol(path);
	Model::Node* found = nullptr;

	// Is the target symbol name the module's name
	if (isAncestorOf(source) && symbol == symbolName()) found = this;

	if (!found) found = projects()->findFirstSymbolDefinition(symbol);
	if (!found) found = libraries()->findFirstSymbolDefinition(symbol);
	if (!found) found = modules()->findFirstSymbolDefinition(symbol);
	if (!found) found = classes()->findFirstSymbolDefinition(symbol);
	if (!found) return ExtendableNode::navigateTo(source, path);

	QString rest = extractSecondaryPath(path);
	if (!rest.isEmpty()) return found->navigateTo(this, rest);
	else return found;
}
示例#6
0
WClause* LiftedAlgsConvertor::convertClauseToLifted(Clause* clause, const Domain* domain, vector<PredicateSymbol*>& symbolsToAdd,bool& containsGroundedClause)
{
   const Array<Predicate*>* preds = clause->getPredicates();
   map<int,LvrTerm*> mapOfTerms;
   WClause* nClause = new WClause();
   nClause->atoms = vector<Atom*>(preds->size());
   nClause->sign = vector<bool>(preds->size());
   nClause->weight = LogDouble(clause->getWt(),false);
   set<int> completedIds;
	for (int i = 0; i < preds->size(); i++)
	{
		nClause->sign[i] = !((*preds)[i]->getSense());
		int predicateId = (*preds)[i]->getId();
		vector<int> var_types((*preds)[i]->getNumTerms());
		string symbolName((*preds)[i]->getName());
		PredicateSymbol* pSymbol = new PredicateSymbol(predicateId,symbolName,var_types,LogDouble(1,false),LogDouble(1,false),predicateId);
		const PredicateTemplate *ptemplate = (*preds)[i]->getTemplate();
		vector<LvrTerm*> atomTerms((*preds)[i]->getNumTerms());
		for (int termno = 0; termno < (*preds)[i]->getNumTerms(); termno++)
		{
			 const Term* term = (*preds)[i]->getTerm(termno);
			 if(term->getType()==Term::CONSTANT)
			 {
				 int id = term->getId();
				 vector<int> domValues(1);
				 domValues[0] = id;
				 LvrTerm* lvrTerm = new LvrTerm(0,domValues);
				 atomTerms[termno]=lvrTerm;
				 //contains a "+" in the term
				 containsGroundedClause=true;
				 continue;
			 }
			 int varId = term->getId();
			 map<int,LvrTerm*>::iterator mapIt = mapOfTerms.find(varId);
			 if(mapIt==mapOfTerms.end())
			 {
				 //new term, add it
				 int varTypeId = ptemplate->getTermTypeAsInt(termno);
				 const Array<int>* constants = domain->getConstantsByType(varTypeId);
				 vector<int> domValues;
				 for(unsigned int j=0;j<constants->size();j++)
				 {
					 domValues.push_back((*constants)[j]);
				 }
				 LvrTerm* lvrTerm = new LvrTerm(0,domValues);
				 mapOfTerms.insert(pair<int,LvrTerm*> (varId,lvrTerm));
				 atomTerms[termno]=lvrTerm;
			 }
			 else
			 {
				 //use existing term
				 atomTerms[termno] = mapIt->second;
			 }
		}
		//sort the domains of all terms
		for(unsigned int jj=0;jj<atomTerms.size();jj++)
			sort(atomTerms[jj]->domain.begin(),atomTerms[jj]->domain.end());
		Atom* atom = new Atom(pSymbol,atomTerms);
		nClause->atoms[i] = atom;
		if(completedIds.count(pSymbol->id) == 0)
		{
			//ADD TO LvrMLN
			PredicateSymbol* nSymbol = new PredicateSymbol(predicateId,symbolName,var_types,LogDouble(1,false),LogDouble(1,false),predicateId);
			symbolsToAdd.push_back(nSymbol);
		}
	}
	return nClause;
}