sa_param_declaration_type.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 /*!
00029   \brief Parameter declaration type analysis.
00030 
00031   Transformation of parameter declaration to SS type.
00032 */
00033 #include <lestes/common.hh>
00034 #include <lestes/lang/cplus/sem/as_decl.g.hh>
00035 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00036 #include <lestes/lang/cplus/sem/sa_param_declaration_type.g.hh>
00037 #include <lestes/lang/cplus/sem/sa_declaration_specifier_list.g.hh>
00038 #include <lestes/lang/cplus/sem/sa_declaration_specifiers.g.hh>
00039 #include <lestes/lang/cplus/sem/sa_declarator_type.g.hh>
00040 #include <lestes/lang/cplus/sem/ss_type2param_type.g.hh>
00041 #include <lestes/lang/cplus/sem/ss_type_builtin.g.hh>
00042 #include <lestes/lang/cplus/sem/sa_loggers.hh>
00043 #include <lestes/msg/logger.hh>
00044 #include <lestes/msg/logger_util.hh>
00045 
00046 package(lestes);
00047 package(lang);
00048 package(cplus);
00049 package(sem);
00050 
00051 /*!
00052   Extracts type from parameter declaration and
00053   sets it into type field.
00054   \pre decl != NULL
00055   \param decl  The parameter declaration to process.
00056 */
00057 void sa_param_declaration_type::process(ptr<as_param_declaration> decl)
00058 {
00059         sa_param_declaration_type_logger << "sa_param_declaration_type::process()\n" << msg::eolog;
00060 
00061         lassert(decl);
00062         
00063         sa_param_declaration_type_logger << "analysing declaration specifiers\n" << msg::eolog;
00064         
00065         // analyse the declaration specifiers
00066         ptr<sa_declaration_specifiers> sads =
00067                 sa_declaration_specifier_list::create()->process(decl->location_get(),decl->declaration_specifiers_get());
00068 
00069         sa_param_declaration_type_logger << "checking specifiers\n" << msg::eolog;
00070         // check disallowed declaration specifiers
00071         if (sads->virtual_flag_get() || sads->explicit_flag_get() || sads->friend_flag_get() ||
00072                  sads->inline_flag_get() || sads->storage_class_get() != ss_storage_class::ST_NONE) {
00073                 // TODO pt report error: invalid specifier
00074                 sa_param_declaration_type_logger << "invalid specifier flag\n" << msg::eolog;
00075         }
00076                  
00077         sa_param_declaration_type_logger << "analysing the declarator\n" << msg::eolog;
00078                 
00079         // get the type from the declarator     
00080         ptr<sa_declarator_type> sadt = sa_declarator_type::create();
00081         type = sadt->process(sads->type_get(),decl->declarator_get());
00082 
00083         sa_param_declaration_type_logger << "normalizing type\n" << msg::eolog;
00084 
00085         // normalize the type of the parameter
00086         type = ss_type2param_type::create()->process(type);
00087 
00088         sa_param_declaration_type_logger << "checking void type\n" << msg::eolog;
00089         
00090         // check void
00091         if (type->is_void()) {
00092                 sa_param_declaration_type_logger << "the type is void\n" << msg::eolog;
00093                 // TODO pt report error: parameter type is void
00094                 type = ss_type_sint::instance();
00095         }
00096         
00097         sa_param_declaration_type_logger << "sa_param_declaration_type::process() end\n" << msg::eolog;
00098 }
00099 
00100 end_package(sem);
00101 end_package(cplus);
00102 end_package(lang);
00103 end_package(lestes);
00104 

Generated on Mon Feb 12 18:23:13 2007 for lestes by doxygen 1.5.1-20070107