/******************* FUNCTION *********************/ void ProjectActionOld::genItLoopCCode ( ostream& out, const CMRProjectContext& context, int depth ) const { CMRProjectContext localContext(&context); //errors assert(name == "cmrSubBlock" && description == "cmrIteratorLoop"); //search the related iterator definition const CMRProjectEntity * entity = context.parent->find(eq->latexEntity); if (entity == NULL) { cerr << "Can't find the definition of iterator " << eq->compute << " in current context." << endl; abort(); } const CMRProjectIterator * iterator = dynamic_cast<const CMRProjectIterator*>(entity); if (iterator == NULL) { cerr << "Cuation, expect iterator " << eq->compute << " but get another type." << endl; context.printDebug(); abort(); } assert(iterator != NULL); CMRProjectLocalVariable localVar(eq->compute,eq->compute); localContext.addEntry(&localVar); out << genCCodeIndent(depth) << "for (int " << eq->compute << " = " << iterator->start << " ; " << eq->compute << " < " << iterator->end << " ; " << eq->compute << "++ )" <<endl; out << genCCodeIndent(depth) << "{" << endl; for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it) it->genCCode(out,it->context,depth+1); //it->genCCode(out,localContext,depth+1); out << genCCodeIndent(depth) << "}" << endl; //checkContext(localContext); }
/******************* FUNCTION *********************/ void ProjectActionOld::genRootElemCCode ( ostream& out, const CMRProjectContext& context, int depth ) const { CMRProjectContext localContext(&context); for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it) it->genCCode(out,it->context,depth+1); //it->genCCode(out,localContext,depth+1); //checkContext(localContext); }
/******************* FUNCTION *********************/ void ProjectActionOld::printDebug(int depth) const { for (int i = 0 ; i < depth ; i++) cout << "\t"; if (name == "cmrEquation") { cout << this->eq->latexName << " = " << this->eq->compute << endl; } else { if (eq != NULL) cout << name << " - " << description << " - " << eq->compute << ":" << endl; else cout << name << " - " << description << ":" << endl; for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it) it->printDebug(depth+1); } }