stage3/flow_control_analysis.cc
author Mario de Sousa <msousa@fe.up.pt>
Sun, 07 Oct 2012 09:33:42 +0100
changeset 673 90d7636e3c39
parent 672 dee28c5bdc73
child 685 5b19e376cc94
permissions -rw-r--r--
Delete unused variables.
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;
661
f537c3315f83 Minor changes needed to build with pedantic flag.
Manuele Conti <conti.ma@alice.it>
parents: 486
diff changeset
   126
  prev_il_instruction_is_JMP_or_RET = false;
f537c3315f83 Minor changes needed to build with pedantic flag.
Manuele Conti <conti.ma@alice.it>
parents: 486
diff changeset
   127
  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
   128
}
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
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
   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
672
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   134
void flow_control_analysis_c::link_insert(symbol_c *prev_instruction, symbol_c *next_instruction) {
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   135
	il_instruction_c *next = dynamic_cast<il_instruction_c *>(next_instruction);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   136
	il_instruction_c *prev = dynamic_cast<il_instruction_c *>(prev_instruction);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   137
	if ((NULL == next) || (NULL == prev)) ERROR;
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   138
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   139
	next->prev_il_instruction.insert(next->prev_il_instruction.begin(), prev);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   140
	prev->next_il_instruction.insert(prev->next_il_instruction.begin(), next);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   141
}
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   142
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   143
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   144
void flow_control_analysis_c::link_pushback(symbol_c *prev_instruction, symbol_c *next_instruction) {
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   145
	il_instruction_c *next = dynamic_cast<il_instruction_c *>(next_instruction);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   146
	il_instruction_c *prev = dynamic_cast<il_instruction_c *>(prev_instruction);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   147
	if ((NULL == next) || (NULL == prev)) ERROR;
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   148
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   149
	next->prev_il_instruction.push_back(prev);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   150
	prev->next_il_instruction.push_back(next);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   151
}
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   152
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
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
/************************************/
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
   155
/* 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
   156
/************************************/
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
/*********************/
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
/* 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
   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
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
   161
	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
   162
	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
   163
	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
   164
	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
   165
	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
   166
	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
   167
}
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
   168
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
/***************************/
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
/* 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
   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
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
   173
	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
   174
	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
   175
	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
   176
	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
   177
	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
   178
	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
   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 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
   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
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
   185
	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
   186
	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
   187
	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
   188
	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
   189
	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
   190
	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
   191
}
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
   192
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
   193
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
   194
/********************************/
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
   195
/* 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
   196
/********************************/
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
   197
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
   198
	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
   199
}
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
/****************************************/
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
/* 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
   204
/****************************************/
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
/***********************************/
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
   206
/* 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
   207
/***********************************/
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
   208
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
   209
/*| 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
   210
// 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
   211
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
   212
	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
   213
	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
   214
		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
   215
		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
   216
		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
   217
		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
   218
		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
   219
	}
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
   220
	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
   221
}
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
   222
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
   223
/* | 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
   224
// 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
   225
// 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
   226
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
   227
	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
   228
		/* 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
   229
		 * 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
   230
		 */
672
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   231
		link_insert(prev_il_instruction, symbol);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   232
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   233
	/* 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
   234
	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
   235
	if (NULL != symbol->il_instruction)
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   236
		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
   237
	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
   238
}
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
   239
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
   240
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   241
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   242
/* | 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
   243
// 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
   244
// 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
   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
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
   248
/* | 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
   249
/* 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
   250
// 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
   251
// 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
   252
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
   253
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
   254
/* | 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
   255
// 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
   256
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
   257
	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
   258
		/* 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
   259
		return NULL;
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   260
  
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   261
	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
   262
	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
   263
	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
   264
	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
   265
	return NULL;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   266
}
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   267
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   268
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   269
/*  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
   270
// 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
   271
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
   272
  /* 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
   273
  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
   274
463
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   275
  /* 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
   276
  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
   277
  if (NULL != destination)
672
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   278
    link_pushback(curr_il_instruction, destination);
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   279
  return NULL;
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   280
}
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   281
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   282
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
   283
/*   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
   284
 * | 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
   285
 * | 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
   286
 * | 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
   287
 * | 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
   288
 */
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
   289
/* 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
   290
// 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
   291
// 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
   292
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
   293
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
   294
/* | 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
   295
/* 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
   296
// 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
   297
// 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
   298
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
   299
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
   300
452
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   301
//  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
   302
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
   303
	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
   304
		/* 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
   305
		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
   306
		symbol->elements[i]->accept(*this);
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   307
	}
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   308
	return NULL;
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   309
}
79ac274d1cc4 Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents: 448
diff changeset
   310
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   311
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   312
// 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
   313
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
   314
	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
   315
		/* 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
   316
		 * 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
   317
		 */
672
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   318
		link_insert(prev_il_instruction, symbol);
dee28c5bdc73 Use doubly linked connections for flow control graph (will be used later).
Mario de Sousa <msousa@fe.up.pt>
parents: 661
diff changeset
   319
453
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   320
	return NULL;
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   321
}
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   322
4733f662362a More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents: 452
diff changeset
   323
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
   324
/*
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
   325
    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
   326
    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
   327
    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
   328
 */
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
   329
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
   330
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
   331
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   332
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   333
/*******************/
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   334
/* 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
   335
/*******************/
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(   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
   337
// 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
   338
// 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
   339
// 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
   340
// 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
   341
// 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
   342
// 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
   343
// 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
   344
// 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
   345
// 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
   346
// 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
   347
// 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
   348
// 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
   349
// 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
   350
// 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
   351
// 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
   352
// 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
   353
// 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
   354
// 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
   355
// 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
   356
// 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
   357
// 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
   358
// 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
   359
// 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
   360
// 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
   361
// 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
   362
// 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
   363
// 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
   364
// 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
   365
// 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
   366
// 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
   367
// 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
   368
// 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
   369
// 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
   370
// 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
   371
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   372
/* 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
   373
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
   374
	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
   375
	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
   376
}
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   377
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   378
// 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
   379
// 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
   380
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   381
/* 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
   382
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
   383
	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
   384
	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
   385
}
fafa9abc166e Correctly handle JMP and RET IL operators in flow control analysis.
Mario de Sousa <msousa@fe.up.pt>
parents: 459
diff changeset
   386
459
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   387
// 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
   388
// 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
   389
01f6664bf8c5 Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents: 457
diff changeset
   390
/* 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
   391
// 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
   392
/* 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
   393
// 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
   394