as_declaration_specifier2properties.cc

Go to the documentation of this file.
00001 /*
00002    The lestes compiler suite
00003    Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy
00004    Copyright (C) 2002, 2003, 2004, 2005 Petr Zika
00005    Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala
00006    Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina
00007    Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda
00008    Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar
00009    Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas
00010 
00011    This program is free software; you can redistribute it and/or modify
00012    it under the terms of the GNU General Public License as published by
00013    the Free Software Foundation; version 2 of the License.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    See the full text of the GNU General Public License version 2, and
00021    the limitations in the file doc/LICENSE.
00022 
00023    By accepting the license the licensee waives any and all claims
00024    against the copyright holder(s) related in whole or in part to the
00025    work, its use, and/or the inability to use it.
00026  
00027  */
00028 /*! \file
00029   \brief Declaration specifier visitor.
00030 
00031   Definition of visitor transforming declaration specifier into SS type and properties.
00032   \author pt
00033 */
00034 
00035 #include <lestes/common.hh>
00036 #include <lestes/lang/cplus/sem/as_declaration_specifier2properties.g.hh>
00037 #include <lestes/lang/cplus/sem/as_decl.g.hh>
00038 #include <lestes/lang/cplus/sem/ss_type_builtin.g.hh>
00039 #include <lestes/lang/cplus/sem/ss_declaration.g.hh>
00040 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00041 #include <lestes/lang/cplus/sem/as_id_to_declaration_set.g.hh>
00042 #include <lestes/lang/cplus/sem/lu_typedef.hh>
00043 
00044 package(lestes);
00045 package(lang);
00046 package(cplus);
00047 package(sem);
00048 
00049 /*!
00050   Processes the declaration specifier.
00051   \pre specifier != NULL
00052   \param specifier  The specifier to process.
00053 */
00054 void as_declaration_specifier2properties::process(ptr<as_declaration_specifier> specifier)
00055 {
00056         lassert(specifier);
00057         specifier->accept_as_declaration_specifier_visitor(this);
00058 }
00059 
00060 /*!
00061   Visits instance of as_function_specifier_inline.
00062   \param specifier  The instance to visit.
00063 */
00064 void as_declaration_specifier2properties::visit_as_function_specifier_inline(
00065         ptr< ::lestes::lang::cplus::sem::as_function_specifier_inline > specifier)
00066 {
00067         lassert(specifier); 
00068         if (inline_flag) {
00069                 // TODO pt report error: duplicate inline
00070         }
00071         inline_flag = true;
00072 }
00073 
00074 /*!
00075   Visits instance of as_function_specifier_virtual.
00076   \param specifier  The instance to visit.
00077 */
00078 void as_declaration_specifier2properties::visit_as_function_specifier_virtual(
00079         ptr< ::lestes::lang::cplus::sem::as_function_specifier_virtual > specifier)
00080 {
00081         lassert(specifier); 
00082         if (virtual_flag) {
00083                 // TODO pt report error: duplicat virtual
00084         }
00085         virtual_flag = true;
00086 }
00087 
00088 /*!
00089   Visits instance of as_function_specifier_explicit.
00090   \param specifier  The instance to visit.
00091 */
00092 void as_declaration_specifier2properties::visit_as_function_specifier_explicit(
00093         ptr< ::lestes::lang::cplus::sem::as_function_specifier_explicit > specifier)
00094 {
00095         lassert(specifier); 
00096         if (explicit_flag) {
00097                 // TODO pt report error: duplicate explicit
00098         }
00099         explicit_flag = true;
00100 }
00101 
00102 /*!
00103   Visits instance of as_friend_specifier.
00104   \param specifier  The instance to visit.
00105 */
00106 void as_declaration_specifier2properties::visit_as_friend_specifier(
00107         ptr< ::lestes::lang::cplus::sem::as_friend_specifier > specifier)
00108 {
00109         lassert(specifier); 
00110         if (friend_flag) {
00111                 // TODO pt report error: duplicate friend
00112         }
00113         friend_flag = true;
00114 }
00115 
00116 /*!
00117   Visits instance of as_typedef_specifier.
00118   \param specifier  The instance to visit.
00119 */
00120 void as_declaration_specifier2properties::visit_as_typedef_specifier(
00121         ptr< ::lestes::lang::cplus::sem::as_typedef_specifier > specifier)
00122 {
00123         lassert(specifier); 
00124         if (storage_class == ss_storage_class::ST_NONE) {
00125                 storage_class = ss_storage_class::ST_TYPEDEF;
00126         } else {
00127                 // TODO pt report errors
00128         }
00129 }
00130 
00131 /*!
00132   Visits instance of as_storage_class_specifier_auto.
00133   \param specifier  The instance to visit.
00134 */
00135 void as_declaration_specifier2properties::visit_as_storage_class_specifier_auto(
00136         ptr< ::lestes::lang::cplus::sem::as_storage_class_specifier_auto > specifier)
00137 {
00138         lassert(specifier); 
00139         if (storage_class == ss_storage_class::ST_NONE) {
00140                 storage_class = ss_storage_class::ST_AUTO;
00141         } else {
00142                 // TODO pt report error
00143         }
00144 }
00145 
00146 /*!
00147   Visits instance of as_storage_class_specifier_register.
00148   \param specifier  The instance to visit.
00149 */
00150 void as_declaration_specifier2properties::visit_as_storage_class_specifier_register(
00151         ptr< ::lestes::lang::cplus::sem::as_storage_class_specifier_register > specifier)
00152 {
00153         lassert(specifier); 
00154         if (storage_class == ss_storage_class::ST_NONE) {
00155                 storage_class = ss_storage_class::ST_REGISTER;
00156         } else {
00157                 // TODO pt report error
00158         }
00159 }
00160 
00161 /*!
00162   Visits instance of as_storage_class_specifier_static.
00163   \param specifier  The instance to visit.
00164 */
00165 void as_declaration_specifier2properties::visit_as_storage_class_specifier_static(
00166         ptr< ::lestes::lang::cplus::sem::as_storage_class_specifier_static > specifier)
00167 {
00168         lassert(specifier); 
00169         if (storage_class == ss_storage_class::ST_NONE) {
00170                 storage_class = ss_storage_class::ST_STATIC;
00171         } else {
00172                 // TODO pt report error
00173         }
00174 }
00175 
00176 /*!
00177   Visits instance of as_storage_class_specifier_extern.
00178   \param specifier  The instance to visit.
00179 */
00180 void as_declaration_specifier2properties::visit_as_storage_class_specifier_extern(
00181         ptr< ::lestes::lang::cplus::sem::as_storage_class_specifier_extern > specifier)
00182 {
00183         lassert(specifier); 
00184         if (storage_class == ss_storage_class::ST_NONE) {
00185                 storage_class = ss_storage_class::ST_EXTERN;
00186         } else {
00187                 // TODO pt report error
00188         }
00189 }
00190 
00191 /*!
00192   Visits instance of as_storage_class_specifier_mutable.
00193   \param specifier  The instance to visit.
00194 */
00195 void as_declaration_specifier2properties::visit_as_storage_class_specifier_mutable(
00196         ptr< ::lestes::lang::cplus::sem::as_storage_class_specifier_mutable > specifier)
00197 {
00198         lassert(specifier); 
00199         if (storage_class == ss_storage_class::ST_NONE) {
00200                 storage_class = ss_storage_class::ST_MUTABLE;
00201         } else {
00202                 // TODO pt report error
00203         }
00204 }
00205 
00206 /*!
00207   Visits instance of as_enumeration_specifier.
00208   \param specifier  The instance to visit.
00209 */
00210 void as_declaration_specifier2properties::visit_as_enumeration_specifier(
00211         ptr< ::lestes::lang::cplus::sem::as_enumeration_specifier > specifier)
00212 {
00213         lassert(specifier); 
00214         if (type_specifier == TS_NONE) {
00215                 // TODO pt lookup
00216                 //other_type = lookup(specifier->name_get());
00217                 other_type = ss_type_wchar_t::instance(); // temporarily wchar
00218                 type_specifier = TS_OTHER;
00219         } else {
00220                 // TODO pt report error: multiple types in declaration 
00221         }
00222 }
00223 
00224 /*!
00225   Visits instance of as_char_simple_type_specifier.
00226   \param specifier  The instance to visit.
00227 */
00228 void as_declaration_specifier2properties::visit_as_char_simple_type_specifier(
00229         ptr< ::lestes::lang::cplus::sem::as_char_simple_type_specifier > specifier)
00230 {
00231         lassert(specifier); 
00232         if (type_specifier == TS_NONE) {
00233                 type_specifier = TS_CHAR;
00234         } else {
00235                 // TODO pt report error: multiple types
00236         }
00237 }
00238 
00239 /*!
00240   Visits instance of as_wchar_t_simple_type_specifier.
00241   \param specifier  The instance to visit.
00242 */
00243 void as_declaration_specifier2properties::visit_as_wchar_t_simple_type_specifier(
00244         ptr< ::lestes::lang::cplus::sem::as_wchar_t_simple_type_specifier > specifier)
00245 {
00246         lassert(specifier); 
00247         if (type_specifier == TS_NONE) {
00248                 type_specifier = TS_OTHER;
00249                 other_type = ss_type_wchar_t::instance();
00250         } else {
00251                 // TODO pt report error: multiple types
00252         }
00253 }
00254 
00255 /*!
00256   Visits instance of as_bool_simple_type_specifier.
00257   \param specifier  The instance to visit.
00258 */
00259 void as_declaration_specifier2properties::visit_as_bool_simple_type_specifier(
00260         ptr< ::lestes::lang::cplus::sem::as_bool_simple_type_specifier > specifier)
00261 {
00262         lassert(specifier); 
00263         if (type_specifier == TS_NONE) {
00264                 type_specifier = TS_OTHER;
00265                 other_type = ss_bool::instance();
00266         } else {
00267                 // TODO pt report error: multiple types
00268         }
00269 }
00270 
00271 /*!
00272   Visits instance of as_int_simple_type_specifier.
00273   \param specifier  The instance to visit.
00274 */
00275 void as_declaration_specifier2properties::visit_as_int_simple_type_specifier(
00276         ptr< ::lestes::lang::cplus::sem::as_int_simple_type_specifier > specifier)
00277 {
00278         lassert(specifier); 
00279         if (type_specifier == TS_NONE) {
00280                 type_specifier = TS_INT;
00281         } else {
00282                 // TODO pt report error: multiple types
00283         }
00284 }
00285 
00286 /*!
00287   Visits instance of as_float_simple_type_specifier.
00288   \param specifier  The instance to visit.
00289 */
00290 void as_declaration_specifier2properties::visit_as_float_simple_type_specifier(
00291         ptr< ::lestes::lang::cplus::sem::as_float_simple_type_specifier > specifier)
00292 {
00293         lassert(specifier); 
00294         if (type_specifier == TS_NONE) {
00295                 type_specifier = TS_OTHER;
00296                 other_type = ss_type_float::instance();
00297         } else {
00298                 // TODO pt report error: multiple types
00299         }
00300 }
00301 
00302 /*!
00303   Visits instance of as_double_simple_type_specifier.
00304   \param specifier  The instance to visit.
00305 */
00306 void as_declaration_specifier2properties::visit_as_double_simple_type_specifier(
00307         ptr< ::lestes::lang::cplus::sem::as_double_simple_type_specifier > specifier)
00308 {
00309         lassert(specifier); 
00310         if (type_specifier == TS_NONE) {
00311                 type_specifier = TS_DOUBLE;
00312         } else {
00313                 // TODO pt report error: multiple types
00314         }
00315 }
00316 
00317 /*!
00318   Visits instance of as_void_simple_type_specifier.
00319   \param specifier  The instance to visit.
00320 */
00321 void as_declaration_specifier2properties::visit_as_void_simple_type_specifier(
00322         ptr< ::lestes::lang::cplus::sem::as_void_simple_type_specifier > specifier)
00323 {
00324         lassert(specifier); 
00325         if (type_specifier == TS_NONE) {
00326                 type_specifier = TS_OTHER;
00327                 other_type = ss_void::instance();
00328         } else {
00329                 // TODO pt report error: multiple types
00330         }
00331 }
00332 
00333 /*!
00334   Visits instance of as_short_simple_type_specifier.
00335   \param specifier  The instance to visit.
00336 */
00337 void as_declaration_specifier2properties::visit_as_short_simple_type_specifier(
00338         ptr< ::lestes::lang::cplus::sem::as_short_simple_type_specifier > specifier)
00339 {
00340         lassert(specifier); 
00341         if (short_flag) {
00342                 // TODO pt report error
00343         } else if (long_flag) {
00344                 // TODO pt report error: short and long
00345         } else {
00346                 short_flag = true;
00347         }
00348 }
00349 
00350 /*!
00351   Visits instance of as_long_simple_type_specifier.
00352   \param specifier  The instance to visit.
00353 */
00354 void as_declaration_specifier2properties::visit_as_long_simple_type_specifier(
00355         ptr< ::lestes::lang::cplus::sem::as_long_simple_type_specifier > specifier)
00356 {
00357         lassert(specifier); 
00358         if (long_flag) {
00359                 // TODO pt report error
00360         } else if (short_flag) {
00361                 // TODO pt report error: short and long
00362         } else {
00363                 long_flag = true;
00364         }
00365 }
00366 
00367 /*!
00368   Visits instance of as_signed_simple_type_specifier.
00369   \param specifier  The instance to visit.
00370 */
00371 void as_declaration_specifier2properties::visit_as_signed_simple_type_specifier(
00372         ptr< ::lestes::lang::cplus::sem::as_signed_simple_type_specifier > specifier)
00373 {
00374         lassert(specifier); 
00375         if (signed_flag) {
00376                 // TODO pt report error
00377         } else if (unsigned_flag) {
00378                 // TODO pt report error: signed and unsigned together
00379         } else {
00380                 signed_flag = true;
00381         }
00382 }
00383 
00384 /*!
00385   Visits instance of as_unsigned_simple_type_specifier.
00386   \param specifier  The instance to visit.
00387 */
00388 void as_declaration_specifier2properties::visit_as_unsigned_simple_type_specifier(
00389         ptr< ::lestes::lang::cplus::sem::as_unsigned_simple_type_specifier > specifier)
00390 {
00391         lassert(specifier); 
00392         if (unsigned_flag) {
00393                 // TODO pt report error
00394         } else if (signed_flag) {
00395                 // TODO pt report error: signed and unsigned together
00396         } else {
00397                 unsigned_flag = true;
00398         }
00399 }
00400 
00401 /*!
00402   Visits instance of as_cv_qualifier_const.
00403   \param specifier  The instance to visit.
00404 */
00405 void as_declaration_specifier2properties::visit_as_cv_qualifier_const(
00406         ptr< ::lestes::lang::cplus::sem::as_cv_qualifier_const > specifier)
00407 {
00408         lassert(specifier); 
00409         if (const_flag) {
00410                 // TODO pt report error
00411         }
00412         const_flag = true;
00413 }
00414 
00415 /*!
00416   Visits instance of as_cv_qualifier_volatile.
00417   \param specifier  The instance to visit.
00418 */
00419 void as_declaration_specifier2properties::visit_as_cv_qualifier_volatile(
00420         ptr< ::lestes::lang::cplus::sem::as_cv_qualifier_volatile > specifier)
00421 {
00422         lassert(specifier); 
00423         if (volatile_flag) {
00424                 // TODO pt report error
00425         }
00426         volatile_flag = true;
00427 }
00428 
00429 /*!
00430   Visits instance of as_cv_qualifier_restrict.
00431   \param specifier  The instance to visit.
00432 */
00433 void as_declaration_specifier2properties::visit_as_cv_qualifier_restrict(
00434         ptr< ::lestes::lang::cplus::sem::as_cv_qualifier_restrict > specifier)
00435 {
00436         lassert2(false,"restrict is not C++");
00437         lassert(specifier); 
00438 }
00439 
00440 /*!
00441   Visits instance of as_named_simple_type_specifier.
00442   \param specifier  The instance to visit.
00443 */
00444 void as_declaration_specifier2properties::visit_as_named_simple_type_specifier(
00445         ptr< ::lestes::lang::cplus::sem::as_named_simple_type_specifier > specifier)
00446 {
00447         lassert(specifier); 
00448         if (type_specifier == TS_NONE) {
00449            ptr<declaration_set_type> decls =
00450                    as_id_to_declaration_set::instance()->process(specifier->name_get()->identifier_get() );
00451            lassert(decls && decls->size() == 1);
00452 
00453                 other_type = (*decls->begin())->type_get();
00454       
00455       type_specifier = TS_OTHER;
00456         } else {
00457                 // TODO pt report error: multiple types in declaration 
00458         } 
00459 }
00460 
00461 /*!
00462   Visits instance of as_elaborated_type_specifier_typename.
00463   \param specifier  The instance to visit.
00464 */
00465 void as_declaration_specifier2properties::visit_as_elaborated_type_specifier_typename(
00466         ptr< ::lestes::lang::cplus::sem::as_elaborated_type_specifier_typename > specifier)
00467 {
00468         lassert2(false,"typename is unsupported");
00469         lassert(specifier); 
00470 }
00471 
00472 /*!
00473   Visits instance of as_elaborated_type_specifier_class_key.
00474   \param specifier  The instance to visit.
00475 */
00476 void as_declaration_specifier2properties::visit_as_elaborated_type_specifier_class_key(
00477         ptr< ::lestes::lang::cplus::sem::as_elaborated_type_specifier_class_key > specifier)
00478 {
00479         lassert(specifier); 
00480         if (type_specifier == TS_NONE) {
00481            ptr<declaration_set_type> decls =
00482                    as_id_to_declaration_set::instance()->process(specifier->name_get()->identifier_get() );
00483                 // TODO pt add the invisible forward for the class, if the name was not found
00484            lassert(decls && decls->size() == 1);
00485 
00486                 other_type = (*decls->begin())->type_get();
00487       
00488       type_specifier = TS_OTHER;
00489         } else {
00490                 // TODO pt report error: multiple types in declaration 
00491         } 
00492 }
00493 
00494 /*!
00495   Visits instance of as_elaborated_type_specifier_enum.
00496   \param specifier  The instance to visit.
00497 */
00498 void as_declaration_specifier2properties::visit_as_elaborated_type_specifier_enum(
00499         ptr< ::lestes::lang::cplus::sem::as_elaborated_type_specifier_enum > specifier)
00500 {
00501         lassert(specifier); 
00502         if (type_specifier == TS_NONE) {
00503            ptr<declaration_set_type> decls =
00504                    as_id_to_declaration_set::instance()->process(specifier->name_get()->identifier_get() );
00505                 // TODO pt add the invisible forward for the enum if the name was not found
00506            lassert(decls && decls->size() == 1);
00507 
00508                 other_type = (*decls->begin())->type_get();
00509       
00510       type_specifier = TS_OTHER;
00511         } else {
00512                 // TODO pt report error: multiple types in declaration 
00513         } 
00514 }
00515 
00516 /*!
00517   Visits instance of as_class_specifier.
00518   \param specifier  The instance to visit.
00519 */
00520 void as_declaration_specifier2properties::visit_as_class_specifier(
00521         ptr< ::lestes::lang::cplus::sem::as_class_specifier > specifier)
00522 {
00523         lassert(specifier); 
00524         if (type_specifier == TS_NONE) {
00525                 // TODO pt lookup
00526                 //other_type = lookup(specifier->name_get(),specifier->key_get()); 
00527                 // TODO pt rename wchar_t to wchar
00528                 other_type = ss_type_wchar_t::instance(); // temporarily wchar
00529       type_specifier = TS_OTHER;
00530         } else {
00531                 // TODO pt report error: multiple types in declaration 
00532         } 
00533 }
00534 
00535 end_package(sem);
00536 end_package(cplus);
00537 end_package(lang);
00538 end_package(lestes);
00539 

Generated on Mon Feb 12 18:22:20 2007 for lestes by doxygen 1.5.1-20070107