sa_declarator.test.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 /*! \file
00029   \brief Unit test.
00030   
00031   Unit test for class sa_declarator.
00032   \author pt
00033 */
00034 #include <lestes/common.hh>
00035 #include <lestes/std/file_info.hh>
00036 #include <lestes/std/source_location.hh>
00037 #include <lestes/lang/cplus/sem/sa_decl_spec.g.hh>
00038 #include <lestes/lang/cplus/sem/sa_declarator.g.hh>
00039 #include <lestes/lang/cplus/sem/as_decl.g.hh>
00040 #include <lestes/lang/cplus/sem/as_other.g.hh>
00041 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00042 #include <lestes/lang/cplus/sem/ss_type_builtin.g.hh>
00043 #include <lestes/lang/cplus/sem/ss_statement.g.hh>
00044 #include <lestes/lang/cplus/sem/ss_misc.g.hh>
00045 
00046 package(lestes);
00047 package(lang);
00048 package(cplus);
00049 package(sem);
00050 
00051 using namespace ::std;
00052 
00053 /*!
00054   \brief Tests sa_declarator class.
00055 
00056   Performs testing of sa_declarator class.
00057 */
00058 void sa_declarator_test(void)
00059 {
00060         ptr<file_info> fi = file_info::create("abc",NULL);
00061         ptr<source_location> loc = source_location::create(fi,1,1);
00062 
00063 #if 0
00064         ptr<ss_sp> psp = ss_sp::create(
00065                 loc,
00066                 NULL, // a__ss_sp__psp,
00067                 NULL, //  a__ss_sp__nsp,
00068                 ::lestes::std::list< srp< ss_se > >::create(),  //  a__ss_sp__pse,
00069                 ::lestes::std::list< srp< ss_se > >::create(),  //  a__ss_sp__nse,
00070                 NULL, // ptr< ::lestes::backend::intercode::pi_sp >   a__ss_sp__pi_spe,
00071                 0    //ulint    a__ss_sp__level
00072                 );
00073                 
00074         ptr<ss_sp> nsp = ss_sp::create(
00075                 loc,
00076                 NULL, // a__ss_sp__psp,
00077                 NULL, //  a__ss_sp__nsp,
00078                 ::lestes::std::list< srp< ss_se > >::create(),  //  a__ss_sp__pse,
00079                 ::lestes::std::list< srp< ss_se > >::create(),  //  a__ss_sp__nse,
00080                 NULL, // ptr< ::lestes::backend::intercode::pi_sp >   a__ss_sp__pi_spe,
00081                 0    //ulint    a__ss_sp__level
00082                 );
00083                 
00084         ptr<ss_compound_stmt> containing_compound =
00085                 ss_compound_stmt::create(
00086                         loc, // ptr< ::lestes::std::object >      a__ss_base_with_location__location,
00087                         ::lestes::std::list< srp< ss_label > >::create(), //   a__ss_statement__labels,
00088                         NULL, // a__ss_statement__parent,
00089                         psp, // a__ss_statement__psp,
00090                         nsp, // a__ss_statement__nsp,
00091                         ::lestes::std::list< srp< ss_sp > >::create(), // a__ss_statement__sequence_points,
00092                         NULL,     // ptr< ss_decl_seq >,  a__ss_compound_stmt__decl,
00093                         ::lestes::std::list< srp< ss_statement > >::create() // statements
00094                         );
00095         
00096         ptr<ss_decl_seq> containing_scope = ss_decl_seq::create(
00097                         loc,
00098                         ::lestes::std::list< srp< ss_declaration > >::create(), // a__ss_decl_seq__declarations
00099                         NULL, //ptr< ss_decl_seq > a__ss_decl_seq__parent
00100                         containing_compound, //ptr< ss_compound_stmt > a__ss_decl_seq__compound_stmt
00101                         ::lestes::std::list< srp< ss_using_directive > >::create(), // using directives
00102                         NULL //   ptr< ss_declaration >       a__ss_decl_seq__declared_by         
00103                         );
00104 #endif
00105 
00106         ptr<ss_compound_stmt> containing_compound = ss_compound_stmt::root_instance();
00107         ptr<ss_decl_seq> containing_scope = ss_decl_seq::root_instance();
00108         
00109         typedef sa_declarator_context::as_decl_spec_list_type ds_list_type;
00110         
00111         ptr<ds_list_type> dsl = ds_list_type::create();
00112         ptr<sa_decl_spec_context> sadsc =
00113                 sa_decl_spec_context::create(declaration_context::CTX_NAMESPACE);
00114         ptr<sa_decl_spec> sads = sa_decl_spec::create(sadsc);
00115         dsl->push_back(as_int_simple_type_specifier::create(loc));
00116         sads->process(dsl);
00117 
00118         typedef ::lestes::std::list< srp<as_cv_qualifier> > as_cv_qualifier_list;
00119         ptr<as_cv_qualifier_list> ascvql = as_cv_qualifier_list::create();
00120         ascvql->push_back(as_cv_qualifier_const::create(loc));
00121         
00122         ptr<as_ptr_op_star> aspos = as_ptr_op_star::create(loc,ascvql);
00123         
00124         typedef ::lestes::std::list< srp<as_declarator_op> > as_declarator_op_list;
00125         ptr<as_declarator_op_list> asdol = as_declarator_op_list::create();
00126         asdol->push_back(aspos);
00127         
00128         ptr<as_name> asn = as_name::create(
00129                         loc,
00130                         as_name::create(loc, NULL,as_global_namespace_fake_id::create(loc),false),
00131                         as_global_namespace_fake_id::create(loc),
00132                         true);
00133         
00134         ptr<as_declarator> asd = as_declarator::create(
00135                         loc,
00136                         asn,
00137                         asdol
00138                         );
00139 
00140         ptr<sa_declarator_context> sadc =
00141                 sa_declarator_context::create(
00142                                 declaration_context::CTX_NAMESPACE,
00143                                 containing_scope,
00144                                 sads);
00145         ptr<sa_declarator> sad = sa_declarator::create(sadc);
00146         sad->process(asd);
00147 
00148 }
00149 
00150 end_package(sem);
00151 end_package(cplus);
00152 end_package(lang);
00153 end_package(lestes);
00154 
00155 /*!
00156   \brief Main function.
00157 
00158   Runs the unit test in different namespace.
00159 */
00160 int main(void)
00161 {
00162 	::lestes::lang::cplus::sem::sa_declarator_test();
00163         return 0;
00164 }
00165 /* vim: set ft=lestes : */

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