#include "semcheck.h" /**************************************************************** ** File Name : check_formal_pars.c ** ** ** ** Actual parameter for formal class parameters must be ** ** non-parameterized classes ** *****************************************************************/ int Cd_graph::check_formal_pars() { return adjacencies->check_formal_pars(); } int Adjacency_Nlist::check_formal_pars() { int result = SUCCESS; Adjacency_list_iterator next(*this); Adjacency_ each; while (each=next()) if (each->check_formal_pars()==ERROR_FORMAL) { cerr << toolname << ": error: near line " << each->get_source()->get_vertex_name()->get_line_number() << endl; result = ERROR_FORMAL; } return (result); } int Adjacency::check_formal_pars() { if (parameters) return ns->check_formal_pars(parameters,this); else return (SUCCESS); } int Neighbors::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return 0; } int Construct_ns::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return this->get_construct_ns()->check_formal_pars(parameters,adj); } int Alternat_ns::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { int result2 = SUCCESS; int result1 = alternat_ns->check_formal_pars(parameters,adj); result2 = this->get_construct_ns()->check_formal_pars(parameters,adj); if ((result1==SUCCESS)&&(result2==SUCCESS)) return (SUCCESS); else return (ERROR_FORMAL); } int Repetit_n::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return sandwiched->check_formal_pars(parameters,adj); } int Kernel_Sandwich::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return inner->check_formal_pars(parameters,adj); } int Kernel::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { int result1 = SUCCESS; int result2 = repeated->check_formal_pars(parameters,adj); if (nonempty) result1 = nonempty->check_formal_pars(parameters,adj); if ((result1==SUCCESS)&&(result2==SUCCESS)) return (SUCCESS); else return (ERROR_FORMAL); } int Term_Sandwich::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return inner->check_formal_pars(parameters,adj); } int Any_vertex_List::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { int result = SUCCESS; Any_vertex_list_iterator next_Any_vertex(*this); Any_vertex_ each_Any_vertex; while (each_Any_vertex=next_Any_vertex()) if (each_Any_vertex->check_formal_pars(parameters,adj)==ERROR_FORMAL) result = ERROR_FORMAL; return (result); } int Any_vertex::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return SUCCESS; } int Regular::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return (this->get_vertex()->check_formal_pars(parameters,adj)); } int Labeled::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return (this->get_vertex()->check_formal_pars(parameters,adj)); } int Optional_term::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return (opt->check_formal_pars(parameters,adj)); } int Opt_labeled_term_Sandwich::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return (inner->check_formal_pars(parameters,adj)); } int Syntax_vertex::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return (SUCCESS); } int Inherit_term::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { return (inherited->check_formal_pars(parameters,adj)); } int Term_Bar_list::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { int result = SUCCESS; Term_list_iterator next_Term(*this); Term_ each_Term; while (each_Term=next_Term()) if (each_Term->check_formal_pars(parameters,adj)==ERROR_FORMAL) result = ERROR_FORMAL; return (result); } int Term_Comma_list::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { int result = SUCCESS; Term_list_iterator next_Term(*this); Term_ each_Term; while (each_Term=next_Term()) if (each_Term->check_formal_pars(parameters,adj)==ERROR_FORMAL) result = ERROR_FORMAL; return (result); } int Term::check_formal_pars(Vertex_Comma_list *parameters,Adjacency *adj) { int result = SUCCESS; Vertex *a_vertex = this->get_vertex(); Term_Comma_list *act_pars = this->get_actual_parameters(); if (act_pars) { if (parameters->is_formal_par(a_vertex)) { cerr << toolname << ": error: on line " << a_vertex->get_vertex_name()->get_line_number() << " formal parameter: '"; a_vertex->pp(cerr); cerr << "' can not be a parameterized class.\n" << endl; } return act_pars->check_formal_pars(parameters,adj); } else return SUCCESS; } int Vertex_Comma_list::is_formal_par(Vertex *avertex) { Vertex_list_iterator next_Vertex(*this); Vertex_ each_Vertex; while (each_Vertex=next_Vertex()) if (each_Vertex->g_equal(avertex)) return YES; return NO; }