@@ -414,7 +414,15 @@ namespace sls {
414
414
return ev.val1 .svalue ;
415
415
}
416
416
}
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
+ }
418
426
case OP_SEQ_NTH:
419
427
case OP_SEQ_NTH_I:
420
428
case OP_SEQ_NTH_U:
@@ -1133,6 +1141,10 @@ namespace sls {
1133
1141
if (seq.is_string (to_app (e)->get_arg (0 )->get_sort ()))
1134
1142
return repair_down_in_re (e);
1135
1143
break ;
1144
+ case OP_SEQ_REPLACE:
1145
+ if (seq.is_string (e->get_sort ()))
1146
+ return repair_down_str_replace (e);
1147
+ break ;
1136
1148
case OP_STRING_UBVTOS:
1137
1149
case OP_STRING_SBVTOS:
1138
1150
case OP_STRING_TO_CODE:
@@ -1141,7 +1153,7 @@ namespace sls {
1141
1153
case OP_SEQ_NTH:
1142
1154
case OP_SEQ_NTH_I:
1143
1155
case OP_SEQ_NTH_U:
1144
- case OP_SEQ_REPLACE:
1156
+
1145
1157
case OP_SEQ_REPLACE_RE_ALL:
1146
1158
case OP_SEQ_REPLACE_RE:
1147
1159
case OP_SEQ_REPLACE_ALL:
@@ -1180,6 +1192,18 @@ namespace sls {
1180
1192
return false ;
1181
1193
}
1182
1194
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
+
1183
1207
bool seq_plugin::repair_down_str_itos (app* e) {
1184
1208
expr* x;
1185
1209
VERIFY (seq.str .is_itos (e, x));
0 commit comments