//////////////////////////////////////////////////////////////// // $Log: genSimpleCode.pp,v $ // Revision 5.5.1.1 1994/08/24 19:32:13 demeter // *** empty log message *** // // Revision 5.5 1994/08/24 19:32:12 demeter // *** empty log message *** // // Revision 5.4.1.4 1994/02/28 15:57:03 demeter // update generated comments // // Revision 5.4.1.3 1994/02/24 20:54:37 demeter // reimplement object transportation -- cun // // Revision 5.4.1.2 1994/02/22 14:45:52 demeter // update according to the new semantics // //////////////////////////////////////////////////////////////// *operation* void noEdgesForCodeFrag() *traverse* *from* Carry_or_wrapper_List *via* Code_fragment *to* Meta_edges *wrapper* Meta_edges *prefix* (@ cout << toolname << ": error: code fragments cannot be attached to edges without" << " traversal specification" << endl; exit(-1); @) *operation* void genSimpleMethod(Header* hdr,const char* tmp_cppfname,Cd_graph* schema) *wrapper* Carry_or_wrapper_List *prefix* (@ ofstream strm(tmp_cppfname,ios::app); if (!strm) { cout << toolname << ": unable to open " << tmp_cppfname << endl; perror(tmp_cppfname); exit(-1); } Vertex_List* vlist = new Vertex_List(); Carry_or_wrapper_list_iterator next(*this); Carry_or_wrapper* each; while (each = next()) each->collectVertices(vlist); Vertex_list_iterator nextv(*vlist); Vertex* eachv; while (eachv = nextv()) { int r = 1; hdr->isAFunc(r); if (r) { hdr->printhdr(strm,eachv); strm << "\n this->"; // generate signature hdr->printRetHdr(strm); strm << " return return_val;\n"; strm << "}\n"; } // generate signature hdr->printExtHdr(r ,strm , eachv ,NULL); strm << " // prefix class wrappers\n"; this->printClassPrefix(strm,eachv,NULL,schema); strm << "\n"; strm << " // suffix class wrappers\n"; this->printClassSuffix(strm,eachv,NULL,schema); strm << "\n"; strm << "}\n\n"; } strm.close(); delete vlist; @) *operation* void collectVertices(Vertex_List* vlist) *wrapper* Carry_or_wrapper_List *prefix* (@ Carry_or_wrapper_list_iterator next(*this); Carry_or_wrapper* each; while (each = next()) each->collectVertices(vlist); @) *wrapper* Carry_or_wrapper *prefix* (@ @) *wrapper* Code_fragment *prefix* (@ vertices_edges->collectVertices(vlist); @) *wrapper* Vertices_edges *prefix* (@ @) *wrapper* Require_vertex_selector *prefix* (@ vertices->collectVertices(vlist); @) *wrapper* Require_meta_edges *prefix* (@ if (vertices) vertices->collectVertices(vlist); @) *wrapper* Vertex_selector *prefix* (@ derror('i',1," unexpected visit at Vertex_selector::collectVertices\n"); abort(); @) *wrapper* Any_term *prefix* (@ derror('i',1," unexpected visit at Vertex_selector::collectVertices\n"); abort(); @) *wrapper* Fixed_term *prefix* (@ derror('i',1," unexpected visit at Vertex_selector::collectVertices\n"); abort(); @) *wrapper* Vertex_set *prefix* (@ derror('i',1," unexpected visit at Vertex_selector::collectVertices\n"); abort(); @) *wrapper* Vertex_set_sim *prefix* (@ terms->collectVertices(vlist); @) *wrapper* Fixed_term_Commalist *prefix* (@ Fixed_term_list_iterator next(*this); Fixed_term* each; while (each = next()) { Vertex_list_iterator next2(*vlist); Vertex* each2; while (each2 = next2()) if (each2->get_vertex_name()-> g_equal(each->get_vertex()->get_vertex()->get_vertex_name())) break; if (each2 == NULL) vlist->append(each->get_vertex()->get_vertex()); } @) *operation* void isAFunc(int &r) *traverse* *from* Header *through* ->Signature,type_spec,Type_spec *to* Void *wrapper* Void *prefix* (@ r = 0; @) *operation* void printCode(ofstream &strm) *wrapper* CppCode *prefix* (@ strm << code->get_val(); @) *operation* void printhdr(ofstream &strm,Vertex* owner) *wrapper* Header *prefix* (@ this->get_signature()->printhdr(strm,owner); @) *wrapper* Signature *prefix* (@ int r = 1; //////////////////////////// // print default arglist //////////////////////////// r = 0; if (this->get_parameter_decls()) this->get_parameter_decls()->hasDefaultArgs(r); if (r) this->get_parameter_decls()->printDefaultArgs(0,strm); ///////////////////////// // print signature ///////////////////////// this->get_type_spec()->printType(strm); strm << " "; owner->printVertex(strm); strm << "::"; strm << this->get_name()->get_op_name()->get_val(); strm << "( "; if (this->get_parameter_decls()) this->get_parameter_decls()->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 << "\",\""; this->get_type_spec()->printType(strm); strm << " "; owner->printVertex(strm); strm << "::"; strm << this->get_name()->get_op_name()->get_val(); strm << "("; if (this->get_parameter_decls()) this->get_parameter_decls()->printArgs(strm); strm << ")"; if (this->get_const_qualifier()) strm << " const"; strm << "\");\n"; /////////////////////////// // generate var for func /////////////////////////// r = 1; this->isAFunc(r); if (r) { strm << " "; this->get_type_spec()->printType(strm); strm << " return_val"; if (this->get_init()) strm << " = " << this->get_init()->get_code()->get_val(); strm << ";\n"; } else if (this->get_init()) { cout << toolname << ": '*init* " << this->get_init()->get_code()->get_val() << "' ignored" << endl; } @) *operation* void printType(ofstream & strm) *wrapper* Type_spec *prefix* (@ @) *wrapper* Void *prefix* (@ strm << "void "; @) *wrapper* Nonvoid_type_spec *prefix* (@ @) *wrapper* Type_without_attribute *prefix* (@ param_type->printType(strm); @) *wrapper* Type_with_attribute *prefix* (@ param_type->printType(strm); param_attribute->printType(strm); @) *wrapper* Param_attribute *prefix* (@ @) *wrapper* In *prefix* (@ @) *wrapper* Out *prefix* (@ strm << "& "; @) *wrapper* Inout *prefix* (@ strm << "& "; @) *wrapper* Type *prefix* (@ if (type_qualifier) type_qualifier->printType(strm); type_name->printVertex(strm); refs->printType(strm); @) *wrapper* Type_qualifier *prefix* (@ @) *wrapper* Const *prefix* (@ strm << "const "; @) *wrapper* Struct *prefix* (@ strm << "struct "; @) *wrapper* Ref_Ptr_List *prefix* (@ Ref_Ptr_list_iterator next(*this); Ref_Ptr *each; while (each = next()) each->printType(strm); @) *wrapper* Ref_Ptr *prefix* (@ @) *wrapper* Ref *prefix* (@ strm << "& "; @) *wrapper* Ptr *prefix* (@ strm << "* "; @) *operation* void printVertex(ofstream & strm) *wrapper* Term *prefix* (@ @) *wrapper* CppTerm *prefix* (@ strm << "$"; this->get_vertex()->printVertex(strm); this->get_moduleRef()->printVertex(strm); @) *wrapper* Normal *prefix* (@ this->get_vertex()->printVertex(strm); this->get_moduleRef()->printVertex(strm); @) *wrapper* Vertex *prefix* (@ strm << vertex_name->get_val(); @) *wrapper* TermRef *prefix* (@ @) *wrapper* LocalRef *prefix* (@ @) *wrapper* ModuleRef *prefix* (@ @) *wrapper* CompRef *prefix* (@ strm << "@"; strm << this->get_moduleName()->get_val(); @) *wrapper* LibRef *prefix* (@ strm << "@@"; strm << this->get_moduleName()->get_val(); @) *operation* void printArgs(ofstream & strm) *wrapper* Param_decl_Commalist *prefix* (@ Param_decl_list_iterator next(*this); Param_decl *each; each = next(); if (each) { each->get_param_type_spec()->printType(strm); strm << " " << each->get_param_name()->get_name()->get_val(); } while (each = next()) { strm << ","; each->get_param_type_spec()->printType(strm); strm << " " << each->get_param_name()->get_name()->get_val(); } @) *operation* void hasDefaultArgs(int & r) *wrapper* Param_decl_Commalist *prefix* (@ Param_decl_list_iterator next(*this); Param_decl *each; while (each = next()) if (each->get_default_val()) { r = 1; return; } @) *operation* void printDefaultArgs(int isFunc,ofstream & strm) *wrapper* Param_decl_Commalist *prefix* (@ strm << "//++ defaults ( "; if (isFunc) strm << ", "; Param_decl_list_iterator next(*this); Param_decl *each; each = next(); if (each) { if (each->get_default_val()) strm << each->get_default_val()->get_code()->get_val(); } while (each = next()) { strm << " , "; if (each->get_default_val()) strm << each->get_default_val()->get_code()->get_val(); } strm << " )\n"; @)