@@ -38,50 +38,37 @@ bv2fpa_converter::bv2fpa_converter(ast_manager & m, fpa2bv_converter & conv) :
38
38
m_fpa_util(m),
39
39
m_bv_util(m),
40
40
m_th_rw(m) {
41
- for (obj_map<func_decl, expr*>::iterator it = conv.m_const2bv .begin ();
42
- it != conv.m_const2bv .end ();
43
- it++)
44
- {
45
- m_const2bv.insert (it->m_key , it->m_value );
46
- m.inc_ref (it->m_key );
47
- m.inc_ref (it->m_value );
41
+ for (auto const & kv : conv.m_const2bv ) {
42
+ m_const2bv.insert (kv.m_key , kv.m_value );
43
+ m.inc_ref (kv.m_key );
44
+ m.inc_ref (kv.m_value );
48
45
}
49
- for (obj_map<func_decl, expr*>::iterator it = conv.m_rm_const2bv .begin ();
50
- it != conv.m_rm_const2bv .end ();
51
- it++)
52
- {
53
- m_rm_const2bv.insert (it->m_key , it->m_value );
54
- m.inc_ref (it->m_key );
55
- m.inc_ref (it->m_value );
46
+ for (auto const & kv : conv.m_rm_const2bv ) {
47
+ m_rm_const2bv.insert (kv.m_key , kv.m_value );
48
+ m.inc_ref (kv.m_key );
49
+ m.inc_ref (kv.m_value );
56
50
}
57
- for (obj_map<func_decl, func_decl*>::iterator it = conv.m_uf2bvuf .begin ();
58
- it != conv.m_uf2bvuf .end ();
59
- it++)
60
- {
61
- m_uf2bvuf.insert (it->m_key , it->m_value );
62
- m.inc_ref (it->m_key );
63
- m.inc_ref (it->m_value );
51
+ for (auto const & kv : conv.m_uf2bvuf ) {
52
+ m_uf2bvuf.insert (kv.m_key , kv.m_value );
53
+ m.inc_ref (kv.m_key );
54
+ m.inc_ref (kv.m_value );
64
55
}
65
- for (obj_map<func_decl, std::pair<app*, app*> >::iterator it = conv.m_min_max_ufs .begin ();
66
- it != conv.m_min_max_ufs .end ();
67
- it++) {
68
- m_specials.insert (it->m_key , it->m_value );
69
- m.inc_ref (it->m_key );
70
- m.inc_ref (it->m_value .first );
71
- m.inc_ref (it->m_value .second );
56
+ for (auto const & kv : conv.m_min_max_ufs ) {
57
+ m_specials.insert (kv.m_key , kv.m_value );
58
+ m.inc_ref (kv.m_key );
59
+ m.inc_ref (kv.m_value .first );
60
+ m.inc_ref (kv.m_value .second );
72
61
}
73
62
}
74
63
75
64
bv2fpa_converter::~bv2fpa_converter () {
76
65
dec_ref_map_key_values (m, m_const2bv);
77
66
dec_ref_map_key_values (m, m_rm_const2bv);
78
67
dec_ref_map_key_values (m, m_uf2bvuf);
79
- for (obj_map<func_decl, std::pair<app*, app*> >::iterator it = m_specials.begin ();
80
- it != m_specials.end ();
81
- it++) {
82
- m.dec_ref (it->m_key );
83
- m.dec_ref (it->m_value .first );
84
- m.dec_ref (it->m_value .second );
68
+ for (auto const & kv : m_specials) {
69
+ m.dec_ref (kv.m_key );
70
+ m.dec_ref (kv.m_value .first );
71
+ m.dec_ref (kv.m_value .second );
85
72
}
86
73
}
87
74
@@ -313,12 +300,9 @@ func_interp * bv2fpa_converter::convert_func_interp(model_core * mc, func_decl *
313
300
}
314
301
315
302
void bv2fpa_converter::convert_consts (model_core * mc, model_core * target_model, obj_hashtable<func_decl> & seen) {
316
- for (obj_map<func_decl, expr*>::iterator it = m_const2bv.begin ();
317
- it != m_const2bv.end ();
318
- it++)
319
- {
320
- func_decl * var = it->m_key ;
321
- app * val = to_app (it->m_value );
303
+ for (auto const & kv : m_const2bv) {
304
+ func_decl * var = kv.m_key ;
305
+ app * val = to_app (kv.m_value );
322
306
SASSERT (m_fpa_util.is_float (var->get_range ()));
323
307
SASSERT (var->get_range ()->get_num_parameters () == 2 );
324
308
unsigned ebits = m_fpa_util.get_ebits (var->get_range ());
@@ -383,13 +367,10 @@ void bv2fpa_converter::convert_consts(model_core * mc, model_core * target_model
383
367
}
384
368
385
369
void bv2fpa_converter::convert_rm_consts (model_core * mc, model_core * target_model, obj_hashtable<func_decl> & seen) {
386
- for (obj_map<func_decl, expr*>::iterator it = m_rm_const2bv.begin ();
387
- it != m_rm_const2bv.end ();
388
- it++)
389
- {
390
- func_decl * var = it->m_key ;
370
+ for (auto const & kv : m_rm_const2bv) {
371
+ func_decl * var = kv.m_key ;
391
372
SASSERT (m_fpa_util.is_rm (var->get_range ()));
392
- expr * val = it-> m_value ;
373
+ expr * val = kv. m_value ;
393
374
SASSERT (m_fpa_util.is_bv2rm (val));
394
375
expr * bvval = to_app (val)->get_arg (0 );
395
376
expr_ref fv = convert_bv2rm (mc, to_app (bvval));
@@ -400,12 +381,10 @@ void bv2fpa_converter::convert_rm_consts(model_core * mc, model_core * target_mo
400
381
}
401
382
402
383
void bv2fpa_converter::convert_min_max_specials (model_core * mc, model_core * target_model, obj_hashtable<func_decl> & seen) {
403
- for (obj_map<func_decl, std::pair<app*, app*> >::iterator it = m_specials.begin ();
404
- it != m_specials.end ();
405
- it++) {
406
- func_decl * f = it->m_key ;
407
- app * pn_cnst = it->m_value .first ;
408
- app * np_cnst = it->m_value .second ;
384
+ for (auto const & kv : m_specials) {
385
+ func_decl * f = kv.m_key ;
386
+ app * pn_cnst = kv.m_value .first ;
387
+ app * np_cnst = kv.m_value .second ;
409
388
410
389
expr_ref pzero (m), nzero (m);
411
390
pzero = m_fpa_util.mk_pzero (f->get_range ());
@@ -434,17 +413,16 @@ void bv2fpa_converter::convert_min_max_specials(model_core * mc, model_core * ta
434
413
}
435
414
436
415
void bv2fpa_converter::convert_uf2bvuf (model_core * mc, model_core * target_model, obj_hashtable<func_decl> & seen) {
437
- for (obj_map<func_decl, func_decl*>::iterator it = m_uf2bvuf.begin ();
438
- it != m_uf2bvuf.end ();
439
- it++) {
440
- seen.insert (it->m_value );
416
+ for (auto const & kv : m_uf2bvuf) {
417
+ seen.insert (kv.m_value );
441
418
442
- func_decl * f = it->m_key ;
419
+ func_decl * f = kv.m_key ;
420
+ std::cout << f->get_name () << " \n " ;
443
421
if (f->get_arity () == 0 )
444
422
{
445
423
array_util au (m);
446
424
if (au.is_array (f->get_range ())) {
447
- array_model am = convert_array_func_interp (mc, f, it-> m_value );
425
+ array_model am = convert_array_func_interp (mc, f, kv. m_value );
448
426
if (am.new_float_fd ) target_model->register_decl (am.new_float_fd , am.new_float_fi );
449
427
if (am.result ) target_model->register_decl (f, am.result );
450
428
if (am.bv_fd ) seen.insert (am.bv_fd );
@@ -453,92 +431,82 @@ void bv2fpa_converter::convert_uf2bvuf(model_core * mc, model_core * target_mode
453
431
// Just keep.
454
432
SASSERT (!m_fpa_util.is_float (f->get_range ()) && !m_fpa_util.is_rm (f->get_range ()));
455
433
expr_ref val (m);
456
- if (mc->eval (it-> m_value , val))
434
+ if (mc->eval (kv. m_value , val))
457
435
target_model->register_decl (f, val);
458
436
}
459
437
}
460
- else {
461
- if (it->get_key ().get_family_id () == m_fpa_util.get_fid ()) {
462
- // it->m_value contains the model for the unspecified cases of it->m_key.
463
- target_model->register_decl (f, convert_func_interp (mc, f, it->m_value ));
464
- }
438
+ else if (f->get_family_id () == m_fpa_util.get_fid ()) {
439
+
440
+ // kv.m_value contains the model for the unspecified cases of kv.m_key.
441
+ // TBD: instead of mapping the interpretation of f to just the graph for the
442
+ // uninterpreted case, map it to a condition, ite, that filters out the
443
+ // pre-condition for which argument combinations are interpreted vs. uninterpreted.
444
+ // if (m_fpa_util.is_to_ieee_bv(f)) {
445
+ // }
446
+ // if (m_fpa_util.is_to_sbv(f)) {
447
+ // }
448
+
449
+
450
+ target_model->register_decl (f, convert_func_interp (mc, f, kv.m_value ));
465
451
}
466
452
}
467
453
}
468
454
469
455
void bv2fpa_converter::display (std::ostream & out) {
470
- for (obj_map<func_decl, expr*>::iterator it = m_const2bv.begin ();
471
- it != m_const2bv.end ();
472
- it++) {
473
- const symbol & n = it->m_key ->get_name ();
456
+ for (auto const & kv : m_const2bv) {
457
+ const symbol & n = kv.m_key ->get_name ();
474
458
out << " \n (" << n << " " ;
475
459
unsigned indent = n.size () + 4 ;
476
- out << mk_ismt2_pp (it-> m_value , m, indent) << " )" ;
460
+ out << mk_ismt2_pp (kv. m_value , m, indent) << " )" ;
477
461
}
478
- for (obj_map<func_decl, expr*>::iterator it = m_rm_const2bv.begin ();
479
- it != m_rm_const2bv.end ();
480
- it++) {
481
- const symbol & n = it->m_key ->get_name ();
462
+ for (auto const & kv : m_rm_const2bv) {
463
+ const symbol & n = kv.m_key ->get_name ();
482
464
out << " \n (" << n << " " ;
483
465
unsigned indent = n.size () + 4 ;
484
- out << mk_ismt2_pp (it-> m_value , m, indent) << " )" ;
466
+ out << mk_ismt2_pp (kv. m_value , m, indent) << " )" ;
485
467
}
486
- for (obj_map<func_decl, func_decl*>::iterator it = m_uf2bvuf.begin ();
487
- it != m_uf2bvuf.end ();
488
- it++) {
489
- const symbol & n = it->m_key ->get_name ();
468
+ for (auto const & kv : m_uf2bvuf) {
469
+ const symbol & n = kv.m_key ->get_name ();
490
470
out << " \n (" << n << " " ;
491
471
unsigned indent = n.size () + 4 ;
492
- out << mk_ismt2_pp (it-> m_value , m, indent) << " )" ;
472
+ out << mk_ismt2_pp (kv. m_value , m, indent) << " )" ;
493
473
}
494
- for (obj_map<func_decl, std::pair<app*, app*> >::iterator it = m_specials.begin ();
495
- it != m_specials.end ();
496
- it++) {
497
- const symbol & n = it->m_key ->get_name ();
474
+ for (auto const & kv : m_specials) {
475
+ const symbol & n = kv.m_key ->get_name ();
498
476
out << " \n (" << n << " " ;
499
477
unsigned indent = n.size () + 4 ;
500
- out << mk_ismt2_pp (it-> m_value .first , m, indent) << " ; " <<
501
- mk_ismt2_pp (it-> m_value .second , m, indent) << " )" ;
478
+ out << mk_ismt2_pp (kv. m_value .first , m, indent) << " ; " <<
479
+ mk_ismt2_pp (kv. m_value .second , m, indent) << " )" ;
502
480
}
503
481
}
504
482
505
483
bv2fpa_converter * bv2fpa_converter::translate (ast_translation & translator) {
506
484
bv2fpa_converter * res = alloc (bv2fpa_converter, translator.to ());
507
- for (obj_map<func_decl, expr*>::iterator it = m_const2bv.begin ();
508
- it != m_const2bv.end ();
509
- it++)
510
- {
511
- func_decl * k = translator (it->m_key );
512
- expr * v = translator (it->m_value );
485
+ for (auto const & kv : m_const2bv) {
486
+ func_decl * k = translator (kv.m_key );
487
+ expr * v = translator (kv.m_value );
513
488
res->m_const2bv .insert (k, v);
514
489
translator.to ().inc_ref (k);
515
490
translator.to ().inc_ref (v);
516
491
}
517
- for (obj_map<func_decl, expr*>::iterator it = m_rm_const2bv.begin ();
518
- it != m_rm_const2bv.end ();
519
- it++)
520
- {
521
- func_decl * k = translator (it->m_key );
522
- expr * v = translator (it->m_value );
492
+ for (auto const & kv : m_rm_const2bv) {
493
+ func_decl * k = translator (kv.m_key );
494
+ expr * v = translator (kv.m_value );
523
495
res->m_rm_const2bv .insert (k, v);
524
496
translator.to ().inc_ref (k);
525
497
translator.to ().inc_ref (v);
526
498
}
527
- for (obj_map<func_decl, func_decl*>::iterator it = m_uf2bvuf.begin ();
528
- it != m_uf2bvuf.end ();
529
- it++) {
530
- func_decl * k = translator (it->m_key );
531
- func_decl * v = translator (it->m_value );
499
+ for (auto const & kv : m_uf2bvuf) {
500
+ func_decl * k = translator (kv.m_key );
501
+ func_decl * v = translator (kv.m_value );
532
502
res->m_uf2bvuf .insert (k, v);
533
503
translator.to ().inc_ref (k);
534
504
translator.to ().inc_ref (v);
535
505
}
536
- for (obj_map<func_decl, std::pair<app*, app*> >::iterator it = m_specials.begin ();
537
- it != m_specials.end ();
538
- it++) {
539
- func_decl * k = translator (it->m_key );
540
- app * v1 = translator (it->m_value .first );
541
- app * v2 = translator (it->m_value .second );
506
+ for (auto const & kv : m_specials) {
507
+ func_decl * k = translator (kv.m_key );
508
+ app * v1 = translator (kv.m_value .first );
509
+ app * v2 = translator (kv.m_value .second );
542
510
res->m_specials .insert (k, std::pair<app*, app*>(v1, v2));
543
511
translator.to ().inc_ref (k);
544
512
translator.to ().inc_ref (v1);
0 commit comments