本文整理汇总了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));
}
}
}
示例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));
}