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 Normalization of SS types in parameters. 00030 00031 Definition of visitor performing normalization of ss_type in function parameters. 00032 */ 00033 #include <lestes/common.hh> 00034 #include <lestes/lang/cplus/sem/ss_type2param_type.g.hh> 00035 #include <lestes/lang/cplus/sem/ss_type.g.hh> 00036 00037 package(lestes); 00038 package(lang); 00039 package(cplus); 00040 package(sem); 00041 00042 /*! 00043 Visits object of any class in ss_struct_base hierarchy. 00044 Does no transformation. 00045 \param obj The object to visit. 00046 */ 00047 void ss_type2param_type::default_ss_struct_base(ptr<ss_struct_base> obj) 00048 { 00049 lassert(obj); 00050 type = obj; 00051 } 00052 00053 /*! 00054 Visits object of any class in ss_builtin_type hierarchy. 00055 Does no transformation. 00056 \pre obj != NULL 00057 \param obj The object to visit. 00058 */ 00059 void ss_type2param_type::default_ss_builtin_type(ptr<ss_builtin_type> obj) 00060 { 00061 lassert(obj); 00062 type = obj; 00063 } 00064 00065 /*! 00066 Visits object of class ss_member_function. 00067 Not allowed. 00068 \pre obj != NULL 00069 \param obj The object to visit. 00070 */ 00071 void ss_type2param_type::visit_ss_member_function(ptr<ss_member_function> obj) 00072 { 00073 lassert(obj); 00074 lassert2(false,"ss_member_function shall not be type of parameter"); 00075 } 00076 00077 /*! 00078 Visits object of class ss_array. 00079 Transforms the type to pointer to the element type. 00080 \pre obj != NULL 00081 \param obj The object to visit. 00082 */ 00083 void ss_type2param_type::visit_ss_array(ptr<ss_array> obj) 00084 { 00085 lassert(obj); 00086 type = ss_pointer::instance(obj->type_get()); 00087 } 00088 00089 /*! 00090 Visits object of class ss_function. 00091 Transforms the type to pointer to the function. 00092 \pre obj != NULL 00093 \param obj The object to visit. 00094 */ 00095 void ss_type2param_type::visit_ss_function(ptr<ss_function> obj) 00096 { 00097 lassert(obj); 00098 // turn the pointer into function 00099 type = ss_pointer::instance(obj); 00100 } 00101 00102 /*! 00103 Visits object of class ss_enum. 00104 Does no transformation. 00105 \pre obj != NULL 00106 \param obj The object to visit. 00107 */ 00108 void ss_type2param_type::visit_ss_enum(ptr<ss_enum> obj) 00109 { 00110 lassert(obj); 00111 type = obj; 00112 } 00113 00114 /*! 00115 Visits object of class ss_const. 00116 Strips the const qualifier. 00117 \pre obj != NULL 00118 \param obj The object to visit. 00119 */ 00120 void ss_type2param_type::visit_ss_const(ptr<ss_const> obj) 00121 { 00122 lassert(obj); 00123 // unconst 00124 type = obj->what_get(); 00125 } 00126 00127 /*! 00128 Visits object of class ss_volatile. 00129 Strips the volatile qualifier. 00130 \pre obj != NULL 00131 \param obj The object to visit. 00132 */ 00133 void ss_type2param_type::visit_ss_volatile(ptr<ss_volatile> obj) 00134 { 00135 lassert(obj); 00136 // unvolatile 00137 type = obj->what_get(); 00138 } 00139 00140 /*! 00141 Visits object of class ss_const_volatile. 00142 Strips the const and volatile qualifiers. 00143 \pre obj != NULL 00144 \param obj The object to visit. 00145 */ 00146 void ss_type2param_type::visit_ss_const_volatile(ptr<ss_const_volatile> obj) 00147 { 00148 lassert(obj); 00149 // unconst unvolatile 00150 type = obj->what_get(); 00151 } 00152 00153 /*! 00154 Visits object of class ss_pointer. 00155 Does no transformation. 00156 \pre obj != NULL 00157 \param obj The object to visit. 00158 */ 00159 void ss_type2param_type::visit_ss_pointer(ptr<ss_pointer> obj) 00160 { 00161 lassert(obj); 00162 type = obj; 00163 } 00164 00165 /*! 00166 Visits object of class ss_member_pointer. 00167 Does no transformation. 00168 \pre obj != NULL 00169 \param obj The object to visit. 00170 */ 00171 void ss_type2param_type::visit_ss_member_pointer(ptr<ss_member_pointer> obj) 00172 { 00173 lassert(obj); 00174 type = obj; 00175 } 00176 00177 /*! 00178 Visits object of class ss_reference. 00179 Sets type information appropriately. 00180 Does no transformation. 00181 \pre obj != NULL 00182 \param obj The object to visit. 00183 */ 00184 void ss_type2param_type::visit_ss_reference(ptr<ss_reference> obj) 00185 { 00186 lassert(obj); 00187 type = obj; 00188 } 00189 00190 /*! 00191 Visits object of class ss_pseudoreference. 00192 Should not happen. 00193 \pre obj != NULL 00194 \param obj The object to visit. 00195 */ 00196 void ss_type2param_type::visit_ss_pseudoreference(ptr<ss_pseudoreference> obj) 00197 { 00198 lassert(obj); 00199 lassert2(false,"pseudoreferences not allowed in parameter type normalizer"); 00200 } 00201 00202 end_package(sem); 00203 end_package(cplus); 00204 end_package(lang); 00205 end_package(lestes);
1.5.1-20070107