absyntax_utils/function_param_iterator.hh
changeset 202 da1a8186f86f
parent 181 38d6eb056260
child 233 3d23a68183d3
equal deleted inserted replaced
201:e657008f43d0 202:da1a8186f86f
    67      */
    67      */
    68     typedef enum {direction_in, direction_out, direction_inout, direction_extref} param_direction_t ;
    68     typedef enum {direction_in, direction_out, direction_inout, direction_extref} param_direction_t ;
    69 
    69 
    70 
    70 
    71   private:
    71   private:
    72       /* a pointer to the function_block_declaration_c
    72     /* a pointer to the function_block_declaration_c
    73        * or function_declaration_c currently being analysed.
    73     * or function_declaration_c currently being analysed.
    74        */
    74     */
    75     symbol_c *f_decl;
    75     symbol_c *f_decl;
    76     int next_param, param_count;
    76     int next_param, param_count;
       
    77     /* used when called to search() for a parameter by name */
       
    78     identifier_c *search_param_name;
       
    79     /* used when called to iterate() for a parameter */
    77     identifier_c *current_param_name;
    80     identifier_c *current_param_name;
    78     symbol_c *current_param_type;
    81     symbol_c *current_param_type;
    79     symbol_c *current_param_default_value;
    82     symbol_c *current_param_default_value;
    80     param_direction_t current_param_direction;
    83     param_direction_t current_param_direction;
    81     bool en_declared;
    84     /* Which operation of the class was called...
    82     bool eno_declared;
    85      * Search a parameter, or iterate to the next parameter.
       
    86      */
       
    87     typedef enum {iterate_op, search_op} operation_t;
       
    88     operation_t current_operation;
    83 
    89 
    84   private:
    90   private:
    85     void* handle_param_list(list_c *list);
    91     void* handle_param_list(list_c *list);
    86     void* handle_single_param(symbol_c *var_name);
    92     void* handle_single_param(symbol_c *var_name);
    87 
    93 
    90   public:
    96   public:
    91     /* start off at the first parameter once again... */
    97     /* start off at the first parameter once again... */
    92     void reset(void);
    98     void reset(void);
    93 
    99 
    94     /* initialise the iterator object.
   100     /* initialise the iterator object.
    95      * We must be given a reference to the function declaration
   101      * We must be given a reference to one of the following
       
   102      *     - function_declaration_c
       
   103      *     - function_block_declaration_c
       
   104      *     - program_declaration_c
    96      * that will be analysed...
   105      * that will be analysed...
    97      */
   106      */
    98     function_param_iterator_c(function_declaration_c *f_decl);
   107     function_param_iterator_c(symbol_c *pou_decl);
    99 
       
   100     /* initialise the iterator object.
       
   101      * We must be given a reference to the function block declaration
       
   102      * that will be analysed...
       
   103      */
       
   104     function_param_iterator_c(function_block_declaration_c *fb_decl);
       
   105 
       
   106     /* initialise the iterator object.
       
   107      * We must be given a reference to the program declaration
       
   108      * that will be analysed...
       
   109      */
       
   110     function_param_iterator_c(program_declaration_c *p_decl);
       
   111 
   108 
   112     /* Skip to the next parameter. After object creation,
   109     /* Skip to the next parameter. After object creation,
   113      * the object references on parameter _before_ the first, so
   110      * the object references on parameter _before_ the first, so
   114      * this function must be called once to get the object to
   111      * this function must be called once to get the object to
   115      * reference the first parameter...
   112      * reference the first parameter...
   116      *
   113      *
   117      * Returns the parameter's name!
   114      * Returns the parameter's name!
   118      */
   115      */
   119     identifier_c *next(void);
   116     identifier_c *next(void);
   120 
   117 
   121     identifier_c *declare_en_param(void);
   118     /* Search for the parameter named <param_name>...  */
   122 
   119     /* The seach() function does not in any way affect the internal state related 
   123     identifier_c *declare_eno_param(void);
   120      * to the iterate() function.
       
   121      * It will, however, affect the internal state necessary to correctly
       
   122      * return the param_type() and default_value() of the found parameter.
       
   123      */
       
   124     identifier_c *search(symbol_c *param_name);
   124 
   125 
   125     /* Returns the currently referenced parameter's default value,
   126     /* Returns the currently referenced parameter's default value,
   126      * or NULL if none is specified in the function declrataion itself.
   127      * or NULL if none is specified in the function declrataion itself.
   127      */
   128      */
   128     symbol_c *default_value(void);
   129     symbol_c *default_value(void);