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


C++ irept::add方法代码示例

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


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

示例1: convert

void convert(const goto_programt::instructiont &instruction, irept &irep)
{
  irep.set(ID_code, instruction.code);

  if(instruction.function!="")
    irep.set(ID_function, instruction.function);

  if(instruction.source_location.is_not_nil())
    irep.set(ID_location, instruction.source_location);

  irep.set(ID_type, (long) instruction.type);

  irep.set(ID_guard, instruction.guard);

  if(!instruction.targets.empty())
  {
    irept &tgts=irep.add(ID_targets);
    for(goto_programt::targetst::const_iterator it=
          instruction.targets.begin();
        it!=instruction.targets.end();
        it++)
    {
      irept t(i2string((*it)->location_number));
      tgts.move_to_sub(t);
    }
  }

  if(!instruction.labels.empty())
  {
    irept &lbls = irep.add(ID_labels);
    irept::subt &subs = lbls.get_sub();
    subs.reserve(instruction.labels.size());
    for(goto_programt::instructiont::labelst::const_iterator it=
          instruction.labels.begin();
        it!=instruction.labels.end();
        it++)
    {
      subs.push_back(irept(*it));
    }
  }
}
开发者ID:diffblue,项目名称:cbmc,代码行数:41,代码来源:goto_program_irep.cpp

示例2: convert_from_json

/// Deserialize a JSON irep representation.
/// \param input: json object to convert
/// \return result - irep equivalent of input
void json_irept::convert_from_json(const jsont &in, irept &out) const
{
  std::vector<std::string> have_keys;
  for(const auto &keyval : in.object)
    have_keys.push_back(keyval.first);
  std::sort(have_keys.begin(), have_keys.end());
  if(have_keys!=std::vector<std::string>{"comment", "id", "namedSub", "sub"})
    throw "irep JSON representation is missing one of needed keys: "
      "'id', 'sub', 'namedSub', 'comment'";

  out.id(in["id"].value);

  for(const auto &sub : in["sub"].array)
  {
    out.get_sub().push_back(irept());
    convert_from_json(sub, out.get_sub().back());
  }

  for(const auto &named_sub : in["namedSub"].object)
    convert_from_json(named_sub.second, out.add(named_sub.first));

  for(const auto &comment : in["comment"].object)
    convert_from_json(comment.second, out.add(comment.first));
}
开发者ID:eigold,项目名称:cbmc,代码行数:27,代码来源:json_irep.cpp


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