本文整理汇总了C++中namespacet::follow_tag方法的典型用法代码示例。如果您正苦于以下问题:C++ namespacet::follow_tag方法的具体用法?C++ namespacet::follow_tag怎么用?C++ namespacet::follow_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类namespacet
的用法示例。
在下文中一共展示了namespacet::follow_tag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bv_width
inline static unsigned bv_width(
const typet &type,
const namespacet &ns)
{
if(type.id()==ID_c_enum_tag)
{
const typet &t=ns.follow_tag(to_c_enum_tag_type(type));
assert(t.id()==ID_c_enum);
return bv_width(t.subtype(), ns);
}
return unsafe_string2unsigned(type.get_string(ID_width));
}
示例2: xml
xmlt xml(
const typet &type,
const namespacet &ns)
{
if(type.id()==ID_symbol)
return xml(ns.follow(type), ns);
xmlt result;
if(type.id()==ID_unsignedbv)
{
result.name="integer";
result.set_attribute("width", to_unsignedbv_type(type).get_width());
}
else if(type.id()==ID_signedbv)
{
result.name="integer";
result.set_attribute("width", to_signedbv_type(type).get_width());
}
else if(type.id()==ID_floatbv)
{
result.name="float";
result.set_attribute("width", to_floatbv_type(type).get_width());
}
else if(type.id()==ID_bv)
{
result.name="integer";
result.set_attribute("width", to_bv_type(type).get_width());
}
else if(type.id()==ID_c_bit_field)
{
result.name="integer";
result.set_attribute("width", to_c_bit_field_type(type).get_width());
}
else if(type.id()==ID_c_enum_tag)
{
// we return the base type
return xml(ns.follow_tag(to_c_enum_tag_type(type)).subtype(), ns);
}
else if(type.id()==ID_fixedbv)
{
result.name="fixed";
result.set_attribute("width", to_fixedbv_type(type).get_width());
}
else if(type.id()==ID_pointer)
{
result.name="pointer";
result.new_element("subtype").new_element()=xml(type.subtype(), ns);
}
else if(type.id()==ID_bool)
{
result.name="boolean";
}
else if(type.id()==ID_array)
{
result.name="array";
result.new_element("subtype").new_element()=xml(type.subtype(), ns);
}
else if(type.id()==ID_vector)
{
result.name="vector";
result.new_element("subtype").new_element()=xml(type.subtype(), ns);
result.new_element("size").new_element()=xml(to_vector_type(type).size(), ns);
}
else if(type.id()==ID_struct)
{
result.name="struct";
const struct_typet::componentst &components=
to_struct_type(type).components();
for(struct_typet::componentst::const_iterator
it=components.begin(); it!=components.end(); it++)
{
xmlt &e=result.new_element("member");
e.set_attribute("name", id2string(it->get_name()));
e.new_element("type").new_element()=xml(it->type(), ns);
}
}
else if(type.id()==ID_union)
{
result.name="union";
const union_typet::componentst &components=
to_union_type(type).components();
for(union_typet::componentst::const_iterator
it=components.begin(); it!=components.end(); it++)
{
xmlt &e=result.new_element("member");
e.set_attribute("name", id2string(it->get_name()));
e.new_element("type").new_element()=xml(it->type(), ns);
}
}
else
result.name="unknown";
return result;
}
示例3: alignment
mp_integer alignment(const typet &type, const namespacet &ns)
{
// is the alignment given?
const exprt &given_alignment=
static_cast<const exprt &>(type.find(ID_C_alignment));
if(given_alignment.is_not_nil())
{
mp_integer a_int;
if(!to_integer(given_alignment, a_int))
return a_int;
// we trust it blindly, no matter how nonsensical
}
// compute default
if(type.id()==ID_array)
{
return alignment(type.subtype(), ns);
}
else if(type.id()==ID_struct || type.id()==ID_union)
{
const struct_union_typet::componentst &components=
to_struct_union_type(type).components();
mp_integer result=1;
// get the max
// (should really be the smallest common denominator)
for(struct_union_typet::componentst::const_iterator
it=components.begin();
it!=components.end();
it++)
result=std::max(result, alignment(it->type(), ns));
return result;
}
else if(type.id()==ID_unsignedbv ||
type.id()==ID_signedbv ||
type.id()==ID_fixedbv ||
type.id()==ID_floatbv ||
type.id()==ID_c_bool)
{
unsigned width=to_bitvector_type(type).get_width();
return width%8?width/8+1:width/8;
}
else if(type.id()==ID_c_enum)
{
return alignment(type.subtype(), ns);
}
else if(type.id()==ID_c_enum_tag)
{
return alignment(ns.follow_tag(to_c_enum_tag_type(type)), ns);
}
else if(type.id()==ID_pointer)
{
unsigned width=config.ansi_c.pointer_width;
return width%8?width/8+1:width/8;
}
else if(type.id()==ID_symbol)
return alignment(ns.follow(type), ns);
return 1;
}