*operation* void check_meta() *traverse* *from* Meta_def *to* Meta_macro_def *wrapper* Meta_macro_def *prefix* (@ /////////////////////////////////////////////////////////////////////////// // there is no need to check class and relation variables // the algorithm goes like this: // first : find all the meta variables which contain no use // of meta variables // second: substitute with the variables found above // if there is no progress and there is still more than one // left, it is an error. //////////////////////////////////////////////////////////////////////////// static Meta_macro_def * final_madef = new Meta_macro_def(); static Meta_def * final_meta = new Meta_def(); final_meta->set_meta_def(final_madef); if ((this->get_class_sets() == NULL) && (this->get_dirs() == NULL)) return; Class_set_def_Amplist * final_csets = NULL; Dir_meta_def_Amplist * final_dirs = NULL; if (this->get_class_sets() != NULL) final_csets = new Class_set_def_Amplist(); if (this->get_dirs() != NULL) final_dirs = new Dir_meta_def_Amplist(); final_madef->set_class_sets(final_csets); final_madef->set_dirs(final_dirs); int progress = 0; while (1) { progress = 0; if (this->get_class_sets() != NULL) { Class_set_def_Amplist * t = new Class_set_def_Amplist(); Class_set_def_list_iterator next(*this->get_class_sets()); Class_set_def * each; while (each = next()) { int c = 0; each->no_meta_vars_in_cset(c); if (!c) { final_csets->append(each); progress = 1; } else t->append(each); } if (t->list_length() == 0) { delete t; t = NULL; } delete this->rset_class_sets(t); } if (this->get_dirs() != NULL) { Dir_meta_def_Amplist * t = new Dir_meta_def_Amplist(); Dir_meta_def_list_iterator next(*this->get_dirs()); Dir_meta_def * each; while (each = next()) { int c = 0; each->no_meta_vars_in_dir(c); if (!c) { final_dirs->append(each); progress = 1; } else t->append(each); } if (t->list_length() == 0) { delete t; t = NULL; } delete this->rset_dirs(t); } ///////////////////////////////////////////////////////////////// // try to reduce meta variables ///////////////////////////////////////////////////////////////// if (this->get_class_sets() != NULL) { this->get_class_sets()->check_meta_csets(final_meta); this->get_class_sets()->check_meta_cdirs(final_meta); } if (this->get_dirs() != NULL) { this->get_dirs()->check_meta_dsets(final_meta); this->get_dirs()->check_meta_ddirs(final_meta); } if (progress == 0) break; } if ((this->get_class_sets() == NULL) && (this->get_dirs() == NULL)) { this->set_class_sets(final_csets); this->set_dirs(final_dirs); return; } cout << toolname << ": illegal meta definitions : there is no way to futher reduce the meta definitions.\n" << " there may be some undefined meta variables or recursive definitions." << endl; if (this->get_class_sets() != NULL) { cout << "*class-set*" << endl; this->get_class_sets()->g_print(cout); cout << endl; } if (this->get_dirs() != NULL) { cout << "*dir*" << endl; this->get_dirs()->g_print(cout); cout << endl; } exit(-1); @) *operation* void check_meta_csets(Meta_def * finalmeta) *traverse* *from* Class_set_def_Amplist *to* Class_set_def *wrapper* Class_set_def *prefix* (@ Vertex_selector * reduced = NULL; this->get_class_set()->check_meta_sets(finalmeta,reduced); if (reduced) this->rset_class_set((Vertex_selector*)reduced->g_copy())->g_delete(); @) *operation* void check_meta_dsets(Meta_def * finalmeta) *traverse* *from* Dir_meta_def_Amplist *to* Dir_meta_def *wrapper* Dir_meta_def *prefix* (@ Vertex_selector * reduced = NULL; this->get_pde()->check_meta_sets(finalmeta,reduced); @) *operation* void check_meta_sets(Meta_def * finalmeta,Vertex_selector *& reduced) *traverse* *from* {Class_set_def, Propagation_directive_exp, Require_vertex_selector, Require_meta_edges} *to* {Vertex_set_comp, Class_set_name, Late_selected_terms} *wrapper* Class_set_name *prefix* (@ DemIdent * n = this->get_name(); Vertex_selector * r = NULL; if ( finalmeta->get_meta_def()->get_class_sets()) finalmeta->get_meta_def()->get_class_sets()->find_set(r,n); if (r != NULL) reduced = (Vertex_selector *)r->g_copy(); @) *wrapper* Vertex_set_comp *prefix* (@ Vertex_selector * reduced_arg1 = NULL; this->get_arg1()->check_meta_sets(finalmeta,reduced_arg1); if (reduced_arg1) this->rset_arg1((Vertex_set*)reduced_arg1->g_copy())->g_delete(); Vertex_selector * reduced_arg2 = NULL; this->get_arg2()->check_meta_sets(finalmeta,reduced_arg2); if (reduced_arg2) this->rset_arg1((Vertex_set*)reduced_arg2->g_copy())->g_delete(); reduced = NULL; @) *wrapper* Require_vertex_selector *suffix* (@ Vertex_selector * r = NULL; this->get_vertices()->check_meta_sets(finalmeta,r); if (r) this->rset_vertices((Vertex_selector*)r->g_copy())->g_delete(); reduced = NULL; @) *wrapper* Pde *suffix* (@ Vertex_selector * r = NULL; this->get_source_port()->check_meta_sets(finalmeta,r); if (r) this->rset_source_port((Vertex_selector*)r->g_copy())->g_delete(); reduced = NULL; @) *wrapper* Targets *suffix* (@ Vertex_selector * r = NULL; this->get_targets()->check_meta_sets(finalmeta,r); if (r) this->rset_targets((Vertex_selector*)r->g_copy())->g_delete(); reduced = NULL; @) *wrapper* Require_meta_edges *suffix* (@ Vertex_selector * r = NULL; this->get_vertices()->check_meta_sets(finalmeta,r); if (r) this->rset_vertices((Vertex_selector*)r->g_copy())->g_delete(); reduced = NULL; @) *wrapper* Meta_construction_edge *suffix* (@ Vertex_selector * reduced_from = NULL; this->get_from()->check_meta_sets(finalmeta,reduced_from); if (reduced_from) this->rset_from((Vertex_selector*)reduced_from->g_copy())->g_delete(); Vertex_selector * reduced_to = NULL; this->get_to()->check_meta_sets(finalmeta,reduced_to); if (reduced_to) this->rset_to((Vertex_selector*)reduced_to->g_copy())->g_delete(); @) *wrapper* Meta_alternation_edge *suffix* (@ Vertex_selector * reduced_from = NULL; this->get_from()->check_meta_sets(finalmeta,reduced_from); if (reduced_from) this->rset_from((Vertex_selector*)reduced_from->g_copy())->g_delete(); Vertex_selector * reduced_to = NULL; this->get_to()->check_meta_sets(finalmeta,reduced_to); if (reduced_to) this->rset_to((Vertex_selector*)reduced_to->g_copy())->g_delete(); @) *wrapper* Meta_inheritance_edge *suffix* (@ Vertex_selector * reduced_from = NULL; this->get_from()->check_meta_sets(finalmeta,reduced_from); if (reduced_from) this->rset_from((Vertex_selector*)reduced_from->g_copy())->g_delete(); Vertex_selector * reduced_to = NULL; this->get_to()->check_meta_sets(finalmeta,reduced_to); if (reduced_to) this->rset_to((Vertex_selector*)reduced_to->g_copy())->g_delete(); @) *wrapper* Meta_repetition_edge *suffix* (@ Vertex_selector * reduced_from = NULL; this->get_from()->check_meta_sets(finalmeta,reduced_from); if (reduced_from) this->rset_from((Vertex_selector*)reduced_from->g_copy())->g_delete(); Vertex_selector * reduced_to = NULL; this->get_to()->check_meta_sets(finalmeta,reduced_to); if (reduced_to) this->rset_to((Vertex_selector*)reduced_to->g_copy())->g_delete(); @) *operation* void check_meta_ddirs(Meta_def * finalmeta) *traverse* *from* Dir_meta_def_Amplist *to* Dir_meta_def *wrapper* Dir_meta_def *suffix* (@ Propagation_directive_exp * pdexp = NULL; this->get_pde()->bind_pde(finalmeta,pdexp); if (pdexp != NULL) this->rset_pde((Propagation_directive_exp *)pdexp->g_copy())->g_delete(); @) *operation* void check_meta_cdirs(Meta_def * finalmeta) *traverse* *from* Class_set_def_Amplist *to* Late_selected_terms *wrapper* Late_selected_terms *suffix* (@ Propagation_directive_exp * pdexp = NULL; this->get_pde()->bind_pde(finalmeta,pdexp); if (pdexp != NULL) this->rset_pde((Propagation_directive_exp *)pdexp->g_copy())->g_delete(); @)