absyntax_utils/function_call_param_iterator.hh
changeset 205 96d8b6e006f0
parent 202 da1a8186f86f
child 265 4d222f46f8cc
equal deleted inserted replaced
200:fde2d08ebaee 205:96d8b6e006f0
    22  *
    22  *
    23  */
    23  */
    24 
    24 
    25 /*
    25 /*
    26  * Function call parameter iterator.
    26  * Function call parameter iterator.
    27  * It will iterate through the formal parameters of a function call
    27  * It will iterate through the non-formal parameters of a function call
    28  * (i.e. function calls using the foo(<param1>, <param2>, ...) syntax).
    28  * (i.e. function calls using the foo(<param1>, <param2>, ...) syntax).
    29  * and/or search through the non-formal parameters of a function call
    29  * and/or search through the formal parameters of a function call
    30  * (i.e. function calls using the foo(<name1> = <param1>, <name2> = <param2>, ...) syntax).
    30  * (i.e. function calls using the foo(<name1> = <param1>, <name2> = <param2>, ...) syntax).
    31  *
    31  *
    32  * Calls to function blocks and programs are also supported.
    32  * Calls to function blocks and programs are also supported.
    33  *
    33  *
    34  * Note that calls to next() will only iterate through formal parameters,
    34  * Note that calls to next_nf() will only iterate through non-formal parameters,
    35  * and calls to search()  will only serach through non-formal parameters.
    35  * calls to next_f() will only iterate through formal parameters,
       
    36  * and calls to search_f() will only serach through formal parameters.
    36  */
    37  */
    37 
    38 
    38 
    39 
    39 #include "../absyntax/visitor.hh"
    40 #include "../absyntax/visitor.hh"
    40 
    41 
    44   private:
    45   private:
    45       /* a pointer to the function call
    46       /* a pointer to the function call
    46        * (or function block or program call!)
    47        * (or function block or program call!)
    47        */
    48        */
    48     symbol_c *f_call;
    49     symbol_c *f_call;
    49     int next_param, param_count;
    50     int iterate_f_next_param, iterate_nf_next_param, param_count;
    50     identifier_c *search_param_name;
    51     identifier_c *search_param_name;
    51 
    52     symbol_c *current_value;
    52     /* Which operation of the class was called...
    53 
    53      * Search a parameter, or iterate to the next parameter.
    54     /* Which operation of the class was called:
       
    55      *  - iterate to the next non-formal parameter. 
       
    56      *  - iterate to the next formal parameter. 
       
    57      *  - search a formal parameter, 
    54      */
    58      */
    55     typedef enum {iterate_op, search_op} operation_t;
    59     typedef enum {iterate_nf_op, iterate_f_op, search_f_op} operation_t;
    56     operation_t current_operation;
    60     operation_t current_operation;
    57 
    61 
    58   private:
    62   private:
    59     void *search_list(list_c *list);
    63     void *search_list(list_c *list);
    60     void *handle_parameter_assignment(symbol_c *variable_name, symbol_c *expression) ;
    64     void *handle_parameter_assignment(symbol_c *variable_name, symbol_c *expression) ;
    68      * We must be given a reference to the function/program/function block call
    72      * We must be given a reference to the function/program/function block call
    69      * that will be analysed...
    73      * that will be analysed...
    70      */
    74      */
    71     function_call_param_iterator_c(symbol_c *f_call);
    75     function_call_param_iterator_c(symbol_c *f_call);
    72 
    76 
    73     /* Skip to the next parameter. After object creation,
    77     /* Skip to the next formal parameter. After object creation,
       
    78      * the object references on parameter _before_ the first, so
       
    79      * this function must be called once to get the object to
       
    80      * reference the first parameter...
       
    81      *
       
    82      * Returns the paramater name to which a value is being passed!
       
    83      * You can determine the value being passed by calling 
       
    84      * function_call_param_iterator_c::search_f()
       
    85      */
       
    86     symbol_c *next_f(void);
       
    87 
       
    88     /* Skip to the next non-formal parameter. After object creation,
    74      * the object references on parameter _before_ the first, so
    89      * the object references on parameter _before_ the first, so
    75      * this function must be called once to get the object to
    90      * this function must be called once to get the object to
    76      * reference the first parameter...
    91      * reference the first parameter...
    77      *
    92      *
    78      * Returns whatever is being passed to the parameter!
    93      * Returns whatever is being passed to the parameter!
    79      */
    94      */
    80     symbol_c *next(void);
    95     symbol_c *next_nf(void);
    81 
    96 
    82     /* Search for the value passed to the parameter named <param_name>...  */
    97     /* Search for the value passed to the parameter named <param_name>...  */
    83     symbol_c *search(symbol_c *param_name);
    98     symbol_c *search_f(symbol_c *param_name);
       
    99 
       
   100     /* Returns the value being passed to the current parameter. */
       
   101     symbol_c *get_current_value(void);
    84 
   102 
    85 
   103 
    86   private:
   104   private:
    87   /********************************/
   105   /********************************/
    88   /* B 1.7 Configuration elements */
   106   /* B 1.7 Configuration elements */
   252 
   270 
   253 
   271 
   254   /*******************/
   272   /*******************/
   255   /* B 2.2 Operators */
   273   /* B 2.2 Operators */
   256   /*******************/
   274   /*******************/
       
   275   /*  any_identifier ASSIGN */
       
   276   // SYM_REF1(il_assign_operator_c, variable_name)
       
   277     void *visit(il_assign_operator_c *symbol);
       
   278 
   257   /*| [NOT] any_identifier SENDTO */
   279   /*| [NOT] any_identifier SENDTO */
   258   // SYM_REF2(il_assign_out_operator_c, option, variable_name)
   280   // SYM_REF2(il_assign_out_operator_c, option, variable_name)
   259     void *visit(il_assign_out_operator_c *symbol);
   281     void *visit(il_assign_out_operator_c *symbol);
   260 
   282 
   261 
   283