absyntax_utils/function_call_param_iterator.hh
changeset 449 3c6225521059
parent 350 2c3c4dc34979
equal deleted inserted replaced
448:1bd18fc06911 449:3c6225521059
    47 
    47 
    48 #include "../absyntax/visitor.hh"
    48 #include "../absyntax/visitor.hh"
    49 
    49 
    50 
    50 
    51 class function_call_param_iterator_c : public null_visitor_c {
    51 class function_call_param_iterator_c : public null_visitor_c {
       
    52 
       
    53   private:
       
    54     void *search_list(list_c *list);
       
    55     void *handle_parameter_assignment(symbol_c *variable_name, symbol_c *expression) ;
       
    56 
       
    57 
       
    58   public:
       
    59     /* start off at the first parameter once again... */
       
    60     void reset(void);
       
    61 
       
    62     /* initialise the iterator object.
       
    63      * We must be given a reference to the function/program/function block call
       
    64      * that will be analysed...
       
    65      */
       
    66     function_call_param_iterator_c(symbol_c *f_call);
       
    67 
       
    68     /* Skip to the next formal parameter. After object creation,
       
    69      * the object references on parameter _before_ the first, so
       
    70      * this function must be called once to get the object to
       
    71      * reference the first parameter...
       
    72      *
       
    73      * Returns the paramater name to which a value is being passed!
       
    74      * You can determine the value being passed by calling 
       
    75      * function_call_param_iterator_c::search_f()
       
    76      */
       
    77     symbol_c *next_f(void);
       
    78 
       
    79     /* Skip to the next non-formal parameter. After object creation,
       
    80      * the object references on parameter _before_ the first, so
       
    81      * this function must be called once to get the object to
       
    82      * reference the first parameter...
       
    83      *
       
    84      * Returns whatever is being passed to the parameter!
       
    85      */
       
    86     symbol_c *next_nf(void);
       
    87 
       
    88     /* Search for the value passed to the parameter named <param_name>...  */
       
    89     symbol_c *search_f(symbol_c *param_name);
       
    90     symbol_c *search_f(const char *param_name);
       
    91 
       
    92     /* Returns the value being passed to the current parameter. */
       
    93     symbol_c *get_current_value(void);
       
    94     
       
    95     /* A type to specify how the current parameter was assigned.
       
    96      * param_name := var   -> assign_in
       
    97      * param_name => var   -> assign_out
       
    98      *                     -> assign_none  (used when handling non formal calls, when no assignment type is used)
       
    99      */
       
   100     typedef enum {assign_in, assign_out, assign_none} assign_direction_t ;
       
   101     /* Returns the assignment direction of the current parameter. */
       
   102     assign_direction_t get_assign_direction(void);
       
   103 
    52 
   104 
    53   private:
   105   private:
    54       /* a pointer to the function call
   106       /* a pointer to the function call
    55        * (or function block or program call!)
   107        * (or function block or program call!)
    56        */
   108        */
    57     symbol_c *f_call;
   109     symbol_c *f_call;
    58     int iterate_f_next_param, iterate_nf_next_param, param_count;
   110     int iterate_f_next_param, iterate_nf_next_param, param_count;
    59     identifier_c *search_param_name;
   111     identifier_c *search_param_name;
    60     symbol_c *current_value;
   112     symbol_c *current_value;
       
   113     assign_direction_t current_assign_direction;
    61 
   114 
    62     /* Which operation of the class was called:
   115     /* Which operation of the class was called:
    63      *  - iterate to the next non-formal parameter. 
   116      *  - iterate to the next non-formal parameter. 
    64      *  - iterate to the next formal parameter. 
   117      *  - iterate to the next formal parameter. 
    65      *  - search a formal parameter, 
   118      *  - search a formal parameter, 
    66      */
   119      */
    67     typedef enum {iterate_nf_op, iterate_f_op, search_f_op} operation_t;
   120     typedef enum {iterate_nf_op, iterate_f_op, search_f_op} operation_t;
    68     operation_t current_operation;
   121     operation_t current_operation;
    69 
   122 
    70   private:
   123     
    71     void *search_list(list_c *list);
       
    72     void *handle_parameter_assignment(symbol_c *variable_name, symbol_c *expression) ;
       
    73 
       
    74 
       
    75   public:
       
    76     /* start off at the first parameter once again... */
       
    77     void reset(void);
       
    78 
       
    79     /* initialise the iterator object.
       
    80      * We must be given a reference to the function/program/function block call
       
    81      * that will be analysed...
       
    82      */
       
    83     function_call_param_iterator_c(symbol_c *f_call);
       
    84 
       
    85     /* Skip to the next formal parameter. After object creation,
       
    86      * the object references on parameter _before_ the first, so
       
    87      * this function must be called once to get the object to
       
    88      * reference the first parameter...
       
    89      *
       
    90      * Returns the paramater name to which a value is being passed!
       
    91      * You can determine the value being passed by calling 
       
    92      * function_call_param_iterator_c::search_f()
       
    93      */
       
    94     symbol_c *next_f(void);
       
    95 
       
    96     /* Skip to the next non-formal parameter. After object creation,
       
    97      * the object references on parameter _before_ the first, so
       
    98      * this function must be called once to get the object to
       
    99      * reference the first parameter...
       
   100      *
       
   101      * Returns whatever is being passed to the parameter!
       
   102      */
       
   103     symbol_c *next_nf(void);
       
   104 
       
   105     /* Search for the value passed to the parameter named <param_name>...  */
       
   106     symbol_c *search_f(symbol_c *param_name);
       
   107     symbol_c *search_f(const char *param_name);
       
   108 
       
   109     /* Returns the value being passed to the current parameter. */
       
   110     symbol_c *get_current_value(void);
       
   111 
       
   112 
       
   113   private:
   124   private:
   114   /********************************/
   125   /********************************/
   115   /* B 1.7 Configuration elements */
   126   /* B 1.7 Configuration elements */
   116   /********************************/
   127   /********************************/
   117  
   128