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

mangle.cc

Go to the documentation of this file.
00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT!         -*- c++ -*-
00002 
00003 #include "mangle.h"
00004 #include "mangle_i.h"
00005 
00006 #line 43 "mangle.cpp"
00007 
00008 using namespace std;
00009 
00010 #line 45 "mangle.cpp"
00011 
00012 
00013 Mangle::Mangle()
00014   : _env (new Namespace_scope (0, ""))
00015 {}
00016 
00017 #line 50 "mangle.cpp"
00018 
00019 
00020 void
00021 Mangle::enter_scope(const std::string& scopename, char symprefix)
00022 {
00023   _scope.push_back(Sstring() << symprefix << scopename);
00024 
00025   _env = new Namespace_scope (dynamic_cast<Namespace_scope*>(_env), 
00026                               _env->get_unique_name (scopename + "::"));
00027 }
00028 
00029 #line 60 "mangle.cpp"
00030 
00031 
00032 void
00033 Mangle::leave_scope()
00034 {
00035   _scope.pop_back();
00036 
00037   _env = _env->get_parent();
00038 }
00039 
00040 #line 69 "mangle.cpp"
00041 
00042 std::string
00043 Mangle::current_scope()
00044 {
00045   string scope;
00046   for (Scopes::iterator i = _scope.begin(); i != _scope.end(); ++i)
00047     {
00048       scope += '\'';
00049       scope += *i;
00050     }
00051   return scope;
00052 }
00053 
00054 #line 81 "mangle.cpp"
00055 
00056 
00057 std::string&
00058 Mangle::insert(/*const*/ Ptree& name,
00059                 char symprefix)
00060 {
00061   cerr << "SYM entering " << name.ToString() << " in scope "
00062        << current_scope();
00063 
00064   // Add to scope
00065 
00066   Variable_symbol* sym = new Variable_symbol (/* XXX */ Type(), 
00067                                               s_None,
00068                                               0, 0, Symbol::st_Defined);
00069 
00070   _env->add_symbol (name.ToString(), sym);
00071 
00072   assert (_env->lookup_here (name.ToString(), true).untag == sym);
00073 
00074   _map[sym] = Sstring() << "C" << current_scope() << '\'' << symprefix 
00075                         << name.ToString();
00076 
00077   cerr << " with name " << _map[sym] << endl;
00078   return _map[sym];
00079 }
00080 
00081 #line 106 "mangle.cpp"
00082 
00083 
00084 bool 
00085 Mangle::lookup_global_name(/*const*/ Ptree& name,
00086                             std::string* out_global_name)
00087 {
00088   cerr << "SYM looking up " << name.ToString();
00089 
00090   if (Symbol* s =_env->lookup_unqualified (name.ToString()).untag )
00091     {
00092       cerr << ": " << _map[s] << endl;
00093       
00094       *out_global_name = _map[s];
00095       return true;
00096     }
00097   
00098   cerr << " FAILED" << endl;
00099   return false;
00100 }

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