stage3/lvalue_check.cc
author Mario de Sousa <msousa@fe.up.pt>
Mon, 16 Apr 2012 14:41:07 +0100
changeset 510 9317e04c1dde
parent 509 35d391c38a30
child 512 f915ab676d7e
permissions -rw-r--r--
Fixing check for assignment to output variables.
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     1
/*
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     3
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     4
 *  Copyright (C) 2009-2012  Mario de Sousa (msousa@fe.up.pt)
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     5
 *  Copyright (C) 2012       Manuele Conti  (conti.ma@alice.it)
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     6
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     7
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    11
 *  (at your option) any later version.
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    12
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    16
 *  GNU General Public License for more details.
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    17
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    20
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    21
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    22
 * This code is made available on the understanding that it will not be
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    23
 * used in safety-critical situations without a full and competent review.
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    24
 */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    25
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    26
/*
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    27
 * An IEC 61131-3 compiler.
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    28
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    29
 * Based on the
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    30
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    31
 *
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    32
 */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    33
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    34
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    35
#include "lvalue_check.hh"
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    36
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    37
#define FIRST_(symbol1, symbol2) (((symbol1)->first_order < (symbol2)->first_order)   ? (symbol1) : (symbol2))
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    38
#define  LAST_(symbol1, symbol2) (((symbol1)->last_order  > (symbol2)->last_order)    ? (symbol1) : (symbol2))
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    39
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    40
#define STAGE3_ERROR(error_level, symbol1, symbol2, ...) {                                                                  \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    41
  if (current_display_error_level >= error_level) {                                                                         \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    42
    fprintf(stderr, "%s:%d-%d..%d-%d: error: ",                                                                             \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    43
            FIRST_(symbol1,symbol2)->first_file, FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column,\
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    44
                                                 LAST_(symbol1,symbol2) ->last_line,  LAST_(symbol1,symbol2) ->last_column);\
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    45
    fprintf(stderr, __VA_ARGS__);                                                                                           \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    46
    fprintf(stderr, "\n");                                                                                                  \
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    47
    error_count++;                                                                                                     \
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    48
  }                                                                                                                         \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    49
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    50
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    51
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    52
#define STAGE3_WARNING(symbol1, symbol2, ...) {                                                                             \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    53
    fprintf(stderr, "%s:%d-%d..%d-%d: warning: ",                                                                           \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    54
            FIRST_(symbol1,symbol2)->first_file, FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column,\
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    55
                                                 LAST_(symbol1,symbol2) ->last_line,  LAST_(symbol1,symbol2) ->last_column);\
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    56
    fprintf(stderr, __VA_ARGS__);                                                                                           \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    57
    fprintf(stderr, "\n");                                                                                                  \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    58
    warning_found = true;                                                                                                   \
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    59
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    60
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    61
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    62
lvalue_check_c::lvalue_check_c(symbol_c *ignore) {
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    63
	error_count = 0;
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    64
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    65
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    66
lvalue_check_c::~lvalue_check_c(void) {
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    67
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    68
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    69
int lvalue_check_c::get_error_count() {
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    70
	return error_count;
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    71
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    72
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
    73
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
    74
#include <strings.h>
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    75
/* No writing to iterator variables (used in FOR loops) inside the loop itself */
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
    76
void lvalue_check_c::check_assignment_to_controlvar(symbol_c *lvalue) {
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    77
	for (unsigned int i = 0; i < control_variables.size(); i++) {
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    78
		symbolic_variable_c *cvar = (symbolic_variable_c *)control_variables[i];
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
    79
		if (strcasecmp(((identifier_c *)((symbolic_variable_c *)lvalue)->var_name)->value, ((identifier_c *)((symbolic_variable_c *)cvar)->var_name)->value) == 0) {
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    80
			STAGE3_ERROR(0, lvalue, lvalue, "Assignment to FOR control variable are not be allowed.");
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    81
			break;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    82
		}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    83
	}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    84
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
    85
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
    86
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    87
/* fb_instance.var := ...  is not valid if var is output variable */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    88
/* NOTE, if a fb_instance1.fb_instance2.fb_instance3.var is used, we must iteratively check that none of the 
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    89
 *       FB records are declared as OUTPUT variables!!  
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    90
 *       This is the reason why we have the while() loop in this function!
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    91
 */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    92
void lvalue_check_c::check_assignment_to_output(symbol_c *lvalue) {
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    93
	decompose_var_instance_name_c decompose_lvalue(lvalue);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    94
	search_base_type_c            search_base_type;
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    95
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    96
	symbol_c *struct_elem = decompose_lvalue.next_part();
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    97
	symbol_c *type_decl   = search_var_instance_decl->get_decl(struct_elem);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    98
	// symbol_c *type_id  = spec_init_sperator_c::get_spec(type_decl); /* this is not required! search_base_type_c can handle spec_init symbols! */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
    99
	symbol_c *basetype_id = search_base_type.get_basetype_id(/*type_id*/ type_decl);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   100
	/* If we can not determine the data type of the element, then the code must have a data type semantic error.
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   101
	 * This will have been caught by the data type semantic verifier, so we do not bother with this anymore!
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   102
	 */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   103
	if (NULL == basetype_id) return;
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   104
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   105
	/* Determine if the record/structure element is of a FB type. */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   106
	/* NOTE: If the structure element is not a FB type, then we can quit this check.
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   107
	 *       Remember that the standard does not allow a STRUCT data type to have elements that are FB instances!
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   108
	 *       Similarly, arrays of FB instances is also not allowed.
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   109
	 *       So, as soon as we find one record/structure element that is not a FB, no other record/structure element
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   110
	 *       will be of FB type, which means we can quit this check!
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   111
	 */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   112
	function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(basetype_id);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   113
	if (function_block_type_symtable.end_value() == fb_decl) return;
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   114
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   115
	while (NULL != (struct_elem = decompose_lvalue.next_part())) {
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   116
		search_var_instance_decl_c   fb_search_var_instance_decl(fb_decl);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   117
		if (search_var_instance_decl_c::output_vt == fb_search_var_instance_decl.get_vartype(struct_elem)) {
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   118
			STAGE3_ERROR(0, struct_elem, struct_elem, "Assignment to FB output variable is not allowed.");
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   119
			return; /* no need to carry on checking once the first error is found! */
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   120
		}
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   121
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   122
		/* prepare for any possible further record/structure elements */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   123
		type_decl   = fb_search_var_instance_decl.get_decl(struct_elem);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   124
		basetype_id = search_base_type.get_basetype_id(type_decl);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   125
		if (NULL == basetype_id) return; /* same comment as above... */
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   126
		fb_decl = function_block_type_symtable.find_value(basetype_id);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   127
		if (function_block_type_symtable.end_value() == fb_decl) return; /* same comment as above... */
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   128
	}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   129
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   130
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   131
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   132
/*  No writing to CONSTANTs */
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   133
void lvalue_check_c::check_assignment_to_constant(symbol_c *lvalue) {
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   134
	unsigned int option = search_var_instance_decl->get_option(lvalue);
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   135
	if (option == search_var_instance_decl_c::constant_opt) {
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   136
		STAGE3_ERROR(0, lvalue, lvalue, "Assignment to CONSTANT variables is not be allowed.");
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   137
	}
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   138
}
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   139
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   140
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   141
/*  No assigning values to expressions. */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   142
void lvalue_check_c::check_assignment_to_expression(symbol_c *lvalue) {
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   143
	/* TODO: check whether the lvalue is an expresion! */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   144
	/* This may occur in function invocations, when passing values (possibly an expression) to one 
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   145
	 * of the function's OUTPUT or IN_OUT parameters.
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   146
	 */
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   147
}
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   148
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   149
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   150
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   151
void lvalue_check_c::verify_is_lvalue(symbol_c *lvalue) {
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   152
	check_assignment_to_expression(lvalue);
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   153
	check_assignment_to_controlvar(lvalue);
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   154
	check_assignment_to_output(lvalue);
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   155
	check_assignment_to_constant(lvalue);
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   156
}
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   157
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   158
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   159
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   160
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   161
/* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   162
void lvalue_check_c::check_nonformal_call(symbol_c *f_call, symbol_c *f_decl) {
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   163
  /* TODO */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   164
}
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   165
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   166
  
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   167
/* check whether all values passed to OUT or IN_OUT parameters are legal lvalues. */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   168
void lvalue_check_c::check_formal_call(symbol_c *f_call, symbol_c *f_decl) {
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   169
	/* if data type semantic verification was unable to determine which function is being called,
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   170
	 * then it does not make sense to go ahead and check for lvalues to unknown parameters.
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   171
	 * We simply bug out!
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   172
	 */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   173
	if (NULL == f_decl) return;
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   174
	
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   175
	symbol_c *call_param_name;
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   176
	function_param_iterator_c       fp_iterator(f_decl);
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   177
	function_call_param_iterator_c fcp_iterator(f_call);
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   178
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   179
	/* Iterating through the formal parameters of the function call */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   180
	while((call_param_name = fcp_iterator.next_f()) != NULL) {
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   181
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   182
		/* Obtaining the value being passed in the function call */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   183
		symbol_c *call_param_value = fcp_iterator.get_current_value();
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   184
		if (NULL == call_param_value) ERROR;
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   185
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   186
		/* Find the corresponding parameter in function declaration, and it's direction (IN, OUT, IN_OUT) */
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   187
		identifier_c *param_name = fp_iterator.search(call_param_name);
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   188
		function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   189
		
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   190
		/* We only check if 'call_param_value' is a valid lvalue if the value is being passed
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   191
		 * to a valid paramater of the function being called, and that parameter is either OUT or IN_OUT.
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   192
		 */
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   193
		if ((param_name != NULL) && ((function_param_iterator_c::direction_out == param_direction) || (function_param_iterator_c::direction_inout == param_direction))) {
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   194
			verify_is_lvalue(call_param_value);
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   195
		}
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   196
	}
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   197
}
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   198
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   199
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   200
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   201
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   202
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   203
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   204
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   205
/**************************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   206
/* B 1.5 - Program organisation units */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   207
/**************************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   208
/***********************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   209
/* B 1.5.1 - Functions */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   210
/***********************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   211
void *lvalue_check_c::visit(function_declaration_c *symbol) {
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   212
	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   213
	search_var_instance_decl = new search_var_instance_decl_c(symbol);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   214
	symbol->function_body->accept(*this);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   215
	delete search_varfb_instance_type;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   216
	delete search_var_instance_decl;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   217
	search_varfb_instance_type = NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   218
	search_var_instance_decl = NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   219
	return NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   220
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   221
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   222
/*****************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   223
/* B 1.5.2 - Function blocks */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   224
/*****************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   225
void *lvalue_check_c::visit(function_block_declaration_c *symbol) {
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   226
	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   227
	search_var_instance_decl = new search_var_instance_decl_c(symbol);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   228
	symbol->fblock_body->accept(*this);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   229
	delete search_varfb_instance_type;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   230
	delete search_var_instance_decl;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   231
	search_varfb_instance_type = NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   232
	search_var_instance_decl = NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   233
	return NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   234
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   235
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   236
/**********************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   237
/* B 1.5.3 - Programs */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   238
/**********************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   239
void *lvalue_check_c::visit(program_declaration_c *symbol) {
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   240
	search_varfb_instance_type = new search_varfb_instance_type_c(symbol);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   241
	search_var_instance_decl = new search_var_instance_decl_c(symbol);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   242
	symbol->function_block_body->accept(*this);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   243
	delete search_varfb_instance_type;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   244
	delete search_var_instance_decl;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   245
	search_varfb_instance_type = NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   246
	search_var_instance_decl = NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   247
	return NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   248
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   249
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   250
/***************************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   251
/* B.3 - Language ST (Structured Text) */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   252
/***************************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   253
/***********************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   254
/* B 3.1 - Expressions */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   255
/***********************/
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   256
// SYM_REF3(function_invocation_c, function_name, formal_param_list, nonformal_param_list, symbol_c *called_function_declaration; int extensible_param_count; std::vector <symbol_c *> candidate_functions;)
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   257
void *lvalue_check_c::visit(function_invocation_c *symbol) {
510
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   258
	if (NULL != symbol->formal_param_list   )  check_formal_call   (symbol, symbol->called_function_declaration);
9317e04c1dde Fixing check for assignment to output variables.
Mario de Sousa <msousa@fe.up.pt>
parents: 509
diff changeset
   259
	if (NULL != symbol->nonformal_param_list)  check_nonformal_call(symbol, symbol->called_function_declaration);
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   260
	return NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   261
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   262
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   263
/*********************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   264
/* B 3.2.1 Assignment Statements */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   265
/*********************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   266
void *lvalue_check_c::visit(assignment_statement_c *symbol) {
509
35d391c38a30 Fixing some bugs in lvalue checking (other bugs remain - to be fixed later)
Mario de Sousa <msousa@fe.up.pt>
parents: 508
diff changeset
   267
	verify_is_lvalue(symbol->l_exp);
508
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   268
	/* We call visit r_exp to check function_call */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   269
	symbol->r_exp->accept(*this);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   270
	return NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   271
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   272
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   273
/********************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   274
/* B 3.2.4 Iteration Statements */
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   275
/********************************/
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   276
void *lvalue_check_c::visit(for_statement_c *symbol) {
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   277
	control_variables.push_back(symbol->control_variable);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   278
	symbol->statement_list->accept(*this);
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   279
	control_variables.pop_back();
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   280
	return NULL;
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   281
}
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   282
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   283
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   284
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   285
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   286
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   287
dc6906338042 Add lvalue check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff changeset
   288