@@ -414,7 +414,15 @@ namespace sls {
414414 return ev.val1 .svalue ;
415415 }
416416 }
417- case OP_SEQ_REPLACE:
417+ case OP_SEQ_REPLACE: {
418+ expr* x, * y, * z;
419+ VERIFY (seq.str .is_replace (e, x, y, z));
420+ zstring r = strval0 (x);
421+ zstring s = strval0 (y);
422+ zstring t = strval0 (z);
423+ ev.val1 .svalue = r.replace (s, t);
424+ return ev.val1 .svalue ;
425+ }
418426 case OP_SEQ_NTH:
419427 case OP_SEQ_NTH_I:
420428 case OP_SEQ_NTH_U:
@@ -1133,6 +1141,10 @@ namespace sls {
11331141 if (seq.is_string (to_app (e)->get_arg (0 )->get_sort ()))
11341142 return repair_down_in_re (e);
11351143 break ;
1144+ case OP_SEQ_REPLACE:
1145+ if (seq.is_string (e->get_sort ()))
1146+ return repair_down_str_replace (e);
1147+ break ;
11361148 case OP_STRING_UBVTOS:
11371149 case OP_STRING_SBVTOS:
11381150 case OP_STRING_TO_CODE:
@@ -1141,7 +1153,7 @@ namespace sls {
11411153 case OP_SEQ_NTH:
11421154 case OP_SEQ_NTH_I:
11431155 case OP_SEQ_NTH_U:
1144- case OP_SEQ_REPLACE:
1156+
11451157 case OP_SEQ_REPLACE_RE_ALL:
11461158 case OP_SEQ_REPLACE_RE:
11471159 case OP_SEQ_REPLACE_ALL:
@@ -1180,6 +1192,18 @@ namespace sls {
11801192 return false ;
11811193 }
11821194
1195+ bool seq_plugin::repair_down_str_replace (app* e) {
1196+ expr* x, * y, * z;
1197+ VERIFY (seq.str .is_replace (e, x, y, z));
1198+ zstring r = strval0 (e);
1199+ if (r == strval1 (e))
1200+ return true ;
1201+ if (!is_value (x))
1202+ m_str_updates.push_back ({ x, r, 1 });
1203+ // TODO some more possible ways, also deal with y, z if they are not values.
1204+ return apply_update ();
1205+ }
1206+
11831207 bool seq_plugin::repair_down_str_itos (app* e) {
11841208 expr* x;
11851209 VERIFY (seq.str .is_itos (e, x));
0 commit comments