stage4/generate_cc/generate_cc_st.cc
author lbessard
Thu, 14 Jun 2007 08:58:10 +0200
changeset 32 289256ec66f1
parent 26 fd67f54e64e1
child 33 4507beb2aac6
permissions -rwxr-xr-x
Adding support for standard function block parsing
Need to be extend to all standard function blocks defined
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     1
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     2
 * (c) 2003 Mario de Sousa
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     3
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     4
 * Offered to the public under the terms of the GNU General Public License
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     5
 * as published by the Free Software Foundation; either version 2 of the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     6
 * License, or (at your option) any later version.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     7
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     8
 * This program is distributed in the hope that it will be useful, but
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    11
 * Public License for more details.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    12
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    13
 * This code is made available on the understanding that it will not be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    14
 * used in safety-critical situations without a full and competent review.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    15
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    16
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    17
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    18
 * An IEC 61131-3 IL and ST compiler.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    19
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    20
 * Based on the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    21
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    22
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    23
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    24
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    25
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    26
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    27
 * Conversion of st statements (i.e. ST code).
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    28
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    29
 * This is part of the 4th stage that generates
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    30
 * a c++ source program equivalent to the IL and ST
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    31
 * code.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    32
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    33
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    34
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    35
/***********************************************************************/
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    36
/***********************************************************************/
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    37
/***********************************************************************/
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    38
/***********************************************************************/
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    39
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    40
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    41
class generate_cc_st_c: public generate_cc_typedecl_c {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    42
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    43
  private:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    44
    /* When calling a function block, we must first find it's type,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    45
     * by searching through the declarations of the variables currently
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    46
     * in scope.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    47
     * This class does just that...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    48
     * A new class is instantiated whenever we begin generating the code
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    49
     * for a function block type declaration, or a program declaration.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    50
     * This object instance will then later be called while the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    51
     * function block's or the program's body is being handled.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    52
     *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    53
     * Note that functions cannot contain calls to function blocks,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    54
     * so we do not create an object instance when handling
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    55
     * a function declaration.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    56
     */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    57
    search_fb_instance_decl_c *search_fb_instance_decl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    58
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    59
    /* When compiling st code, it becomes necessary to determine the
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    60
     * data type of st expressions. To do this, we must first find the
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    61
     * st operand's declaration, within the scope of the function block
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    62
     * or function currently being processed.
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    63
     * The following object does just that...
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    64
     * This object instance will then later be called while the
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    65
     * remaining st code is being handled.
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    66
     */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    67
    search_expression_type_c *search_expression_type;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    68
25
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
    69
    search_varfb_instance_type_c *search_varfb_instance_type;
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
    70
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    71
  public:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    72
    generate_cc_st_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    73
    : generate_cc_typedecl_c(s4o_ptr) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    74
      search_fb_instance_decl = new search_fb_instance_decl_c(scope);
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    75
      search_expression_type = new search_expression_type_c(scope);
25
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
    76
      search_varfb_instance_type = new search_varfb_instance_type_c(scope);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    77
      this->set_variable_prefix(variable_prefix);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    78
    }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    79
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    80
    virtual ~generate_cc_st_c(void) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    81
      delete search_fb_instance_decl;
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
    82
      delete search_expression_type;
25
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
    83
      delete search_varfb_instance_type;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    84
    }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    85
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    86
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    87
  private:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    88
    /* Some function calls in the body of functions or function blocks
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    89
     * may leave some parameters to their default values, and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    90
     * ignore some output parameters of the function being called.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    91
     * Our conversion of ST functions to C++ does not contemplate that,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    92
     * i.e. each called function must get all it's input and output
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    93
     * parameters set correctly.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    94
     * For input parameters we merely need to call the function with
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    95
     * the apropriate default value, but for output parameters
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    96
     * we must create temporary variables to hold the output value.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    97
     *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    98
     * We declare all the temporary output variables at the begining of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    99
     * the body of each function or function block, and use them as
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   100
     * in function calls later on as they become necessary...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   101
     * Note that we cannot create these variables just before a function
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   102
     * call, as the function call itself may be integrated within an
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   103
     * expression, or another function call!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   104
     *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   105
     * The variables are declared in the exact same order in which they
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   106
     * will be used later on during the function calls, which allows us
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   107
     * to simply re-create the name that was used for the temporary variable
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   108
     * instead of keeping it in some list.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   109
     * The names are recreated by the temp_var_name_factory, after reset()
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   110
     * has been called!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   111
     *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   112
     * This function will genertae code similar to...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   113
     *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   114
     *     INT __TMP_0 = 23;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   115
     *     REAL __TMP_1 = 45.5;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   116
     *     ...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   117
     */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   118
    temp_var_name_c temp_var_name_factory;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   119
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   120
  public:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   121
    void generate(statement_list_c *stl) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   122
      generate_cc_tempvardecl_c generate_cc_tempvardecl(&s4o);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   123
      generate_cc_tempvardecl.generate(stl, &temp_var_name_factory);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   124
      stl->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   125
    }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   126
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   127
  private:
25
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   128
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   129
/*********************/
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   130
/* B 1.4 - Variables */
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   131
/*********************/
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   132
void *visit(symbolic_variable_c *symbol) {
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   133
  unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
26
fd67f54e64e1 Now, LOCATED variables do declare extern C variables the same way EXTERNAL variables do.
etisserant
parents: 25
diff changeset
   134
  if (vartype == search_var_instance_decl_c::external_vt || vartype == search_var_instance_decl_c::located_vt) {
25
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   135
    s4o.print("*(");
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   136
    generate_cc_base_c::visit(symbol);
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   137
    s4o.print(")");
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   138
  }
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   139
  else {
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   140
    generate_cc_base_c::visit(symbol);
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   141
  }
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   142
  return NULL;
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   143
}
e6a841e365b7 Adding support for internal variable call generating
lbessard
parents: 24
diff changeset
   144
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   145
/***************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   146
/* B.3 - Language ST (Structured Text) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   147
/***************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   148
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   149
/* B 3.1 - Expressions */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   150
/***********************/
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   151
void *visit(or_expression_c *symbol) {
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   152
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   153
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
32
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   154
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   155
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   156
  if (search_expression_type->is_bool_type(left_type))
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   157
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " || ");
32
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   158
  if (search_expression_type->is_binary_type(left_type))
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   159
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " | ");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   160
  ERROR;
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   161
  return NULL;
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   162
}
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   163
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   164
void *visit(xor_expression_c *symbol) {
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   165
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   166
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
32
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   167
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   168
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   169
  if (search_expression_type->is_bool_type(left_type)) {
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   170
    s4o.print("(");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   171
    symbol->l_exp->accept(*this);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   172
    s4o.print(" && !");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   173
    symbol->r_exp->accept(*this);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   174
    s4o.print(") || (!");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   175
    symbol->l_exp->accept(*this);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   176
    s4o.print(" && ");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   177
    symbol->r_exp->accept(*this);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   178
    s4o.print(")");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   179
  }
32
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   180
  if (search_expression_type->is_binary_type(left_type))
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   181
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " ^ ");
32
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   182
  ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   183
  return NULL;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   184
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   185
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   186
void *visit(and_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   187
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   188
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   189
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   190
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   191
  if (search_expression_type->is_bool_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   192
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " && ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   193
  if (search_expression_type->is_binary_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   194
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " & ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   195
  ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   196
  return NULL;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   197
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   198
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   199
void *visit(equ_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   200
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   201
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   202
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   203
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   204
  if (search_expression_type->is_time_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   205
    return print_compare_function("__compare_timespec", "==", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   206
  return print_binary_expression(symbol->l_exp, symbol->r_exp, " == ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   207
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   208
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   209
void *visit(notequ_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   210
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   211
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   212
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   213
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   214
  if (search_expression_type->is_time_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   215
    return print_compare_function("__compare_timespec", "!=", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   216
  return print_binary_expression(symbol->l_exp, symbol->r_exp, " != ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   217
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   218
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   219
void *visit(lt_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   220
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   221
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   222
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   223
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   224
  if (search_expression_type->is_time_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   225
    return print_compare_function("__compare_timespec", "<", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   226
  return print_binary_expression(symbol->l_exp, symbol->r_exp, " < ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   227
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   228
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   229
void *visit(gt_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   230
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   231
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   232
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   233
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   234
  if (search_expression_type->is_time_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   235
    return print_compare_function("__compare_timespec", ">", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   236
  return print_binary_expression(symbol->l_exp, symbol->r_exp, " > ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   237
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   238
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   239
void *visit(le_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   240
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   241
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   242
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   243
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   244
  if (search_expression_type->is_time_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   245
    return print_compare_function("__compare_timespec", "<=", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   246
  return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   247
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   248
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   249
void *visit(ge_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   250
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   251
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   252
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   253
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   254
  if (search_expression_type->is_time_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   255
    return print_compare_function("__compare_timespec", ">=", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   256
  return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   257
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   258
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   259
void *visit(add_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   260
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   261
	symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   262
	if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   263
      (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   264
      (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   265
    return print_binary_function("__add_timespec", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   266
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   267
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   268
  if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   269
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " + ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   270
  ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   271
  return NULL;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   272
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   273
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   274
void *visit(sub_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   275
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   276
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   277
  if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   278
      (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   279
      (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   280
      (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   281
      (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   282
      (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c)))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   283
    return print_binary_function("__sub_timespec", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   284
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   285
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   286
  if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   287
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " - ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   288
  ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   289
  return NULL;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   290
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   291
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   292
void *visit(mul_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   293
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   294
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   295
  if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) ||
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   296
      (typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type)))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   297
    return print_binary_function("__mul_timespec", symbol->l_exp, symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   298
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   299
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   300
  if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   301
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " * ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   302
  ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   303
  return NULL;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   304
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   305
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   306
void *visit(div_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   307
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   308
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   309
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   310
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   311
  if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   312
    return print_binary_expression(symbol->l_exp, symbol->r_exp, " / ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   313
  ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   314
  return NULL;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   315
}
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   316
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   317
void *visit(mod_expression_c *symbol) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   318
  symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   319
  symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   320
  if (!search_expression_type->is_same_type(left_type, right_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   321
      ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   322
  if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type)) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   323
    s4o.print("((");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   324
    symbol->r_exp->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   325
    s4o.print(" == 0)?0:");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   326
    print_binary_expression(symbol->l_exp, symbol->r_exp, " % ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   327
    s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   328
    return NULL;
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   329
  }
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   330
  ERROR;
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   331
  return NULL;
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   332
}
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 0
diff changeset
   333
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   334
/* TODO: power expression... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   335
void *visit(power_expression_c *symbol) {ERROR; return print_binary_expression(symbol->l_exp, symbol->r_exp, " ** ");}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   336
void *visit(neg_expression_c *symbol) {return print_unary_expression(symbol->exp, " -");}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   337
void *visit(not_expression_c *symbol) {return print_unary_expression(symbol->exp, "!");}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   338
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   339
void *visit(function_invocation_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   340
  function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
32
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   341
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   342
  if (f_decl == function_symtable.end_value()) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   343
    /* The function called is not in the symtable, so we test if it is a
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   344
     * standard function defined in standard */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   345
    
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   346
    function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   347
    if (current_function_type == function_none) ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   348
    
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   349
    symbol_c *function_return_type = search_expression_type->get_type(symbol);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   350
    
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   351
    function_call_param_iterator_c function_call_param_iterator(symbol);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   352
    
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   353
    int nb_param = ((list_c *)symbol->parameter_assignment_list)->n;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   354
    for(int current_param = 0; current_param < nb_param; current_param++) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   355
      symbol_c *param_name = NULL;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   356
      switch (current_function_type) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   357
        case function_add:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   358
        case function_and:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   359
        case function_or:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   360
          param_name = generate_param_name("IN%d", current_param + 1);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   361
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   362
        case function_sub:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   363
          if (current_param < 2)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   364
            param_name = generate_param_name("IN%d", current_param + 1);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   365
          else
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   366
            ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   367
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   368
        default: ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   369
      }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   370
      
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   371
      /* Get the value from a foo(<param_name> = <param_value>) style call */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   372
      symbol_c *param_value = function_call_param_iterator.search(param_name);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   373
      delete param_name;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   374
      
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   375
      /* Get the value from a foo(<param_value>) style call */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   376
      if (param_value == NULL)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   377
        param_value = function_call_param_iterator.next();
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   378
      
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   379
      if (param_value == NULL) ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   380
      
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   381
      switch (current_function_type) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   382
        case function_add:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   383
          if (search_expression_type->is_time_type(function_return_type)) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   384
            if (current_param == 0) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   385
              s4o.print("__add_timespec(");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   386
              param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   387
            }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   388
            else if (current_param == 1) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   389
              s4o.print(", ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   390
              param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   391
              s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   392
            }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   393
            else ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   394
          }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   395
          else {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   396
            if (current_param == 0)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   397
              s4o.print("(");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   398
            else
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   399
              s4o.print(" + ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   400
            param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   401
            if (current_param == nb_param - 1)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   402
              s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   403
          }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   404
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   405
        case function_sub:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   406
          if (search_expression_type->is_time_type(function_return_type)) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   407
            if (current_param == 0) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   408
              s4o.print("__sub_timespec(");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   409
              param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   410
            }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   411
            else if (current_param == 1) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   412
              s4o.print(", ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   413
              param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   414
              s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   415
            }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   416
            else ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   417
          }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   418
          else {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   419
            if (current_param == 0) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   420
              s4o.print("(");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   421
              param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   422
            }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   423
            else if (current_param == 1) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   424
              s4o.print(" - ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   425
              param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   426
              s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   427
            }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   428
            else ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   429
          }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   430
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   431
        case function_and:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   432
          if (current_param == 0)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   433
            s4o.print("(");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   434
          else
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   435
            if (search_expression_type->is_bool_type(function_return_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   436
              s4o.print(" && ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   437
            else
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   438
              s4o.print(" & ");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   439
          param_value->accept(*this);
32
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   440
          if (current_param == nb_param - 1)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   441
            s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   442
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   443
        case function_or:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   444
          if (current_param == 0)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   445
            s4o.print("(");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   446
          else
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   447
            if (search_expression_type->is_bool_type(function_return_type))
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   448
              s4o.print(" || ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   449
            else
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   450
              s4o.print(" | ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   451
          param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   452
          if (current_param == nb_param - 1)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   453
            s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   454
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   455
        default: ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   456
      }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   457
    } /* for(...) */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   458
  }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   459
  else {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   460
    /* loop through each function parameter, find the value we should pass
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   461
     * to it, and then output the c equivalent...
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   462
     */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   463
    function_param_iterator_c fp_iterator(f_decl);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   464
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   465
    symbol->function_name->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   466
    s4o.print("(");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   467
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   468
    identifier_c *param_name;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   469
    function_call_param_iterator_c function_call_param_iterator(symbol);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   470
    for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   471
      if (i != 1)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   472
        s4o.print(", ");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   473
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   474
      function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   475
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   476
      /* Get the value from a foo(<param_name> = <param_value>) style call */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   477
      symbol_c *param_value = function_call_param_iterator.search(param_name);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   478
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   479
      /* Get the value from a foo(<param_value>) style call */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   480
      if (param_value == NULL)
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   481
        param_value = function_call_param_iterator.next();
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   482
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   483
      symbol_c *param_type = fp_iterator.param_type();
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   484
      if (param_type == NULL) ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   485
  
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   486
      switch (param_direction) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   487
        case function_param_iterator_c::direction_in:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   488
          if (param_value == NULL) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   489
            /* No value given for parameter, so we must use the default... */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   490
            /* First check whether default value specified in function declaration...*/
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   491
            param_value = fp_iterator.default_value();
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   492
          }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   493
          if (param_value == NULL) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   494
            /* If not, get the default value of this variable's type */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   495
            param_value = (symbol_c *)param_type->accept(*type_initial_value_c::instance());
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   496
          }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   497
          if (param_value == NULL) ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   498
          param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   499
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   500
        case function_param_iterator_c::direction_out:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   501
        case function_param_iterator_c::direction_inout:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   502
          if (param_value == NULL) {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   503
            /* no parameter value given, so we pass a previously declared temporary variable. */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   504
            std::string *temp_var_name = temp_var_name_factory.new_name();
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   505
            s4o.print(*temp_var_name);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   506
            delete temp_var_name;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   507
          } else {
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   508
            param_value->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   509
          }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   510
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   511
        case function_param_iterator_c::direction_extref:
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   512
          /* TODO! */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   513
          ERROR;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   514
          break;
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   515
      } /* switch */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   516
    } /* for(...) */
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   517
    // symbol->parameter_assignment->accept(*this);
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   518
    s4o.print(")");
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   519
  }
289256ec66f1 Adding support for standard function block parsing
lbessard
parents: 26
diff changeset
   520
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   521
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   522
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   523
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   524
/********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   525
/* B 3.2 Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   526
/********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   527
void *visit(statement_list_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   528
  return print_list(symbol, s4o.indent_spaces, ";\n" + s4o.indent_spaces, ";\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   529
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   530
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   531
/*********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   532
/* B 3.2.1 Assignment Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   533
/*********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   534
void *visit(assignment_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   535
  symbol->l_exp->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   536
  s4o.print(" = ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   537
  symbol->r_exp->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   538
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   539
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   540
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   541
/*****************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   542
/* B 3.2.2 Subprogram Control Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   543
/*****************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   544
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   545
/* fb_name '(' [param_assignment_list] ')' */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   546
/* param_assignment_list -> may be NULL ! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   547
//SYM_REF2(fb_invocation_c, fb_name, param_assignment_list)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   548
void *visit(fb_invocation_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   549
  TRACE("fb_invocation_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   550
  /* first figure out what is the name of the function block type of the function block being called... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   551
  symbol_c *function_block_type_name = this->search_fb_instance_decl->get_type_name(symbol->fb_name);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   552
    /* should never occur. The function block instance MUST have been declared... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   553
  if (function_block_type_name == NULL) ERROR;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   554
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   555
  /* Now find the declaration of the function block type being called... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   556
  function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(function_block_type_name);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   557
    /* should never occur. The function block type being called MUST be in the symtable... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   558
  if (fb_decl == function_block_type_symtable.end_value()) ERROR;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   559
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   560
  /* loop through each function block parameter, find the value we should pass
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   561
   * to it, and then output the c equivalent...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   562
   */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   563
  function_param_iterator_c fp_iterator(fb_decl);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   564
  identifier_c *param_name;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   565
  function_call_param_iterator_c function_call_param_iterator(symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   566
  for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   567
    function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   568
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   569
    /* Get the value from a foo(<param_name> = <param_value>) style call */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   570
    symbol_c *param_value = function_call_param_iterator.search(param_name);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   571
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   572
    /* Get the value from a foo(<param_value>) style call */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   573
    if (param_value == NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   574
      param_value = function_call_param_iterator.next();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   575
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   576
    /* now output the value assignment */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   577
    if (param_value != NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   578
      if ((param_direction == function_param_iterator_c::direction_in) ||
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   579
          (param_direction == function_param_iterator_c::direction_inout)) {
24
7e830409f72a Adding init function on programs
etisserant
parents: 22
diff changeset
   580
        print_variable_prefix();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   581
        symbol->fb_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   582
        s4o.print(".");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   583
        param_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   584
        s4o.print(" = ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   585
        param_value->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   586
        s4o.print(";\n" + s4o.indent_spaces);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   587
      }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   588
  } /* for(...) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   589
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   590
  /* now call the function... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   591
  function_block_type_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   592
  s4o.print(FB_FUNCTION_SUFFIX);
24
7e830409f72a Adding init function on programs
etisserant
parents: 22
diff changeset
   593
  s4o.print("(");
7e830409f72a Adding init function on programs
etisserant
parents: 22
diff changeset
   594
  print_variable_prefix();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   595
  symbol->fb_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   596
  s4o.print(")");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   597
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   598
  /* loop through each function parameter, find the variable to which
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   599
   * we should atribute the value of all output or inoutput parameters.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   600
   */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   601
  fp_iterator.reset();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   602
  function_call_param_iterator.reset();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   603
  for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   604
    function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   605
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   606
    /* Get the value from a foo(<param_name> = <param_value>) style call */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   607
    symbol_c *param_value = function_call_param_iterator.search(param_name);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   608
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   609
    /* Get the value from a foo(<param_value>) style call */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   610
    if (param_value == NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   611
      param_value = function_call_param_iterator.next();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   612
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   613
    /* now output the value assignment */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   614
    if (param_value != NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   615
      if ((param_direction == function_param_iterator_c::direction_out) ||
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   616
          (param_direction == function_param_iterator_c::direction_inout)) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   617
        s4o.print(";\n"+ s4o.indent_spaces);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   618
        param_value->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   619
        s4o.print(" = ");
24
7e830409f72a Adding init function on programs
etisserant
parents: 22
diff changeset
   620
        print_variable_prefix();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   621
        symbol->fb_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   622
        s4o.print(".");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   623
        param_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   624
      }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   625
  } /* for(...) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   626
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   627
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   628
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   629
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   630
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   631
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   632
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   633
/* helper symbol for fb_invocation */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   634
/* param_assignment_list ',' param_assignment */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   635
void *visit(param_assignment_list_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   636
  TRACE("param_assignment_list_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   637
  /* this should never be called... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   638
  ERROR;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   639
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   640
//  return print_list(symbol, "", ", ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   641
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   642
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   643
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   644
void *visit(input_variable_param_assignment_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   645
  TRACE("input_variable_param_assignment_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   646
  /* this should never be called... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   647
  ERROR;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   648
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   649
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   650
  symbol->variable_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   651
  s4o.print(" = ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   652
  symbol->expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   653
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   654
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   655
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   656
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   657
void *visit(output_variable_param_assignment_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   658
  TRACE("output_variable_param_assignment_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   659
  /* this should never be called... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   660
  ERROR;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   661
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   662
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   663
  s4o.print(s4o.indent_spaces);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   664
  if (symbol->not_param != NULL)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   665
    symbol->not_param->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   666
  symbol->variable_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   667
  s4o.print(" => ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   668
  symbol->variable->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   669
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   670
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   671
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   672
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   673
// TODO: the NOT symbol in function (block) calls...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   674
void *visit(not_paramassign_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   675
  TRACE("not_paramassign_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   676
  /* this should never be called... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   677
  ERROR;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   678
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   679
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   680
  s4o.print("NOT ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   681
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   682
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   683
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   684
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   685
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   686
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   687
/* B 3.2.3 Selection Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   688
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   689
void *visit(if_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   690
  s4o.print("if (");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   691
  symbol->expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   692
  s4o.print(") {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   693
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   694
  symbol->statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   695
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   696
  symbol->elseif_statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   697
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   698
  if (symbol->else_statement_list != NULL) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   699
    s4o.print(s4o.indent_spaces); s4o.print("} else {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   700
    s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   701
    symbol->else_statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   702
    s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   703
  }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   704
  s4o.print(s4o.indent_spaces); s4o.print("}");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   705
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   706
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   707
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   708
/* helper symbol for if_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   709
void *visit(elseif_statement_list_c *symbol) {return print_list(symbol);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   710
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   711
/* helper symbol for elseif_statement_list */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   712
void *visit(elseif_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   713
  s4o.print(s4o.indent_spaces); s4o.print("} else if (");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   714
  symbol->expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   715
  s4o.print(") {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   716
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   717
  symbol->statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   718
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   719
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   720
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   721
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   722
void *visit(case_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   723
  s4o.print("switch(");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   724
  symbol->expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   725
  s4o.print(") {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   726
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   727
  symbol->case_element_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   728
  if (symbol->statement_list != NULL) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   729
    s4o.print(s4o.indent_spaces + "default:\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   730
    s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   731
    symbol->statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   732
    s4o.print(s4o.indent_spaces + "break;\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   733
    s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   734
  }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   735
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   736
  s4o.print(s4o.indent_spaces + "}");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   737
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   738
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   739
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   740
/* helper symbol for case_statement */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   741
void *visit(case_element_list_c *symbol) {return print_list(symbol);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   742
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   743
void *visit(case_element_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   744
  s4o.print(s4o.indent_spaces + "case ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   745
  symbol->case_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   746
  s4o.print(" :\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   747
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   748
  symbol->statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   749
  s4o.print(s4o.indent_spaces + "break;\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   750
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   751
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   752
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   753
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   754
void *visit(case_list_c *symbol) {return print_list(symbol, "", ", ");}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   755
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   756
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   757
/* B 3.2.4 Iteration Statements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   758
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   759
void *visit(for_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   760
  s4o.print("for(");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   761
  symbol->control_variable->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   762
  s4o.print(" = ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   763
  symbol->beg_expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   764
  s4o.print("; ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   765
  symbol->control_variable->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   766
  s4o.print(" != ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   767
  symbol->end_expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   768
  s4o.print("; ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   769
  symbol->control_variable->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   770
  if (symbol->by_expression != NULL) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   771
    s4o.print(" += ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   772
    symbol->by_expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   773
  } else {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   774
    s4o.print("++");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   775
  }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   776
  s4o.print(") {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   777
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   778
  symbol->statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   779
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   780
  s4o.print(s4o.indent_spaces); s4o.print("}");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   781
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   782
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   783
void *visit(while_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   784
  s4o.print("while (");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   785
  symbol->expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   786
  s4o.print(") {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   787
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   788
  symbol->statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   789
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   790
  s4o.print(s4o.indent_spaces); s4o.print("}");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   791
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   792
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   793
void *visit(repeat_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   794
  s4o.print("do {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   795
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   796
  symbol->statement_list->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   797
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   798
  s4o.print(s4o.indent_spaces); s4o.print("} while(");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   799
  symbol->expression->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   800
  s4o.print(")");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   801
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   802
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   803
void *visit(exit_statement_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   804
  s4o.print("exit(0)");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   805
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   806
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   807
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   808
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   809
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   810
}; /* generate_cc_st_c */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   811
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   812
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   813
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   814
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   815
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   816
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   817
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   818
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   819