stage3/lvalue_check.cc
changeset 513 99aa36a77703
parent 512 f915ab676d7e
child 518 a0a32a0c61ef
equal deleted inserted replaced
512:f915ab676d7e 513:99aa36a77703
   157 
   157 
   158 
   158 
   159 
   159 
   160 
   160 
   161 /* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */
   161 /* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */
       
   162 /*
       
   163  * All parameters being passed to the called function MUST be in the parameter list to which f_call points to!
       
   164  * This means that, for non formal function calls in IL, de current (default value) must be artificially added to the
       
   165  * beginning of the parameter list BEFORE calling handle_function_call().
       
   166  */
       
   167 #include <string.h> /* required for strcmp() */
   162 void lvalue_check_c::check_nonformal_call(symbol_c *f_call, symbol_c *f_decl) {
   168 void lvalue_check_c::check_nonformal_call(symbol_c *f_call, symbol_c *f_decl) {
   163   /* TODO */
   169 	symbol_c *call_param_value;
   164 }
   170 	identifier_c *param_name;
       
   171 	function_param_iterator_c       fp_iterator(f_decl);
       
   172 	function_call_param_iterator_c fcp_iterator(f_call);
       
   173 
       
   174 	/* Iterating through the non-formal parameters of the function call */
       
   175 	while((call_param_value = fcp_iterator.next_nf()) != NULL) {
       
   176 		/* Iterate to the next parameter of the function being called.
       
   177 		 * Get the name of that parameter, and ignore if EN or ENO.
       
   178 		 */
       
   179 		do {
       
   180 			param_name = fp_iterator.next();
       
   181 			/* If there is no other parameter declared, then we are passing too many parameters... */
       
   182 			/* This error should have been caught in data type verification, so we simply abandon our check! */
       
   183 			if(param_name == NULL) return;
       
   184 		} while ((strcmp(param_name->value, "EN") == 0) || (strcmp(param_name->value, "ENO") == 0));
       
   185 
       
   186 		/* Find the corresponding parameter in function declaration, and it's direction (IN, OUT, IN_OUT) */
       
   187 		function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
       
   188 		
       
   189 		/* We only check if 'call_param_value' is a valid lvalue if the value is being passed
       
   190 		 * to a valid paramater of the function being called, and that parameter is either OUT or IN_OUT.
       
   191 		 */
       
   192 		if ((param_name != NULL) && ((function_param_iterator_c::direction_out == param_direction) || (function_param_iterator_c::direction_inout == param_direction))) {
       
   193 			verify_is_lvalue(call_param_value);
       
   194 		}
       
   195 	}
       
   196 }
       
   197 
       
   198 
       
   199 
       
   200 
   165 
   201 
   166   
   202   
   167 /* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */
   203 /* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */
   168 void lvalue_check_c::check_formal_call(symbol_c *f_call, symbol_c *f_decl) {
   204 void lvalue_check_c::check_formal_call(symbol_c *f_call, symbol_c *f_decl) {
   169 	/* if data type semantic verification was unable to determine which function is being called,
   205 	/* if data type semantic verification was unable to determine which function is being called,