예제 #1
0
/**
 * Unfolds formal parameters to real parameters
 *
 * @param fParams: list of formal parameters
 * @param rParams: list of real parameters
 * @return: unfolded macro
 */
ASTForm* ASTForm_vf::unfoldMacro(IdentList* fParams, ASTList* rParams) {
	IdentList *ffParams = fParams->copy();
	ASTList *rrParams = (ASTList*) rParams->copy();

	for(Ident* iter = this->vl->begin(); iter != this->vl->end(); ++iter) {
		if (this->kind == aAll0 || this->kind == aEx0) {
			*iter = generate_variable<ASTForm_Var0, generateFreshZeroOrder>(iter, ffParams, rrParams);
		} else if(this->kind == aAll1 || this->kind == aEx1) {
			*iter = generate_variable<ASTTerm1_Var1, generateFreshFirstOrder>(iter, ffParams, rrParams);
		} else {
			assert(this->kind == aAll2 || this->kind == aEx2);
			*iter = generate_variable<ASTTerm2_Var2, generateFreshSecondOrder>(iter, ffParams, rrParams);
		}
	}

	f = _unfoldCore(f, ffParams, rrParams);
	for(Ident* iter = this->vl->begin(); iter != this->vl->end(); ++iter) {
		AST* temp = rrParams->pop_back();
		delete temp;
	}
	while(!rrParams->empty())
		rrParams->pop_back();
	delete rrParams;
	delete ffParams;

	return this;
}
예제 #2
0
/**
 * Unfolds formal parameters to real parameters in called function
 *
 * @param fParams: list of formal parameters
 * @param rParams: list of real parameters
 * @return: unfolded macro
 */
ASTForm* unfoldCall(ASTForm* form, IdentList* fParams, ASTList* rParams) {
	assert(form->kind == aCall);
	ASTForm_Call* callForm = static_cast<ASTForm_Call*>(form);

	PredLibEntry* called = predicateLib.lookup(callForm->n);
	ASTList* realParams = static_cast<ASTList*>(callForm->args->copy());

	for(AST** ast = realParams->begin(); ast != realParams->end(); ++ast) {
		(*ast) = (*ast)->unfoldMacro(fParams, rParams);
	}

	ASTForm* clonnedFormula = (called->ast)->clone();
	ASTForm* unfoldedFormula = _unfoldCore(clonnedFormula, called->formals, realParams);
	// Fixme: this is segfaulting something i guess? 
	//delete realParams;
	callForm->detach();
	//delete callForm;

	return unfoldedFormula;
}
예제 #3
0
QString MakefileHandler::resolveVariable( const QString& variable, AutoTools::ProjectAST* ast )
{
    if ( !ast )
        return variable;

    kdDebug(9020) << k_funcinfo << "attempting to resolve '" << variable << "'"<< endl;
    ASTList childList = ast->children();
    ASTList::iterator it( childList.begin() ), clEnd( childList.end() );
    for ( ; it != clEnd; ++it )
    {
        if ( ( *it )->nodeType() == AutoTools::AST::AssignmentAST )
        {
            AutoTools::AssignmentAST* assignment = static_cast<AutoTools::AssignmentAST*>( ( *it ) );
            if ( variable.find( assignment->scopedID ) != -1 )
            {
                kdDebug(9020) << k_funcinfo << "Resolving variable '" << variable << "' to '"
                              << assignment->values.join( QString::null ).stripWhiteSpace() << "'" << endl;
                return assignment->values.join( QString::null ).stripWhiteSpace();
            }
        }
    }

    return variable;
}