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_declaration_specifier_list.g.hh>
00036 #include <lestes/lang/cplus/sem/sa_declaration_specifier_list.m.hh>
00037 #include <lestes/lang/cplus/sem/as_decl.g.hh>
00038 #include <lestes/lang/cplus/sem/sa_declaration_specifiers.g.hh>
00039 #include <lestes/lang/cplus/sem/as_declaration_specifier2properties.g.hh>
00040 #include <lestes/lang/cplus/sem/ss_type_builtin.g.hh>
00041 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00042
00043 package(lestes);
00044 package(lang);
00045 package(cplus);
00046 package(sem);
00047
00048
00049
00050
00051
00052
00053
00054
00055 ptr<sa_declaration_specifiers> sa_declaration_specifier_list::process(ptr<source_location> loc, ptr<as_declaration_specifier_list_type> lst)
00056 {
00057
00058 ptr<as_declaration_specifier2properties> v = as_declaration_specifier2properties::create();
00059
00060
00061 for (as_declaration_specifier_list_type::iterator it = lst->begin(), end = lst->end();
00062 it != end; ++it) {
00063
00064 v->process(*it);
00065 }
00066
00067 ptr<ss_type> type;
00068
00069
00070 switch (v->type_specifier_get()) {
00071 case as_declaration_specifier2properties::TS_NONE:
00072
00073 if (!v->short_flag_get() && !v->long_flag_get() &&
00074 !v->signed_flag_get() && !v->unsigned_flag_get()) {
00075
00076 report << declaration_without_type << loc;
00077 }
00078
00079 case as_declaration_specifier2properties::TS_INT:
00080 if (v->unsigned_flag_get()) {
00081 if (v->short_flag_get()) {
00082 type = ss_type_ushort::instance();
00083 } else if (v->long_flag_get()) {
00084 type = ss_type_ulong::instance();
00085 } else {
00086 type = ss_type_uint::instance();
00087 }
00088 } else {
00089
00090 if (v->short_flag_get()) {
00091 type = ss_type_sshort::instance();
00092 } else if (v->long_flag_get()) {
00093 type = ss_type_slong::instance();
00094 } else {
00095 type = ss_type_sint::instance();
00096 }
00097 }
00098 break;
00099 case as_declaration_specifier2properties::TS_CHAR:
00100 if (v->short_flag_get() || v->long_flag_get()) {
00101
00102 report << invalid_char_specifier << loc;
00103 }
00104 if (v->signed_flag_get()) {
00105 type = ss_type_schar::instance();
00106 } else if (v->unsigned_flag_get()) {
00107 type = ss_type_uchar::instance();
00108 } else {
00109 type = ss_type_pchar::instance();
00110 }
00111 break;
00112 case as_declaration_specifier2properties::TS_DOUBLE:
00113 if (v->signed_flag_get() || v->unsigned_flag_get() || v->short_flag_get()) {
00114
00115 report << invalid_double_specifier << loc;
00116 }
00117 if (v->long_flag_get()) {
00118 type = ss_type_ldouble::instance();
00119 } else {
00120 type = ss_type_double::instance();
00121 }
00122 break;
00123 case as_declaration_specifier2properties::TS_OTHER:
00124 if (v->signed_flag_get() || v->unsigned_flag_get() || v->short_flag_get() || v->long_flag_get()) {
00125
00126 }
00127 type = v->other_type_get();
00128 break;
00129 default:
00130 lassert(false);
00131 break;
00132 }
00133
00134
00135 if (v->const_flag_get()) type = ss_const::instance(type);
00136 if (v->volatile_flag_get()) type = ss_volatile::instance(type);
00137
00138
00139 return sa_declaration_specifiers::create(type,v->storage_class_get(), v->explicit_flag_get(),
00140 v->inline_flag_get(), v->virtual_flag_get(), v->friend_flag_get());
00141 }
00142
00143 end_package(sem);
00144 end_package(cplus);
00145 end_package(lang);
00146 end_package(lestes);
00147