1141 "an array now holds the following array #(#(receiver argument) answer) or #(#(receiver) answer). |
1141 "an array now holds the following array #(#(receiver argument) answer) or #(#(receiver) answer). |
1142 which should be suitable input for the method finder." |
1142 which should be suitable input for the method finder." |
1143 self withCursor:(Cursor execute) do:[ |
1143 self withCursor:(Cursor execute) do:[ |
1144 mf := MethodFinder new. |
1144 mf := MethodFinder new. |
1145 mf load:anArray. |
1145 mf load:anArray. |
1146 resultArray := mf findMessage. |
1146 resultArrayOrErrorString := mf findMessage. |
1147 ]. |
1147 ]. |
1148 |
1148 |
1149 (resultArray isString "(resultArray at:1) includesSubString:'no single'") ifTrue:[ |
1149 (resultArrayOrErrorString isString "(resultArray at:1) includesSubString:'no single'") ifTrue:[ |
1150 false ifTrue:[ |
1150 false ifTrue:[ |
1151 (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' bindWith:(resultArray at:1))) |
1151 (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' |
|
1152 bindWith:resultArrayOrErrorString)) |
1152 ifTrue:[ |
1153 ifTrue:[ |
1153 self search2Levels. |
1154 self search2Levels. |
1154 ]. |
1155 ]. |
1155 ] ifFalse:[ |
1156 ] ifFalse:[ |
1156 self warn:(resultArray at:1). |
1157 self warn:resultArrayOrErrorString. |
|
1158 ]. |
|
1159 ^ self |
|
1160 ]. |
|
1161 |
|
1162 "the following then replaces data1 and data2 created by the method finder to the appropriate arguments" |
|
1163 resultArrayOrErrorString |
|
1164 keysAndValuesDo:[:key :value | |
|
1165 |newValue| |
|
1166 |
|
1167 newValue := value copyReplaceString:'data1' |
|
1168 withString:(tempReceiver value storeString). "/ was: "tempReceiver key" |
|
1169 (tempArguments size) >= 1 ifTrue:[ |
|
1170 newValue := newValue copyReplaceString:'data2' |
|
1171 withString:(tempArguments valueAt:1) storeString "/ was "keyAt:1" |
|
1172 ]. |
|
1173 (tempArguments size) > 1 ifTrue:[ |
|
1174 newValue := newValue copyReplaceString:'data3' |
|
1175 withString:(tempArguments valueAt:2) storeString. "/ was "keyAt:2" |
|
1176 ]. |
|
1177 (tempArguments size) > 2 ifTrue:[ |
|
1178 newValue := newValue copyReplaceString:'data4' |
|
1179 withString:(tempArguments valueAt:3) storeString. "/ was: keyAt:3 |
|
1180 ]. |
|
1181 (tempArguments size) > 3 ifTrue:[ |
|
1182 self halt:'unimplemented'. |
|
1183 ]. |
|
1184 " newValue:= value copyReplaceString: 'data3' withString:(self messageAnswer key). " |
|
1185 newValue := newValue , ' --> ' , (tempAnswer key). |
|
1186 newValue replaceAll:Character cr with:Character space. |
|
1187 resultArrayOrErrorString at:key put:newValue. |
|
1188 ]. |
|
1189 self resultHolder value:resultArrayOrErrorString. |
|
1190 resultSelectors := mf selectors. |
|
1191 receiver := tempReceiver |
|
1192 |
|
1193 "Modified: / 26-09-2011 / 12:42:28 / cg" |
|
1194 "Modified: / 27-02-2018 / 11:37:58 / stefan" |
|
1195 "Modified: / 18-07-2019 / 21:57:12 / Claus Gittinger" |
|
1196 ! |
|
1197 |
|
1198 search2Levels |
|
1199 "Do an exhaustive search. |
|
1200 Given the original message, |
|
1201 try applying all unary messages first to the receiver, |
|
1202 then to each argument. |
|
1203 This takes O(N²) time - so be prepared" |
|
1204 |
|
1205 |tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf| |
|
1206 |
|
1207 tempArguments := self argumentEditorsContents. |
|
1208 tempReceiver := self receiverEditorContents. |
|
1209 tempAnswer := self messageAnswerEditorContents. |
|
1210 |
|
1211 receiverWithArgument := self mergeReceiver:(tempReceiver value) |
|
1212 withArgument:(tempArguments values). |
|
1213 anArray := Array |
|
1214 with:receiverWithArgument; |
|
1215 with:tempAnswer value. |
|
1216 |
|
1217 "an array now holds the following array #(#(receiver argument) answer) or #(#(receiver) answer). |
|
1218 which should be suitable input for the method finder." |
|
1219 self withCursor:Cursor execute do:[ |
|
1220 mf := MethodFinder new. |
|
1221 mf load:anArray. |
|
1222 resultArray := mf findMessage. |
|
1223 ]. |
|
1224 |
|
1225 (resultArray isString "(resultArray at:1) includesSubString:'no single'") ifTrue:[ |
|
1226 (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' bindWith:(resultArray at:1))) |
|
1227 ifTrue:[ |
|
1228 self search2Levels. |
1157 ]. |
1229 ]. |
1158 ^ self |
1230 ^ self |
1159 ]. |
1231 ]. |
1160 |
1232 |
1161 "the following then replaces data1 and data2 created by the method finder to the appropriate arguments" |
1233 "the following then replaces data1 and data2 created by the method finder to the appropriate arguments" |
1187 ]. |
1259 ]. |
1188 self resultHolder value:resultArray. |
1260 self resultHolder value:resultArray. |
1189 resultSelectors := mf selectors. |
1261 resultSelectors := mf selectors. |
1190 receiver := tempReceiver |
1262 receiver := tempReceiver |
1191 |
1263 |
1192 "Modified: / 26-09-2011 / 12:42:28 / cg" |
|
1193 "Modified: / 27-02-2018 / 11:37:58 / stefan" |
|
1194 "Modified: / 18-07-2019 / 21:57:12 / Claus Gittinger" |
|
1195 ! |
|
1196 |
|
1197 search2Levels |
|
1198 "Do an exhaustive search. |
|
1199 Given the original message, |
|
1200 try applying all unary messages first to the receiver, |
|
1201 then to each argument. |
|
1202 This takes O(N²) time - so be prepared" |
|
1203 |
|
1204 |tempReceiver tempAnswer tempArguments anArray resultArray receiverWithArgument mf| |
|
1205 |
|
1206 tempArguments := self argumentEditorsContents. |
|
1207 tempReceiver := self receiverEditorContents. |
|
1208 tempAnswer := self messageAnswerEditorContents. |
|
1209 |
|
1210 receiverWithArgument := self mergeReceiver:(tempReceiver value) |
|
1211 withArgument:(tempArguments values). |
|
1212 anArray := Array |
|
1213 with:receiverWithArgument; |
|
1214 with:tempAnswer value. |
|
1215 |
|
1216 "an array now holds the following array #(#(receiver argument) answer) or #(#(receiver) answer). |
|
1217 which should be suitable input for the method finder." |
|
1218 self withCursor:Cursor execute do:[ |
|
1219 mf := MethodFinder new. |
|
1220 mf load:anArray. |
|
1221 resultArray := mf findMessage. |
|
1222 ]. |
|
1223 |
|
1224 (resultArray isString "(resultArray at:1) includesSubString:'no single'") ifTrue:[ |
|
1225 (self confirm:(c'%1\nTry a more exhaustive search (may take long)?' bindWith:(resultArray at:1))) |
|
1226 ifTrue:[ |
|
1227 self search2Levels. |
|
1228 ]. |
|
1229 ^ self |
|
1230 ]. |
|
1231 |
|
1232 "the following then replaces data1 and data2 created by the method finder to the appropriate arguments" |
|
1233 resultArray |
|
1234 keysAndValuesDo:[:key :value | |
|
1235 |newValue| |
|
1236 |
|
1237 newValue := value copyReplaceString:'data1' |
|
1238 withString:(tempReceiver value storeString). "/ was: "tempReceiver key" |
|
1239 (tempArguments size) >= 1 ifTrue:[ |
|
1240 newValue := newValue copyReplaceString:'data2' |
|
1241 withString:(tempArguments valueAt:1) storeString "/ was "keyAt:1" |
|
1242 ]. |
|
1243 (tempArguments size) > 1 ifTrue:[ |
|
1244 newValue := newValue copyReplaceString:'data3' |
|
1245 withString:(tempArguments valueAt:2) storeString. "/ was "keyAt:2" |
|
1246 ]. |
|
1247 (tempArguments size) > 2 ifTrue:[ |
|
1248 newValue := newValue copyReplaceString:'data4' |
|
1249 withString:(tempArguments valueAt:3) storeString. "/ was: keyAt:3 |
|
1250 ]. |
|
1251 (tempArguments size) > 3 ifTrue:[ |
|
1252 self halt:'unimplemented'. |
|
1253 ]. |
|
1254 " newValue:= value copyReplaceString: 'data3' withString:(self messageAnswer key). " |
|
1255 newValue := newValue , ' --> ' , (tempAnswer key). |
|
1256 newValue replaceAll:Character cr with:Character space. |
|
1257 resultArray at:key put:newValue. |
|
1258 ]. |
|
1259 self resultHolder value:resultArray. |
|
1260 resultSelectors := mf selectors. |
|
1261 receiver := tempReceiver |
|
1262 |
|
1263 "Created: / 18-07-2019 / 21:22:47 / Claus Gittinger" |
1264 "Created: / 18-07-2019 / 21:22:47 / Claus Gittinger" |
1264 ! |
1265 ! |
1265 |
1266 |
1266 searchPatternMatches:pattern |
1267 searchPatternMatches:pattern |
1267 "Do a search based on the pattern match" |
1268 "Do a search based on the pattern match" |