li_class_by_name_in_single_scope.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/lang/cplus/sem/lu_filter.g.hh>
00029 #include <lestes/lang/cplus/sem/li_class_by_name_in_single_scope.g.hh>
00030 #include <lestes/lang/cplus/sem/lu_lu.g.hh>
00031 #include <lestes/lang/cplus/sem/ss_decl_name.g.hh>
00032 #include <lestes/lang/cplus/sem/ss_declaration.g.hh>
00033 #include <lestes/lang/cplus/sem/ss_misc.g.hh>
00034 #include <lestes/std/source_location.hh>
00035 #include <lestes/std/set.hh>
00036 #include <lestes/msg/logger.hh>
00037 #include <lestes/msg/logger_util.hh>
00038 
00039 /*! \file
00040   \brief Lookup for classes in a given scope, taking invisible into account
00041   
00042   \author TMA
00043  */
00044 
00045 package(lestes);
00046 package(lang);
00047 package(cplus);
00048 package(sem);
00049 
00050 /*!
00051  */
00052 ptr < ss_structure_declaration > li_class_by_name_in_single_scope::process(ptr < ss_decl_name > name, ptr < ss_decl_seq > scope)
00053 {
00054         ptr < lu_name_filter > nf = lu_name_filter::create(name);
00055         ptr < lu_struct_filter > sf = lu_struct_filter::instance();
00056         ptr < lu_multi_filter > mf = lu_multi_filter::create();
00057         mf->add_filter(sf);
00058         mf->add_filter(nf);
00059         ptr < lu_params > params = lu_params::create(lu_params::UDIR_IGNORE, lu_params::UDECL_IGNORE, lu_params::SKIP_PARENTS,
00060                         ss_declaration_time::create(name->location_get()->order_get()), mf);
00061         ptr < ::lestes::std::set < srp < ss_declaration > > > res = lu_lookup::instance()->main(scope, params);
00062         
00063         lassert2(res->size() <= 1, "There should be at most one declaration of a class for a given name in any single scope.");
00064 
00065         if (res->empty())
00066                 return NULL;
00067         else
00068                 return res->begin()->dncast<ss_structure_declaration>();
00069 }
00070 
00071 end_package(sem);
00072 end_package(cplus);
00073 end_package(lang);
00074 end_package(lestes);
00075 

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