stage3/lvalue_check.cc
changeset 845 5fa872f3d073
parent 833 27f246b35ac2
child 846 24d0be6c31f7
equal deleted inserted replaced
844:39c755f41ee8 845:5fa872f3d073
   161 }
   161 }
   162 
   162 
   163 
   163 
   164 /*  No assigning values to expressions. */
   164 /*  No assigning values to expressions. */
   165 void lvalue_check_c::check_assignment_to_expression(symbol_c *lvalue) {
   165 void lvalue_check_c::check_assignment_to_expression(symbol_c *lvalue) {
   166 	/* This may occur in function invocations, when passing values (possibly an expression) to one 
       
   167 	 * of the function's OUTPUT or IN_OUT parameters.
       
   168 	 */
       
   169 	/* This may occur in function invocations, when passing values (possibly an expression) to one
   166 	/* This may occur in function invocations, when passing values (possibly an expression) to one
   170 	 * of the function's OUTPUT or IN_OUT parameters.
   167 	 * of the function's OUTPUT or IN_OUT parameters.
   171 	 */
   168 	 */
   172 	if ( 
   169 	if ( 
   173 	     /*********************/
   170 	     /*********************/
   236 		STAGE3_ERROR(0, lvalue, lvalue, "Assigning an expression to an OUT or IN_OUT parameter is not allowed.");
   233 		STAGE3_ERROR(0, lvalue, lvalue, "Assigning an expression to an OUT or IN_OUT parameter is not allowed.");
   237 }                                                                  
   234 }                                                                  
   238 
   235 
   239 
   236 
   240 
   237 
       
   238 /*  No assigning values to IL lists. */
       
   239 void lvalue_check_c::check_assignment_to_il_list(symbol_c *lvalue) {
       
   240 	/* This may occur in formal invocations in IL, where an embedded IL list may be used instead of a symbolic_variable
       
   241 	 * when passing an IN_OUT parameter! Note that it will never occur to OUT parameters, as the syntax does not allow it,
       
   242 	 * although this does not affect out algorithm here!
       
   243 	 */
       
   244 	if ( 
       
   245 	     /****************************************/
       
   246 	     /* B.2 - Language IL (Instruction List) */
       
   247 	     /****************************************/
       
   248 	     /***********************************/
       
   249 	     /* B 2.1 Instructions and Operands */
       
   250 	     /***********************************/
       
   251 	     (typeid( *lvalue ) == typeid( simple_instr_list_c)))
       
   252 		STAGE3_ERROR(0, lvalue, lvalue, "Assigning an IL list IN_OUT parameter is not allowed.");
       
   253 }                                                                  
   241 
   254 
   242 
   255 
   243 
   256 
   244 
   257 
   245 void lvalue_check_c::verify_is_lvalue(symbol_c *lvalue) {
   258 void lvalue_check_c::verify_is_lvalue(symbol_c *lvalue) {
   246 	if (NULL == lvalue) return; // missing operand in source code being compiled. Error will be caught and reported by datatype checking!
   259 	if (NULL == lvalue) return; // missing operand in source code being compiled. Error will be caught and reported by datatype checking!
   247 	int init_error_count = error_count;  /* stop the checks once an error has been found... */
   260 	int init_error_count = error_count;  /* stop the checks once an error has been found... */
   248 	if (error_count == init_error_count)  check_assignment_to_expression(lvalue);
   261 	if (error_count == init_error_count)  check_assignment_to_expression(lvalue);
       
   262 	if (error_count == init_error_count)  check_assignment_to_il_list   (lvalue);
   249 	if (error_count == init_error_count)  check_assignment_to_controlvar(lvalue);
   263 	if (error_count == init_error_count)  check_assignment_to_controlvar(lvalue);
   250 	if (error_count == init_error_count)  check_assignment_to_output(lvalue);
   264 	if (error_count == init_error_count)  check_assignment_to_output    (lvalue);
   251 	if (error_count == init_error_count)  check_assignment_to_constant(lvalue);
   265 	if (error_count == init_error_count)  check_assignment_to_constant  (lvalue);
   252 }
   266 }
   253 
   267 
   254 
   268 
   255 
   269 
   256 
   270