00001
00002
00003 #ifndef symbol_name_h
00004 #define symbol_name_h
00005
00006 #include <string>
00007 #include "type_rep.h"
00008 #include "symbol_table.h"
00009
00010
00011
00012
00013
00014
00015 class Ptree;
00016 class Abstract_scope;
00027 class Symbol_name {
00028 public:
00029 enum Kind {
00030 k_Normal,
00031 k_Operator,
00032 k_Alloc,
00033 k_Constructor,
00034 k_Destructor,
00035 k_Conversion
00036 };
00037
00039 static const char CONVERSION_OPERATOR_NAME[], CONSTRUCTOR_NAME[], DESTRUCTOR_NAME[],
00040 PTR_OPERATOR_NAME[], CALL_OPERATOR_NAME[], ASSIGNMENT_OPERATOR_NAME[],
00041 INDEX_OPERATOR_NAME[], NEW_OPERATOR_NAME[], ANEW_OPERATOR_NAME[],
00042 DELETE_OPERATOR_NAME[], ADELETE_OPERATOR_NAME[], COMMA_OPERATOR_NAME[];
00043 private:
00044 std::string basename;
00045 Abstract_scope* scope;
00046 bool qualified;
00047 Type conv_type;
00048 Kind kind;
00049 Ptree* tpl_args;
00050 Abstract_scope* start_scope;
00051
00052 public:
00069 Symbol_name(std::string s, Abstract_scope* scope, Kind k);
00070
00076 Symbol_name(Ptree* tree, Abstract_scope* const scope, bool is_fdecl);
00077
00078 ~Symbol_name();
00079
00083 static bool is_qualified_name(Ptree* p);
00084
00091 static Abstract_scope* lookup_symbol_in_scope(Ptree* p, Abstract_scope* scope, Abstract_scope* start_scope);
00092
00094 bool is_qualified() const;
00095
00098 std::string get_name() const;
00099
00101 Symbol_name::Kind get_kind() const;
00102
00105 Abstract_scope* get_scope() const;
00106
00108 Type get_type() const;
00109
00111 bool is_template() const;
00112
00114 Ptree* get_template_args() const;
00115
00121 Symbol_pair lookup_for_use(bool qual) const;
00122
00124 Symbol_pair lookup_for_decl() const;
00125
00126
00127
00129 static std::string gensym();
00130
00132 static std::string get_unnamed_namespace_name();
00133
00136 static std::string get_mangled_symbol_name(std::string scope, std::string name);
00137
00140 static std::string get_mangled_scope_from_symbol(std::string name);
00141
00144 static std::string get_mangled_function_name(std::string fname, Type t, Type this_type);
00145
00148 static std::string get_mangled_template_name(std::string name, const Type_vector& types);
00149
00152 static std::string get_mangled_block_scope(std::string fname);
00153
00154 static std::string get_basename_from_symbol(std::string sym, std::string::size_type len);
00155
00157 static std::string get_block_name();
00158
00160 static const char* get_operator_name(Ptree* tree);
00161
00162 private:
00170 void init_name(Abstract_scope* s, Ptree* p, bool is_fdecl);
00171 };
00172
00173
00174
00175
00176
00177
00178
00181 inline std::string
00182 Symbol_name::get_name() const
00183 {
00184 return basename;
00185 }
00186
00187
00189 inline Symbol_name::Kind
00190 Symbol_name::get_kind() const
00191 {
00192 return kind;
00193 }
00194
00195
00197 inline bool
00198 Symbol_name::is_template() const
00199 {
00200 return tpl_args != 0;
00201 }
00202
00203
00205 inline Ptree*
00206 Symbol_name::get_template_args() const
00207 {
00208 return tpl_args;
00209 }
00210
00211 #endif // symbol_name_h