本文整理汇总了C++中typet::id方法的典型用法代码示例。如果您正苦于以下问题:C++ typet::id方法的具体用法?C++ typet::id怎么用?C++ typet::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typet
的用法示例。
在下文中一共展示了typet::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is_unsigned
/**
* Conveniece function -- is the type unsigned?
*/
bool is_unsigned(const typet &t)
{
return t.id()==ID_bv ||
t.id()==ID_unsignedbv ||
t.id()==ID_pointer ||
t.id()==ID_bool;
}
示例2: is_string_type
bool is_string_type(const typet &t) const
{
return
(t.id()==ID_pointer || t.id()==ID_array) &&
(t.subtype().id()==ID_signedbv || t.subtype().id()==ID_unsignedbv) &&
(to_bitvector_type(t.subtype()).get_width()==config.ansi_c.char_width);
}
示例3: is_bitvector
/**
* Convenience function -- is the type a bitvector of some kind?
*/
bool is_bitvector(const typet &t) {
return t.id() == ID_bv ||
t.id() == ID_signedbv ||
t.id() == ID_unsignedbv ||
t.id() == ID_pointer ||
t.id() == ID_bool;
}
示例4: name_anon_struct_union
void cpp_declarationt::name_anon_struct_union(typet &dest)
{
// We name any anon struct/unions according to the first
// declarator. No need to do anon enums, which get
// a name based on the enum elements.
if(dest.id()==ID_struct || dest.id()==ID_union)
{
if(dest.find(ID_tag).is_nil())
{
// it's anonymous
const declaratorst &d=declarators();
if(!d.empty() &&
d.front().name().is_simple_name())
{
// Anon struct/unions without declarator are pretty
// useless, but still possible.
irep_idt base_name="anon-"+id2string(d.front().name().get_base_name());
dest.set(ID_tag, cpp_namet(base_name));
dest.set(ID_C_is_anonymous, true);
}
}
}
else if(dest.id()==ID_merged_type)
{
Forall_subtypes(it, dest)
name_anon_struct_union(*it);
}
}
示例5: type_eq
bool type_eq(const typet &type1, const typet &type2, const namespacet &ns)
{
if(type1 == type2)
return true;
if(type1.id() == "symbol")
{
const symbolt &symbol = ns.lookup(type1);
if(!symbol.is_type)
throw "symbol " + id2string(symbol.name) + " is not a type";
return type_eq(symbol.type, type2, ns);
}
if(type2.id() == "symbol")
{
const symbolt &symbol = ns.lookup(type2);
if(!symbol.is_type)
throw "symbol " + id2string(symbol.name) + " is not a type";
return type_eq(type1, symbol.type, ns);
}
return false;
}
示例6: get_class_refs_rec
void java_bytecode_parsert::get_class_refs_rec(const typet &src)
{
if(src.id()==ID_code)
{
const code_typet &ct=to_code_type(src);
const typet &rt=ct.return_type();
get_class_refs_rec(rt);
for(const auto &p : ct.parameters())
get_class_refs_rec(p.type());
}
else if(src.id()==ID_symbol)
{
irep_idt name=src.get(ID_C_base_name);
if(has_prefix(id2string(name), "array["))
{
const typet &element_type=
static_cast<const typet &>(src.find(ID_C_element_type));
get_class_refs_rec(element_type);
}
else
parse_tree.class_refs.insert(name);
}
else if(src.id()==ID_struct)
{
const struct_typet &struct_type=to_struct_type(src);
for(const auto &c : struct_type.components())
get_class_refs_rec(c.type());
}
else if(src.id()==ID_pointer)
get_class_refs_rec(src.subtype());
}
示例7: read
void c_storage_spect::read(const typet &type)
{
if(type.id()==ID_merged_type ||
type.id()==ID_code)
{
forall_subtypes(it, type)
read(*it);
}
else if(type.id()==ID_static)
is_static=true;
else if(type.id()==ID_thread_local)
is_thread_local=true;
else if(type.id()==ID_inline)
is_inline=true;
else if(type.id()==ID_extern)
is_extern=true;
else if(type.id()==ID_typedef)
is_typedef=true;
else if(type.id()==ID_register)
is_register=true;
else if(type.id()==ID_weak)
is_weak=true;
else if(type.id()==ID_auto)
{
// ignore
}
else if(type.id()==ID_msc_declspec)
{
const exprt &as_expr=
static_cast<const exprt &>(static_cast<const irept &>(type));
forall_operands(it, as_expr)
if(it->id()==ID_thread)
is_thread_local=true;
}
else if(type.id()==ID_alias &&
示例8: is_a_bv_type
static bool is_a_bv_type(const typet &type)
{
return type.id()==ID_unsignedbv ||
type.id()==ID_signedbv ||
type.id()==ID_bv ||
type.id()==ID_fixedbv ||
type.id()==ID_floatbv ||
type.id()==ID_c_enum_tag;
}
示例9: base_type_rec
void base_type_rec(
typet &type, const namespacet &ns, std::set<irep_idt> &symb)
{
if(type.id()==ID_symbol ||
type.id()==ID_c_enum_tag ||
type.id()==ID_struct_tag ||
type.id()==ID_union_tag)
{
const symbolt *symbol;
if(!ns.lookup(type.get(ID_identifier), symbol) &&
symbol->is_type &&
!symbol->type.is_nil())
{
type=symbol->type;
base_type_rec(type, ns, symb); // recursive call
return;
}
}
else if(type.id()==ID_array)
{
base_type_rec(to_array_type(type).subtype(), ns, symb);
}
else if(type.id()==ID_struct ||
type.id()==ID_union)
{
struct_union_typet::componentst &components=
to_struct_union_type(type).components();
for(auto &component : components)
base_type_rec(component.type(), ns, symb);
}
else if(type.id()==ID_pointer)
{
typet &subtype=to_pointer_type(type).subtype();
// we need to avoid running into an infinite loop
if(subtype.id()==ID_symbol ||
subtype.id()==ID_c_enum_tag ||
subtype.id()==ID_struct_tag ||
subtype.id()==ID_union_tag)
{
const irep_idt &id=subtype.get(ID_identifier);
if(symb.find(id)!=symb.end())
return;
symb.insert(id);
base_type_rec(subtype, ns, symb);
symb.erase(id);
}
else
base_type_rec(subtype, ns, symb);
}
}
示例10: bv_sem
bv_semt bv_sem(const typet &type)
{
if(type.id()==ID_bv)
return BV_NONE;
else if(type.id()==ID_unsignedbv)
return BV_UNSIGNED;
else if(type.id()==ID_signedbv)
return BV_SIGNED;
return BV_UNKNOWN;
}
示例11: from_type
void bv_spect::from_type(const typet &type)
{
if(type.id()==ID_unsignedbv)
is_signed=false;
else if(type.id()==ID_signedbv)
is_signed=true;
else
assert(0);
width=atoi(type.get(ID_width).c_str());
}
示例12: if
static std::string type_max(const typet &src)
{
if(src.id()==ID_signedbv)
return integer2string(
power(2, to_signedbv_type(src).get_width()-1)-1);
else if(src.id()==ID_unsignedbv)
return integer2string(
power(2, to_unsignedbv_type(src).get_width()-1)-1);
else
assert(false);
}
示例13: from_type
void bv_spect::from_type(const typet &type)
{
if(type.id()==ID_unsignedbv)
is_signed=false;
else if(type.id()==ID_signedbv)
is_signed=true;
else
assert(0);
width=unsafe_string2unsigned(type.get_string(ID_width));
}
示例14: do_initializer_list
exprt c_typecheck_baset::do_initializer_list(
const exprt &value,
const typet &type,
bool force_constant)
{
assert(value.id()==ID_initializer_list);
if(type.id()==ID_symbol)
return do_initializer_list(
value, follow(type), force_constant);
exprt result;
if(type.id()==ID_struct ||
type.id()==ID_array ||
type.id()==ID_union)
{
// start with zero everywhere
result=zero_initializer(type, value.location());
}
else if(type.id()==ID_incomplete_array)
{
// start with empty array
result=exprt(ID_array, type);
result.location()=value.location();
}
else
{
// The initializer for a scalar shall be a single expression,
// * optionally enclosed in braces. *
if(value.operands().size()==1)
return do_initializer_rec(value.op0(), type, force_constant);
err_location(value);
str << "cannot initialize `" << to_string(type) << "' with "
"an initializer list";
throw 0;
}
designatort current_designator;
designator_enter(type, current_designator);
forall_operands(it, value)
{
do_designated_initializer(
result, current_designator, *it, force_constant);
// increase designator -- might go up
increment_designator(current_designator);
}
示例15: jsil_is_subtype
bool jsil_is_subtype(const typet &type1, const typet &type2)
{
if(type2.id()==ID_union)
{
const jsil_union_typet &type2_union=to_jsil_union_type(type2);
if(type1.id()==ID_union)
return to_jsil_union_type(type1).is_subtype(type2_union);
else
return jsil_union_typet(type1).is_subtype(type2_union);
}
else
return type1.id()==type2.id();
}