Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

symbol_table.cc

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #include "symbol_table.h"
00004 #include "symbol_table_i.h"
00005 
00006 #line 101 "symbol_table.cpp"
00007 
00008 /****************************** Symbol_table *****************************/
00009 
00010 Symbol_table Symbol_table::instance;
00011 #line 105 "symbol_table.cpp"
00012 
00013 const char* Symbol_table::dump_flags = "";
00014 
00015 #line 107 "symbol_table.cpp"
00016 
00021 Symbol_table::Symbol_table()
00022 { }
00023 
00024 #line 114 "symbol_table.cpp"
00025 
00026 
00027 Symbol_table::~Symbol_table()
00028 { }
00029 
00030 #line 118 "symbol_table.cpp"
00031 
00033 void
00034 Symbol_table::add_symbol(std::string name, std::string::size_type base_len, Symbol* sym)
00035 {
00036     content_type::iterator i = content.find(name);
00037     if (i != content.end()) {
00038         /* symbol already there; for example, `int stat(...)' and
00039            `struct stat' */
00040         if (sym->is_tagged()) {
00041             if (!i->second.tag || i->second.tag == i->second.untag)
00042                 /* function there, structure being added. I guess
00043                    the second part can't happen */
00044                 i->second.tag = sym;
00045             else
00046                 compile_error("redeclaration of `" + name + "' not allowed");
00047         } else {
00048             if (i->second.tag == i->second.untag)
00049                 /* structure already there, function being added */
00050                 i->second.untag = sym;
00051             else
00052                 compile_error("redeclaration of `" + name + "' not allowed");
00053         }
00054     } else {
00055         /* symbol does not exist yet */
00056         if (sym->is_tagged())
00057             content[name] = Symbol_pair(sym, sym);
00058         else
00059             content[name] = Symbol_pair(sym, 0);
00060     }
00061     sym->set_name(name, base_len);
00062 }
00063 
00064 #line 150 "symbol_table.cpp"
00065 
00070 void
00071 Symbol_table::set_peer(Symbol* orig, Symbol* faelschung)
00072 {
00073     assert(!orig->is_tagged());
00074     assert(faelschung->is_tagged());
00075     content[orig->get_name()].tag = faelschung;
00076 }
00077 
00078 #line 162 "symbol_table.cpp"
00079 
00081 Symbol_pair
00082 Symbol_table::get_symbol(std::string name) const
00083 {
00084     content_type::const_iterator i = content.find(name);
00085     if (i != content.end())
00086         return i->second;
00087     else
00088         return Symbol_pair(0, 0);
00089 }
00090 
00091 #line 173 "symbol_table.cpp"
00092 
00094 void
00095 Symbol_table::dump(std::ostream& out)
00096 {
00097     for (content_type::const_iterator i = content.begin(); i != content.end(); ++i) {
00098         out << i->first << ":\n";
00099         i->second.untag->dump(out);
00100         out << "\n";
00101         if (i->second.tag && i->second.tag != i->second.untag)
00102             i->second.tag->dump(out), out << "\n";
00103     }
00104 }
00105 
00106 #line 186 "symbol_table.cpp"
00107 
00108 bool
00109 Symbol_table::has_dump_flag(char c)
00110 {
00111     const char* p = dump_flags;
00112     while (*p)
00113         if (*p++ == c)
00114             return true;
00115     return false;
00116 }
00117 
00118 #line 196 "symbol_table.cpp"
00119 
00120 void
00121 Symbol_table::clear()
00122 {
00123     content_type().swap(content);
00124 }
00125 
00126 #line 211 "symbol_table.cpp"
00127 
00128 
00129 Symbol::~Symbol()
00130 { 
00131     // std::cout << "destroy " << (void*)this << "\n";
00132 }
00133 
00134 #line 217 "symbol_table.cpp"
00135 
00137 Abstract_scope*
00138 Symbol::get_scope() 
00139 {
00140     return 0;
00141 }
00142 
00143 #line 224 "symbol_table.cpp"
00144 
00146 void
00147 Symbol::set_status(Status st)
00148 {
00149     assert(st >= status);       // we can only raise the status,
00150                                 // there's no way to undefine
00151                                 // something
00152     status = st;
00153 }
00154 
00155 #line 234 "symbol_table.cpp"
00156 
00157 std::string
00158 Symbol::get_basename() const
00159 {
00160     // return name.substr(name.length() - base_len);
00161     return Symbol_name::get_basename_from_symbol(name, base_len);
00162 }
00163 
00164 #line 241 "symbol_table.cpp"
00165 
00168 void
00169 Symbol::dump(std::ostream& out)
00170 {
00171     static const char*const names[] = {
00172         "variable",
00173         "namespace",
00174         "typedef",
00175         "function",
00176         "enum",
00177         "class",
00178         "union",
00179         "class template"
00180     };
00181     const char* st = is_defined() ? "" : is_declared() ? "undefined " : "undeclared ";
00182 
00183     out << "- " << st << names[get_kind()];
00184 }
00185 
00186 #line 261 "symbol_table.cpp"
00187 
00188 /**************************** Type_symbol ****************************/
00189 
00190 
00191 Type_symbol::Type_symbol()
00192     : Symbol()
00193 { }
00194 
00195 #line 268 "symbol_table.cpp"
00196 
00197 
00198 Type_symbol::~Type_symbol()
00199 { }
00200 
00201 #line 272 "symbol_table.cpp"
00202 
00204 Type
00205 Type_symbol::get_type() const
00206 {
00207     return Type::get_named_type(get_name());
00208 }

Generated on Mon Feb 10 17:32:57 2003 for VFiasco Semantics Compiler by doxygen1.2.15