#include <symbol_name.h>
Collaboration diagram for Symbol_name:
Public Types | |
enum | Kind { k_Normal, k_Operator, k_Alloc, k_Constructor, k_Destructor, k_Conversion } |
Public Methods | |
Symbol_name (std::string s, Abstract_scope *scope, Kind k) | |
This ctor is used in initialisation. More... | |
Symbol_name (Ptree *tree, Abstract_scope *const scope, bool is_fdecl) | |
Initialize symbol name. More... | |
~Symbol_name () | |
bool | is_qualified () const |
True iff this is a qualified symbol ("foo::bar"). More... | |
std::string | get_name () const |
Get base name. More... | |
Symbol_name::Kind | get_kind () const |
Get symbol kind. More... | |
Abstract_scope * | get_scope () const |
Get scope. More... | |
Type | get_type () const |
Get target type if this is a conversion operator. More... | |
bool | is_template () const |
True iff this is a templatized thing. More... | |
Ptree * | get_template_args () const |
Get template arguments. More... | |
Symbol_pair | lookup_for_use (bool qual) const |
Look up symbol in order to use it. More... | |
Symbol_pair | lookup_for_decl () const |
Look up symbol in order to declare it. More... | |
Static Public Methods | |
bool | is_qualified_name (Ptree *p) |
Helper: true iff p is a qualified name. More... | |
Abstract_scope * | lookup_symbol_in_scope (Ptree *p, Abstract_scope *scope, Abstract_scope *start_scope) |
Helper: look up a scope. More... | |
std::string | gensym () |
Generate a new, unused symbol name. More... | |
std::string | get_unnamed_namespace_name () |
Get name for nameless namespace. More... | |
std::string | get_mangled_symbol_name (std::string scope, std::string name) |
Mangle symbol name into scope. More... | |
std::string | get_mangled_scope_from_symbol (std::string name) |
Convert symbol name into scope name. More... | |
std::string | get_mangled_function_name (std::string fname, Type t, Type this_type) |
Mangle function prototype into name. More... | |
std::string | get_mangled_template_name (std::string name, const Type_vector &types) |
Mangle template parameters into name. More... | |
std::string | get_mangled_block_scope (std::string fname) |
Generate mangled block scope name. More... | |
std::string | get_basename_from_symbol (std::string sym, std::string::size_type len) |
std::string | get_block_name () |
Generate name for a block. More... | |
const char * | get_operator_name (Ptree *tree) |
Given an operator symbol, return its mangled name. More... | |
Static Public Attributes | |
const char | CONVERSION_OPERATOR_NAME [] = "__cvt" |
Names for certain operators. More... | |
const char | CONSTRUCTOR_NAME [] = "__ctor" |
Names for certain operators. More... | |
const char | DESTRUCTOR_NAME [] = "__dtor" |
Names for certain operators. More... | |
const char | PTR_OPERATOR_NAME [] = "__opar" |
Names for certain operators. More... | |
const char | CALL_OPERATOR_NAME [] = "__opf" |
Names for certain operators. More... | |
const char | ASSIGNMENT_OPERATOR_NAME [] = "__opas" |
Names for certain operators. More... | |
const char | INDEX_OPERATOR_NAME [] = "__opi" |
Names for certain operators. More... | |
const char | NEW_OPERATOR_NAME [] = "__opnew" |
Names for certain operators. More... | |
const char | ANEW_OPERATOR_NAME [] = "__opanew" |
Names for certain operators. More... | |
const char | DELETE_OPERATOR_NAME [] = "__opdel" |
Names for certain operators. More... | |
const char | ADELETE_OPERATOR_NAME [] = "__opadel" |
Names for certain operators. More... | |
const char | COMMA_OPERATOR_NAME [] = "__opcom" |
Names for certain operators. More... | |
Private Methods | |
void | init_name (Abstract_scope *s, Ptree *p, bool is_fdecl) |
Initialize this Symbol_name. More... | |
Private Attributes | |
std::string | basename |
base name of symbol (sans scopes, mangled). More... | |
Abstract_scope * | scope |
scope in which symbol appears, if qualified name. More... | |
bool | qualified |
true iff this is a qualified name. More... | |
Type | conv_type |
target type for conversion operators, only if kind == k_Conversion. More... | |
Kind | kind |
kind of symbol. More... | |
Ptree * | tpl_args |
template args, null if not a template. Format is "[< [a1 , a2] >]". More... | |
Abstract_scope * | start_scope |
starting scope for lookup. More... |
This represents a symbol name, such as `i', `NS::x', `Class::Class' or `Foo::operator='.
If the symbol is a template, as in `vector<Foo>', is_template() is true.
Special case: the last component may also be "*", as in `Class::*', to represent member pointers.
In addition, this class is a container for name mangling related stuff.
Definition at line 27 of file symbol_name.h.
|
Definition at line 29 of file symbol_name.h. Referenced by Function_symbol::Function_symbol(), and Function_symbol::get_function_kind(). |
|
This ctor is used in initialisation.
Definition at line 26 of file symbol_name.cc. |
|
Initialize symbol name.
Definition at line 38 of file symbol_name.cc. References basename, Ptree::Car(), Ptree::Cdr(), compile_error(), Ptree::Eq(), expect_ptree(), gensym(), Abstract_scope::get_global_scope(), Abstract_scope::get_parent(), init_name(), is_qualified_name(), k_Normal, kind, lookup_symbol_in_scope(), qualified, start_scope, and Ptree::ToString(). |
|
Definition at line 93 of file symbol_name.cc. |
|
Generate a new, unused symbol name.
Definition at line 331 of file symbol_name.cc. Referenced by Symbol_name(). |
|
Definition at line 442 of file symbol_name.cc. Referenced by Symbol::get_basename(). |
|
Generate name for a block.
Definition at line 455 of file symbol_name.cc. Referenced by get_mangled_block_scope(). |
|
Get symbol kind.
Definition at line 190 of file symbol_name.h. References kind. Referenced by Namespace_scope::add_function_decl(), Class_scope::add_function_decl(), Simple_declaration_reader::declare_variable(), and get_type(). |
|
Generate mangled block scope name. Given a function "fname", return the name of a new block. Definition at line 434 of file symbol_name.cc. References get_block_name(). |
|
Mangle function prototype into name. For example, to determine the name for "int X::func(void)", use "get_mangled_function_name(func, int(void))". Definition at line 389 of file symbol_name.cc. References Type::get_encoded_type(), Type::get_function_signature(), Type::is_qualified(), Type::is_valid(), Type::make_pointer_type(), Type::q_Const, and Type::q_Volatile. Referenced by Function_symbol::fill_in_mangled_names(). |
|
Convert symbol name into scope name. To determine the scope name for class "A::B", use "get_mangled_scope_from_symbol(A::B)". Definition at line 373 of file symbol_name.cc. Referenced by Class_symbol::lookup_helper(). |
|
Mangle symbol name into scope. For example, to determine the name for symbol "A::B::sym", use "get_mangled_symbol_name(A::B, sym)". Definition at line 356 of file symbol_name.cc. References scope. Referenced by Namespace_scope::get_unique_name(), Class_scope::get_unique_name(), Block_scope::get_unique_name(), and Class_symbol::lookup_helper(). |
|
Mangle template parameters into name. For example, to determine the name for "std::vector<int>", use "get_mangled_template_name(vector, [int])". Definition at line 412 of file symbol_name.cc. References Type_vector. Referenced by Template_class_symbol::get_specialisation(). |
|
Get base name. This is the name under which the declared object will appear in the symbol table. Definition at line 182 of file symbol_name.h. References basename. Referenced by Namespace_scope::add_function_decl(), Class_scope::add_function_decl(), Namespace_scope::add_variable(), Class_scope::add_variable(), Block_scope::add_variable(), Template_visitor::declare_class(), Simple_declaration_reader::declare_variable(), lookup_for_decl(), lookup_for_use(), parse_class(), Declaration_reader::parse_declarator_internal(), parse_enum(), and Expr_annotator::process_member_access(). |
|
Given an operator symbol, return its mangled name.
Definition at line 486 of file symbol_name.cc. References ADELETE_OPERATOR_NAME, ANEW_OPERATOR_NAME, ASSIGNMENT_OPERATOR_NAME, CALL_OPERATOR_NAME, Ptree::Car(), COMMA_OPERATOR_NAME, DELETE_OPERATOR_NAME, Ptree::Eq(), INDEX_OPERATOR_NAME, Ptree::IsLeaf(), NEW_OPERATOR_NAME, and PTR_OPERATOR_NAME. Referenced by init_name(), Expr_annotator::visit_postfix(), and Expr_annotator::visit_unary(). |
|
Get scope. Qualified symbols are looked up in this scope only; unqualified ones are looked up here and in its parents. Definition at line 273 of file symbol_name.cc. References scope. Referenced by Namespace_scope::add_function_decl(), Namespace_scope::add_variable(), lookup_for_decl(), lookup_for_use(), Declaration_reader::parse_declarator_internal(), and Expr_annotator::process_member_access(). |
|
Get template arguments.
Definition at line 206 of file symbol_name.h. References tpl_args. |
|
Get target type if this is a conversion operator.
Definition at line 282 of file symbol_name.cc. References conv_type, get_kind(), and k_Conversion. Referenced by Simple_declaration_reader::declare_variable(). |
|
Get name for nameless namespace.
Definition at line 344 of file symbol_name.cc. Referenced by Annotator::visit_namespacespec(). |
|
Initialize this Symbol_name.
Definition at line 152 of file symbol_name.cc. References ADELETE_OPERATOR_NAME, ANEW_OPERATOR_NAME, basename, bogus_ptree_error(), Ptree::Car(), compile_error(), CONSTRUCTOR_NAME, conv_type, CONVERSION_OPERATOR_NAME, DELETE_OPERATOR_NAME, DESTRUCTOR_NAME, Ptree::Eq(), Ptree::First(), get_operator_name(), Abstract_scope::is_constructor(), Ptree::IsLeaf(), k_Alloc, k_Constructor, k_Conversion, k_Destructor, k_Normal, k_Operator, kind, Ptree::Length(), NEW_OPERATOR_NAME, parse_abstract_declarator(), parse_type(), scope, Ptree::Second(), start_scope, Ptree::ToString(), and tpl_args. Referenced by Symbol_name(). |
|
True iff this is a qualified symbol ("foo::bar").
Definition at line 263 of file symbol_name.cc. References qualified. Referenced by Namespace_scope::add_function_decl(), Class_scope::add_function_decl(), Namespace_scope::add_variable(), Class_scope::add_variable(), Block_scope::add_variable(), Template_visitor::declare_class(), lookup_for_use(), parse_class(), parse_enum(), Expr_annotator::process_member_access(), and Expr_annotator::visit_unary(). |
|
Helper: true iff p is a qualified name. Unqualified names might also have more than one component (operator, destructor, template). Definition at line 102 of file symbol_name.cc. References Ptree::Eq(), Ptree::First(), Ptree::IsLeaf(), Ptree::Length(), and Ptree::Second(). Referenced by Template_visitor::declare_name(), and Symbol_name(). |
|
True iff this is a templatized thing.
Definition at line 198 of file symbol_name.h. References tpl_args. Referenced by Namespace_scope::add_function_decl(), Class_scope::add_function_decl(), Namespace_scope::add_variable(), Class_scope::add_variable(), Block_scope::add_variable(), Simple_declaration_reader::declare_variable(), lookup_for_use(), parse_class(), Declaration_reader::parse_declarator_internal(), and parse_enum(). |
|
Look up symbol in order to declare it.
Definition at line 320 of file symbol_name.cc. References get_name(), get_scope(), and Abstract_scope::lookup_here(). Referenced by Namespace_scope::add_variable(), Class_scope::add_variable(), Template_visitor::declare_class(), and parse_class(). |
|
Look up symbol in order to use it. This uses the normal name lookup rules.
Definition at line 296 of file symbol_name.cc. References compile_error(), get_name(), get_scope(), Template_class_symbol::get_specialisation(), is_qualified(), is_template(), Abstract_scope::lookup_here(), Abstract_scope::lookup_unqualified(), parse_template_arg_list(), start_scope, Symbol_pair::tag, tpl_args, Type_vector, and Symbol_pair::untag. Referenced by Expr_annotator::process_member_access(), Type_reader::Type_reader(), Expr_annotator::visit_funcall(), and Expr_annotator::visit_unary(). |
|
Helper: look up a scope.
Definition at line 117 of file symbol_name.cc. References Ptree::Car(), compile_error(), Symbol::get_kind(), Class_symbol::get_scope(), Symbol::get_scope(), Template_class_symbol::get_specialisation_from_ptree(), Ptree::IsLeaf(), Symbol::k_Function, Symbol::k_Variable, Ptree::Length(), Abstract_scope::lookup_here(), Ptree::Second(), Symbol_pair::tag, Ptree::ToString(), and Symbol_pair::untag. Referenced by Template_visitor::declare_name(), and Symbol_name(). |
|
Names for certain operators.
Definition at line 479 of file symbol_name.cc. Referenced by get_operator_name(), init_default_symbols(), and init_name(). |
|
Names for certain operators.
Definition at line 477 of file symbol_name.cc. Referenced by get_operator_name(), init_default_symbols(), init_name(), and Expr_annotator::visit_new(). |
|
Names for certain operators.
Definition at line 474 of file symbol_name.cc. Referenced by Class_symbol::finish_definition(), get_operator_name(), Class_symbol::implicit_assignment_operator_style(), and Expr_annotator::visit_assign(). |
|
base name of symbol (sans scopes, mangled).
Definition at line 44 of file symbol_name.h. Referenced by get_name(), init_name(), and Symbol_name(). |
|
Names for certain operators.
Definition at line 473 of file symbol_name.cc. Referenced by Expr_annotator::do_funcall(), and get_operator_name(). |
|
Names for certain operators.
Definition at line 480 of file symbol_name.cc. Referenced by get_operator_name(), and Expr_annotator::visit_comma(). |
|
Names for certain operators.
Definition at line 470 of file symbol_name.cc. Referenced by Class_symbol::finish_definition(), gen_constructors(), Init_handler::get_default_initializer_for_type(), Class_symbol::implicit_copy_ctor_is_const(), init_name(), and Init_handler::make_constructor_call(). |
|
target type for conversion operators, only if kind == k_Conversion.
Definition at line 47 of file symbol_name.h. |
|
Names for certain operators.
Definition at line 469 of file symbol_name.cc. Referenced by enumerate_conversion_ops(), init_name(), and Class_op_lookup_helper::predicate(). |
|
Names for certain operators.
Definition at line 478 of file symbol_name.cc. Referenced by get_operator_name(), init_default_symbols(), and init_name(). |
|
Names for certain operators.
Definition at line 471 of file symbol_name.cc. Referenced by init_name(). |
|
Names for certain operators.
Definition at line 475 of file symbol_name.cc. Referenced by get_operator_name(), and Expr_annotator::visit_array(). |
|
kind of symbol.
Definition at line 48 of file symbol_name.h. Referenced by get_kind(), init_name(), and Symbol_name(). |
|
Names for certain operators.
Definition at line 476 of file symbol_name.cc. Referenced by get_operator_name(), init_default_symbols(), init_name(), and Expr_annotator::visit_new(). |
|
Names for certain operators.
Definition at line 472 of file symbol_name.cc. Referenced by get_operator_name(), and Expr_annotator::visit_arrowmember(). |
|
true iff this is a qualified name.
Definition at line 46 of file symbol_name.h. Referenced by is_qualified(), and Symbol_name(). |
|
scope in which symbol appears, if qualified name.
Definition at line 45 of file symbol_name.h. Referenced by get_mangled_symbol_name(), get_scope(), and init_name(). |
|
starting scope for lookup.
Definition at line 50 of file symbol_name.h. Referenced by init_name(), lookup_for_use(), and Symbol_name(). |
|
template args, null if not a template. Format is "[< [a1 , a2] >]".
Definition at line 49 of file symbol_name.h. Referenced by get_template_args(), init_name(), is_template(), and lookup_for_use(). |