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

implicit_conversion.cc File Reference

#include "implicit_conversion.h"
#include "implicit_conversion_i.h"

Include dependency graph for implicit_conversion.cc:

Include dependency graph

Go to the source code of this file.

Functions

bool is_ptr_to_bool (Implicit_conversion::Step_vec::const_iterator p)
 True iff p is a conversion of a pointer to bool. More...

Class_symbolclass_or_null (const Type &t)
Implicit_conversion::Action fundamental_conversion_type (Type src, Type dest)
 Given two fundamental types, figure out how we can convert between them. More...

bool gen_builtin_conversions (Implicit_conversion *ics, Type arg_type)
 Generate (partial) implicit conversion which converts /ics/ to /arg_type/. More...

void gen_constructors (const Expr_result &expr, Type arg_type, Function_signature *symbol_hint, std::vector< Implicit_conversion * > *icv)
 Generate all conversions that are possible with constructors. More...

bool gen_conv_ops (const Expr_result &expr, Type arg_type, Function_signature *symbol_hint, std::vector< Implicit_conversion * > *icv)
 Generate all conversions using a conversion function. More...

bool operator== (const ICS_Step &lhs, const ICS_Step &rhs)
void enumerate_conversion_ops (const Expr_result &expr, Conversion_op_map *output)
void gen_candidates (Expr_result expr, Type arg_type, Function_signature *symbol_hint, bool with_userdef, bool is_object, std::vector< Implicit_conversion * > *candidates)
 Generate all implicit conversion candidates for an expression. More...

Implicit_conversiongenerate_implicit_conversion (Expr_result expr, Type arg_type, Function_signature *symbol_hint, bool with_userdef, bool is_copy_initialisation, bool is_implicit_object_arg)
 Generate all ICS's and return the best one. More...


Function Documentation

Class_symbol * class_or_null const Type   t [static]
 

Definition at line 200 of file implicit_conversion.cc.

References Type::get_kind(), Type::get_type_symbol(), and Type::k_Userdef.

Referenced by Implicit_conversion::scs_is_better_than().

void enumerate_conversion_ops const Expr_result   expr,
Conversion_op_map   output
 

Definition at line 977 of file implicit_conversion.cc.

References Class_symbol::bases_t, compile_error(), Conversion_op_map, Symbol_name::CONVERSION_OPERATOR_NAME, Class_symbol::enumerate_base_classes(), Type::get_kind(), Symbol::get_name(), Expr_result::get_type(), Type::get_type_symbol(), Symbol::is_defined(), Class_op_lookup_helper::is_visible_in(), Type::k_Userdef, Type::make_member_type(), Function_symbol::sig_begin(), Function_symbol::sig_end(), and Function_symbol::Sig_it.

Referenced by Overload_resolver::add_builtin_binary_ops(), Overload_resolver::add_builtin_incdec(), Overload_resolver::add_builtin_unary_ops(), Expr_annotator::do_funcall(), gen_conv_ops(), and Annotator::visit_switch().

Implicit_conversion::Action fundamental_conversion_type Type    src,
Type    dest
[static]
 

Given two fundamental types, figure out how we can convert between them.

We can convert any fundamental type (except void) into any of the others, so no validity checks needed here.

Definition at line 664 of file implicit_conversion.cc.

References ICS_Types::a_BoolConversion, ICS_Types::a_FloatingConversion, ICS_Types::a_FloatingIntegralConversion, ICS_Types::a_FloatingPromotion, ICS_Types::a_IntegralConversion, ICS_Types::a_IntegralPromotion, Type::get_kind(), Type::get_promoted_integer(), Type::get_unqualified_type(), Type::is_float(), Type::is_int(), Type::is_same_unqualified_type(), Type::is_valid(), Type::is_void(), and Type::k_Fundamental.

Referenced by gen_builtin_conversions().

bool gen_builtin_conversions Implicit_conversion   ics,
Type    arg_type
[static]
 

Generate (partial) implicit conversion which converts /ics/ to /arg_type/.

Returns true on success.

Definition at line 717 of file implicit_conversion.cc.

References ICS_Types::a_BoolConversion, ICS_Types::a_IntegralConversion, ICS_Types::a_PointerConversion, ICS_Types::a_PtrMemConversion, ICS_Types::a_QualificationAdjustment, Implicit_conversion::add_conversion(), Implicit_conversion::convert_to_rvalue(), fundamental_conversion_type(), Type::get_basis_type(), Type::get_class_type(), Implicit_conversion::get_current(), Symbol::get_kind(), Type::get_kind(), Type::get_member_type(), Type_symbol::get_type(), Type::get_type_symbol(), Type::get_unqualified_type(), Type::is_int(), Implicit_conversion::is_npc(), Type::is_qualification_convertible_to(), Type::is_same_unqualified_type(), Class_symbol::is_unique_base_class_of(), Type::is_valid(), Type::is_void(), Type::k_Array, Type::k_Ellipsis, Symbol::k_Enum, Type::k_Function, Type::k_Fundamental, Type::k_Member, Type::k_Nothing, Type::k_Pointer, Type::k_Reference, Type::k_Template, Type::k_Userdef, Type::make_member_type(), Type::make_pointer_type(), and Type::with_qualifiers().

Referenced by gen_candidates().

void gen_candidates Expr_result    expr,
Type    arg_type,
Function_signature   symbol_hint,
bool    with_userdef,
bool    is_object,
std::vector< Implicit_conversion * > *    candidates
 

Generate all implicit conversion candidates for an expression.

Parameters:
expr  the "input" expression
arg_type  the target type to convert to
symbol_hint  value to put into the ICS as symbol hint. This is used for expressions like "f(g)" where "g" is an overloaded function. Normally, the "g" node of "expr.tree" should be annotated with "symbol_hint", but we don't know that until we do overload resolution.
with_userdef  include user-defined conversions
candidates  output space

Definition at line 1079 of file implicit_conversion.cc.

References ICS_Types::a_BindReferenceToTemporary, Implicit_conversion::add_step(), Implicit_conversion::convert_reference(), gen_builtin_conversions(), gen_constructors(), gen_conv_ops(), generate_implicit_conversion(), Type::get_basis_type(), Expr_result::get_function(), Type::get_kind(), Expr_result::get_tree(), Expr_result::get_type(), Type::get_unqualified_type(), Expr_result::is_bound_member(), Expr_result::is_function(), Expr_result::is_lvalue(), Type::is_qualified(), Type::is_valid(), Expr_result::k_LValue, Type::k_Reference, Type::k_Userdef, Type::q_Const, Type::q_Volatile, Expr_result::set_value(), Function_symbol::sig_begin(), Function_symbol::sig_end(), and Function_symbol::Sig_it.

Referenced by generate_implicit_conversion().

void gen_constructors const Expr_result   expr,
Type    arg_type,
Function_signature   symbol_hint,
std::vector< Implicit_conversion * > *    icv
[static]
 

Generate all conversions that are possible with constructors.

Definition at line 892 of file implicit_conversion.cc.

References ICS_Types::a_CtorCall, Implicit_conversion::add_step(), Symbol_name::CONSTRUCTOR_NAME, Implicit_conversion::convert_to_rvalue(), f_Explicit, generate_implicit_conversion(), Type::get_function_arg(), Function_signature::get_function_specifiers(), Type::get_kind(), Type::get_num_function_args(), Function_signature::get_proto_type(), Class_symbol::get_scope(), Type::get_type_symbol(), Type::get_unqualified_type(), Symbol::is_declared(), Symbol::is_defined(), Expr_result::k_RValue, Type::k_Userdef, Class_scope::lookup_here(), Function_symbol::sig_begin(), Function_symbol::sig_end(), Function_symbol::Sig_it, Implicit_conversion::Step, and Symbol_pair::untag.

Referenced by gen_candidates().

bool gen_conv_ops const Expr_result   expr,
Type    arg_type,
Function_signature   symbol_hint,
std::vector< Implicit_conversion * > *    icv
[static]
 

Generate all conversions using a conversion function.

Returns true if there was at least one such conversion.

Definition at line 1016 of file implicit_conversion.cc.

References ICS_Types::a_ConversionOp, Implicit_conversion::add_step(), Implicit_conversion::append_from(), Conversion_op_map, Implicit_conversion::convert_reference(), enumerate_conversion_ops(), generate_implicit_conversion(), Expr_result::get_kind(), Expr_result::get_type(), Implicit_conversion::set_ambiguous(), Expr_result::set_value(), and Implicit_conversion::Step.

Referenced by gen_candidates().

Implicit_conversion* generate_implicit_conversion Expr_result    expr,
Type    arg_type,
Function_signature   symbol_hint,
bool    with_userdef,
bool    is_copy_initialisation,
bool    is_implicit_object_arg
 

Generate all ICS's and return the best one.

Returns an ambiguous sequence if conversion is ambiguous, null if impossible.

Definition at line 1171 of file implicit_conversion.cc.

References ICS_Types::c_CompareBeforeUserConversion, ICS_Types::c_CompareWithInitRules, ICS_Types::Compare, gen_candidates(), Expr_result::get_type(), Implicit_conversion::is_better_than(), Type::is_class_type(), Type::is_same_unqualified_type(), Type::is_void(), and Implicit_conversion::set_ambiguous().

Referenced by Overload_resolver::add_signature_with_type(), gen_candidates(), gen_constructors(), gen_conv_ops(), generate_ics_for_ternary(), Init_handler::get_default_initializer_for_type(), Init_handler::make_constructor_call(), Init_handler::process_brace(), Init_handler::process_class(), Expr_annotator::try_static_cast(), Expr_annotator::visit_assign(), Expr_annotator::visit_cond(), Annotator::visit_do(), Annotator::visit_for(), Annotator::visit_if(), Annotator::visit_return(), Annotator::visit_switch(), and Annotator::visit_while().

bool is_ptr_to_bool Implicit_conversion::Step_vec::const_iterator    p [inline, static]
 

True iff p is a conversion of a pointer to bool.

Definition at line 53 of file implicit_conversion.cc.

References ICS_Types::a_BoolConversion, Type::k_Member, and Type::k_Pointer.

Referenced by Implicit_conversion::scs_is_better_than().

bool operator== const ICS_Step   lhs,
const ICS_Step   rhs
 

Definition at line 536 of file implicit_conversion.cc.

References ICS_Step::action, ICS_Step::function, ICS_Step::kind, and ICS_Step::type.


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