sa_usings.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 #include <lestes/common.hh>
00029 #include <lestes/lang/cplus/sem/as_decl.g.hh>
00030 #include <lestes/lang/cplus/sem/as_id_to_ss_decl_name.g.hh>
00031 #include <lestes/lang/cplus/sem/li_by_name_in_single_scope.g.hh>
00032 #include <lestes/lang/cplus/sem/lu_typedef.hh>
00033 #include <lestes/lang/cplus/sem/sa_context.g.hh>
00034 #include <lestes/lang/cplus/sem/sa_loggers.hh>
00035 #include <lestes/lang/cplus/sem/sa_scope_of_as_name.g.hh>
00036 #include <lestes/lang/cplus/sem/sa_usings.g.hh>
00037 #include <lestes/lang/cplus/sem/ss_decl_name.g.hh>
00038 #include <lestes/lang/cplus/sem/ss_declaration.g.hh>
00039 #include <lestes/lang/cplus/sem/ss_misc.g.hh>
00040 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00041 #include <lestes/lang/cplus/sem/ss_using_target.g.hh>
00042 #include <lestes/lang/cplus/syn/manager.hh>
00043 #include <lestes/msg/logger.hh>
00044 #include <lestes/msg/logger_util.hh>
00045 
00046 #if 0
00047 #include <lestes/lang/cplus/sem/as_access_specifier_to_ss_access_specifier.g.hh>
00048 #include <lestes/lang/cplus/sem/as_base_specifier_to_ss_base_specifier.g.hh>
00049 #include <lestes/lang/cplus/sem/as_class_key_to_ss_access_specifier.g.hh>
00050 #include <lestes/lang/cplus/sem/as_class_key_to_ss_struct_base.g.hh>
00051 #include <lestes/lang/cplus/sem/as_id_to_declaration_set.g.hh>
00052 #include <lestes/lang/cplus/sem/sa_class_declaration.g.hh>
00053 #include <lestes/lang/cplus/sem/sa_class_declaration.m.hh>
00054 #include <lestes/lang/cplus/sem/sa_context.g.hh>
00055 #include <lestes/lang/cplus/sem/sa_decl_seq_compound_pair_creator.g.hh>
00056 #include <lestes/lang/cplus/sem/ss_declaration_to_ss_decl_seq.g.hh>
00057 #include <lestes/lang/cplus/sem/ss_enums.g.hh>
00058 #include <lestes/lang/cplus/sem/ss_statement.g.hh>
00059 #include <lestes/lang/cplus/sem/ss_type2info.g.hh>
00060 #include <lestes/lang/cplus/syn/token.hh>
00061 #endif
00062 
00063 
00064 /*! \file
00065   \brief Handling of using declarations and directives.
00066   
00067   \author TMA
00068  */
00069 
00070 package(lestes);
00071 package(lang);
00072 package(cplus);
00073 package(sem);
00074 
00075 /*!
00076   \invariant !syn::manager::in_disambiguation()
00077  */
00078 void sa_usings::process_declaration(ptr < ::lestes::lang::cplus::sem::as_using_declaration > ud)
00079 {
00080         lassert(!syn::manager::in_disambiguation());
00081 
00082         ptr < source_location > location = ud->location_get();
00083         ptr < ss_declaration_time > dt = ss_declaration_time::create(location->order_get());
00084 
00085         ptr < as_name > name = ud->name_get();
00086         lassert(name->was_qualified_get());
00087 
00088         ptr < ss_decl_name > decl_name = as_id_to_ss_decl_name::instance()->process(name->identifier_get());
00089         // FIXME: get scope from qualification
00090         ptr < ss_decl_seq > containing = sa_scope_of_as_name::instance()->extract(name);
00091 
00092         // FIXME: lookup in scope
00093         ptr < declaration_set_type > target_declarations = li_by_name_in_single_scope::instance()->process_preserve_usings(decl_name, containing);
00094 
00095         if ( target_declarations->empty() ) {
00096                 lassert3(false, "declaration of used name not found",location);
00097         }
00098 
00099         for (declaration_set_type::iterator it = target_declarations->begin() ; it != target_declarations->end() ; ++it) {
00100                 ptr < ss_declaration > target_decl = *it;
00101 
00102                 // FIXME: a check shall be done whether the fund declaration
00103                 // does not clash with an existing declaration in the current
00104                 // scope.
00105                 
00106                 // FIXME: lookup in scope
00107                 ptr < ss_declaration > real_decl = ss_using_target::instance()->process(target_decl);
00108 
00109                 // FIXME: foreach looked up:
00110                 sa_class_declaration_logger << "using\n" << msg::eolog;
00111                 ptr < ss_using_declaration > using_decl = ss_using_declaration::create(
00112                                 location, // location
00113                                 dt, // visible
00114                                 dt, // decl time
00115                                 decl_name, //name
00116                                 sa_context_manager::instance()->current()->ss_get()->scope_get(), // contained in
00117                                 real_decl->type_get(), // type
00118                                 // FIXME: correct?
00119                                 ss_linkage::create("C++", ss_linkage::LINKAGE_EXTERNAL), // linkage
00120                                 //real_decl->linkage_get(), // linkage
00121                                 // FIXME: correct?
00122                                 sa_context_manager::instance()->current()->ss_get()->access_specifier_get(), // access specifier
00123                                 //real_decl->access_specifier_get(), // access specifier
00124                                 ss_storage_class::ST_NONE, // storage class
00125                                 target_decl, // using's target declaration
00126                                 real_decl // real declaration
00127                                 );
00128                 // add to decl_seq:
00129                 sa_context_manager::instance()->current()->ss_get()->scope_get()->contents_get()->push_back(using_decl);
00130         }
00131 }
00132 
00133 /*!
00134   \invariant !syn::manager::in_disambiguation()
00135  */
00136 void sa_usings::process_directive(ptr < ::lestes::lang::cplus::sem::as_using_directive > ud)
00137 {
00138         lassert2(!syn::manager::in_disambiguation(), "invariant");
00139         lassert3(false,"using directives not implemented", ud->location_get());
00140 }
00141 
00142 end_package(sem);
00143 end_package(cplus);
00144 end_package(lang);
00145 end_package(lestes);
00146 

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