stage4/generate_c/generate_c_inlinefcall.cc
author laurent
Tue, 12 Jul 2011 22:20:28 +0200
changeset 337 9a2262fb7994
parent 336 229eb3e29216
child 345 894c0e6d951c
permissions -rwxr-xr-x
Fix bug with inline function call in POU programmed in IL
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     1
/*
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
     2
 *  matiec - a compiler for the programming languages defined in IEC 61131-3
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     3
 *
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
     4
 *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
     5
 *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
     6
 *
279
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
     7
 *  This program is free software: you can redistribute it and/or modify
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
     8
 *  it under the terms of the GNU General Public License as published by
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
     9
 *  the Free Software Foundation, either version 3 of the License, or
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    10
 *  (at your option) any later version.
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    11
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    12
 *  This program is distributed in the hope that it will be useful,
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    15
 *  GNU General Public License for more details.
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    16
 *
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    17
 *  You should have received a copy of the GNU General Public License
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
c0453b7f99df Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents: 238
diff changeset
    19
 *
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    20
 *
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    21
 * This code is made available on the understanding that it will not be
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    22
 * used in safety-critical situations without a full and competent review.
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    23
 */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    24
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    25
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    26
#define INLINE_RESULT_TEMP_VAR "__res"
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    27
234
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
    28
class generate_c_inlinefcall_c: public generate_c_typedecl_c {
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    29
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
    30
  public:
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
    31
    typedef enum {
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
    32
      expression_vg,
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
    33
      assignment_vg,
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
    34
      complextype_base_vg,
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
    35
      complextype_suffix_vg
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
    36
    } variablegeneration_t;
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
    37
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    38
  private:
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    39
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    40
    /* The initial value that should be given to the IL default variable
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    41
	 * imediately after a parenthesis is opened.
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    42
	 * This variable is only used to pass data from the
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    43
	 * il_expression_c visitor to the simple_instr_list_c visitor.
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    44
	 *
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    45
	 * e.g.:
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    46
	 *         LD var1
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    47
	 *         AND ( var2
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    48
	 *         OR var3
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    49
	 *         )
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    50
	 *
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    51
	 * In the above code sample, the line 'AND ( var2' constitutes
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    52
	 * an il_expression_c, where var2 should be loaded into the
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    53
	 * il default variable before continuing with the expression
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    54
	 * inside the parenthesis.
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    55
	 * Unfortunately, only the simple_instr_list_c may do the
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    56
	 * initial laoding of the var2 bariable following the parenthesis,
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    57
	 * so the il_expression_c visitor will have to pass 'var2' as a
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    58
	 * parameter to the simple_instr_list_c visitor.
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    59
	 * Ergo, the existance of the following parameter...!
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    60
	 */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    61
	symbol_c *il_default_variable_init_value;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    62
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    63
    /* Operand to the IL operation currently being processed... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    64
	/* These variables are used to pass data from the
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    65
	 * il_simple_operation_c and il_expression_c visitors
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    66
	 * to the il operator visitors (i.e. LD_operator_c,
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    67
	 * LDN_operator_c, ST_operator_c, STN_operator_c, ...)
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    68
	 */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    69
	symbol_c *current_operand;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    70
	symbol_c *current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    71
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    72
	 /* The result of the comparison IL operations (GT, EQ, LT, ...)
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    73
	 * is a boolean variable.
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    74
	 * This class keeps track of the current data type stored in the
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    75
	 * il default variable. This is usually done by keeping a reference
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    76
	 * to the data type of the last operand. Nevertheless, in the case of
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    77
	 * the comparison IL operators, the data type of the result (a boolean)
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    78
	 * is not the data type of the operand. We therefore need an object
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    79
	 * of the boolean data type to keep as a reference of the current
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    80
	 * data type.
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    81
	 * The following object is it...
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    82
	 */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    83
	bool_type_name_c bool_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    84
	lint_type_name_c lint_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    85
	lword_type_name_c lword_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    86
	lreal_type_name_c lreal_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    87
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    88
    /* The name of the IL default variable... */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    89
	#define IL_DEFVAR   VAR_LEADER "IL_DEFVAR"
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    90
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    91
	/* The name of the variable used to pass the result of a
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    92
	 * parenthesised instruction list to the immediately preceding
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    93
	 * scope ...
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    94
	 */
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    95
    #define IL_DEFVAR_BACK   VAR_LEADER "IL_DEFVAR_BACK"
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    96
    il_default_variable_c default_variable_name;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
    97
	il_default_variable_c default_variable_back_name;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
    98
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
    99
	symbol_c* current_array_type;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   100
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   101
	int fcall_number;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   102
	symbol_c *fbname;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   103
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   104
    search_expression_type_c *search_expression_type;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   105
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   106
    search_varfb_instance_type_c *search_varfb_instance_type;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   107
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   108
    search_base_type_c search_base_type;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   109
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
   110
    variablegeneration_t wanted_variablegeneration;
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
   111
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   112
  public:
234
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   113
    generate_c_inlinefcall_c(stage4out_c *s4o_ptr, symbol_c *name, symbol_c *scope, const char *variable_prefix = NULL)
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   114
    : generate_c_typedecl_c(s4o_ptr),
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   115
      default_variable_name(IL_DEFVAR, NULL),
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   116
      default_variable_back_name(IL_DEFVAR_BACK, NULL)
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   117
    {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   118
      search_expression_type = new search_expression_type_c(scope);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   119
      search_varfb_instance_type = new search_varfb_instance_type_c(scope);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   120
      this->set_variable_prefix(variable_prefix);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   121
      fcall_number = 0;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   122
      fbname = name;
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
   123
      wanted_variablegeneration = expression_vg;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   124
    }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   125
234
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   126
    virtual ~generate_c_inlinefcall_c(void) {
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   127
      delete search_expression_type;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   128
      delete search_varfb_instance_type;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   129
    }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   130
234
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   131
    void print(symbol_c* symbol) {
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   132
      function_call_iterator_c fc_iterator(symbol);
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   133
      symbol_c* function_call;
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   134
      while ((function_call = fc_iterator.next()) != NULL) {
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   135
    	function_call->accept(*this);
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   136
      }
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   137
    }
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   138
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   139
    void generate_inline(symbol_c *function_name,
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   140
            symbol_c *function_type_prefix,
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   141
            symbol_c *function_type_suffix,
234
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   142
            std::list<FUNCTION_PARAM*> param_list) {
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
   143
            std::list<FUNCTION_PARAM*>::iterator pt;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   144
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   145
      fcall_number++;
336
229eb3e29216 Fix bug in function calls with literal parameters
laurent
parents: 332
diff changeset
   146
      function_type_prefix = search_expression_type->default_literal_type(function_type_prefix);
229eb3e29216 Fix bug in function calls with literal parameters
laurent
parents: 332
diff changeset
   147
      if (function_type_suffix) {
229eb3e29216 Fix bug in function calls with literal parameters
laurent
parents: 332
diff changeset
   148
        function_type_suffix = search_expression_type->default_literal_type(function_type_suffix);
332
0f1d91a37506 Fix bug in inline function calls when using function with undetermined type interface with literals as input
laurent
parents: 321
diff changeset
   149
      }
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   150
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   151
      s4o.print(s4o.indent_spaces);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   152
      s4o.print("inline ");
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   153
      function_type_prefix->accept(*this);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   154
      s4o.print(" __");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   155
      fbname->accept(*this);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   156
      s4o.print("_");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   157
      function_name->accept(*this);
336
229eb3e29216 Fix bug in function calls with literal parameters
laurent
parents: 332
diff changeset
   158
      if (function_type_suffix) {
229eb3e29216 Fix bug in function calls with literal parameters
laurent
parents: 332
diff changeset
   159
    	function_type_suffix->accept(*this);
229eb3e29216 Fix bug in function calls with literal parameters
laurent
parents: 332
diff changeset
   160
      }
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   161
      s4o.print_integer(fcall_number);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   162
      s4o.print("(");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   163
      s4o.indent_right();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   164
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   165
      PARAM_LIST_ITERATOR() {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   166
        if (PARAM_DIRECTION == function_param_iterator_c::direction_in) {
336
229eb3e29216 Fix bug in function calls with literal parameters
laurent
parents: 332
diff changeset
   167
          search_expression_type->default_literal_type(PARAM_TYPE)->accept(*this);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   168
          s4o.print(" ");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   169
          PARAM_NAME->accept(*this);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   170
          s4o.print(",\n" + s4o.indent_spaces);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   171
        }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   172
      }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   173
      fbname->accept(*this);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   174
	  s4o.print(" *");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   175
	  s4o.print(FB_FUNCTION_PARAM);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   176
	  s4o.indent_left();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   177
	  s4o.print(")\n" + s4o.indent_spaces);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   178
	  s4o.print("{\n");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   179
      s4o.indent_right();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   180
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   181
      s4o.print(s4o.indent_spaces);
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   182
      function_type_prefix->accept(*this);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   183
      s4o.print(" "),
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   184
      s4o.print(INLINE_RESULT_TEMP_VAR);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   185
      s4o.print(";\n");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   186
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   187
	  PARAM_LIST_ITERATOR() {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   188
		if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   189
		     PARAM_DIRECTION == function_param_iterator_c::direction_inout) &&
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   190
		    PARAM_VALUE != NULL) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   191
		  s4o.print(s4o.indent_spaces);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   192
		  PARAM_TYPE->accept(*this);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   193
          s4o.print(" ");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   194
          s4o.print(TEMP_VAR);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   195
          PARAM_NAME->accept(*this);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   196
          s4o.print(" = ");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   197
          print_check_function(PARAM_TYPE, PARAM_VALUE);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   198
          s4o.print(";\n");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   199
		}
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   200
	  }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   201
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   202
	  s4o.print(s4o.indent_spaces + INLINE_RESULT_TEMP_VAR),
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   203
			  s4o.print(" = ");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   204
	  function_name->accept(*this);
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   205
	  if (function_type_suffix)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   206
        function_type_suffix->accept(*this);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   207
	  s4o.print("(");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   208
	  s4o.indent_right();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   209
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   210
	  PARAM_LIST_ITERATOR() {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   211
		if (pt != param_list.begin())
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   212
		  s4o.print(",\n" + s4o.indent_spaces);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   213
		if (PARAM_DIRECTION == function_param_iterator_c::direction_in)
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   214
		  PARAM_NAME->accept(*this);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   215
		else if (PARAM_VALUE != NULL){
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   216
          s4o.print("&");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   217
          s4o.print(TEMP_VAR);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   218
          PARAM_NAME->accept(*this);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   219
        }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   220
		else {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   221
		  s4o.print("NULL");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   222
		}
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   223
	  }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   224
	  s4o.print(");\n");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   225
	  s4o.indent_left();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   226
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   227
	  PARAM_LIST_ITERATOR() {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   228
        if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   229
        	 PARAM_DIRECTION == function_param_iterator_c::direction_inout) &&
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   230
        	PARAM_VALUE != NULL) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   231
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   232
          s4o.print(s4o.indent_spaces);
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   233
          print_setter(PARAM_VALUE, PARAM_TYPE, PARAM_NAME);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   234
          s4o.print(";\n");
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   235
		}
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   236
	  }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   237
	  s4o.print(s4o.indent_spaces + "return ");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   238
	  s4o.print(INLINE_RESULT_TEMP_VAR);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   239
	  s4o.print(";\n");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   240
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   241
      s4o.indent_left();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   242
      s4o.print(s4o.indent_spaces + "}\n\n");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   243
    }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   244
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   245
  private:
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   246
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   247
    /* A helper function... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   248
	void *CMP_operator_result_type() {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   249
	  /* the data type resulting from this operation... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   250
	  this->default_variable_name.current_type = &(this->bool_type);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   251
	  return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   252
	}
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   253
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   254
	/* A helper function... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   255
    void *BYTE_operator_result_type(void) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   256
	  if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   257
		if (search_expression_type->is_literal_integer_type(this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   258
		  this->default_variable_name.current_type = &(this->lword_type);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   259
		else
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   260
		  this->default_variable_name.current_type = this->current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   261
	  }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   262
	  else if (search_expression_type->is_literal_integer_type(this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   263
		  this->current_operand_type = this->default_variable_name.current_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   264
	  return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   265
	}
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   266
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   267
    /* A helper function... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   268
    void *NUM_operator_result_type(void) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   269
	  if (search_expression_type->is_literal_real_type(this->default_variable_name.current_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   270
		if (search_expression_type->is_literal_integer_type(this->current_operand_type) ||
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   271
			search_expression_type->is_literal_real_type(this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   272
		  this->default_variable_name.current_type = &(this->lreal_type);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   273
		else
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   274
		  this->default_variable_name.current_type = this->current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   275
	  }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   276
	  else if (search_expression_type->is_literal_integer_type(this->default_variable_name.current_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   277
		if (search_expression_type->is_literal_integer_type(this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   278
		  this->default_variable_name.current_type = &(this->lint_type);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   279
		else if (search_expression_type->is_literal_real_type(this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   280
		  this->default_variable_name.current_type = &(this->lreal_type);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   281
		else
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   282
		  this->default_variable_name.current_type = this->current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   283
	  }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   284
	  else if (search_expression_type->is_literal_integer_type(this->current_operand_type) ||
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   285
			   search_expression_type->is_literal_real_type(this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   286
		this->current_operand_type = this->default_variable_name.current_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   287
	  return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   288
	}
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   289
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   290
    void *print_getter(symbol_c *symbol) {
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   291
      unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   292
      if (vartype == search_var_instance_decl_c::external_vt)
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   293
    	s4o.print(GET_EXTERNAL);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   294
      else if (vartype == search_var_instance_decl_c::located_vt)
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   295
    	s4o.print(GET_LOCATED);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   296
      else
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   297
    	s4o.print(GET_VAR);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   298
      s4o.print("(");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   299
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   300
      wanted_variablegeneration = complextype_base_vg;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   301
      symbol->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   302
      if (search_varfb_instance_type->type_is_complex())
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   303
    	s4o.print(",");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   304
      wanted_variablegeneration = complextype_suffix_vg;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   305
      symbol->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   306
      s4o.print(")");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   307
      wanted_variablegeneration = expression_vg;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   308
      return NULL;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   309
    }
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   310
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   311
    void *print_setter(symbol_c* symbol,
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   312
    		symbol_c* type,
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   313
    		symbol_c* value) {
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   314
      unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
231
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   315
      if (vartype == search_var_instance_decl_c::external_vt) {
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   316
        symbolic_variable_c *variable = dynamic_cast<symbolic_variable_c *>(symbol);
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   317
        /* TODO Find a solution for forcing global complex variables */
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   318
        if (variable != NULL) {
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   319
          s4o.print(SET_EXTERNAL);
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   320
          s4o.print("(");
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   321
          variable->var_name->accept(*this);
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   322
          s4o.print(",");
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   323
        }
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   324
        else {
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   325
          s4o.print(SET_COMPLEX_EXTERNAL);
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   326
          s4o.print("(");
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   327
        }
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   328
      }
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   329
      else {
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   330
        if (vartype == search_var_instance_decl_c::located_vt)
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   331
          s4o.print(SET_LOCATED);
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   332
        else
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   333
          s4o.print(SET_VAR);
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   334
        s4o.print("(");
b8527b0abe75 Adding support for forcing global without perturbation from setting external
laurent
parents: 228
diff changeset
   335
      }
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   336
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   337
      wanted_variablegeneration = complextype_base_vg;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   338
      symbol->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   339
      s4o.print(",");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   340
      wanted_variablegeneration = expression_vg;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   341
      print_check_function(type, value, NULL, true);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   342
      if (search_varfb_instance_type->type_is_complex()) {
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   343
        s4o.print(",");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   344
        wanted_variablegeneration = complextype_suffix_vg;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   345
        symbol->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   346
      }
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   347
      s4o.print(")");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   348
      wanted_variablegeneration = expression_vg;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   349
      return NULL;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   350
    }
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   351
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   352
    /*********************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   353
    /* B 1.4 - Variables */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   354
    /*********************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   355
    void *visit(symbolic_variable_c *symbol) {
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   356
      unsigned int vartype;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   357
      if (wanted_variablegeneration == complextype_base_vg)
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   358
        generate_c_base_c::visit(symbol);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   359
      else if (wanted_variablegeneration == complextype_suffix_vg)
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   360
        return NULL;
221
c6aed7e5f070 Adding support for flags on Function Block variables for marking which variable must be debugged, retained or is forced
laurent
parents: 219
diff changeset
   361
      else
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   362
        print_getter(symbol);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   363
      return NULL;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   364
    }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   365
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   366
    /********************************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   367
    /* B.1.4.1   Directly Represented Variables */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   368
    /********************************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   369
    // direct_variable: direct_variable_token   {$$ = new direct_variable_c($1);};
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   370
    void *visit(direct_variable_c *symbol) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   371
      TRACE("direct_variable_c");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   372
      /* Do not use print_token() as it will change everything into uppercase */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   373
      if (strlen(symbol->value) == 0) ERROR;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   374
      s4o.print(GET_LOCATED);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   375
      s4o.print("(");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   376
      this->print_variable_prefix();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   377
      s4o.printlocation(symbol->value + 1);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   378
      s4o.print(")");
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   379
      return NULL;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   380
    }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   381
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   382
    /*************************************/
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   383
    /* B.1.4.2   Multi-element Variables */
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   384
    /*************************************/
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   385
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   386
    // SYM_REF2(structured_variable_c, record_variable, field_selector)
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   387
    void *visit(structured_variable_c *symbol) {
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   388
      TRACE("structured_variable_c");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   389
      switch (wanted_variablegeneration) {
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   390
        case complextype_base_vg:
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   391
          symbol->record_variable->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   392
          break;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   393
        case complextype_suffix_vg:
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   394
          symbol->record_variable->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   395
          s4o.print(".");
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   396
          symbol->field_selector->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   397
          break;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   398
        default:
237
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   399
          print_getter(symbol);
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   400
          break;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   401
      }
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   402
      return NULL;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   403
    }
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   404
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   405
    /*  subscripted_variable '[' subscript_list ']' */
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   406
    //SYM_REF2(array_variable_c, subscripted_variable, subscript_list)
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   407
    void *visit(array_variable_c *symbol) {
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   408
      switch (wanted_variablegeneration) {
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   409
        case complextype_base_vg:
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   410
          symbol->subscripted_variable->accept(*this);
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   411
          break;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   412
        case complextype_suffix_vg:
238
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   413
          symbol->subscripted_variable->accept(*this);
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   414
321
a96399ab57c2 Add better comments, and change name of functions to clarify what they do.
Mario de Sousa <msousa@fe.up.pt>
parents: 279
diff changeset
   415
          current_array_type = search_varfb_instance_type->get_type_id(symbol->subscripted_variable);
238
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   416
          if (current_array_type == NULL) ERROR;
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   417
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   418
          s4o.print(".table");
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   419
          symbol->subscript_list->accept(*this);
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   420
0919986a5c98 Bug when trying to get type of elements in a big complex structure fixed
laurent
parents: 237
diff changeset
   421
          current_array_type = NULL;
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   422
          break;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   423
        default:
237
cece842c7417 Adding support for using arrays in POU interface
laurent
parents: 235
diff changeset
   424
          print_getter(symbol);
228
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   425
          break;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   426
      }
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   427
      return NULL;
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   428
    }
43831b683764 Adding support for setter and getter on complex datatype in IL
berem
parents: 221
diff changeset
   429
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   430
    /****************************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   431
    /* B.2 - Language IL (Instruction List) */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   432
    /****************************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   433
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   434
    /***********************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   435
    /* B 2.1 Instructions and Operands */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   436
    /***********************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   437
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   438
    /* | label ':' [il_incomplete_instruction] eol_list */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   439
    // SYM_REF2(il_instruction_c, label, il_instruction)
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   440
    void *visit(il_instruction_c *symbol) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   441
      if (NULL != symbol->il_instruction) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   442
        symbol->il_instruction->accept(*this);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   443
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   444
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   445
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   446
    /* | il_simple_operator [il_operand] */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   447
    //SYM_REF2(il_simple_operation_c, il_simple_operator, il_operand)
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   448
    void *visit(il_simple_operation_c *symbol) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   449
      this->current_operand = symbol->il_operand;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   450
      if (NULL == this->current_operand) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   451
        this->current_operand_type = NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   452
      } else {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   453
        this->current_operand_type = search_expression_type->get_type(this->current_operand);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   454
        if (NULL == this->current_operand_type) ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   455
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   456
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   457
      symbol->il_simple_operator->accept(*this);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   458
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   459
      this->current_operand = NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   460
      this->current_operand_type = NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   461
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   462
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   463
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   464
    void *visit(il_function_call_c *symbol) {
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   465
      symbol_c* function_type_prefix = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   466
      symbol_c* function_name = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   467
      symbol_c* function_type_suffix = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   468
      DECLARE_PARAM_LIST()
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   469
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   470
      symbol_c *param_data_type = default_variable_name.current_type;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   471
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   472
      function_call_param_iterator_c function_call_param_iterator(symbol);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   473
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   474
      function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   475
	  if (f_decl == function_symtable.end_value()) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   476
        function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   477
        if (current_function_type == function_none) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   478
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   479
        function_type_prefix = (symbol_c *)search_expression_type->compute_standard_function_il(symbol, param_data_type);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   480
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   481
        symbol_c *en_param_name = (symbol_c *)(new identifier_c("EN"));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   482
        /* Add the value from EN param */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   483
        ADD_PARAM_LIST(en_param_name,
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   484
                       (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c())),
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   485
                       (symbol_c*)(new bool_type_name_c()),
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   486
                       function_param_iterator_c::direction_in)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   487
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   488
        symbol_c *eno_param_name = (symbol_c *)(new identifier_c("ENO"));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   489
        /* Add the value from ENO param */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   490
        ADD_PARAM_LIST(eno_param_name, NULL, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_out)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   491
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   492
        int nb_param = 1;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   493
        if (symbol->il_operand_list != NULL)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   494
          nb_param += ((list_c *)symbol->il_operand_list)->n;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   495
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   496
        #include "il_code_gen.c"
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   497
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   498
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   499
	  else {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   500
		function_name = symbol->function_name;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   501
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   502
		/* determine the base data type returned by the function being called... */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   503
		search_base_type_c search_base_type;
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   504
		function_type_prefix = (symbol_c *)f_decl->type_name->accept(search_base_type);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   505
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   506
		/* loop through each function parameter, find the value we should pass
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   507
		 * to it, and then output the c equivalent...
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   508
		 */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   509
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   510
		function_param_iterator_c fp_iterator(f_decl);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   511
		identifier_c *param_name;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   512
		for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   513
		  symbol_c *param_type = fp_iterator.param_type();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   514
		  if (param_type == NULL) ERROR;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   515
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   516
		  function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   517
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   518
		  symbol_c *param_value = NULL;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   519
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   520
		  /* if it is the first parameter, semantics specifies that we should
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   521
		   * get the value off the IL default variable!
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   522
		   */
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   523
		  if (1 == i)
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   524
		    param_value = &this->default_variable_name;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   525
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   526
		  /* Get the value from a foo(<param_name> = <param_value>) style call */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   527
		  /* NOTE: the following line of code is not required in this case, but it doesn't
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   528
		   * harm to leave it in, as in the case of a non-formal syntax function call,
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   529
		   * it will always return NULL.
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   530
		   * We leave it in in case we later decide to merge this part of the code together
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   531
		   * with the function calling code in generate_c_st_c, which does require
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   532
		   * the following line...
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   533
		   */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   534
		  if (param_value == NULL)
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   535
			param_value = function_call_param_iterator.search_f(param_name);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   536
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   537
		  /* Get the value from a foo(<param_value>) style call */
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   538
          if (param_value == NULL) {
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   539
            param_value = function_call_param_iterator.next_nf();
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   540
            if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR;
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   541
          }
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   542
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   543
		  if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   544
			/* No value given for parameter, so we must use the default... */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   545
			/* First check whether default value specified in function declaration...*/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   546
			param_value = fp_iterator.default_value();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   547
		  }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   548
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   549
		  ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction())
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   550
		} /* for(...) */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   551
	  }
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   552
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   553
	  if (function_call_param_iterator.next_nf() != NULL) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   554
      if (NULL == function_type_prefix) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   555
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   556
      bool has_output_params = false;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   557
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   558
      PARAM_LIST_ITERATOR() {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   559
        if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   560
             PARAM_DIRECTION == function_param_iterator_c::direction_inout) &&
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   561
             PARAM_VALUE != NULL) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   562
          has_output_params = true;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   563
        }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   564
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   565
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   566
      if (has_output_params)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   567
        generate_inline(function_name, function_type_prefix, function_type_suffix, param_list);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   568
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   569
      CLEAR_PARAM_LIST()
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   570
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   571
      /* the data type resulting from this operation... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   572
      default_variable_name.current_type = function_type_prefix;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   573
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   574
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   575
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   576
    /* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   577
    //SYM_REF4(il_expression_c, il_expr_operator, il_operand, simple_instr_list, unused)
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   578
    void *visit(il_expression_c *symbol) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   579
      /* We will be recursevely interpreting an instruction list,
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   580
       * so we store a backup of the data type of the value currently stored
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   581
       * in the default variable, and set the current data type to NULL
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   582
       */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   583
      symbol_c *old_current_default_variable_data_type = this->default_variable_name.current_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   584
      this->default_variable_name.current_type = NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   585
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   586
     /* Pass the symbol->il_operand to the simple_instr_list visitor
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   587
      * using the il_default_variable_init_value parameter...
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   588
      * Note that the simple_instr_list_c visitor will set this parameter
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   589
      * to NULL as soon as it does not require it any longer,
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   590
      * so we don't do it here again after the
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   591
      *   symbol->simple_instr_list->accept(*this);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   592
      * returns...
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   593
      */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   594
      this->il_default_variable_init_value = symbol->il_operand;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   595
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   596
      /* Now do the parenthesised instructions... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   597
      /* NOTE: the following code line will get the variable
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   598
       * this->default_variable_name.current_type updated!
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   599
       */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   600
      symbol->simple_instr_list->accept(*this);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   601
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   602
      /* Now do the operation, using the previous result! */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   603
      /* NOTE: The result of the previous instruction list will be stored
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   604
       * in a variable named IL_DEFVAR_BACK. This is done in the visitor
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   605
       * to instruction_list_c objects...
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   606
       */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   607
      this->current_operand = &(this->default_variable_back_name);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   608
      this->current_operand_type = this->default_variable_back_name.current_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   609
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   610
      this->default_variable_name.current_type = old_current_default_variable_data_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   611
      if (NULL == this->current_operand_type) ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   612
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   613
      symbol->il_expr_operator->accept(*this);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   614
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   615
      this->current_operand = NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   616
      this->current_operand_type = NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   617
      this->default_variable_back_name.current_type = NULL;
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   618
      return NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   619
    }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   620
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   621
    /* | function_name '(' eol_list [il_param_list] ')' */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   622
    // SYM_REF2(il_formal_funct_call_c, function_name, il_param_list)
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   623
    void *visit(il_formal_funct_call_c *symbol) {
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   624
      symbol_c* function_type_prefix = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   625
      symbol_c* function_name = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   626
      symbol_c* function_type_suffix = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   627
      DECLARE_PARAM_LIST()
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   628
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   629
      function_call_param_iterator_c function_call_param_iterator(symbol);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   630
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   631
      function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   632
      if (f_decl == function_symtable.end_value()) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   633
        function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   634
        if (current_function_type == function_none) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   635
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   636
        function_type_prefix = (symbol_c *)search_expression_type->compute_standard_function_default(NULL, symbol);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   637
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   638
        int nb_param = 0;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   639
        if (symbol->il_param_list != NULL)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   640
          nb_param += ((list_c *)symbol->il_param_list)->n;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   641
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   642
        symbol_c *en_param_name = (symbol_c *)(new identifier_c("EN"));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   643
        /* Get the value from EN param */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   644
        symbol_c *EN_param_value = function_call_param_iterator.search_f(en_param_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   645
        if (EN_param_value == NULL)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   646
          EN_param_value = (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c()));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   647
        else
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   648
          nb_param --;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   649
        ADD_PARAM_LIST(en_param_name, EN_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_in)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   650
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   651
        symbol_c *eno_param_name = (symbol_c *)(new identifier_c("ENO"));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   652
        /* Get the value from ENO param */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   653
        symbol_c *ENO_param_value = function_call_param_iterator.search_f(eno_param_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   654
        if (ENO_param_value != NULL)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   655
          nb_param --;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   656
        ADD_PARAM_LIST(eno_param_name, ENO_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_out)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   657
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   658
        #include "st_code_gen.c"
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   659
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   660
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   661
      else {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   662
        function_name = symbol->function_name;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   663
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   664
		/* determine the base data type returned by the function being called... */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   665
		search_base_type_c search_base_type;
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   666
		function_type_prefix = (symbol_c *)f_decl->type_name->accept(search_base_type);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   667
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   668
		/* loop through each function parameter, find the value we should pass
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   669
		 * to it, and then output the c equivalent...
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   670
		 */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   671
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   672
		function_param_iterator_c fp_iterator(f_decl);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   673
		identifier_c *param_name;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   674
		for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   675
		  symbol_c *param_type = fp_iterator.param_type();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   676
		  if (param_type == NULL) ERROR;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   677
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   678
		  function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   679
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   680
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   681
		  symbol_c *param_value = NULL;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   682
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   683
		  /* Get the value from a foo(<param_name> = <param_value>) style call */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   684
		  if (param_value == NULL)
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   685
			param_value = function_call_param_iterator.search_f(param_name);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   686
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   687
		  /* Get the value from a foo(<param_value>) style call */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   688
		  /* NOTE: the following line of code is not required in this case, but it doesn't
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   689
		   * harm to leave it in, as in the case of a formal syntax function call,
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   690
		   * it will always return NULL.
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   691
		   * We leave it in in case we later decide to merge this part of the code together
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   692
		   * with the function calling code in generate_c_st_c, which does require
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   693
		   * the following line...
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   694
		   */
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   695
		  if (param_value == NULL) {
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   696
            param_value = function_call_param_iterator.next_nf();
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   697
            if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR;
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   698
          }
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   699
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   700
		  if (param_value == NULL) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   701
			/* No value given for parameter, so we must use the default... */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   702
			/* First check whether default value specified in function declaration...*/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   703
			param_value = fp_iterator.default_value();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   704
		  }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   705
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   706
		  ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction())
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   707
		}
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   708
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   709
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   710
      if (function_call_param_iterator.next_nf() != NULL) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   711
      if (NULL == function_type_prefix) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   712
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   713
      bool has_output_params = false;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   714
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   715
      PARAM_LIST_ITERATOR() {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   716
        if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   717
             PARAM_DIRECTION == function_param_iterator_c::direction_inout) &&
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   718
             PARAM_VALUE != NULL) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   719
          has_output_params = true;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   720
        }
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   721
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   722
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   723
      if (has_output_params)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   724
        generate_inline(function_name, function_type_prefix, function_type_suffix, param_list);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   725
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   726
      CLEAR_PARAM_LIST()
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   727
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   728
      /* the data type resulting from this operation... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   729
      default_variable_name.current_type = function_type_prefix;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   730
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   731
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   732
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   733
    /* | simple_instr_list il_simple_instruction */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   734
    // SYM_LIST(simple_instr_list_c)
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   735
    void *visit(simple_instr_list_c *symbol) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   736
      /* Check whether we should initiliase the il default variable... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   737
      if (NULL != this->il_default_variable_init_value) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   738
        /* Yes, we must... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   739
        /* We will do it by instatiating a LD operator, and having this
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   740
         * same generate_c_il_c class visiting it!
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   741
         */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   742
        LD_operator_c ld_oper;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   743
        il_simple_operation_c il_simple_oper(&ld_oper, this->il_default_variable_init_value);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   744
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   745
        il_simple_oper.accept(*this);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   746
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   747
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   748
      /* this parameter no longer required... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   749
      this->il_default_variable_init_value = NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   750
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   751
      iterator_visitor_c::visit(symbol);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   752
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   753
      /* copy the result in the default variable to the variable
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   754
	   * used to pass the data out to the scope enclosing
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   755
	   * the current scope!
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   756
	   *
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   757
	   * We also need to update the data type currently stored within
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   758
	   * the variable used to pass the data to the outside scope...
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   759
	   */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   760
	  this->default_variable_back_name.current_type = this->default_variable_name.current_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   761
	  return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   762
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   763
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   764
    void *visit(LD_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   765
      /* the data type resulting from this operation... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   766
      this->default_variable_name.current_type = this->current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   767
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   768
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   769
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   770
    void *visit(LDN_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   771
      /* the data type resulting from this operation... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   772
      this->default_variable_name.current_type = this->current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   773
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   774
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   775
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   776
    void *visit(ADD_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   777
      if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   778
          search_expression_type->is_time_type(this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   779
        /* the data type resulting from this operation... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   780
        this->default_variable_name.current_type = this->current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   781
        return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   782
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   783
      if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   784
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   785
        return NUM_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   786
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   787
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   788
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   789
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   790
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   791
    void *visit(SUB_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   792
      if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   793
          search_expression_type->is_time_type(this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   794
        /* the data type resulting from this operation... */
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   795
        this->default_variable_name.current_type = this->current_operand_type;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   796
        return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   797
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   798
      if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   799
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   800
    	return NUM_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   801
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   802
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   803
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   804
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   805
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   806
    void *visit(MUL_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   807
      if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   808
          search_expression_type->is_integer_type(this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   809
        return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   810
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   811
      if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   812
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   813
    	return NUM_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   814
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   815
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   816
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   817
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   818
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   819
    void *visit(DIV_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   820
      if (search_expression_type->is_time_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   821
          search_expression_type->is_integer_type(this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   822
        return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   823
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   824
      if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   825
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   826
        return NUM_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   827
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   828
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   829
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   830
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   831
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   832
    void *visit(MOD_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   833
      if (search_expression_type->is_num_type(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   834
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   835
        return NUM_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   836
      }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   837
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   838
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   839
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   840
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   841
    void *visit(GT_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   842
      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   843
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   844
        return CMP_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   845
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   846
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   847
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   848
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   849
    void *visit(GE_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   850
      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   851
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   852
        return CMP_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   853
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   854
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   855
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   856
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   857
    void *visit(EQ_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   858
      if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   859
        return CMP_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   860
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   861
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   862
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   863
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   864
    void *visit(LT_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   865
      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   866
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   867
        return CMP_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   868
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   869
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   870
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   871
    void *visit(LE_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   872
      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   873
          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   874
        return CMP_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   875
      ERROR;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   876
      return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   877
    }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   878
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   879
    void *visit(NE_operator_c *symbol)	{
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   880
      if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type))
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   881
        return CMP_operator_result_type();
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   882
      ERROR;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   883
      return NULL;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   884
    }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   885
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   886
    /***************************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   887
    /* B.3 - Language ST (Structured Text) */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   888
    /***************************************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   889
    /***********************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   890
    /* B 3.1 - Expressions */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   891
    /***********************/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   892
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   893
    void *visit(statement_list_c *symbol) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   894
	  function_call_iterator_c fc_iterator(symbol);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   895
	  symbol_c* function_call;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   896
	  while ((function_call = fc_iterator.next()) != NULL) {
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   897
		function_call->accept(*this);
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   898
	  }
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   899
	  return NULL;
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   900
	}
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
   901
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   902
    void *visit(function_invocation_c *symbol) {
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   903
      symbol_c* function_type_prefix = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   904
      symbol_c* function_name = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   905
      symbol_c* function_type_suffix = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   906
      DECLARE_PARAM_LIST()
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   907
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   908
      symbol_c *parameter_assignment_list = NULL;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   909
      if (NULL != symbol->   formal_param_list) parameter_assignment_list = symbol->   formal_param_list;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   910
      if (NULL != symbol->nonformal_param_list) parameter_assignment_list = symbol->nonformal_param_list;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   911
      if (NULL == parameter_assignment_list) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   912
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   913
      function_call_param_iterator_c function_call_param_iterator(symbol);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   914
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   915
      function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   916
      if (f_decl == function_symtable.end_value()) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   917
        /* The function called is not in the symtable, so we test if it is a
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   918
         * standard function defined in standard */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   919
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   920
        function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   921
        if (current_function_type == function_none) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   922
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   923
        function_type_prefix = search_expression_type->get_type(symbol);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   924
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   925
        int nb_param = ((list_c *)parameter_assignment_list)->n;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   926
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   927
        symbol_c *en_param_name = (symbol_c *)(new identifier_c("EN"));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   928
        /* Get the value from EN param */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   929
        symbol_c *EN_param_value = function_call_param_iterator.search_f(en_param_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   930
        if (EN_param_value == NULL)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   931
          EN_param_value = (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c()));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   932
        else
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   933
          nb_param --;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   934
        ADD_PARAM_LIST(en_param_name, EN_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_in)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   935
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   936
        symbol_c *eno_param_name = (symbol_c *)(new identifier_c("ENO"));
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   937
        /* Get the value from ENO param */
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   938
        symbol_c *ENO_param_value = function_call_param_iterator.search_f(eno_param_name);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   939
        if (ENO_param_value != NULL)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   940
          nb_param --;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   941
        ADD_PARAM_LIST(eno_param_name, ENO_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_out)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   942
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   943
        #include "st_code_gen.c"
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   944
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   945
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   946
      else {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   947
        function_name = symbol->function_name;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   948
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   949
	    /* determine the base data type returned by the function being called... */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   950
		search_base_type_c search_base_type;
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   951
		function_type_prefix = (symbol_c *)f_decl->type_name->accept(search_base_type);
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   952
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   953
    	/* loop through each function parameter, find the value we should pass
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   954
         * to it, and then output the c equivalent...
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   955
         */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   956
        function_param_iterator_c fp_iterator(f_decl);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   957
        identifier_c *param_name;
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   958
        for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   959
          symbol_c *param_type = fp_iterator.param_type();
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   960
          if (param_type == NULL) ERROR;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   961
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   962
          function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   963
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   964
          /* Get the value from a foo(<param_name> = <param_value>) style call */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   965
          symbol_c *param_value = function_call_param_iterator.search_f(param_name);
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   966
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   967
          /* Get the value from a foo(<param_value>) style call */
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   968
          if (param_value == NULL) {
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   969
            param_value = function_call_param_iterator.next_nf();
233
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   970
            if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR;
3d23a68183d3 Bug on standard functions called with literals fixed
laurent
parents: 231
diff changeset
   971
          }
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   972
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   973
          if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) {
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   974
            /* No value given for parameter, so we must use the default... */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   975
            /* First check whether default value specified in function declaration...*/
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   976
            param_value = fp_iterator.default_value();
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   977
          }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   978
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   979
          ADD_PARAM_LIST(param_name, param_value, param_type, param_direction)
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   980
        } /* for(...) */
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   981
        // symbol->parameter_assignment->accept(*this);
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   982
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   983
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   984
      if (function_call_param_iterator.next_nf() != NULL) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   985
      if (NULL == function_type_prefix) ERROR;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   986
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   987
	  bool has_output_params = false;
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   988
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   989
	  PARAM_LIST_ITERATOR() {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   990
        if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   991
             PARAM_DIRECTION == function_param_iterator_c::direction_inout) &&
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   992
             PARAM_VALUE != NULL) {
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   993
          has_output_params = true;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
   994
        }
235
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   995
      }
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   996
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   997
      if (has_output_params)
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   998
        generate_inline(function_name, function_type_prefix, function_type_suffix, param_list);
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
   999
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
  1000
      CLEAR_PARAM_LIST()
ed66dc50f31a Bug on generate_c_inlinefcall fixed
laurent
parents: 234
diff changeset
  1001
337
9a2262fb7994 Fix bug with inline function call in POU programmed in IL
laurent
parents: 336
diff changeset
  1002
      return NULL;
219
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
  1003
    }
9bb38736f126 Adding support for declare, init, get and set macros
laurent
parents:
diff changeset
  1004
234
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
  1005
};  /* generate_c_inlinefcall_c */
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
  1006
e4d31cd0e6d8 Using function_call_iterator in generate_c_inlinefcall instead of creating a new visitor
laurent
parents: 233
diff changeset
  1007