absyntax_utils/search_il_label.hh
author mjsousa
Sun, 19 Oct 2014 11:53:36 +0100
changeset 937 887e7d90445a
parent 460 00f39a4b25fb
permissions -rw-r--r--
Fix bug with multple dereferencing (bool_var := bool_ptr_ptr^^;)
460
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2012  Mario de Sousa (msousa@fe.up.pt)
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *  (at your option) any later version.
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *  GNU General Public License for more details.
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
 */
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
/*
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 * An IEC 61131-3 compiler.
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 * Based on the
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
 */
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
/*
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 *  Search for a specific label in an IL list. 
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    37
 *  when instantiated, must be given a pointer to one of the following
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    38
 *     - function_declaration_c
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
 *     - function_block_declaration_c
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    40
 *     - program_declaration_c
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    41
 *     - instruction_list_c
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    42
 *
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    43
 * which is where all calls to search for a specific label will look for said label.
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    44
 */
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    45
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    46
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    47
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    48
#include "../absyntax_utils/absyntax_utils.hh"
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    49
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    50
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    51
class search_il_label_c: public search_visitor_c {
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    52
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    53
  private:
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    54
    search_varfb_instance_type_c *search_varfb_instance_type;
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    55
    symbol_c *search_scope;
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    56
    symbol_c *search_label;
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    57
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    58
  public:
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    59
    search_il_label_c(symbol_c *search_scope);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    60
    virtual ~search_il_label_c(void);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    61
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    62
    il_instruction_c *find_label(const char *label);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    63
    il_instruction_c *find_label(symbol_c   *label);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    64
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    65
    
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    66
    /****************************************/
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    67
    /* B.2 - Language IL (Instruction List) */
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    68
    /****************************************/
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    69
    /***********************************/
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    70
    /* B 2.1 Instructions and Operands */
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    71
    /***********************************/
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    72
//     void *visit(instruction_list_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    73
    void *visit(il_instruction_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    74
//     void *visit(il_simple_operation_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    75
//     void *visit(il_function_call_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    76
//     void *visit(il_expression_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    77
//     void *visit(il_fb_call_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    78
//     void *visit(il_formal_funct_call_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    79
//     void *visit(il_operand_list_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    80
//     void *visit(simple_instr_list_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    81
//     void *visit(il_simple_instruction_c*symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    82
//     void *visit(il_param_list_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    83
//     void *visit(il_param_assignment_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    84
//     void *visit(il_param_out_assignment_c *symbol);
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    85
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    86
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    87
}; // search_il_label_c
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    88
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    89
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    90
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    91
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    92
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    93
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    94
00f39a4b25fb Add missing files.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    95