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/std/source_location.hh>
00036 #include <lestes/lang/cplus/lex/cpp_token.hh>
00037 #include <lestes/lang/cplus/sem/as_declarator_op2ss_type.g.hh>
00038 #include <lestes/lang/cplus/sem/sa_param_declaration_type.g.hh>
00039 #include <lestes/lang/cplus/sem/sa_param_declaration_empty.g.hh>
00040 #include <lestes/lang/cplus/sem/as_cv_qualifier2ss_type.g.hh>
00041 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00042 #include <lestes/lang/cplus/sem/ss_type2cv_unqualified.g.hh>
00043 #include <lestes/lang/cplus/sem/as_decl.g.hh>
00044 #include <lestes/lang/cplus/sem/ss_type2info.g.hh>
00045 #include <lestes/lang/cplus/sem/ss_type_builtin.g.hh>
00046 #if 0
00047 #include <lestes/lang/cplus/sem/ss_misc.g.hh>
00048 #include <lestes/lang/cplus/sem/sa_declarator.g.hh>
00049 #include <lestes/lang/cplus/sem/sa_decl_spec.g.hh>
00050 #include <lestes/lang/cplus/sem/as_other.g.hh>
00051 #include <lestes/lang/cplus/sem/ss_decl_name.g.hh>
00052 #include <lestes/lang/cplus/sem/ss_expression.g.hh>
00053 #endif
00054
00055 package(lestes);
00056 package(lang);
00057 package(cplus);
00058 package(sem);
00059
00060
00061
00062
00063
00064
00065 void as_declarator_op2ss_type::process(ptr<as_declarator_op> dop)
00066 {
00067 dop->accept_as_declarator_op_visitor(this);
00068 }
00069
00070
00071
00072
00073
00074
00075 void as_declarator_op2ss_type::visit_as_ptr_op_star(ptr<as_ptr_op_star> dop)
00076 {
00077 lassert(dop);
00078
00079 typedef list< srp<as_cv_qualifier> > as_cv_qualifier_list;
00080
00081 ptr<as_cv_qualifier2ss_type> acqst =
00082 as_cv_qualifier2ss_type::create(ss_pointer::instance(type));
00083
00084 ptr<as_cv_qualifier_list> lst = dop->cv_qualifiers_get();
00085
00086 for (as_cv_qualifier_list::iterator it = lst->begin(), end = lst->end();
00087 it != end; ++it) {
00088 acqst->process(*it);
00089 }
00090
00091 type = acqst->type_get();
00092 }
00093
00094
00095
00096
00097
00098
00099 void as_declarator_op2ss_type::visit_as_ptr_op_amp(ptr<as_ptr_op_amp> dop)
00100 {
00101 lassert(dop);
00102
00103
00104 if (ss_type2cv_unqualified::create()->process(type)->is_void()) {
00105
00106 return;
00107 }
00108
00109 if (ss_type2info::create()->process(type) == ss_type2info::SS_REFERENCE) {
00110
00111 return;
00112 }
00113
00114 type = ss_reference::instance(type);
00115 }
00116
00117
00118
00119
00120
00121
00122 void as_declarator_op2ss_type::visit_as_declarator_op_func(ptr<as_declarator_op_func> dop)
00123 {
00124 lassert(dop);
00125
00126 typedef ::lestes::std::list< srp<as_param_declaration> > as_param_declaration_list_type;
00127 typedef ::lestes::std::list< srp<ss_type> > ss_type_list_type;
00128
00129 if (ss_type2info::create()->process(type) == ss_type2info::SS_FUNCTION) {
00130
00131 }
00132
00133 ptr<as_param_decl_clause> apdc = dop->parameters_get();
00134 bool ellipsis = apdc->ellipsis_get();
00135
00136 ptr<ss_type_list_type> sstl = ss_type_list_type::create();
00137
00138 ptr<as_param_declaration_list_type> apdl = apdc->parameters_get();
00139 ptr<sa_param_declaration_type> sapdt = sa_param_declaration_type::create();
00140
00141
00142 if (apdl->size() != 1 || !sa_param_declaration_empty::create()->process(apdl->front())) {
00143 for (as_param_declaration_list_type::iterator it = apdl->begin(), end = apdl->end();
00144 it != end; ++it) {
00145
00146
00147 sapdt->process(*it);
00148 sstl->push_back(sapdt->type_get());
00149 }
00150 }
00151
00152
00153 type = ss_function::instance(type,sstl,ellipsis);
00154 }
00155
00156 #if 0
00157
00158
00159
00160
00161
00162 void as_declarator_op2ss_type::visit_as_declarator_op_func(ptr<as_declarator_op_func> dop)
00163 {
00164 lassert(dop);
00165
00166 typedef ::lestes::std::list< srp<as_param_declaration> > as_param_declaration_list_type;
00167 typedef ::lestes::std::list< srp<ss_type> > ss_type_list_type;
00168
00169
00170 ptr<ss_type2info> ssti = ss_type2info::create();
00171 ssti->process(type);
00172
00173 if (ssti->info_get() == ss_type2info::SS_FUNCTION) {
00174
00175 }
00176
00177 ptr<as_param_decl_clause> apdc = dop->parameters_get();
00178 bool ellipsis = apdc->ellipsis_get();
00179
00180 ptr<ss_type_list_type> sstl = ss_type_list_type::create();
00181 parameters = ss_type_list_type::create();
00182
00183 ptr<as_param_declaration_list_type> apdl = apdc->parameters_get();
00184 ptr<sa_param_declaration_type> sapdt = sa_param_declaration_type::create(apdl->size() == 1);
00185
00186 {
00187 as_param_declaration_list_type::iterator it = apdl->begin(), end = apdl->end();
00188
00189 if (apdl->size() == 1)
00190 if (it != end) {
00191 sapdt->process(*it);
00192 ++it;
00193
00194 if (it
00195 }
00196
00197
00198 for (as_param_declaration_list_type::iterator it = apdl->begin(), end = apdl->end();
00199 it != end; ++it) {
00200
00201 sapdt->process(*it);
00202
00203 sstl->push_back(sapdt->norm_type_get());
00204 parameters->push_back(sapdt->param_type_get());
00205 }
00206
00207 if (sstl->size() == 1 && sslt->begin()->is_void()) {
00208
00209 sstl->clear();
00210 parameters->clear();
00211 } else {
00212
00213 for (ss_type_list_type::iterator it = sstl->begin(), end = sstl->end();
00214 it != end; ++it) {
00215 if ((*it)->is_void()) {
00216
00217 *it = ss_sint::instance();
00218 }
00219 }
00220 }
00221
00222
00223
00224
00225
00226
00227 type = ss_function::instance(type,sstl,ellipsis);
00228 type = ss_member_function::instance(type,sstl,ellipsis);
00229 }
00230 #endif
00231
00232
00233
00234
00235
00236
00237 void as_declarator_op2ss_type::visit_as_declarator_op_array(ptr<as_declarator_op_array> dop)
00238 {
00239 lassert(dop);
00240
00241 if (type->is_void()) {
00242
00243
00244 type = ss_type_sint::instance();
00245 } else {
00246 ptr<ss_type2info> sst2i = ss_type2info::create();
00247 sst2i->process(type);
00248 switch (ss_type2info::create()->process(type)) {
00249 case ss_type2info::SS_REFERENCE:
00250
00251 type = ss_type_sint::instance();
00252 break;
00253 case ss_type2info::SS_FUNCTION:
00254
00255 type = ss_type_sint::instance();
00256 break;
00257 default:
00258 break;
00259 }
00260 }
00261
00262
00263
00264
00265
00266 t_size size = 1;
00267 type = ss_array::instance(size,type);
00268 }
00269
00270
00271
00272
00273
00274
00275 void as_declarator_op2ss_type::visit_as_declarator_op_non_constant_array(ptr<as_declarator_op_non_constant_array> dop)
00276 {
00277 lassert(dop);
00278
00279
00280 lassert2(false,"Non constant array is not supported.");
00281 }
00282
00283
00284
00285
00286
00287
00288
00289 void as_declarator_op2ss_type::visit_as_ptr_op_member_ptr(ptr<as_ptr_op_member_ptr> dop)
00290 {
00291 lassert(dop);
00292
00293
00294 lassert2(false,"Member pointer not supported.");
00295 }
00296
00297 #if 0
00298 FUCK THIS ALL
00299
00300
00301
00302
00303
00304 ptr<sa_param_decl_context> sapdc = sa_param_decl_context::create(declaration_context::CTX_PARAMETER,
00305
00306
00307
00308 NULL
00309
00310 );
00311 ptr<sa_param_decl> sapd = sa_param_decl::create(sapdc);
00312
00313
00314
00315 if (last_flag) {
00316 parameters = ss_parameter_declaration_list_type::create();
00317 ulint position = 0;
00318
00319 for (as_param_declaration_list_type::iterator it = apdl->begin(), end = apdl->end();
00320 it != end; ++it) {
00321
00322 sapd->process(*it,++position);
00323 parameters->push_back(sapd->declaration_get());
00324 sstl->push_back(sapd->type_get());
00325 }
00326
00327 } else {
00328 for (as_param_declaration_list_type::iterator it = apdl->begin(), end = apdl->end();
00329 it != end; ++it) {
00330
00331 sapd->process(*it);
00332 sstl->push_back(sapd->type_get());
00333 }
00334
00335 }
00336 #endif
00337
00338 #if 0
00339
00340
00341
00342
00343
00344 void as_declarator_op2ss_type_param::visit_as_declarator_op_func(ptr<as_declarator_op_func> dop)
00345 {
00346 lassert(dop);
00347
00348 typedef ::lestes::std::list< srp<as_param_declaration> > as_param_declaration_list_type;
00349 typedef ::lestes::std::list< srp<ss_type> > ss_type_list_type;
00350 typedef ::lestes::std::list< srp<ss_parameter_declaration> > ss_parameter_declaration_list_type;
00351
00352
00353
00354
00355 ptr<as_param_decl_clause> apdc = dop->parameters_get();
00356 bool ellipsis = apdc->ellipsis_get();
00357 ptr<as_param_declaration_list_type> apdl = apdc->parameters_get();
00358 ptr<ss_type_list_type> sstl = ss_type_list_type::create();
00359
00360
00361 ptr<sa_param_decl_context> sapdc = sa_param_decl_context::create(declaration_context::CTX_PARAMETER,
00362
00363
00364
00365 NULL
00366 );
00367
00368 ptr<sa_param_decl> sapd = sa_param_decl::create(sapdc);
00369
00370 for (as_param_declaration_list_type::iterator it = apdl->begin(), end = apdl->end();
00371 it != end; ++it) {
00372
00373 sapd->process(*it);
00374 sstl->push_back(sapd->type_get());
00375 }
00376
00377 ptr<ss_type> sst = type_get();
00378
00379 sst = ss_function::instance(sst,sstl,ellipsis);
00380
00381 if (last_flag_get()) sst = ss_pointer::instance(sst);
00382 type_set(sst);
00383 }
00384
00385
00386
00387
00388
00389
00390 void as_declarator_op2ss_type_plain::visit_as_declarator_op_func(ptr<as_declarator_op_func> dop)
00391 {
00392 lassert(dop);
00393
00394 typedef ::lestes::std::list< srp<as_param_declaration> > as_param_declaration_list_type;
00395 typedef ::lestes::std::list< srp<ss_type> > ss_type_list_type;
00396
00397
00398
00399
00400 ptr<as_param_decl_clause> apdc = dop->parameters_get();
00401 bool ellipsis = apdc->ellipsis_get();
00402 ptr<as_param_declaration_list_type> apdl = apdc->parameters_get();
00403 ptr<ss_type_list_type> sstl = ss_type_list_type::create();
00404 ptr<sa_param_decl_context> sapdc = sa_param_decl_context::create(
00405 declaration_context::CTX_PARAMETER,
00406
00407 NULL
00408 );
00409 ptr<sa_param_decl> sapd = sa_param_decl::create(sapdc);
00410
00411
00412 for (as_param_declaration_list_type::iterator it = apdl->begin(), end = apdl->end();
00413 it != end; ++it) {
00414
00415 sapd->process(*it);
00416 sstl->push_back(sapd->type_get());
00417 }
00418
00419
00420 type_set(ss_function::instance(type_get(),sstl,ellipsis));
00421 }
00422
00423 #endif
00424
00425 end_package(sem);
00426 end_package(cplus);
00427 end_package(lang);
00428 end_package(lestes);
00429
00430