Пример #1
0
// Compare two integer or function values.
Value
Evaluator::eval(Ne_expr const* e)
{
  Value v1 = eval(e->left());
  Value v2 = eval(e->right());
  return compare_equal(v1, v2, std::not_equal_to<>());
}
Пример #2
0
///This function finds a TypeID in the descendants (recusively) of this.
so_type::weak_pointer RK_CALL so_type_impl::findDescendant_impl(const unsigned int* aTypeID ) const {
  if( compare_equal(aTypeID, this->TypeID_begin()) )
    return so_type::weak_pointer(rk_static_ptr_cast<so_type>(mThis));
  
  if(mDescendants.empty())
    return so_type::weak_pointer();
  
  detail::dummy_so_type d(aTypeID);
  std::set< so_type::shared_pointer, so_type_impl::compare_shared_t>::const_iterator it = mDescendants.lower_bound(so_type::shared_pointer(&d,null_deleter()));
  
  if((it != mDescendants.end()) && (compare_equal((*it)->TypeID_begin(),aTypeID))) 
    return *it;
  
  for(it = mDescendants.begin(); it != mDescendants.end(); ++it) {
    so_type::weak_pointer p = (*it)->findDescendant(aTypeID);
    if(p.lock())
      return p;
  };
  
  return so_type::weak_pointer();
};
Пример #3
0
so_type::shared_pointer RK_CALL so_type_impl::addDescendant(const so_type::shared_pointer& aObj ) {
  std::set< so_type::shared_pointer, so_type_impl::compare_shared_t>::iterator it = mDescendants.lower_bound(aObj);
  if((it != mDescendants.end()) && 
     (compare_equal((*it)->TypeID_begin(),aObj->TypeID_begin()))) {
    if((*it)->TypeVersion() < aObj->TypeVersion()) {
      mDescendants.erase(it);
      mDescendants.insert(aObj);
    } else 
      return *it;
  } else
    mDescendants.insert(it,aObj);
  return aObj;
};
Пример #4
0
so_type::weak_pointer RK_CALL so_type_impl::addAncestor(so_type::shared_pointer& aThis, const so_type::weak_pointer& aObj) {
  so_type::shared_pointer p = aObj.lock();
  if(p) {
    std::set< so_type::weak_pointer, so_type_impl::compare_weak_t>::iterator it = mAncestors.lower_bound(aObj);
    if((it != mAncestors.end()) &&
       ((*it).lock()) &&
       (compare_equal((*it).lock()->TypeID_begin(),p->TypeID_begin()))) {
      if((*it).lock()->TypeVersion() < p->TypeVersion()) {
        mAncestors.erase(it);
        mAncestors.insert(aObj);
      } else 
        return *it;
    } else
      mAncestors.insert(aObj);
    p->addDescendant(aThis);
  };
  return aObj;
};
Пример #5
0
 template<typename A1, typename A2, std::size_t N> BOOST_FORCEINLINE
 bool compare_equal(A1 const& a1, A2 const& a2, boost::mpl::size_t<N> const&)
 {
   return (boost::fusion::at_c<N-1>(a1) == boost::fusion::at_c<N-1>(a2) )
       &&  compare_equal(a1,a2,boost::mpl::size_t<N-1>());
 }