sa_class_creation.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 #include <lestes/lang/cplus/sem/ss_type.g.hh>
00029 #include <lestes/lang/cplus/sem/ss_misc.g.hh>
00030 #include <lestes/lang/cplus/sem/ss_expression.g.hh>
00031 #include <lestes/lang/cplus/sem/ss_decl_name.g.hh>
00032 #include <lestes/lang/cplus/sem/ss_declaration.g.hh>
00033 #include <lestes/lang/cplus/sem/ss_statement.g.hh>
00034 #include <lestes/lang/cplus/sem/ss_enums.g.hh>
00035 #include <lestes/lang/cplus/sem/sa_decl_seq_compound_pair_creator.g.hh>
00036 #include <lestes/std/pair.hh>
00037 
00038 #include <lestes/std/dumper.hh>
00039 #include <fstream>
00040 
00041 /*! \file
00042   \author TMA
00043  */
00044 
00045 package(lestes);
00046 package(lang);
00047 package(cplus);
00048 package(sem);
00049 
00050 void run()
00051 {
00052         /* these are conceivably comming from the context */
00053         ptr < source_location > loc = source_location::create(file_info::create("",NULL),1,1);
00054         ptr < ss_compound_stmt > parent_stmt = ss_compound_stmt::root_instance();
00055         ptr < ss_decl_seq > parent_scope = ss_decl_seq::root_instance();
00056         ss_access_specifier::type access_specifier = ss_access_specifier::ACCESS_PUBLIC;
00057         
00058 
00059         /* these could be comming from the handled thing */
00060         /* their form is not fixed. they might come in different flavor */
00061         ptr < ss_decl_name > name = ss_ordinary_name::create(loc, "name_of_the_class");
00062         ptr < ::lestes::std::list < srp < ss_base_specifier > > > base_class_list = ::lestes::std::list < srp < ss_base_specifier > >::create();
00063 
00064         /* these are the ``true'' local variables */
00065 
00066         ptr < pair < srp < ss_decl_seq >, srp < ss_compound_stmt > > > p = sa_decl_seq_compound_pair_creator::instance()->process(loc, parent_scope, parent_stmt);
00067 
00068         ptr < ss_decl_seq > decl_seq = p->first;
00069         ptr < ss_compound_stmt > stmt = p->second;
00070 
00071 
00072         ptr < ss_class > a_class = ss_class::create(
00073                         decl_seq, /* members */
00074                         ss_decl_seq::root_instance()->declared_by_get(), /* declaration */
00075                         // FIXME more complicated approach needed
00076                         // to handle the POD requirements wrt/ to base classes
00077                         true, /* POD */
00078                         ss_declaration_time::infinity(), /* completition time */
00079                         base_class_list /* bases */
00080                         /* descendants */
00081                         );
00082 
00083 
00084 
00085         ptr < ss_structure_declaration > class_decl = ss_structure_declaration::create(
00086                         loc, // location
00087                         ss_declaration_time::create(loc->order_get()), // visible
00088                         ss_declaration_time::create(loc->order_get()), // decl time
00089                         name, //name
00090                         parent_scope, // contained in
00091                         a_class, // type
00092                         ss_linkage::create("C++", ss_linkage::LINKAGE_EXTERNAL), // linkage
00093                         // FIXME: lookup needed here:
00094                         access_specifier, // access specifier
00095                         ss_storage_class::ST_NONE, // storage class
00096                         ::lestes::std::set< srp< ss_struct_base > >::create(), // friends
00097                         decl_seq
00098                         );
00099 
00100         ptr < ss_injected_class_declaration > class_decl_alias = ss_injected_class_declaration::create(
00101                         loc, // location
00102                         ss_declaration_time::create(loc->order_get()), // visible
00103                         ss_declaration_time::create(loc->order_get()), // decl time
00104                         name, //name
00105                         parent_scope, // contained in
00106                         a_class, // type
00107                         ss_linkage::create("C++", ss_linkage::LINKAGE_EXTERNAL), // linkage
00108                         ss_access_specifier::ACCESS_PUBLIC, // access specifier
00109                         ss_storage_class::ST_NONE, // storage class
00110                         class_decl // real class
00111                         );
00112 
00113         /* fill 'em with THE RIGHT values */
00114         a_class->decl_set(class_decl);
00115         decl_seq->declared_by_set(class_decl);
00116         decl_seq->contents_get()->push_back(class_decl_alias);
00117         parent_scope->contents_get()->push_back(class_decl);
00118 
00119         ::std::ofstream f("sa_class_creation.test.xml");
00120 	::lestes::std::dumper::dump(f, a_class);
00121         f.close();
00122         //lassert2(false, "AAAAAAAAAAAAAAAAAAAAAAA");
00123         //lassert2(false, "BBBBBBBBBBBBBBBBBBBBBBB");
00124 }
00125 
00126 end_package(sem);
00127 end_package(cplus);
00128 end_package(lang);
00129 end_package(lestes);
00130 
00131 int main()
00132 {
00133 	::lestes::lang::cplus::sem::run();
00134 }

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