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 Declarator type analyser. 00030 00031 Declarator structural analysis and conversion to ss_type. 00032 \author pt 00033 */ 00034 #include <lestes/common.hh> 00035 #include <lestes/lang/cplus/sem/as_declarator_op2ss_type.g.hh> 00036 #include <lestes/lang/cplus/sem/sa_declarator_type.g.hh> 00037 #include <lestes/lang/cplus/sem/as_decl.g.hh> 00038 #include <lestes/lang/cplus/sem/ss_type.g.hh> 00039 #include <lestes/lang/cplus/sem/sa_loggers.hh> 00040 #include <lestes/msg/logger.hh> 00041 #include <lestes/msg/logger_util.hh> 00042 #if 0 00043 #include <lestes/std/source_location.hh> 00044 #include <lestes/lang/cplus/sem/sa_declarator.g.hh> 00045 #include <lestes/lang/cplus/sem/sa_decl_spec.g.hh> 00046 #include <lestes/lang/cplus/sem/as_other.g.hh> 00047 #include <lestes/lang/cplus/sem/ss_type_builtin.g.hh> 00048 #include <lestes/lang/cplus/sem/ss_declaration.g.hh> 00049 #include <lestes/lang/cplus/sem/ss_misc.g.hh> 00050 #include <lestes/lang/cplus/sem/ss_decl_name.g.hh> 00051 #include <lestes/lang/cplus/sem/ss_expression.g.hh> 00052 #include <lestes/lang/cplus/sem/ss_statement.g.hh> 00053 00054 #include <iostream> 00055 #endif 00056 00057 package(lestes); 00058 package(lang); 00059 package(cplus); 00060 package(sem); 00061 00062 // TODO pt remove 00063 #if 0 00064 /*! 00065 Returns as_declarator_op visitor. 00066 \return A visitor appropriate for the context. 00067 */ 00068 ptr<as_declarator_op2ss_type> sa_declarator_type_context::create_as_declarator_op2ss_type(void) 00069 { 00070 return as_declarator_op2ss_type::create(decl_specs->type_get()); 00071 } 00072 #endif 00073 00074 typedef list< srp< as_declarator_op > > as_declarator_op_list_type; 00075 00076 /*! 00077 Returns the type of the declarator. 00078 \pre initial != NULL 00079 \pre declarator != NULL 00080 \param start_type The initial type. 00081 \param declarator The the declarator to process. 00082 \return The type of the declarator. 00083 */ 00084 ptr<ss_type> sa_declarator_type::process(ptr<ss_type> start_type, ptr<as_declarator> declarator) 00085 { 00086 sa_declarator_type_logger << "sa_declarator_type::process()\n" << msg::eolog; 00087 00088 lassert(start_type); 00089 lassert(declarator); 00090 00091 // create the appropriate visitor 00092 ptr<as_declarator_op2ss_type> v = as_declarator_op2ss_type::create(start_type); 00093 00094 ptr<as_declarator_op_list_type> lst = declarator->declarator_ops_get(); 00095 00096 sa_declarator_type_logger << "analysing declarator ops\n" << msg::eolog; 00097 00098 // walk through all declarator ops in reverse direction 00099 for (as_declarator_op_list_type::reverse_iterator rit = lst->rbegin(), rend = lst->rend(); 00100 rit != rend; ++rit) { 00101 // classify individual declarator ops 00102 v->process(*rit); 00103 } 00104 00105 sa_declarator_type_logger << "sa_declarator_type::process() end\n" << msg::eolog; 00106 00107 return v->type_get(); 00108 } 00109 00110 end_package(sem); 00111 end_package(cplus); 00112 end_package(lang); 00113 end_package(lestes); 00114 /* vim: set ft=lestes : */
1.5.1-20070107