stage3/flow_control_analysis.cc
author Mario de Sousa <msousa@fe.up.pt>
Wed, 01 Aug 2012 09:05:25 +0100
changeset 618 5e09f665c2f1
parent 486 e22150ad75fd
child 661 f537c3315f83
permissions -rw-r--r--
Remove dead code.
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2012  Mario de Sousa (msousa@fe.up.pt)
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *  This program is free software: you can redistribute it and/or modify
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  it under the terms of the GNU General Public License as published by
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  the Free Software Foundation, either version 3 of the License, or
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  (at your option) any later version.
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *  This program is distributed in the hope that it will be useful,
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  GNU General Public License for more details.
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *  You should have received a copy of the GNU General Public License
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 * This code is made available on the understanding that it will not be
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * used in safety-critical situations without a full and competent review.
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
/*
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
 * An IEC 61131-3 compiler.
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 * Based on the
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
/*
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
 *  Do flow control analysis of the IEC 61131-3 code.
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 *
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
 *  We currently only do this for IL code.
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    37
 *  This class will annotate the abstract syntax tree, by filling in the
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    38
 *  prev_il_instruction variable in the il_instruction_c, so it points to
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
 *  the previous il_instruction_c object in the instruction list instruction_list_c.
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    40
 *
486
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    41
 *  Since IL code can contain jumps (JMP), the same il_instruction may effectively have
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    42
 *  several previous il_instructions. In order to accommodate this, each il_instruction
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    43
 *  will maintain a vector (i..e an array) of pointers to all the previous il_instructions.
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    44
 *  We do however attempt to guarantee that the first element in the vector (array) will preferentially
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    45
 *  point to the il instruction that is right before / imediately preceding the current il instructions, 
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    46
 *  i.e. the first element in the array will tend to point to the previous il_instruction
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    47
 *  that is not a jump JMP IL instruction!
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    48
 *
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    49
 *  The result will essentially be a graph of il_instruction_c objects, each 
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    50
 *  pointing to the previous il_instruction_c object.
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    51
 *
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    52
 *  The reality is we will get several independent and isolated linked lists
486
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
    53
 *  (actually, since we now process labels correctly, this is really a graph):
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    54
 *  one for each block of IL code (e.g. inside a Function, FB or Program).
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    55
 *  Additionally, when the IL code has an expression (expression_c object), we will actually
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    56
 *  have one more isolated linked list for the IL code inside that expression.
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    57
 *
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    58
 *  e.g.
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    59
 *       line_1:   LD 1
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    60
 *       line_2:   ADD (42
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    61
 *       line_3:        ADD B
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    62
 *       line_4:        ADD C 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    63
 *       line_5:       )
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    64
 *       line_6:   ADD D
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    65
 *       line_7:   ST  E
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    66
 * 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    67
 *     will result in two independent linked lists:
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    68
 *       main list:  line_7 -> line_6 -> line2 -> line_1
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    69
 *       expr list:  lin4_4 -> line_3 -> (operand of line_2, i.e. '42')
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    70
 * 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    71
 * 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    72
 *     In the main list, each:
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    73
 *        line_x: IL_operation IL_operand
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    74
 *      is encoded as
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    75
 *          il_instruction_c(label, il_incomplete_instruction)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    76
 *      these il_instruction_c objects will point back to the previous il_instruction_c object.
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    77
 *
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    78
 *     In the expr list, each 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    79
 *        line_x:        IL_operation IL_operand
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    80
 *      is encoded as
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    81
 *          il_simple_instruction_c(il_simple_instruction)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    82
 *      these il_simple_instruction_c objects will point back to the previous il_simple_instruction_c object,
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    83
 *      except the for the first il_simple_instruction_c object in the list, which will point back to
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    84
 *      the first il_operand (in the above example, '42'), or NULL is it does not exist.
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    85
 *          
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    86
 *
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    87
 * label:
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    88
 *   identifier_c  
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    89
 *   
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    90
 * il_incomplete_instruction:
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    91
 *   il_simple_operation   (il_simple_operation_c, il_function_call_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    92
 * | il_expression         (il_expression_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    93
 * | il_jump_operation     (il_jump_operation_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    94
 * | il_fb_call            (il_fb_call_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    95
 * | il_formal_funct_call  (il_formal_funct_call_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    96
 * | il_return_operator    (RET_operator_c, RETC_operator_c, RETCN_operator_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    97
 *  
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    98
 * 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
    99
 * il_expression_c(il_expr_operator, il_operand, simple_instr_list)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   100
 * 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   101
 * il_operand:
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   102
 *   variable            (symbolic_variable_c, direct_variable_c, array_variable_c, structured_variable_c)  
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   103
 * | enumerated_value    (enumerated_value_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   104
 * | constant            (lots of literal classes _c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   105
 * 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   106
 * simple_instr_list:
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   107
 *   list of il_simple_instruction
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   108
 * 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   109
 * il_simple_instruction:
454
099aa5d655de Finish support for semantic verification of IL paranthesised expressions.
Mario de Sousa <msousa@fe.up.pt>
parents: 453
diff changeset
   110
 *   il_simple_operation       (il_simple_operation_c, il_function_call_c)
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   111
 * | il_expression             (il_expression_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   112
 * | il_formal_funct_call      (il_formal_funct_call_c)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   113
 * 
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   114
 */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   115
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   116
#include "flow_control_analysis.hh"
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   117
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   118
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   119
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   120
/* set to 1 to see debug info during execution */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   121
static int debug = 0;
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   122
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   123
flow_control_analysis_c::flow_control_analysis_c(symbol_c *ignore) {
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   124
  prev_il_instruction = NULL;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   125
  curr_il_instruction = NULL;
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   126
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   127
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   128
flow_control_analysis_c::~flow_control_analysis_c(void) {
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   129
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   130
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   131
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   132
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   133
/************************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   134
/* B 1.5 Program organization units */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   135
/************************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   136
/*********************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   137
/* B 1.5.1 Functions */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   138
/*********************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   139
void *flow_control_analysis_c::visit(function_declaration_c *symbol) {
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   140
	search_il_label = new search_il_label_c(symbol);
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   141
	if (debug) printf("Doing flow control analysis in body of function %s\n", ((token_c *)(symbol->derived_function_name))->value);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   142
	symbol->function_body->accept(*this);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   143
	delete search_il_label;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   144
	search_il_label = NULL;
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   145
	return NULL;
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   146
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   147
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   148
/***************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   149
/* B 1.5.2 Function blocks */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   150
/***************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   151
void *flow_control_analysis_c::visit(function_block_declaration_c *symbol) {
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   152
	search_il_label = new search_il_label_c(symbol);
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   153
	if (debug) printf("Doing flow control analysis in body of FB %s\n", ((token_c *)(symbol->fblock_name))->value);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   154
	symbol->fblock_body->accept(*this);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   155
	delete search_il_label;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   156
	search_il_label = NULL;
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   157
	return NULL;
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   158
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   159
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   160
/********************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   161
/* B 1.5.3 Programs */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   162
/********************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   163
void *flow_control_analysis_c::visit(program_declaration_c *symbol) {
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   164
	search_il_label = new search_il_label_c(symbol);
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   165
	if (debug) printf("Doing flow control analysis in body of program %s\n", ((token_c *)(symbol->program_type_name))->value);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   166
	symbol->function_block_body->accept(*this);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   167
	delete search_il_label;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   168
	search_il_label = NULL;
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   169
	return NULL;
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   170
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   171
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   172
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   173
/********************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   174
/* B 1.7 Configuration elements */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   175
/********************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   176
void *flow_control_analysis_c::visit(configuration_declaration_c *symbol) {
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   177
	return NULL;
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   178
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   179
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   180
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   181
/****************************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   182
/* B.2 - Language IL (Instruction List) */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   183
/****************************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   184
/***********************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   185
/* B 2.1 Instructions and Operands */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   186
/***********************************/
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   187
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   188
/*| instruction_list il_instruction */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   189
// SYM_LIST(instruction_list_c)
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   190
void *flow_control_analysis_c::visit(instruction_list_c *symbol) {
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   191
	prev_il_instruction_is_JMP_or_RET = false;
448
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 443
diff changeset
   192
	for(int i = 0; i < symbol->n; i++) {
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 443
diff changeset
   193
		prev_il_instruction = NULL;
1bd18fc06911 Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents: 443
diff changeset
   194
		if (i > 0) prev_il_instruction = symbol->elements[i-1];
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   195
		curr_il_instruction = symbol->elements[i];
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   196
		curr_il_instruction->accept(*this);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   197
		curr_il_instruction = NULL;
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   198
	}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   199
	return NULL;
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   200
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   201
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   202
/* | label ':' [il_incomplete_instruction] eol_list */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   203
// SYM_REF2(il_instruction_c, label, il_instruction)
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   204
// void *visit(instruction_list_c *symbol);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   205
void *flow_control_analysis_c::visit(il_instruction_c *symbol) {
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   206
	if ((NULL != prev_il_instruction) && (!prev_il_instruction_is_JMP_or_RET))
486
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   207
		/* We try to guarantee that the previous il instruction that is in the previous line, will occupy the first element of the vector.
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   208
		 * In order to do that, we use insert() instead of push_back()
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   209
		 */
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   210
		symbol->prev_il_instruction.insert(symbol->prev_il_instruction.begin() , prev_il_instruction);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   211
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   212
	/* check if it is an il_expression_c, a JMP[C[N]], or a RET, and if so, handle it correctly */
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   213
	prev_il_instruction_is_JMP_or_RET = false;
452
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   214
	if (NULL != symbol->il_instruction)
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   215
		symbol->il_instruction->accept(*this);
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   216
	return NULL;
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   217
}
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   218
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   219
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   220
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   221
/* | il_simple_operator [il_operand] */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   222
// SYM_REF2(il_simple_operation_c, il_simple_operator, il_operand)
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   223
// void *flow_control_analysis_c::visit(il_simple_operation_c *symbol)
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   224
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   225
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   226
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   227
/* | function_name [il_operand_list] */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   228
/* NOTE: The parameters 'called_function_declaration' and 'extensible_param_count' are used to pass data between the stage 3 and stage 4. */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   229
// SYM_REF2(il_function_call_c, function_name, il_operand_list, symbol_c *called_function_declaration; int extensible_param_count;)
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   230
// void *flow_control_analysis_c::visit(il_function_call_c *symbol) 
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   231
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   232
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   233
/* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   234
// SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   235
void *flow_control_analysis_c::visit(il_expression_c *symbol) {
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   236
	if(NULL == symbol->simple_instr_list) 
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   237
		/* nothing to do... */
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   238
		return NULL;
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   239
  
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   240
	symbol_c *save_prev_il_instruction = prev_il_instruction;
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   241
	prev_il_instruction = symbol->il_operand;
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   242
	symbol->simple_instr_list->accept(*this);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   243
	prev_il_instruction = save_prev_il_instruction;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   244
	return NULL;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   245
}
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   246
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   247
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   248
/*  il_jump_operator label */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   249
// SYM_REF2(il_jump_operation_c, il_jump_operator, label)
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   250
void *flow_control_analysis_c::visit(il_jump_operation_c *symbol) {
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   251
  /* search for the il_instruction_c containing the label */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   252
  il_instruction_c *destination = search_il_label->find_label(symbol->label);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   253
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   254
  /* give the visit(JMP_operator *) an oportunity to set the prev_il_instruction_is_JMP_or_RET flag! */
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   255
  symbol->il_jump_operator->accept(*this);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   256
  /* add, to that il_instruction's list of prev_il_intsructions, the curr_il_instruction */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   257
  if (NULL != destination)
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   258
    destination->prev_il_instruction.push_back(curr_il_instruction);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   259
  return NULL;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   260
}
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   261
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   262
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   263
/*   il_call_operator prev_declared_fb_name
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   264
 * | il_call_operator prev_declared_fb_name '(' ')'
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   265
 * | il_call_operator prev_declared_fb_name '(' eol_list ')'
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   266
 * | il_call_operator prev_declared_fb_name '(' il_operand_list ')'
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   267
 * | il_call_operator prev_declared_fb_name '(' eol_list il_param_list ')'
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   268
 */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   269
/* NOTE: The parameter 'called_fb_declaration'is used to pass data between stage 3 and stage4 (although currently it is not used in stage 4 */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   270
// SYM_REF4(il_fb_call_c, il_call_operator, fb_name, il_operand_list, il_param_list, symbol_c *called_fb_declaration)
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   271
// void *flow_control_analysis_c::visit(il_fb_call_c *symbol)
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   272
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   273
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   274
/* | function_name '(' eol_list [il_param_list] ')' */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   275
/* NOTE: The parameter 'called_function_declaration' is used to pass data between the stage 3 and stage 4. */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   276
// SYM_REF2(il_formal_funct_call_c, function_name, il_param_list, symbol_c *called_function_declaration; int extensible_param_count;)
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   277
// void *flow_control_analysis_c::visit(il_formal_funct_call_c *symbol)
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   278
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   279
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   280
452
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   281
//  void *visit(il_operand_list_c *symbol);
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   282
void *flow_control_analysis_c::visit(simple_instr_list_c *symbol) {
454
099aa5d655de Finish support for semantic verification of IL paranthesised expressions.
Mario de Sousa <msousa@fe.up.pt>
parents: 453
diff changeset
   283
	for(int i = 0; i < symbol->n; i++) {
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   284
		/* The prev_il_instruction for element[0] was set in visit(il_expression_c *) */
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   285
		if (i>0) prev_il_instruction = symbol->elements[i-1];
452
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   286
		symbol->elements[i]->accept(*this);
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   287
	}
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   288
	return NULL;
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   289
}
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   290
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   291
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   292
// SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;)
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   293
void *flow_control_analysis_c::visit(il_simple_instruction_c*symbol) {
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   294
	if (NULL != prev_il_instruction)
486
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   295
		/* We try to guarantee that the previous il instruction that is in the previous line, will occupy the first element of the vector.
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   296
		 * In order to do that, we use insert() instead of push_back()
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   297
		 */
e22150ad75fd Fix error messages of il function calls - it now prints out location info of first parameter.
Mario de Sousa <msousa@fe.up.pt>
parents: 463
diff changeset
   298
		symbol->prev_il_instruction.insert(symbol->prev_il_instruction.begin() , prev_il_instruction);
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   299
	return NULL;
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   300
}
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   301
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   302
443
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   303
/*
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   304
    void *visit(il_param_list_c *symbol);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   305
    void *visit(il_param_assignment_c *symbol);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   306
    void *visit(il_param_out_assignment_c *symbol);
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   307
 */
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   308
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   309
ff4d26b7e51d Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
   310
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   311
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   312
/*******************/
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   313
/* B 2.2 Operators */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   314
/*******************/
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   315
// void *visit(   LD_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   316
// void *visit(  LDN_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   317
// void *visit(   ST_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   318
// void *visit(  STN_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   319
// void *visit(  NOT_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   320
// void *visit(    S_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   321
// void *visit(    R_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   322
// void *visit(   S1_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   323
// void *visit(   R1_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   324
// void *visit(  CLK_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   325
// void *visit(   CU_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   326
// void *visit(   CD_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   327
// void *visit(   PV_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   328
// void *visit(   IN_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   329
// void *visit(   PT_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   330
// void *visit(  AND_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   331
// void *visit(   OR_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   332
// void *visit(  XOR_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   333
// void *visit( ANDN_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   334
// void *visit(  ORN_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   335
// void *visit( XORN_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   336
// void *visit(  ADD_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   337
// void *visit(  SUB_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   338
// void *visit(  MUL_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   339
// void *visit(  DIV_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   340
// void *visit(  MOD_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   341
// void *visit(   GT_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   342
// void *visit(   GE_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   343
// void *visit(   EQ_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   344
// void *visit(   LT_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   345
// void *visit(   LE_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   346
// void *visit(   NE_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   347
// void *visit(  CAL_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   348
// void *visit( CALC_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   349
// void *visit(CALCN_operator_c *symbol);
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   350
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   351
/* this next visit function will be called directly from visit(il_instruction_c *) */
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   352
void *flow_control_analysis_c::visit(  RET_operator_c *symbol) {
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   353
	prev_il_instruction_is_JMP_or_RET = true;
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   354
	return NULL;
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   355
}
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   356
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   357
// void *visit( RETC_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   358
// void *visit(RETCN_operator_c *symbol);
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   359
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   360
/* this next visit function will be called from visit(il_jump_operation_c *) */
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   361
void *flow_control_analysis_c::visit(  JMP_operator_c *symbol) {
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   362
	prev_il_instruction_is_JMP_or_RET = true;
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   363
	return NULL;
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   364
}
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   365
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   366
// void *visit( JMPC_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   367
// void *visit(JMPCN_operator_c *symbol);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   368
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   369
/* Symbol class handled together with function call checks */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   370
// void *visit(il_assign_operator_c *symbol, variable_name);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   371
/* Symbol class handled together with function call checks */
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   372
// void *visit(il_assign_operator_c *symbol, option, variable_name);
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   373