00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <lestes/common.hh>
00035 #include <lestes/lang/cplus/sem/sa_param_declaration.g.hh>
00036 #include <lestes/std/source_location.hh>
00037 #include <lestes/lang/cplus/sem/as_id_to_ss_decl_name.g.hh>
00038 #include <lestes/lang/cplus/sem/as_decl.g.hh>
00039 #include <lestes/lang/cplus/sem/sa_declarator_type.g.hh>
00040 #include <lestes/lang/cplus/sem/sa_declaration_specifiers.g.hh>
00041 #include <lestes/lang/cplus/sem/sa_declaration_specifier_list.g.hh>
00042 #include <lestes/lang/cplus/sem/ss_misc.g.hh>
00043 #include <lestes/lang/cplus/sem/ss_declaration.g.hh>
00044 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00045 #include <lestes/lang/cplus/sem/ss_decl_name.g.hh>
00046 #include <lestes/lang/cplus/sem/or_or.g.hh>
00047 #include <lestes/lang/cplus/sem/sa_loggers.hh>
00048 #include <lestes/msg/logger.hh>
00049 #include <lestes/msg/logger_util.hh>
00050
00051
00052
00053
00054
00055
00056
00057 package(lestes);
00058 package(lang);
00059 package(cplus);
00060 package(sem);
00061
00062
00063 #if 0
00064
00065
00066
00067
00068
00069
00070 ptr<as_declarator_op2ss_type> sa_param_type_context::create_as_declarator_op2ss_type(ptr<ss_type> type)
00071 {
00072 lassert(type);
00073
00074 return as_declarator_op2ss_type_param::create(type);
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 ptr<as_declarator_op2ss_type> sa_param_decl_context::create_as_declarator_op2ss_type(ptr<ss_type> type)
00084 {
00085 lassert(type);
00086
00087 return as_declarator_op2ss_type_param::create(type);
00088 }
00089 #endif
00090
00091
00092
00093
00094
00095
00096
00097
00098 void sa_param_declaration::process( ptr<as_param_declaration> decl)
00099 {
00100 sa_param_declaration_logger << "sa_param_declaration::process()\n" << msg::eolog;
00101
00102 lassert(decl);
00103
00104
00105
00106 #if 1
00107
00108
00109 ptr<sa_declaration_specifiers> sads =
00110 sa_declaration_specifier_list::create()->process(decl->location_get(),decl->declaration_specifiers_get());
00111
00112 sa_param_declaration_logger << "checking specifiers\n" << msg::eolog;
00113
00114 if (sads->virtual_flag_get() || sads->explicit_flag_get() || sads->friend_flag_get() ||
00115 sads->inline_flag_get()) {
00116
00117 sa_param_declaration_logger << "invalid specifier flag\n" << msg::eolog;
00118 }
00119 #endif
00120
00121
00122 ss_storage_class::type storage_class = sads->storage_class_get();
00123 switch (storage_class) {
00124 case ss_storage_class::ST_NONE:
00125 break;
00126 case ss_storage_class::ST_AUTO:
00127 case ss_storage_class::ST_REGISTER:
00128 sa_param_declaration_logger << "got storage class\n" << msg::eolog;
00129 break;
00130 case ss_storage_class::ST_STATIC:
00131 case ss_storage_class::ST_EXTERN:
00132 case ss_storage_class::ST_MUTABLE:
00133 case ss_storage_class::ST_TYPEDEF:
00134
00135 sa_param_declaration_logger << "got invalid storage class specifier\n" << msg::eolog;
00136 break;
00137 default:
00138 lassert2(false,"You should never get here");
00139 }
00140
00141 sa_param_declaration_logger << "analysing the declarator\n" << msg::eolog;
00142
00143 ptr<as_declarator> declarator = decl->declarator_get();
00144
00145 ptr<sa_declarator_type> sadt = sa_declarator_type::create();
00146 ptr<ss_type> type = sadt->process(sads->type_get(),declarator);
00147
00148
00149 ptr<source_location> loc = declarator->location_get();
00150 ptr<ss_declaration_time> tm = ss_declaration_time::create(loc->order_get());
00151
00152 ptr<as_name> name = declarator->name_get();
00153
00154 ptr<ss_decl_name> decl_name;
00155
00156 if (name)
00157 decl_name = as_id_to_ss_decl_name::instance()->process(name->identifier_get());
00158 else
00159 decl_name = ss_dummy_name::create(loc);
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 ptr<ss_decl_seq> param_scope = scope_get();
00176
00177 sa_param_declaration_logger << "creating the parameter declaration\n" << msg::eolog;
00178
00179 ptr<ss_declaration> declaration = ss_parameter_declaration::create(
00180 loc,
00181 tm,
00182 tm,
00183 decl_name,
00184 param_scope,
00185 type,
00186
00187 ss_linkage::create("C++",ss_linkage::LINKAGE_NO),
00188 ss_access_specifier::ACCESS_PUBLIC,
00189 storage_class,
00190
00191 ss_declaration_time::infinity(),
00192
00193 NULL,
00194 index++
00195 );
00196
00197 sa_param_declaration_logger << "adding the parameter\n" << msg::eolog;
00198
00199 param_scope->contents_get()->push_back(declaration);
00200
00201 sa_param_declaration_logger << "sa_param_declaration::process() end\n" << msg::eolog;
00202 }
00203
00204
00205 #if 0
00206
00207 ptr<as_declarator_op2ss_type> v = context->create_as_declarator_op2ss_type(sads->type_get());
00208
00209 ptr<as_declarator> declarator = decl->declarator_get();
00210
00211 typedef ::lestes::std::list< srp<as_declarator_op> > as_declarator_op_list_type;
00212 ptr<as_declarator_op_list_type> lst = declarator->declarator_ops_get();
00213
00214 {
00215 as_declarator_op_list_type::reverse_iterator rit = lst->rbegin(), rend = lst->rend(),
00216 tit = lst->rbegin();
00217
00218 ++tit;
00219
00220
00221 for ( ; tit != rend; ++rit, ++tit) {
00222
00223 v->process(*rit,false);
00224 }
00225
00226
00227 v->process(*rit,true);
00228 }
00229 #endif
00230
00231
00232 #if 0
00233
00234
00235
00236
00237
00238
00239 void sa_param_type::process(ptr<as_param_declaration> decl)
00240 {
00241
00242 lassert(decl);
00243
00244 ptr<sa_decl_spec_context> sadsc = sa_decl_spec_context::create(declaration_context::CTX_PARAMETER);
00245 ptr<sa_decl_spec> sads = sa_decl_spec::create(sadsc);
00246
00247 sads->process(decl->declaration_specifiers_get());
00248
00249
00250 ptr<as_declarator_op2ss_type> v = context->create_as_declarator_op2ss_type(sads->type_get());
00251
00252 ptr<as_declarator> declarator = decl->declarator_get();
00253
00254 typedef ::lestes::std::list< srp<as_declarator_op> > as_declarator_op_list_type;
00255 ptr<as_declarator_op_list_type> lst = declarator->declarator_ops_get();
00256
00257 {
00258 as_declarator_op_list_type::reverse_iterator rit = lst->rbegin(), rend = lst->rend(),
00259 tit = lst->rbegin();
00260 ++tit;
00261
00262
00263 for ( ; tit != rend; ++rit, ++tit) {
00264
00265 v->process(*rit,false);
00266 }
00267
00268
00269 v->process(*rit,true);
00270 }
00271
00272 if (sads->virtual_flag_get() ||
00273 sads->explicit_flag_get() ||
00274 sads->inline_flag_get()) {
00275
00276 }
00277
00278 ss_storage_class::type stc = sads->storage_class_get();
00279
00280 switch (stc) {
00281 case ss_storage_class::ST_NONE:
00282 case ss_storage_class::ST_AUTO:
00283 case ss_storage_class::ST_REGISTER:
00284
00285 break;
00286 case ss_storage_class::ST_STATIC:
00287 case ss_storage_class::ST_EXTERN:
00288 case ss_storage_class::ST_MUTABLE:
00289 case ss_storage_class::ST_TYPEDEF:
00290
00291 break;
00292 default:
00293 lassert2(false,"You should never get here");
00294 }
00295
00296 type = v->type_get();
00297 }
00298 #endif
00299
00300 end_package(sem);
00301 end_package(cplus);
00302 end_package(lang);
00303 end_package(lestes);
00304