Пример #1
0
 expression operator()(
   const Left &, const Right &,
   typename boost::enable_if<
     type_traits::meta::is_arithmetic_convertible< Left, Right >
   >::type* = 0
 ) const {
   const auto result_type = get_type< bool >();
   const auto converted_left = implicit_cast( context, ir_builder, result_type, left );
   const auto converted_right = implicit_cast( context, ir_builder, result_type, right );
   const std::shared_ptr< llvm::LLVMContext > &context_ = context;
   const auto llvm_type = get_llvm_type( context, result_type );
   return expression(
     result_type, llvm_type,
     std::shared_ptr< llvm::Value >(
       ir_builder->CreateOr(
         converted_left.llvm_value().get(),
         converted_right.llvm_value().get()
       ),
       [context_]( llvm::Value* ){}
     )
   );
 }
Пример #2
0
int implicit_cast(const class_rep* crep,
                  LUABIND_TYPE_INFO const& type_id,
                  int& pointer_offset)
{
    int offset = 0;
    if (LUABIND_TYPE_INFO_EQUAL(crep->type(), type_id)) return 0;

    for (std::vector<class_rep::base_info>::const_iterator
            i = crep->bases().begin(); i != crep->bases().end(); ++i)
    {
        int steps = implicit_cast(i->base, type_id, offset);
        pointer_offset = offset + i->pointer_offset;
        if (steps >= 0) return steps + 2;
    }
    return -1;
}
Пример #3
0
    int implicit_cast(
        class_rep const* crep
      , type_id const& id
      , int& pointer_offset)
    {
        if (crep->type() == id) return 0;

        for (std::vector<class_rep::base_info>::const_iterator i = 
            crep->bases().begin(); i != crep->bases().end(); ++i)
        {
            int offset = 0;
            int steps = implicit_cast(i->base, id, offset);
            pointer_offset = offset + i->pointer_offset;
            if (steps >= 0) return steps + 2;
        }
        return -1;
    }