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


C++ typet::width方法代码示例

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


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

示例1: gen_one

exprt gen_one(const typet &type)
{
  const std::string &type_id=type.id_string();
  exprt result=exprt("constant", type);

  if(type_id=="bool" ||
     type_id=="rational" ||
     type_id=="real" ||
     type_id=="integer" ||
     type_id=="natural" ||
     type_id=="complex")
  {
    result.value("1");
  }
  else if(type_id=="unsignedbv" ||
          type_id=="signedbv")
  {
    std::string value;
    for(int i=0; i<atoi(type.width().c_str())-1; i++)
      value+='0';
    value+='1';
    result.value(value);
  }
  else if(type_id=="fixedbv")
  {
    fixedbvt fixedbv;
    fixedbv.spec=to_fixedbv_type(type);
    fixedbv.from_integer(1);
    result=fixedbv.to_expr();
  }
  else if(type_id=="floatbv")
  {
    std::cerr << "floatbv unsupported, sorry" << std::endl;
    abort();
  }
  else
    result.make_nil();

  return result;
}
开发者ID:huangshiyou,项目名称:esbmc,代码行数:40,代码来源:expr_util.cpp

示例2: write


//.........这里部分代码省略.........
    }

    type.id("bool");
  }
  else if(ptr32_cnt || ptr64_cnt)
  {
    type.id("pointer");
    type.subtype() = typet("empty");
  }
  else
  {
    // it is integer -- signed or unsigned?

    if(signed_cnt && unsigned_cnt)
    {
      err_location(location);
      error("conflicting type modifiers");
      throw 0;
    }
    if(unsigned_cnt)
      type.id("unsignedbv");
    else if(signed_cnt)
      type.id("signedbv");
    else
    {
      if(char_cnt)
        type.id(config.ansi_c.char_is_unsigned ? "unsignedbv" : "signedbv");
      else
        type.id("signedbv");
    }

    // get width

    unsigned width;

    if(int8_cnt || int16_cnt || int32_cnt || int64_cnt)
    {
      if(long_cnt || char_cnt || short_cnt)
      {
        err_location(location);
        error("conflicting type modifiers");
        throw 0;
      }

      if(int8_cnt)
        width = 1 * 8;
      else if(int16_cnt)
        width = 2 * 8;
      else if(int32_cnt)
        width = 4 * 8;
      else if(int64_cnt)
        width = 8 * 8;
      else
        abort();
    }
    else if(short_cnt)
    {
      if(long_cnt || char_cnt)
      {
        err_location(location);
        error("conflicting type modifiers");
        throw 0;
      }

      width = config.ansi_c.short_int_width;
    }
开发者ID:esbmc,项目名称:esbmc,代码行数:67,代码来源:ansi_c_convert_type.cpp

示例3: bv_width

unsigned bv_width(const typet &type)
{
  return atoi(type.width().c_str());
}
开发者ID:esbmc,项目名称:esbmc,代码行数:4,代码来源:bitvector.cpp


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