ss_decl_name_matcher.cc

Go to the documentation of this file.
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 #include <lestes/lang/cplus/sem/ss_decl_name.g.hh>
00029 #include <lestes/lang/cplus/sem/ss_decl_name_matcher.g.hh>
00030 
00031 package(lestes);
00032 package(lang);
00033 package(cplus);
00034 package(sem);
00035 
00036 bool ss_decl_name_matcher::match( ptr< ss_decl_name > n1, ptr< ss_decl_name > n2 )
00037 {
00038         lassert( n1 && n2 );
00039         /* can be instance() when suported */
00040         ptr<ss_decl_name_matcher> m = ss_decl_name_matcher::create();
00041 
00042         lassert( m->state == READY );
00043 
00044         n1->accept_ss_decl_name_visitor(m);
00045         n2->accept_ss_decl_name_visitor(m);
00046         n1->accept_ss_decl_name_visitor(m);
00047 
00048         lassert( m->state == HAVE_RESULT );
00049         m->state = READY;
00050         return m->result;
00051 }
00052 
00053 #define define_matcher_visit( type )                            \
00054         void ss_decl_name_matcher::visit_##type( ptr< type > o )\
00055         {                                                       \
00056                 static ptr<type> arg1 = NULL;                   \
00057                 switch (state) {                                \
00058                 case READY:                                     \
00059                         lassert( !arg1 );                       \
00060                         arg1 = o;                               \
00061                         state = GOT_ARG1;                       \
00062                         break;                                  \
00063                 case GOT_ARG1:                                  \
00064                         if (arg1)                               \
00065                                 result = arg1->matches_same(o); \
00066                         else                                    \
00067                                 result = false;                 \
00068                         state = NEED_CLEANUP;                   \
00069                         break;                                  \
00070                 case NEED_CLEANUP:                              \
00071                         lassert( arg1 );                        \
00072                         arg1 = NULL;                            \
00073                         state = HAVE_RESULT;                    \
00074                         break;                                  \
00075                 case HAVE_RESULT:                               \
00076                         lassert(false);                         \
00077                         break;                                  \
00078                 }                                               \
00079         }
00080 
00081 define_matcher_visit( ss_ordinary_name );
00082 define_matcher_visit( ss_conversion_name );
00083 define_matcher_visit( ss_dummy_name );
00084 define_matcher_visit( ss_operator_new );
00085 define_matcher_visit( ss_operator_delete );
00086 define_matcher_visit( ss_operator_new_array );
00087 define_matcher_visit( ss_operator_delete_array );
00088 define_matcher_visit( ss_operator_add );
00089 define_matcher_visit( ss_operator_sub );
00090 define_matcher_visit( ss_operator_mul );
00091 define_matcher_visit( ss_operator_div );
00092 define_matcher_visit( ss_operator_mod );
00093 define_matcher_visit( ss_operator_bxor );
00094 define_matcher_visit( ss_operator_band );
00095 define_matcher_visit( ss_operator_bor );
00096 define_matcher_visit( ss_operator_bnot );
00097 define_matcher_visit( ss_operator_lnot );
00098 define_matcher_visit( ss_operator_assign );
00099 define_matcher_visit( ss_operator_assign_add );
00100 define_matcher_visit( ss_operator_assign_sub );
00101 define_matcher_visit( ss_operator_assign_mul );
00102 define_matcher_visit( ss_operator_assign_div );
00103 define_matcher_visit( ss_operator_assign_mod );
00104 define_matcher_visit( ss_operator_assign_bxor );
00105 define_matcher_visit( ss_operator_assign_band );
00106 define_matcher_visit( ss_operator_assign_bor );
00107 define_matcher_visit( ss_operator_assign_shl );
00108 define_matcher_visit( ss_operator_assign_shr );
00109 define_matcher_visit( ss_operator_shr );
00110 define_matcher_visit( ss_operator_shl );
00111 define_matcher_visit( ss_operator_sbl );
00112 define_matcher_visit( ss_operator_sbg );
00113 define_matcher_visit( ss_operator_sbng );
00114 define_matcher_visit( ss_operator_sbnl );
00115 define_matcher_visit( ss_operator_sbe );
00116 define_matcher_visit( ss_operator_sbne );
00117 define_matcher_visit( ss_operator_land );
00118 define_matcher_visit( ss_operator_lor );
00119 define_matcher_visit( ss_operator_inc );
00120 define_matcher_visit( ss_operator_dec );
00121 define_matcher_visit( ss_operator_comma );
00122 define_matcher_visit( ss_operator_access );
00123 define_matcher_visit( ss_operator_access_member );
00124 define_matcher_visit( ss_operator_function_call );
00125 define_matcher_visit( ss_operator_array );
00126 define_matcher_visit( ss_operator_ternary );
00127 
00128 end_package(sem);
00129 end_package(cplus);
00130 end_package(lang);
00131 end_package(lestes);

Generated on Mon Feb 12 18:23:20 2007 for lestes by doxygen 1.5.1-20070107