本文整理汇总了C++中typet类的典型用法代码示例。如果您正苦于以下问题:C++ typet类的具体用法?C++ typet怎么用?C++ typet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了typet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: write
void c_qualifierst::write(typet &dest) const
{
if(is_constant)
dest.set(ID_C_constant, true);
else
dest.remove(ID_C_constant);
if(is_volatile)
dest.set(ID_C_volatile, true);
else
dest.remove(ID_C_volatile);
if(is_restricted)
dest.set(ID_C_restricted, true);
else
dest.remove(ID_C_restricted);
if(is_ptr32)
dest.set(ID_C_ptr32, true);
else
dest.remove(ID_C_ptr32);
if(is_ptr64)
dest.set(ID_C_ptr64, true);
else
dest.remove(ID_C_ptr64);
}
示例5: typecheck_typeof_type
void c_typecheck_baset::typecheck_typeof_type(typet &type)
{
// retain the qualifiers as is
c_qualifierst c_qualifiers;
c_qualifiers.read(type);
if(!((const exprt &)type).has_operands())
{
typet t=static_cast<const typet &>(type.find(ID_type_arg));
typecheck_type(t);
type.swap(t);
}
else
{
exprt expr=((const exprt &)type).op0();
typecheck_expr(expr);
// undo an implicit address-of
if(expr.id()==ID_address_of &&
expr.get_bool(ID_C_implicit))
{
assert(expr.operands().size()==1);
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
}
type.swap(expr.type());
}
c_qualifiers.write(type);
}
示例6: 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 &&
示例7: 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);
}
示例8: clear
void c_qualifierst::clear(typet &dest)
{
dest.remove(ID_C_constant);
dest.remove(ID_C_volatile);
dest.remove(ID_C_restricted);
dest.remove(ID_C_ptr32);
dest.remove(ID_C_ptr64);
}
示例9: adjust_type
void ranking_synthesis_satt::adjust_type(typet &type) const
{
if(type.id()=="bool")
{
type=uint_type();
type.set("width", 1);
}
}
示例10: replace_symbol
void c_typecheck_baset::typecheck_symbol_type(typet &type)
{
{
// add prefix
symbol_typet &symbol_type=to_symbol_type(type);
symbol_type.set_identifier(add_language_prefix(symbol_type.get_identifier()));
}
// adjust identifier, if needed
replace_symbol(type);
const irep_idt &identifier=
to_symbol_type(type).get_identifier();
symbol_tablet::symbolst::const_iterator s_it=
symbol_table.symbols.find(identifier);
if(s_it==symbol_table.symbols.end())
{
err_location(type);
str << "type symbol `" << identifier << "' not found";
throw 0;
}
const symbolt &symbol=s_it->second;
if(!symbol.is_type)
{
err_location(type);
throw "expected type symbol";
}
if(symbol.is_macro)
{
// overwrite, but preserve (add) any qualifiers and other flags
c_qualifierst c_qualifiers(type);
bool is_packed=type.get_bool(ID_C_packed);
irept alignment=type.find(ID_C_alignment);
c_qualifiers+=c_qualifierst(symbol.type);
type=symbol.type;
c_qualifiers.write(type);
if(is_packed) type.set(ID_C_packed, true);
if(alignment.is_not_nil()) type.set(ID_C_alignment, alignment);
}
// CPROVER extensions
if(symbol.base_name=="__CPROVER_rational")
{
type=rational_typet();
}
else if(symbol.base_name=="__CPROVER_integer")
{
type=integer_typet();
}
}
示例11: 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;
}
示例12: clear
void c_qualifierst::clear(typet &dest)
{
dest.remove(ID_C_constant);
dest.remove(ID_C_volatile);
dest.remove(ID_C_restricted);
dest.remove(ID_C_ptr32);
dest.remove(ID_C_ptr64);
dest.remove(ID_C_transparent_union);
dest.remove(ID_C_noreturn);
}
示例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: 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());
}
示例15: 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;
}