// Check that a class does not inherit from itself either directly // or indirectly. *operation* int check_cycle_free() *init* (@ 1 @) *traverse* *from* Cd_graph *through* ->Alternat_ns,*,Term_Bar_list *to-stop* Term *carry* *in* Vertex* src = (@ this->get_source() @) *along* *from* Adjacency *to* Term *carry* *in* Cd_graph* graph = (@ this @) *along* *from* Cd_graph *to* Term *wrapper* Cd_graph *prefix* (@ cout << endl << "Checking inheritance cycles ..." << endl; @) *wrapper* Term *prefix* (@ Adjacency* adjclass = graph->find_adjacency(this->get_vertex()); if (adjclass != NULL) { if ((return_val) && (adjclass->check_cycle1(graph, src))) { if (!src->g_equal(this->get_vertex())) { cout << "\tto "; this->get_vertex()->g_print(); cout << endl; } cout << "\tto "; src->g_print(); cout << endl; return_val = 0; } } @) *operation* int check_cycle1(Cd_graph* graph, Vertex* src) *init* (@ 0 @) *traverse* *from* Adjacency *through* ->Alternat_ns,*,Term_Bar_list *to-stop* Term *wrapper* Term *prefix* (@ if (this->get_vertex()->g_equal(src)) { cout << "sem-check: error: on line " << this->find_line_number() << " find inheritance cycle 1 :" << endl; cout << endl << endl << "\tfrom "; src->g_print(); cout << endl; return_val = 1; } else { Adjacency* adjclass = graph->find_adjacency(this->get_vertex()); if (adjclass != NULL) if (adjclass->check_cycle1(graph, src)) { cout << "\tto "; this->g_print(); cout << endl; return_val = 1; } } @)