#include "pp.h" void Implementation::genMethod( Cd_graph* schema,Header* hdr,const char* tmp_cppfname,Propagation_schema* ps ) { DEM_TRACE("Implementation","void Implementation::genMethod(Cd_graph* schema,Header* hdr,const char* tmp_cppfname,Propagation_schema* ps)"); // prefix class wrappers ps->get_paths()->genMethod(ps, schema, hdr, tmp_cppfname, ps->get_source_port(), carry_or_wrapper); // suffix class wrappers } void Cd_graph::genMethod( Propagation_schema* ps,Cd_graph* schema,Header* hdr,const char* tmp_cppfname,Vertex_selector* source_port,Carry_or_wrapper_List* frags ) { DEM_TRACE("Cd_graph","void Cd_graph::genMethod(Propagation_schema* ps,Cd_graph* schema,Header* hdr,const char* tmp_cppfname,Vertex_selector* source_port,Carry_or_wrapper_List* frags)"); // prefix class wrappers ofstream tmp_cpptarget(tmp_cppfname,ios::app); if (!tmp_cpptarget) { cout << toolname << ": unable to open " << tmp_cppfname << endl; perror(tmp_cppfname); exit(-1); } adjacencies->genMethod(ps, schema->get_adjacencies(), schema, hdr, tmp_cpptarget, source_port, frags); //adjacencies->genMethod(ps, schema->get_adjacencies(), this, hdr, tmp_cpptarget, source_port, frags); tmp_cpptarget.close(); // suffix class wrappers } void Adjacency_Nlist::genMethod( Propagation_schema* ps,Adjacency_Nlist* adjs,Cd_graph* schema,Header* hdr,ofstream& strm,Vertex_selector* source_port,Carry_or_wrapper_List* frags ) { DEM_TRACE("Adjacency_Nlist","void Adjacency_Nlist::genMethod(Propagation_schema* ps,Adjacency_Nlist* adjs,Cd_graph* schema,Header* hdr,ofstream& strm,Vertex_selector* source_port,Carry_or_wrapper_List* frags)"); // prefix class wrappers Adjacency_list_iterator next(*this); Adjacency* each; while (each = next()) { Adjacency_list_iterator next2(*adjs); Adjacency* each2; while (each2 = next2()) if (each2->get_source()->get_vertex_name() ->g_equal(each->get_source()->get_vertex_name())) break; each->genMethod(ps, adjs, each2, schema, hdr, strm, source_port, frags); } // suffix class wrappers } void Adjacency::genMethod( Propagation_schema* ps,Adjacency_Nlist* adjs,Adjacency* adj,Cd_graph* schema,Header* hdr,ofstream& strm,Vertex_selector* source_port,Carry_or_wrapper_List* frags ) { DEM_TRACE("Adjacency","void Adjacency::genMethod(Propagation_schema* ps,Adjacency_Nlist* adjs,Adjacency* adj,Cd_graph* schema,Header* hdr,ofstream& strm,Vertex_selector* source_port,Carry_or_wrapper_List* frags)"); // prefix class wrappers if (ps->isTarget(this->get_source()) || schema->isConstructRepetit(this->get_source())) { Adjacency_List* considered = new Adjacency_List(); schema->collectDelayBindForTrans(schema, ps, considered, this); considered->printDelayBindForTrans(schema,ps,this,frags,hdr,strm); delete considered; } Adjacency_list_iterator next(*schema->get_adjacencies()); Adjacency* each; while (each = next()) if (each->get_source()->equal(this->get_source())) break; assert(each); each->cd_pp(strm); int r = 1; hdr->isAFunc(r); // generate signature hdr->printExtHdr(r ,strm ,source ,inarguments); // checking it is a propagation class int targetAssociated = 0; ps->get_target_port()->alternationReachable(schema,source,targetAssociated); if (targetAssociated || schema->isConstructRepetit(this->get_source())) { // carry out variable defs strm << " // variables for carrying in and out\n"; if (outarguments) { outarguments->genCarryVarDefs(strm); } strm << "\n"; // carry in assignments strm << " // assignments for carrying in\n"; // reach out to superclasses schema->genSuperCarryPrefixAssign( schema, source, ps, strm, inarguments, outarguments); if (param_assignments) { param_assignments->genCarryPrefixAssign( source, strm, inarguments, outarguments); } strm << "\n"; //generate function calls strm << " // prefix class wrappers\n"; frags->printClassPrefix(strm,source,ps,schema); strm << "\n"; } else strm << "#ifndef NOTRACE\n DemTrace demTraceEmptyMethod(__FILE__,__LINE__,\"" << source->get_vertex_name()->get_val() << "\",form(\" at %s , *** PREMATURELY TERMINATED *** \", this->get_type()));\n#endif\n"; if (schema->isConstructRepetit(this->get_source())) { // outgoing calls strm << " // outgoing calls\n"; ns->printCalls(schema, source, hdr, strm, frags, inarguments); if (superclasses) superclasses->printSuperCalls(schema, source, hdr, strm, frags, ps); } strm << "\n"; // checking it is a propagation class if (targetAssociated || schema->isConstructRepetit(this->get_source())) { strm << " // suffix class wrappers\n"; frags->printClassSuffix(strm,source,ps,schema); strm << "\n"; // carry out assignments strm << " // assignments for carrying out\n"; // reach out to superclasses schema->genSuperCarrySuffixAssign( schema, source, ps, strm, inarguments, outarguments); if (param_assignments) { param_assignments->genCarrySuffixAssign(source, strm, inarguments, outarguments); } } strm << "}\n\n"; // suffix class wrappers } void Header::printExtHdr( int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs ) { DEM_TRACE("Header","void Header::printExtHdr(int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs)"); // prefix class wrappers this->get_signature()->printExtHdr(isFunc, strm, owner, inargs); // suffix class wrappers } void Signature::printExtHdr( int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs ) { DEM_TRACE("Signature","void Signature::printExtHdr(int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs)"); // prefix class wrappers int r; //////////////////////////// // print default arglist //////////////////////////// r = 0; if (this->get_parameter_decls()) this->get_parameter_decls()->hasDefaultArgs(r); if (r) this->get_parameter_decls()->printDefaultArgs(isFunc,strm); ///////////////////////// // print signature ///////////////////////// strm << "void "; owner->printVertex(strm); strm << "::"; strm << this->get_name()->get_op_name()->get_val(); if (isFunc) { strm << "_( "; this->get_type_spec()->printType(strm); strm << "& return_val"; if (inargs || this->get_parameter_decls()) strm << ", "; } else strm << "( "; if (this->get_parameter_decls()) this->get_parameter_decls()->printArgs(strm); if (inargs) { if (this->get_parameter_decls()) strm << ", "; inargs->printArgs(strm); } strm << " )"; if (this->get_const_qualifier()) strm << " const\n"; else strm << "\n"; strm << "{\n "; /////////////////////////// // generate traces /////////////////////////// strm << "DEM_TRACE(\""; owner->printVertex(strm); strm << "\",\""; strm << "void "; owner->printVertex(strm); strm << "::"; strm << this->get_name()->get_op_name()->get_val(); if (isFunc) { strm << "_("; this->get_type_spec()->printType(strm); strm << "& return_val"; if (inargs || this->get_parameter_decls()) strm << ","; } else strm << "("; if (this->get_parameter_decls()) this->get_parameter_decls()->printArgs(strm); if (inargs) { if (this->get_parameter_decls()) strm << ","; inargs->printArgs(strm); } strm << ")"; if (this->get_const_qualifier()) strm << " const"; strm << "\");\n"; // suffix class wrappers } void Header::printSplitHdr( int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs,Vertex* v ) { DEM_TRACE("Header","void Header::printSplitHdr(int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs,Vertex* v)"); // prefix class wrappers this->get_signature()->printSplitHdr(isFunc, strm, owner, inargs, v); // suffix class wrappers } void Signature::printSplitHdr( int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs,Vertex* v ) { DEM_TRACE("Signature","void Signature::printSplitHdr(int isFunc,ofstream& strm,Vertex* owner,Param_decl_Commalist* inargs,Vertex* v)"); // prefix class wrappers int r; //////////////////////////// // print default arglist //////////////////////////// r = 0; if (this->get_parameter_decls()) this->get_parameter_decls()->hasDefaultArgs(r); if (r) this->get_parameter_decls()->printDefaultArgs(isFunc,strm); ///////////////////////// // print signature ///////////////////////// strm << "void "; owner->printVertex(strm); strm << "::"; strm << v->get_vertex_name()->get_val() << this->get_name()->get_op_name()->get_val(); if (isFunc) { strm << "_( "; this->get_type_spec()->printType(strm); strm << "& return_val"; if (inargs || this->get_parameter_decls()) strm << ", "; } else strm << "( "; if (this->get_parameter_decls()) this->get_parameter_decls()->printArgs(strm); if (inargs) { if (this->get_parameter_decls()) strm << ", "; inargs->printArgs(strm); } strm << " )"; if (this->get_const_qualifier()) strm << " const\n"; else strm << "\n"; strm << "{\n "; /////////////////////////// // generate traces /////////////////////////// strm << "DEM_TRACE(\""; owner->printVertex(strm); strm << "\",\""; strm << "void "; owner->printVertex(strm); strm << "::"; strm << v->get_vertex_name()->get_val() << this->get_name()->get_op_name()->get_val(); if (isFunc) { strm << "_("; this->get_type_spec()->printType(strm); strm << "& return_val"; if (inargs || this->get_parameter_decls()) strm << ","; } else strm << "("; if (this->get_parameter_decls()) this->get_parameter_decls()->printArgs(strm); if (inargs) { if (this->get_parameter_decls()) strm << ","; inargs->printArgs(strm); } strm << ")"; if (this->get_const_qualifier()) strm << " const"; strm << "\");\n"; // suffix class wrappers }