当前位置: 首页>>代码示例>>C++>>正文


C++ Exp::IsBound方法代码示例

本文整理汇总了C++中Exp::IsBound方法的典型用法代码示例。如果您正苦于以下问题:C++ Exp::IsBound方法的具体用法?C++ Exp::IsBound怎么用?C++ Exp::IsBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exp的用法示例。


在下文中一共展示了Exp::IsBound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MatchEquality

Exp* MatchEquality(Exp *base, const BaseCompare &equality)
{
  Exp *source = equality.source;
  Exp *target = equality.target;

  // check for the source and base being the same value.
  if (source == base)
    return target;

  // check for the source and base begin different bounds on the same lvalue.
  if (source->IsBound() && base->IsBound()) {
    ExpBound *nsource = source->AsBound();
    ExpBound *nbase = base->AsBound();

    if (nsource->GetTarget() != nbase->GetTarget())
      return NULL;
    if (nsource->GetBoundKind() != nbase->GetBoundKind())
      return NULL;

    size_t base_width = nbase->GetStrideType()->Width();
    size_t source_width = nsource->GetStrideType()->Width();

    if (source_width == base_width)
      return target;

    // only handling upper bounds where the base's width is an even multiple
    // of the source's width. this is to handle cases where there is an
    // equality due to calling a primitive allocation function.
    if (nbase->GetBoundKind() != BND_Upper)
      return NULL;
    if (source_width == 0)
      return NULL;
    if (base_width < source_width)
      return NULL;

    size_t factor = base_width / source_width;
    if (source_width * factor != base_width)
      return NULL;

    // construct a new equality and recurse on it. the base's bound
    // can be compared with (target / factor).
    Exp *factor_exp = Exp::MakeInt(factor);
    return Exp::MakeBinop(B_Div, target, factor_exp);
  }

  return NULL;
}
开发者ID:brifordwylie,项目名称:turnersr.github.io,代码行数:47,代码来源:sufficient.cpp


注:本文中的Exp::IsBound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。