stage3/narrow_candidate_datatypes.cc
changeset 423 f4a2d400ddbd
parent 421 840cb1e1e177
child 424 43d73e28eca8
equal deleted inserted replaced
422:c957f712ef4d 423:f4a2d400ddbd
    82 		 * Get the name of that parameter, and ignore if EN or ENO.
    82 		 * Get the name of that parameter, and ignore if EN or ENO.
    83 		 */
    83 		 */
    84 		do {
    84 		do {
    85 			param_name = fp_iterator.next();
    85 			param_name = fp_iterator.next();
    86 			/* If there is no other parameter declared, then we are passing too many parameters... */
    86 			/* If there is no other parameter declared, then we are passing too many parameters... */
    87 			/* This error should have been caught in fill_candidate_datatypes_c */
    87 			/* This error should have been caught in fill_candidate_datatypes_c, but may occur here again when we handle FB invocations! */
    88 			if(param_name == NULL) ERROR;
    88 			if(param_name == NULL) return;
    89 		} while ((strcmp(param_name->value, "EN") == 0) || (strcmp(param_name->value, "ENO") == 0));
    89 		} while ((strcmp(param_name->value, "EN") == 0) || (strcmp(param_name->value, "ENO") == 0));
    90 
    90 
    91 		/* Set the desired datatype for this parameter, and call it recursively. */
    91 		/* Set the desired datatype for this parameter, and call it recursively. */
    92 		call_param_value->datatype = base_type(fp_iterator.param_type());
    92 		call_param_value->datatype = base_type(fp_iterator.param_type());
       
    93 		if (NULL == call_param_value->datatype) ERROR;
    93 		call_param_value->accept(*this);
    94 		call_param_value->accept(*this);
    94 
    95 
    95 		if (extensible_parameter_highest_index < fp_iterator.extensible_param_index())
    96 		if (extensible_parameter_highest_index < fp_iterator.extensible_param_index())
    96 			extensible_parameter_highest_index = fp_iterator.extensible_param_index();
    97 			extensible_parameter_highest_index = fp_iterator.extensible_param_index();
    97 	}
    98 	}
   132 
   133 
   133 		/* Find the corresponding parameter in function declaration */
   134 		/* Find the corresponding parameter in function declaration */
   134 		param_name = fp_iterator.search(call_param_name);
   135 		param_name = fp_iterator.search(call_param_name);
   135 
   136 
   136 		/* Set the desired datatype for this parameter, and call it recursively. */
   137 		/* Set the desired datatype for this parameter, and call it recursively. */
   137 		call_param_name->datatype = base_type(fp_iterator.param_type());
   138 		call_param_value->datatype = base_type(fp_iterator.param_type());
   138 		call_param_name->accept(*this);
   139 		if (NULL == call_param_value->datatype) ERROR;
       
   140 		call_param_value->accept(*this);
   139 
   141 
   140 		if (extensible_parameter_highest_index < fp_iterator.extensible_param_index())
   142 		if (extensible_parameter_highest_index < fp_iterator.extensible_param_index())
   141 			extensible_parameter_highest_index = fp_iterator.extensible_param_index();
   143 			extensible_parameter_highest_index = fp_iterator.extensible_param_index();
   142 	}
   144 	}
   143 	/* call is compatible! */
   145 	/* call is compatible! */
   158 /* a helper function... */
   160 /* a helper function... */
   159 symbol_c *narrow_candidate_datatypes_c::base_type(symbol_c *symbol) {
   161 symbol_c *narrow_candidate_datatypes_c::base_type(symbol_c *symbol) {
   160 	/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used
   162 	/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used
   161 	 *       in the code.
   163 	 *       in the code.
   162 	 */
   164 	 */
   163 	return NULL;
   165 	if (symbol == NULL) return NULL;
       
   166 	return (symbol_c *)symbol->accept(search_base_type);	
   164 }
   167 }
   165 
   168 
   166 /*********************/
   169 /*********************/
   167 /* B 1.2 - Constants */
   170 /* B 1.2 - Constants */
   168 /*********************/
   171 /*********************/
  1033 
  1036 
  1034 /*****************************************/
  1037 /*****************************************/
  1035 /* B 3.2.2 Subprogram Control Statements */
  1038 /* B 3.2.2 Subprogram Control Statements */
  1036 /*****************************************/
  1039 /*****************************************/
  1037 
  1040 
       
  1041 void *narrow_candidate_datatypes_c::visit(fb_invocation_c *symbol) {
       
  1042 	symbol_c *fb_decl = search_varfb_instance_type->get_basetype_decl(symbol->fb_name);
       
  1043 	if (NULL == fb_decl) ERROR;
       
  1044 	if (NULL != symbol->nonformal_param_list)  narrow_nonformal_call(symbol, fb_decl);
       
  1045 	if (NULL != symbol->   formal_param_list)     narrow_formal_call(symbol, fb_decl);
       
  1046 
       
  1047 	return NULL;
       
  1048 }
       
  1049 
       
  1050 
  1038 /********************************/
  1051 /********************************/
  1039 /* B 3.2.3 Selection Statements */
  1052 /* B 3.2.3 Selection Statements */
  1040 /********************************/
  1053 /********************************/
  1041 
  1054 
  1042 void *narrow_candidate_datatypes_c::visit(if_statement_c *symbol) {
  1055 void *narrow_candidate_datatypes_c::visit(if_statement_c *symbol) {