absyntax_utils/search_varfb_instance_type.hh
changeset 417 d48f53715f77
parent 372 25332e048742
child 420 866eb35e4e14
equal deleted inserted replaced
416:0c2ef191b22a 417:d48f53715f77
     1 /*
     1 /*
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
     2  *  matiec - a compiler for the programming languages defined in IEC 61131-3
     3  *
     3  *
     4  *  Copyright (C) 2003-2011  Mario de Sousa (msousa@fe.up.pt)
     4  *  Copyright (C) 2003-2012  Mario de Sousa (msousa@fe.up.pt)
     5  *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
     5  *  Copyright (C) 2007-2011  Laurent Bessard and Edouard Tisserant
     6  *
     6  *
     7  *  This program is free software: you can redistribute it and/or modify
     7  *  This program is free software: you can redistribute it and/or modify
     8  *  it under the terms of the GNU General Public License as published by
     8  *  it under the terms of the GNU General Public License as published by
     9  *  the Free Software Foundation, either version 3 of the License, or
     9  *  the Free Software Foundation, either version 3 of the License, or
    75  *   option (2) will return INT
    75  *   option (2) will return INT
    76  * 
    76  * 
    77  *
    77  *
    78  * Member functions:
    78  * Member functions:
    79  * ================
    79  * ================
       
    80  *   get_basetype_id()    ---> returns 2A   (implemented, although currently it is not needed! )
    80  *   get_basetype_decl()  ---> returns 2B 
    81  *   get_basetype_decl()  ---> returns 2B 
    81  *   get_type_id()        ---> returns 1A
    82  *   get_type_id()        ---> returns 1A
    82  * 
    83  * 
    83  *   Since we haven't yet needed them, we don't yet implement
    84  *   Since we haven't yet needed it, we don't yet implement
    84  *   get_basetype_id()    ----> would return 2A
    85  *   get_type_decl()      ---> returns 1B 
    85  *   get_type_decl()      ----> would return 1B
       
    86  */ 
    86  */ 
    87 
    87 
    88 class search_varfb_instance_type_c: public search_base_type_c {
    88 class search_varfb_instance_type_c : null_visitor_c {
    89 
    89 
    90   private:
    90   private:
    91     search_var_instance_decl_c search_var_instance_decl;
    91     search_var_instance_decl_c search_var_instance_decl;
    92     decompose_var_instance_name_c *decompose_var_instance_name;
    92     search_base_type_c         search_base_type;
    93     symbol_c *current_structelement_name;
    93 
    94     symbol_c *current_typeid;
    94 //  symbol_c *current_type_decl;
    95     symbol_c *current_basetypeid;
    95     symbol_c *current_type_id;
       
    96     symbol_c *current_basetype_decl;
       
    97     symbol_c *current_basetype_id;
       
    98     
       
    99     symbol_c *current_field_selector;
       
   100 
    96     bool is_complex;
   101     bool is_complex;
       
   102     
       
   103     /* sets all the above variables to NULL, or false */
       
   104     void init(void);
    97 
   105 
    98   public:
   106   public:
    99     search_varfb_instance_type_c(symbol_c *search_scope);
   107     search_varfb_instance_type_c(symbol_c *search_scope);
   100     symbol_c *get_basetype_decl(symbol_c *variable_name);
   108     symbol_c *get_basetype_decl(symbol_c *variable_name);
   101     symbol_c *get_type_decl(symbol_c *variable_name);
   109     symbol_c *get_basetype_id  (symbol_c *variable_name);
       
   110 //     symbol_c *get_type_decl(symbol_c *variable_name);
   102     symbol_c *get_type_id(symbol_c *variable_name);
   111     symbol_c *get_type_id(symbol_c *variable_name);
   103 
   112 
   104     /* NOTE: this function should be remvoed/deleted.
   113     /* NOTE: this function should be remvoed/deleted.
   105      *       However, it is currently used in stage 4, and before deleting it
   114      *       However, it is currently used in stage 4, and before deleting it
   106      *       requires that the stage4 code be analysed and fixed (i.e. replace by 
   115      *       requires that the stage4 code be analysed and fixed (i.e. replace by 
   128     /* We override the base class' visitor to identifier_c.
   137     /* We override the base class' visitor to identifier_c.
   129      * This is so because the base class does not consider a function block
   138      * This is so because the base class does not consider a function block
   130      * to be a type, unlike this class that allows a variable instance
   139      * to be a type, unlike this class that allows a variable instance
   131      * of a function block type...
   140      * of a function block type...
   132      */
   141      */
   133     void *visit(identifier_c *type_name);
   142 //     void *visit(identifier_c *type_name);
   134 
   143 
   135     /********************************/
   144     /********************************/
   136     /* B 1.3.3 - Derived data types */
   145     /* B 1.3.3 - Derived data types */
   137     /********************************/
   146     /********************************/
   138     
       
   139     /*  identifier ':' array_spec_init */
   147     /*  identifier ':' array_spec_init */
   140     void *visit(array_type_declaration_c *symbol);
   148     void *visit(array_type_declaration_c *symbol);
   141     
   149     
   142     /* array_specification [ASSIGN array_initialization} */
   150     /* array_specification [ASSIGN array_initialization} */
   143     /* array_initialization may be NULL ! */
   151     /* array_initialization may be NULL ! */
   168     void *visit(structure_element_initialization_list_c *symbol); /* should never get called... */
   176     void *visit(structure_element_initialization_list_c *symbol); /* should never get called... */
   169     /*  structure_element_name ASSIGN value */
   177     /*  structure_element_name ASSIGN value */
   170     void *visit(structure_element_initialization_c *symbol); /* should never get called... */
   178     void *visit(structure_element_initialization_c *symbol); /* should never get called... */
   171 
   179 
   172 
   180 
   173 
   181     /*********************/
       
   182     /* B 1.4 - Variables */
       
   183     /*********************/
       
   184     void *visit(symbolic_variable_c *symbol);
       
   185 
       
   186     /********************************************/
       
   187     /* B.1.4.1   Directly Represented Variables */
       
   188     /********************************************/
       
   189     /*************************************/
       
   190     /* B 1.4.2 - Multi-element variables */
       
   191     /*************************************/
       
   192     void *visit(array_variable_c *symbol);
       
   193     void *visit(structured_variable_c *symbol);
       
   194     
   174     /**************************************/
   195     /**************************************/
   175     /* B.1.5 - Program organization units */
   196     /* B.1.5 - Program organization units */
   176     /**************************************/
   197     /**************************************/
   177     /*****************************/
   198     /*****************************/
   178     /* B 1.5.2 - Function Blocks */
   199     /* B 1.5.2 - Function Blocks */