void struct_factory::register_value(expr * new_value) { sort * s = m_manager.get_sort(new_value); value_set * set = get_value_set(s); if (!set->contains(new_value)) { m_values.push_back(new_value); set->insert(new_value); } }
bool value_sett::eval_pointer_offset( exprt &expr, const namespacet &ns) const { bool mod=false; if(expr.id()==ID_pointer_offset) { assert(expr.operands().size()==1); object_mapt reference_set; get_value_set(expr.op0(), reference_set, ns, true); exprt new_expr; mp_integer previous_offset=0; const object_map_dt &object_map=reference_set.read(); for(object_map_dt::const_iterator it=object_map.begin(); it!=object_map.end(); it++) if(!it->second.offset_is_set) return false; else { const exprt &object=object_numbering[it->first]; mp_integer ptr_offset=compute_pointer_offset(object, ns); if(ptr_offset<0) return false; ptr_offset+=it->second.offset; if(mod && ptr_offset!=previous_offset) return false; new_expr=from_integer(ptr_offset, index_type()); previous_offset=ptr_offset; mod=true; } if(mod) expr.swap(new_expr); } else { Forall_operands(it, expr) mod=eval_pointer_offset(*it, ns) || mod; } return mod; }
bool struct_factory::get_some_values(sort * s, expr_ref & v1, expr_ref & v2) { value_set * set = get_value_set(s); switch (set->size()) { case 0: v1 = get_fresh_value(s); v2 = get_fresh_value(s); return v1 != 0 && v2 != 0; case 1: v1 = get_some_value(s); v2 = get_fresh_value(s); return v2 != 0; default: obj_hashtable<expr>::iterator it = set->begin(); v1 = *it; ++it; v2 = *it; return true; } }
void value_sett::get_value_set( const exprt &expr, value_setst::valuest &dest, const namespacet &ns) const { object_mapt object_map; get_value_set(expr, object_map, ns, false); for(object_map_dt::const_iterator it=object_map.read().begin(); it!=object_map.read().end(); it++) dest.push_back(to_expr(it)); #if 0 for(value_setst::valuest::const_iterator it=dest.begin(); it!=dest.end(); it++) std::cout << "GET_VALUE_SET: " << from_expr(ns, "", *it) << std::endl; #endif }