stage3/forced_narrow_candidate_datatypes.hh
author Mario de Sousa <msousa@fe.up.pt>
Wed, 24 Oct 2012 15:32:48 +0100
changeset 682 966f32af570d
parent 681 e837adad2437
child 691 958454e9e40f
permissions -rw-r--r--
Major code cleanup: IL code generation now uses symbol.datatype (filled in during stage3 data type checking) instead of determining the symbol's datatype by itself.
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     1
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes 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
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     3
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     4
 *  Copyright (C) 2012  Mario de Sousa (msousa@fe.up.pt)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     5
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     6
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    10
 *  (at your option) any later version.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    11
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    15
 *  GNU General Public License for more details.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    16
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    19
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    20
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    23
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    24
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    25
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    26
 * An IEC 61131-3 compiler.
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    27
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    28
 * Based on the
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    29
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    30
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    31
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    32
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    33
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    34
/*
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    35
 *  forced_narrow_candidate_datatypes_c
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    36
 *
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    37
 */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    38
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    39
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    40
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    41
#include "../absyntax_utils/absyntax_utils.hh"
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    42
#include "narrow_candidate_datatypes.hh"
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    43
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    44
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    45
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    46
class forced_narrow_candidate_datatypes_c: public narrow_candidate_datatypes_c {
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    47
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    48
  private:
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    49
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    50
  private:
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    51
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    52
  public:
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    53
    forced_narrow_candidate_datatypes_c(symbol_c *ignore);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    54
    virtual ~forced_narrow_candidate_datatypes_c(void);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    55
    
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    56
    /****************************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    57
    /* B.2 - Language IL (Instruction List) */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    58
    /****************************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    59
    /***********************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    60
    /* B 2.1 Instructions and Operands */
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    61
    /***********************************/
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    62
    void *visit(instruction_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    63
    void *visit(il_instruction_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    64
//  void *visit(il_simple_operation_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    65
//  void *visit(il_function_call_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    66
//  void *visit(il_expression_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    67
//  void *visit(il_jump_operation_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    68
//  void *visit(il_fb_call_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    69
//  void *visit(il_formal_funct_call_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    70
//  void *visit(il_operand_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    71
//  void *visit(simple_instr_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    72
//  void *visit(il_simple_instruction_c*symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    73
//  void *visit(il_param_list_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    74
//  void *visit(il_param_assignment_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    75
//  void *visit(il_param_out_assignment_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    76
//  void *visit(il_assign_operator_c *symbol);
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    77
//  void *visit(il_assign_operator_c *symbol);
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    78
 
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    79
    /***************************************/
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    80
    /* B.3 - Language ST (Structured Text) */
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    81
    /***************************************/
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    82
    void *visit(statement_list_c *symbol);
677
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    83
}; // forced_narrow_candidate_datatypes_c
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    84
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    85
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    86
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    87
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    88
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    89
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    90
740da3255d9d Remove all remaining NULL (undefined) datatypes from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff changeset
    91
681
e837adad2437 Do not repeat narrow algorithm for ST code, and better comments.
Mario de Sousa <msousa@fe.up.pt>
parents: 677
diff changeset
    92