author | Claus Gittinger <cg@exept.de> |
Sun, 12 May 2019 13:22:00 +0200 | |
changeset 4421 | d992c2e999b4 |
parent 4405 | cd0bc5bc3c23 |
child 4441 | 29ef162823ce |
permissions | -rw-r--r-- |
1983 | 1 |
" |
4026 | 2 |
Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls) |
3 |
Copyright (C) 2001 eXept Software AG |
|
1983 | 4 |
|
4026 | 5 |
Permission is hereby granted, free of charge, to any |
6 |
person obtaining a copy of this software and associated |
|
7 |
documentation files (the 'Software'), to deal in the |
|
8 |
Software without restriction, including without limitation |
|
9 |
the rights to use, copy, modify, merge, publish, distribute, |
|
10 |
sublicense, and/or sell copies of the Software, and to |
|
11 |
permit persons to whom the Software is furnished to do so, |
|
12 |
subject to the following conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall |
|
15 |
be included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
20 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
21 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
22 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
23 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
1983 | 24 |
" |
1089 | 25 |
"{ Package: 'stx:libbasic3' }" |
26 |
||
3773 | 27 |
"{ NameSpace: Smalltalk }" |
28 |
||
1089 | 29 |
Object subclass:#MethodFinder |
1106 | 30 |
instanceVariableNames:'data answers selector argMap thisData mapStage mapList |
31 |
expressions cachedClass cachedArgNum cachedSelectorLists' |
|
1491 | 32 |
classVariableNames:'AddAndRemove Approved Blocks BlocksOptional Dangerous' |
1106 | 33 |
poolDictionaries:'' |
3872 | 34 |
category:'Interface-Tools' |
1089 | 35 |
! |
36 |
||
1100 | 37 |
!MethodFinder class methodsFor:'documentation'! |
38 |
||
1983 | 39 |
copyright |
40 |
" |
|
4026 | 41 |
Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls) |
42 |
Copyright (C) 2001 eXept Software AG |
|
1983 | 43 |
|
4026 | 44 |
Permission is hereby granted, free of charge, to any |
45 |
person obtaining a copy of this software and associated |
|
46 |
documentation files (the 'Software'), to deal in the |
|
47 |
Software without restriction, including without limitation |
|
48 |
the rights to use, copy, modify, merge, publish, distribute, |
|
49 |
sublicense, and/or sell copies of the Software, and to |
|
50 |
permit persons to whom the Software is furnished to do so, |
|
51 |
subject to the following conditions: |
|
52 |
||
53 |
The above copyright notice and this permission notice shall |
|
54 |
be included in all copies or substantial portions of the Software. |
|
55 |
||
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
59 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
60 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
61 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
62 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
1983 | 63 |
" |
64 |
! |
|
65 |
||
1100 | 66 |
documentation |
67 |
" |
|
4026 | 68 |
a utility to find implementing methods by example. |
69 |
Give it values for a receiver, optional arguments and a desired result, |
|
70 |
and it will find methods which do that for you. |
|
71 |
Please read the online documentation for details, |
|
72 |
or open the MethodFinderView GUI. |
|
73 |
||
74 |
[example:] |
|
75 |
which message, answers 7, given to 4 with an argument of 3, |
|
76 |
and also answers 5, if sent with an arg of 5 to 0 |
|
77 |
and 10, if send to 5 with an argument of 5: |
|
78 |
||
79 |
MethodFinder methodFor: #( |
|
80 |
(4 3) 7 |
|
81 |
(0 5) 5 |
|
82 |
(5 5) 10 |
|
83 |
) |
|
84 |
You guessed it; it's the '+' message. |
|
85 |
||
1100 | 86 |
[author:] |
4026 | 87 |
original squeak version by Ted Kaehler, Scott Wallace and Dan Ingalls. |
88 |
ported from Squeak and GUI enhanced 2001 by James Hayes james@exept.de. |
|
89 |
improved by Claus Gittinger. |
|
1100 | 90 |
" |
91 |
! ! |
|
1089 | 92 |
|
93 |
!MethodFinder class methodsFor:'accessing'! |
|
94 |
||
95 |
abortAllSignal |
|
96 |
"return the value of the static variable 'AbortAllSignal' (automatically generated)" |
|
97 |
||
98 |
^ AbortAllSignal |
|
99 |
! |
|
100 |
||
101 |
abortAllSignal:something |
|
102 |
"set the value of the static variable 'AbortAllSignal' (automatically generated)" |
|
103 |
||
104 |
AbortAllSignal := something. |
|
105 |
! |
|
106 |
||
107 |
addAndRemove |
|
108 |
"return the value of the static variable 'AddAndRemove' (automatically generated)" |
|
109 |
||
110 |
^ AddAndRemove |
|
111 |
! |
|
112 |
||
113 |
addAndRemove:something |
|
114 |
"set the value of the static variable 'AddAndRemove' (automatically generated)" |
|
115 |
||
116 |
AddAndRemove := something. |
|
117 |
! |
|
118 |
||
119 |
approved |
|
120 |
"return the value of the static variable 'Approved' (automatically generated)" |
|
121 |
||
122 |
^ Approved |
|
123 |
! |
|
124 |
||
125 |
approved:something |
|
126 |
"set the value of the static variable 'Approved' (automatically generated)" |
|
127 |
||
128 |
Approved := something. |
|
129 |
! |
|
130 |
||
131 |
blocks |
|
132 |
"return the value of the static variable 'Blocks' (automatically generated)" |
|
133 |
||
134 |
^ Blocks |
|
135 |
! |
|
136 |
||
137 |
blocks:something |
|
138 |
"set the value of the static variable 'Blocks' (automatically generated)" |
|
139 |
||
140 |
Blocks := something. |
|
141 |
! |
|
142 |
||
143 |
dangerous |
|
144 |
"return the value of the static variable 'Dangerous' (automatically generated)" |
|
145 |
||
146 |
^ Dangerous |
|
147 |
! |
|
148 |
||
149 |
dangerous:something |
|
150 |
"set the value of the static variable 'Dangerous' (automatically generated)" |
|
151 |
||
152 |
Dangerous := something. |
|
153 |
! ! |
|
154 |
||
4026 | 155 |
!MethodFinder class methodsFor:'utilities'! |
156 |
||
157 |
methodFor: dataAndAnswers |
|
158 |
"Return a Smalltalk expression that computes these answers." |
|
159 |
||
160 |
| resultOC resultString | |
|
161 |
||
162 |
resultOC := (self new) load: dataAndAnswers; findMessage. |
|
163 |
resultString := |
|
164 |
String streamContents: [:strm | |
|
165 |
resultOC do: [:exp | strm nextPut: $(; nextPutAll: exp; nextPut: $); space] |
|
166 |
]. |
|
167 |
||
168 |
^ resultString |
|
169 |
! ! |
|
170 |
||
2772 | 171 |
!MethodFinder methodsFor:'accessing'! |
1089 | 172 |
|
173 |
answers |
|
174 |
||
1104 | 175 |
^ answers |
1089 | 176 |
! |
177 |
||
178 |
data |
|
179 |
||
1104 | 180 |
^ data |
1089 | 181 |
! |
182 |
||
183 |
expressions |
|
1104 | 184 |
^ expressions |
1089 | 185 |
! |
186 |
||
187 |
selectors |
|
1104 | 188 |
"Note the inst var does not have an S on the end" |
1089 | 189 |
|
1104 | 190 |
^ selector |
1089 | 191 |
! ! |
192 |
||
193 |
!MethodFinder methodsFor:'arg maps'! |
|
194 |
||
195 |
argMap |
|
1104 | 196 |
^ argMap |
1089 | 197 |
! |
198 |
||
199 |
makeAllMaps |
|
1104 | 200 |
"Make a giant list of all permutations of the args. To find the function, we will try these permutations of the input data. receiver, args." |
1089 | 201 |
|
1104 | 202 |
| ii | |
203 |
mapList _ Array new: argMap size factorial. |
|
204 |
ii _ 1. |
|
205 |
argMap permutationsDo: [:perm | |
|
206 |
mapList at: ii put: perm copy. |
|
207 |
ii _ ii + 1]. |
|
208 |
mapStage _ 1. "about to be bumped" |
|
1089 | 209 |
! |
210 |
||
211 |
mapData |
|
1104 | 212 |
"Force the data through the map (permutation) to create the data to test." |
1089 | 213 |
|
1104 | 214 |
thisData _ data collect: [:realData | |
215 |
argMap collect: [:ind | realData at: ind]]. |
|
216 |
||
1089 | 217 |
! |
218 |
||
219 |
permuteArgs |
|
1104 | 220 |
"Run through ALL the permutations. First one was as presented." |
1089 | 221 |
|
1104 | 222 |
data first size <= 1 ifTrue: [^ false]. "no other way" |
1928 | 223 |
mapList isNil ifTrue: [self makeAllMaps]. |
1104 | 224 |
mapStage _ mapStage + 1. |
225 |
mapStage > mapList size ifTrue: [^ false]. |
|
226 |
argMap _ mapList at: mapStage. |
|
227 |
self mapData. |
|
228 |
^ true |
|
1089 | 229 |
! |
230 |
||
231 |
thisData |
|
1104 | 232 |
^ thisData |
1089 | 233 |
! ! |
234 |
||
235 |
!MethodFinder methodsFor:'find a constant'! |
|
236 |
||
237 |
allNumbers |
|
1104 | 238 |
"Return true if all answers and all data are numbers." |
1089 | 239 |
|
1104 | 240 |
answers do: [:aa | aa isNumber ifFalse: [^ false]]. |
241 |
thisData do: [:vec | |
|
242 |
vec do: [:nn | nn isNumber ifFalse: [^ false]]]. |
|
243 |
^ true |
|
1089 | 244 |
! |
245 |
||
246 |
const |
|
1104 | 247 |
| const | |
248 |
"See if (^ constant) is the answer" |
|
1089 | 249 |
|
1104 | 250 |
"quick test" |
251 |
((const _ answers at: 1) closeTo: (answers at: 2)) ifFalse: [^ false]. |
|
252 |
3 to: answers size do: [:ii | (const closeTo: (answers at: ii)) ifFalse: [^ false]]. |
|
253 |
expressions add: '^ ', const printString. |
|
254 |
selector add: #yourself. |
|
255 |
^ true |
|
1089 | 256 |
! |
257 |
||
258 |
constDiv |
|
259 |
"See if (data1 // C) is the answer" |
|
2054 | 260 |
self breakPoint:#cg. |
1089 | 261 |
^ false. |
2026 | 262 |
|
3320 | 263 |
"/ const _ ((thisData at: 1) at: 1) // (answers at: 1). "May not be right!!" |
264 |
"/ got _ (subTest _ MethodFinder new copy: self addArg: const) |
|
265 |
"/ searchForOne isEmpty not. |
|
266 |
"/ got ifFalse: [^ false]. |
|
267 |
"/ |
|
268 |
"/ "replace data2 with const in expressions" |
|
269 |
"/ subTest expressions do: [:exp | |
|
270 |
"/ expressions add: (exp copyReplaceString: "copyReplaceAll:" 'data2' withString: "with:" const printString)]. |
|
271 |
"/ selector addAll: subTest selectors. |
|
272 |
"/ ^ true |
|
1089 | 273 |
! |
274 |
||
275 |
constLessThan |
|
1104 | 276 |
| const subTest got minConst maxConst tt | |
277 |
"See if (data1 <= C) or (data1 >= C) is the answer" |
|
1089 | 278 |
|
1104 | 279 |
"quick test" |
280 |
((answers at: 1) class superclass == Boolean) ifFalse: [^ false]. |
|
281 |
2 to: answers size do: [:ii | |
|
282 |
((answers at: ii) class superclass == Boolean) ifFalse: [^ false]]. |
|
1089 | 283 |
|
1104 | 284 |
minConst _ Float infinity. maxConst _ minConst negated. |
285 |
answers withIndexDo: [:aa :ii | |
|
286 |
aa ifTrue: [tt _ (thisData at: ii) at: 1. |
|
287 |
minConst _ minConst min: tt. |
|
288 |
maxConst _ maxConst max: tt]]. |
|
289 |
const _ (thisData at: 1) at: 1. |
|
290 |
got _ (subTest _ MethodFinder new copy: self addArg: minConst) |
|
291 |
searchForOne isEmpty not. |
|
292 |
got ifFalse: ["try other extreme for <= >= " |
|
293 |
got _ (subTest _ MethodFinder new copy: self addArg: maxConst) |
|
294 |
searchForOne isEmpty not]. |
|
295 |
got ifFalse: [^ false]. |
|
1089 | 296 |
|
1104 | 297 |
"replace data2 with const in expressions" |
298 |
subTest expressions do: [:exp | |
|
2904 | 299 |
expressions add: (exp copyReplaceString: "copyReplaceAll:" 'data2' withString: "with:" const printString)]. |
1104 | 300 |
selector addAll: subTest selectors. |
301 |
^ true |
|
1089 | 302 |
! |
303 |
||
304 |
constLinear |
|
1104 | 305 |
| const subTest got denom num slope offset | |
306 |
"See if (data1 * C1) + C2 is the answer. In the form #(C2 C1) polynomialEval: data1 " |
|
1089 | 307 |
|
1104 | 308 |
denom _ ((thisData at: 2) at: 1) - ((thisData at: 1) at: 1). |
309 |
denom = 0 ifTrue: [^ false]. "will divide by it" |
|
310 |
num _ (answers at: 2) - (answers at: 1). |
|
1089 | 311 |
|
312 |
slope := (num asFloat / denom) reduce. |
|
313 |
offset := ((answers at: 2) - (((thisData at: 2) at: 1) * slope)) reduce. |
|
314 |
||
1104 | 315 |
const _ Array with: offset with: slope. |
316 |
got _ (subTest _ MethodFinder new copy: self addArg: const) |
|
317 |
searchForOne isEmpty not. |
|
318 |
got ifFalse: [^ false]. |
|
1089 | 319 |
|
1104 | 320 |
"replace data2 with const in expressions" |
321 |
subTest expressions do: [:exp | |
|
2904 | 322 |
expressions add: (exp copyReplaceString: "copyReplaceAll:" 'data2' withString: "with:" const printString)]. |
1104 | 323 |
selector addAll: subTest selectors. |
324 |
^ true |
|
1089 | 325 |
! |
326 |
||
327 |
constMod |
|
1104 | 328 |
| subTest low | |
329 |
"See if mod, (data1 \\ C) is the answer" |
|
1089 | 330 |
|
1104 | 331 |
low _ answers max. |
332 |
low+1 to: low+20 do: [:const | |
|
333 |
subTest _ MethodFinder new copy: self addArg: const. |
|
334 |
(subTest testPerfect: #\\) ifTrue: [ |
|
335 |
expressions add: 'data1 \\ ', const printString. |
|
336 |
selector add: #\\. |
|
337 |
^ true]]. |
|
338 |
^ false |
|
1089 | 339 |
! |
340 |
||
341 |
constMult |
|
1104 | 342 |
| const subTest got | |
343 |
"See if (data1 * C) is the answer" |
|
1089 | 344 |
|
1104 | 345 |
((thisData at: 1) at: 1) = 0 ifTrue: [^ false]. |
346 |
const _ ((answers at: 1) asFloat / ((thisData at: 1) at: 1)) reduce. |
|
347 |
got _ (subTest _ MethodFinder new copy: self addArg: const) |
|
348 |
searchForOne isEmpty not. |
|
349 |
got ifFalse: [^ false]. |
|
1089 | 350 |
|
1104 | 351 |
"replace data2 with const in expressions" |
352 |
subTest expressions do: [:exp | |
|
2904 | 353 |
expressions add: (exp copyReplaceString: "copyReplaceAll:" 'data2' withString: "with:" const printString)]. |
1104 | 354 |
selector addAll: subTest selectors. |
355 |
^ true |
|
1089 | 356 |
! |
357 |
||
358 |
constPlus |
|
1104 | 359 |
| const subTest got | |
360 |
"See if (data1 + C) is the answer" |
|
1089 | 361 |
|
1104 | 362 |
const _ (answers at: 1) - ((thisData at: 1) at: 1). |
363 |
got _ (subTest _ MethodFinder new copy: self addArg: const) |
|
364 |
searchForOne isEmpty not. |
|
365 |
got ifFalse: [^ false]. |
|
1089 | 366 |
|
1104 | 367 |
"replace data2 with const in expressions" |
368 |
subTest expressions do: [:exp | |
|
2904 | 369 |
expressions add: (exp copyReplaceString: "copyReplaceAll:" 'data2' withString: "with:" const printString)]. |
1104 | 370 |
selector addAll: subTest selectors. |
371 |
^ true |
|
1089 | 372 |
! ! |
373 |
||
2248 | 374 |
!MethodFinder methodsFor:'initialization'! |
1089 | 375 |
|
3515 | 376 |
cleanInputs:dataAndAnswerString |
377 |
"Find and remove common mistakes. Complain when ill formed." |
|
378 |
||
379 |
|fixed ddd rs places| |
|
1089 | 380 |
|
3515 | 381 |
ddd := dataAndAnswerString. |
4025 | 382 |
|
383 |
"/ check if user typed #true / #false instead of true / false |
|
384 |
||
3515 | 385 |
fixed := false. |
386 |
rs := ReadStream on:ddd , ' '. |
|
387 |
places := OrderedCollection new. |
|
388 |
[ |
|
389 |
rs upToAll_positionBefore:'#true'. |
|
390 |
rs atEnd |
|
391 |
] whileFalse:[ places addFirst:rs position ]. |
|
392 |
places do:[:pos | |
|
393 |
ddd := ddd |
|
394 |
copyReplaceFrom:pos |
|
395 |
to:pos |
|
396 |
with:''. |
|
397 |
fixed := true |
|
398 |
]. |
|
399 |
rs := ReadStream on:ddd. |
|
400 |
places := OrderedCollection new. |
|
401 |
[ |
|
402 |
rs upToAll_positionBefore:'#false'. |
|
403 |
rs atEnd |
|
404 |
] whileFalse:[ places addFirst:rs position ]. |
|
405 |
places do:[:pos | |
|
406 |
ddd := ddd |
|
407 |
copyReplaceFrom:pos |
|
408 |
to:pos |
|
409 |
with:''. |
|
410 |
fixed := true |
|
411 |
]. |
|
412 |
fixed ifTrue:[ |
|
413 |
self |
|
414 |
information:'#(true false) are Symbols, not Booleans. |
|
415 |
Next time use { true. false }.' |
|
416 |
]. |
|
4025 | 417 |
|
418 |
"/ check if user typed #nil instead of nil |
|
419 |
||
3515 | 420 |
fixed := false. |
421 |
rs := ReadStream on:ddd. |
|
422 |
places := OrderedCollection new. |
|
423 |
[ |
|
424 |
rs upToAll_positionBefore:'#nil'. |
|
425 |
rs atEnd |
|
426 |
] whileFalse:[ places addFirst:rs position ]. |
|
427 |
places do:[:pos | |
|
428 |
ddd := ddd |
|
429 |
copyReplaceFrom:pos |
|
430 |
to:pos |
|
431 |
with:''. |
|
432 |
fixed := true |
|
433 |
]. |
|
434 |
fixed ifTrue:[ |
|
435 |
self |
|
436 |
information:'#nil is a Symbol, not the authentic UndefinedObject. |
|
437 |
Next time use nil instead of #nil' |
|
438 |
]. |
|
439 |
^ ddd |
|
1089 | 440 |
! |
441 |
||
442 |
initialize |
|
443 |
"The methods we are allowed to use. (MethodFinder new initialize) " |
|
444 |
Approved _ Set new. |
|
445 |
AddAndRemove _ Set new. |
|
1491 | 446 |
Blocks _ Set new. |
447 |
BlocksOptional := Set new. |
|
1089 | 448 |
"These modify an argument: longPrintOn: printOn: storeOn: sentTo: storeOn:base: printOn:base: absPrintExactlyOn:base: absPrintOn:base: absPrintOn:base:digitCount: writeOn: writeScanOn: possibleVariablesFor:continuedFrom:" |
449 |
||
450 |
"Object" |
|
1108 | 451 |
#( |
452 |
"in class, instance creation" |
|
453 |
categoryForUniclasses chooseUniqueClassName initialInstance isSystemDefined newFrom: officialClass readCarefullyFrom: |
|
454 |
"accessing" |
|
455 |
at: basicAt: basicSize bindWithTemp: in: size yourself |
|
456 |
"testing" |
|
1109 | 457 |
basicType ifNil: #'ifNil:ifNotNil:' ifNotNil: #'ifNotNil:ifNil:' |
3486 | 458 |
isColor isArray isFloat isFraction isInMemory isInteger isMorph isNil isNumber |
459 |
isPoint isPseudoContext isText isTransparent isWebBrowser isCollection |
|
1109 | 460 |
knownName notNil pointsTo: wantsSteps |
1108 | 461 |
"comparing" |
1109 | 462 |
= == closeTo: hash hashMappedBy: identityHash identityHashMappedBy: identityHashPrintString |
463 |
~= ~~ |
|
1108 | 464 |
"copying" |
465 |
clone copy shallowCopy |
|
466 |
"dependents access" |
|
467 |
canDiscardEdits dependents hasUnacceptedEdits |
|
468 |
"updating" |
|
3487 | 469 |
"changed changed: okToChange update: windowIsClosing" - not useful |
1108 | 470 |
"printing" |
471 |
fullPrintString isLiteral longPrintString printString storeString stringForReadout stringRepresentation |
|
472 |
"class membership" |
|
1109 | 473 |
class isKindOf: #'isKindOf:orOf:' isMemberOf: respondsTo: respondsToArithmetic |
1108 | 474 |
"error handling" |
475 |
"user interface" |
|
3513 | 476 |
defaultBackgroundColor defaultLabelForInspector fullScreenSize initialExtent modelWakeUp mouseUpBalk: |
477 |
"newTileMorphRepresentative" windowActiveOnFirstClick windowReqNewLabel: |
|
1108 | 478 |
"system primitives" |
479 |
instVarAt: instVarNamed: |
|
480 |
"private" |
|
481 |
"associating" -> |
|
482 |
"converting" |
|
483 |
as: asOrderedCollection asString |
|
484 |
"casing" |
|
485 |
caseOf: #'caseOf:otherwise:' |
|
486 |
"binding" |
|
487 |
bindingOf: |
|
488 |
"macpal" |
|
489 |
contentsChanged #'ifKindOf:thenDo:' instanceVariableValues |
|
490 |
"flagging" |
|
491 |
flag: |
|
492 |
"translation support" |
|
493 |
"objects from disk" |
|
494 |
"finalization" |
|
1109 | 495 |
"ST/X converting" |
496 |
literalArrayEncoding |
|
1108 | 497 |
) do: [:sel | Approved add: sel]. |
498 |
||
499 |
#( |
|
500 |
#'at:add:' #'at:modify:' #'at:put:' #'basicAt:put:' "NOT instVar:at:" |
|
501 |
"message handling" |
|
502 |
perform: |
|
503 |
#'perform:with:' #'perform:with:with:' #'perform:with:with:with:' #'perform:withArguments:' |
|
504 |
#'perform:withArguments:inSuperclass:' |
|
505 |
#'perform:orSendTo:' |
|
506 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 507 |
|
508 |
"Boolean, True, False, UndefinedObject" |
|
1108 | 509 |
#( |
510 |
"logical operations" |
|
511 |
& eqv: not xor: | |
|
512 |
"controlling" |
|
1961 | 513 |
and: ifFalse: #'ifFalse:ifTrue:' ifTrue: #'ifTrue:ifFalse:' or: ifNil: ifNotNil: |
1108 | 514 |
"copying" |
515 |
"testing" |
|
2061 | 516 |
isEmptyOrNil isNilOrEmptyCollection notEmptyOrNil |
1108 | 517 |
) do: [:sel | Approved add: sel]. |
1089 | 518 |
|
519 |
"Behavior" |
|
520 |
#("initialize-release" |
|
1108 | 521 |
"accessing" |
522 |
compilerClass decompilerClass evaluatorClass format methodDict parserClass sourceCodeTemplate subclassDefinerClass |
|
523 |
"testing" |
|
524 |
instSize instSpec isBits isBytes isFixed isPointers isVariable isWeak isWords |
|
525 |
"copying" |
|
526 |
"printing" |
|
527 |
defaultNameStemForInstances printHierarchy |
|
528 |
"creating class hierarchy" |
|
529 |
"creating method dictionary" |
|
530 |
"instance creation" |
|
531 |
basicNew basicNew: new new: |
|
532 |
"accessing class hierarchy" |
|
533 |
allSubclasses #'allSubclassesWithLevelDo:startingLevel:' allSuperclasses subclasses superclass withAllSubclasses withAllSuperclasses |
|
534 |
"accessing method dictionary" |
|
1109 | 535 |
allSelectors changeRecordsAt: compiledMethodAt: #'compiledMethodAt:ifAbsent:' firstCommentAt: lookupSelector: selectors selectorsDo: selectorsWithArgs: |
536 |
"slow but useful ->" sourceCodeAt: sourceCodeAt:ifAbsent: sourceMethodAt: sourceMethodAt:ifAbsent: |
|
1108 | 537 |
"accessing instances and variables" |
1109 | 538 |
allClassVarNames allInstVarNames allSharedPools classVarNames instVarNames instanceCount sharedPools |
539 |
"someInstance" subclassInstVarNames |
|
1108 | 540 |
"testing class hierarchy" |
541 |
inheritsFrom: kindOfSubclass |
|
542 |
"testing method dictionary" |
|
1109 | 543 |
canUnderstand: classThatUnderstands: hasMethods includesSelector: #'scopeHas:ifTrue:' |
544 |
whichClassIncludesSelector: |
|
545 |
whichSelectorsAccess: whichSelectorsReferTo: #'whichSelectorsReferTo:special:byte:' whichSelectorsStoreInto: |
|
1108 | 546 |
"enumerating" |
547 |
"user interface" |
|
548 |
"private" |
|
549 |
indexIfCompact |
|
1109 | 550 |
"ST/X testing method dictionary" |
551 |
implements: |
|
1108 | 552 |
) do: [:sel | Approved add: sel]. |
1089 | 553 |
|
554 |
"ClassDescription" |
|
1109 | 555 |
#( |
556 |
"initialize-release" |
|
1108 | 557 |
"accessing" |
558 |
classVersion isMeta name theNonMetaClass |
|
559 |
"copying" |
|
560 |
"printing" |
|
561 |
classVariablesString instanceVariablesString sharedPoolsString |
|
562 |
"instance variables" |
|
563 |
checkForInstVarsOK: |
|
564 |
"method dictionary" |
|
565 |
"organization" |
|
566 |
category organization whichCategoryIncludesSelector: |
|
567 |
"compiling" |
|
568 |
acceptsLoggingOfCompilation wantsChangeSetLogging |
|
569 |
"fileIn/Out" |
|
570 |
definition |
|
571 |
"private" |
|
1109 | 572 |
"ST/X queries" |
573 |
theMetaclass theNonMetaclass |
|
1108 | 574 |
) do: [:sel | Approved add: sel]. |
1089 | 575 |
|
576 |
"Class" |
|
1109 | 577 |
#( |
578 |
"initialize-release" |
|
1108 | 579 |
"accessing" |
580 |
classPool |
|
581 |
"testing" |
|
582 |
"copying" |
|
583 |
"class name" |
|
584 |
"instance variables" |
|
585 |
"class variables" |
|
586 |
classVarAt: classVariableAssociationAt: |
|
587 |
"pool variables" |
|
588 |
"compiling" |
|
589 |
"subclass creation" |
|
590 |
"fileIn/Out" |
|
1109 | 591 |
"ST/X queries" |
592 |
nameSpace nameWithoutPrefix nameWithoutNameSpacePrefix |
|
1108 | 593 |
) do: [:sel | Approved add: sel]. |
1089 | 594 |
|
595 |
"Metaclass" |
|
596 |
#("initialize-release" |
|
1108 | 597 |
"accessing" |
598 |
isSystemDefined soleInstance |
|
599 |
"copying" "instance creation" "instance variables" |
|
600 |
"pool variables" "class hierarchy" "compiling" |
|
601 |
"fileIn/Out" |
|
602 |
nonTrivial |
|
603 |
) do: [:sel | Approved add: sel]. |
|
1089 | 604 |
|
605 |
"Context, BlockContext" |
|
1108 | 606 |
#( |
607 |
receiver client method receiver tempAt: |
|
608 |
"debugger access" |
|
609 |
mclass pc selector sender shortStack sourceCode tempNames tempsAndValues |
|
610 |
"controlling" "printing" "system simulation" |
|
611 |
"initialize-release" |
|
612 |
"accessing" |
|
613 |
hasMethodReturn home numArgs |
|
614 |
"evaluating" |
|
615 |
value #'value:ifError:' #'value:value:' #'value:value:value:' #'value:value:value:value:' #'valueWithArguments:' |
|
616 |
"controlling" "scheduling" "instruction decoding" "printing" "private" "system simulation" ) do: [:sel | Approved add: sel]. |
|
617 |
#(value: "<- Association has it as a store" |
|
618 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 619 |
|
620 |
"Message" |
|
1108 | 621 |
#( |
622 |
"inclass, instance creation" |
|
623 |
selector: #'selector:argument:' #'selector:arguments:' |
|
624 |
"accessing" |
|
625 |
argument argument: arguments sends: |
|
626 |
"printing" "sending" |
|
627 |
) do: [:sel | Approved add: sel]. |
|
628 |
#( |
|
629 |
"private" |
|
630 |
#'setSelector:arguments:' |
|
631 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 632 |
|
633 |
"Magnitude" |
|
1108 | 634 |
#( |
635 |
"comparing" |
|
636 |
< <= > >= #'between:and:' |
|
637 |
"testing" |
|
638 |
max: min: min:max: |
|
639 |
) do: [:sel | Approved add: sel]. |
|
1089 | 640 |
|
641 |
"Date, Time" |
|
1108 | 642 |
#( |
643 |
"in class, instance creation" |
|
644 |
fromDays: fromSeconds: fromString: #'newDay:month:year:' #'newDay:year:' today |
|
645 |
"in class, general inquiries" |
|
646 |
dateAndTimeNow dayOfWeek: #'daysInMonth:forYear:' daysInYear: #'firstWeekdayOfMonth:year:' indexOfMonth: leapYear: nameOfDay: nameOfMonth: |
|
647 |
"accessing" |
|
1961 | 648 |
day isLeapYear "leap" monthIndex monthName weekday year |
1108 | 649 |
"arithmetic" |
650 |
addDays: subtractDate: subtractDays: |
|
651 |
"comparing" |
|
652 |
"inquiries" |
|
1961 | 653 |
dayOfMonth daysInMonth daysInYear daysLeftInMonth daysLeftInYear firstDayOfMonth previous: |
1108 | 654 |
"converting" |
1961 | 655 |
asSeconds asDays |
1108 | 656 |
"printing" |
657 |
mmddyy mmddyyyy printFormat: printOn:format: |
|
658 |
"private" |
|
659 |
firstDayOfMonthIndex: weekdayIndex |
|
660 |
||
661 |
"in class, instance creation" |
|
662 |
fromSeconds: now |
|
663 |
"in class, general inquiries" |
|
664 |
dateAndTimeFromSeconds: dateAndTimeNow millisecondClockValue millisecondsToRun: totalSeconds |
|
665 |
"accessing" |
|
666 |
hours minutes seconds |
|
667 |
"arithmetic" |
|
668 |
addTime: subtractTime: |
|
669 |
"comparing" |
|
670 |
"printing" |
|
671 |
intervalString print24 |
|
672 |
"converting" |
|
1961 | 673 |
"st/x" |
674 |
dayOfWeek abbreviatedDayName abbreviatedMonthName |
|
675 |
abbreviatedMonthNameForLanguage: dayCount dayInWeek dayInYear |
|
676 |
monthNameForLanguage: weekInYear daysSince: daysUntil: |
|
677 |
asTimestamp asDate |
|
678 |
timeZoneDeltaInMinutes asTime asTimeDuration asMilliseconds |
|
679 |
asUtcTimestamp utcSecondsSince1901 printStringIso8601Format |
|
680 |
printString12HourFormat printString24HourFormat |
|
681 |
days utcOffset millisecondDeltaFrom: secondDeltaFrom: |
|
1108 | 682 |
) do: [:sel | Approved add: sel]. |
683 |
#( |
|
684 |
"private" |
|
685 |
hours: #'hours:minutes:seconds:' #'day:year:' |
|
686 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 687 |
|
688 |
"Number" |
|
1108 | 689 |
#( |
690 |
"in class" |
|
691 |
#'readFrom:base:' |
|
692 |
"arithmetic" |
|
2061 | 693 |
* + - / // \\ abs negated quo: reciprocal rem: |
1089 | 694 |
"mathematical functions" |
1108 | 695 |
arcCos arcSin arcTan arcTan: cos exp floorLog: ln log log: raisedTo: raisedToInteger: sin sqrt squared tan |
1089 | 696 |
"truncation and round off" |
1108 | 697 |
ceiling #'detentBy:atMultiplesOf:snap:' floor roundTo: roundUpTo: rounded truncateTo: truncated |
1089 | 698 |
"comparing" |
699 |
"testing" |
|
1108 | 700 |
even isDivisibleBy: isInf isInfinite isNaN isZero negative odd positive sign strictlyPositive |
1089 | 701 |
"converting" |
2285 | 702 |
@ asInteger asNumber asPoint asSmallAngleDegrees degreesToRadians radiansToDegrees |
703 |
asFixedPoint asFixedPoint: asFixedPointRoundedToScale asFixedPointRoundedToScale: |
|
704 |
asFloat asFraction |
|
1108 | 705 |
"intervals" |
706 |
to: #'to:by:' |
|
707 |
"printing" |
|
708 |
printStringBase: storeStringBase: |
|
709 |
||
710 |
"ST/X in class" |
|
711 |
#'readFrom:base:' |
|
712 |
"ST/X intervals" |
|
713 |
downTo: #'downTo:by:' |
|
714 |
"ST/X printing" |
|
2061 | 715 |
radixPrintStringRadix: printStringRadix: storeStringRadix: romanPrintString |
1108 | 716 |
) do: [:sel | Approved add: sel]. |
717 |
||
1089 | 718 |
"Integer" |
1108 | 719 |
#( |
720 |
"in class" |
|
721 |
primesUpTo: |
|
722 |
"testing" |
|
3316 | 723 |
isPowerOfTwo isPowerOf: digitBytes isPrime nextPrime |
1108 | 724 |
"arithmetic" |
725 |
alignedTo: |
|
726 |
"comparing" |
|
727 |
"truncation and round off" |
|
728 |
atRandom normalize |
|
729 |
"enumerating" |
|
730 |
timesRepeat: |
|
731 |
"mathematical functions" |
|
2061 | 732 |
degreeCos degreeSin factorial gcd: lcm: binco: take: primeFactors |
1108 | 733 |
"bit manipulation" |
2061 | 734 |
<< >> allMask: anyMask: bitAnd: bitClear: bitInvert bitInvert32 bitOr: bitShift: bitXor: |
735 |
highBit lowBit bitCount noMask: |
|
1108 | 736 |
"converting" |
737 |
asCharacter asColorOfDepth: asFloat asFraction asHexDigit |
|
738 |
"printing" |
|
739 |
asStringWithCommas hex hex8 radix: |
|
740 |
"system primitives" |
|
741 |
lastDigit #'replaceFrom:to:with:startingAt:' |
|
742 |
"private" "benchmarks" |
|
1089 | 743 |
|
1108 | 744 |
"ST/X printing" |
2061 | 745 |
hexPrintString |
1108 | 746 |
|
747 |
) do: [:sel | Approved add: sel]. |
|
1106 | 748 |
|
1089 | 749 |
"SmallInteger, LargeNegativeInteger, LargePositiveInteger" |
1108 | 750 |
#( |
751 |
"arithmetic" |
|
752 |
"bit manipulation" |
|
753 |
"testing" "comparing" "copying" "converting" "printing" |
|
754 |
"system primitives" |
|
755 |
digitAt: digitLength |
|
756 |
"private" |
|
757 |
#'fromString:radix:' |
|
758 |
) do: [:sel | Approved add: sel]. |
|
2059
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
759 |
|
1089 | 760 |
#((#'digitAt:put:') ) do: [:sel | AddAndRemove add: sel]. |
761 |
||
762 |
"Float" |
|
1108 | 763 |
#( |
764 |
"arithmetic" |
|
765 |
"mathematical functions" |
|
766 |
reciprocalFloorLog: reciprocalLogBase2 timesTwoPower: |
|
767 |
"comparing" "testing" |
|
768 |
"truncation and round off" |
|
769 |
exponent fractionPart integerPart significand significandAsInteger |
|
770 |
"converting" |
|
771 |
asApproximateFraction asIEEE32BitWord asTrueFraction |
|
772 |
"copying" |
|
773 |
) do: [:sel | Approved add: sel]. |
|
1089 | 774 |
|
775 |
"Fraction, Random" |
|
1108 | 776 |
#( |
777 |
denominator numerator reduced next nextValue |
|
778 |
) do: [:sel | Approved add: sel]. |
|
779 |
#( |
|
780 |
#'setNumerator:denominator:' |
|
781 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 782 |
|
783 |
"Collection" |
|
1108 | 784 |
#( |
785 |
"accessing" |
|
786 |
anyOne |
|
787 |
"testing" |
|
3486 | 788 |
includes: includesAllOf: includesAnyOf: includesSubstringAnywhere: |
789 |
isEmpty notEmpty isSequenceable occurrencesOf: |
|
1108 | 790 |
"enumerating" |
3486 | 791 |
collect: #'collect:thenSelect:' count: contains: |
792 |
detect: #'detect:ifNone:' detectMax: detectMin: detectSum: |
|
793 |
#'inject:into:' reject: select: #'select:thenCollect:' map: |
|
1108 | 794 |
"converting" |
3486 | 795 |
asArray asBag asCharacterSet asSet asSortedArray asSortedCollection asSortedCollection: |
796 |
asStringWith: asNilIfEmpty asOrderedCollection |
|
1108 | 797 |
"printing" |
798 |
"private" |
|
3486 | 799 |
maxSize largest: smallest: |
1108 | 800 |
"arithmetic" |
801 |
"math functions" |
|
3486 | 802 |
average max median min range sum product abs minMax |
1108 | 803 |
) do: [:sel | Approved add: sel]. |
804 |
||
805 |
#( |
|
806 |
"adding" |
|
807 |
add: addAll: addIfNotPresent: |
|
808 |
"removing" |
|
809 |
remove: #'remove:ifAbsent:' removeAll: removeAllFoundIn: removeAllSuchThat: #'remove:ifAbsent:' |
|
810 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 811 |
|
812 |
"SequenceableCollection" |
|
1108 | 813 |
#( |
814 |
"comparing" |
|
815 |
hasEqualElements: |
|
816 |
"accessing" allButFirst allButLast at:ifAbsent: atAll: atPin: atRandom: atWrap: |
|
3486 | 817 |
fifth first fourth last second sixth third nth: |
1108 | 818 |
identityIndexOf: #'identityIndexOf:startingAt:' #'identityIndexOf:ifAbsent:' #'identityIndexOf:startingAt:ifAbsent:' |
819 |
indexOf: #'indexOf:startingAt:' #'indexOf:ifAbsent:' #'indexOf:startingAt:ifAbsent:' |
|
820 |
lastIndexOf: #'lastIndexOf:startingAt:' #'lastIndexOf:ifAbsent:' #'lastIndexOf:startingAt:ifAbsent:' |
|
821 |
#'indexOfSubCollection:' |
|
822 |
#'indexOfSubCollection:ifAbsent:' |
|
823 |
#'indexOfSubCollection:startingAt:' |
|
824 |
#'indexOfSubCollection:startingAt:ifAbsent:' |
|
825 |
#'lastIndexOfSubCollection:' |
|
826 |
#'lastIndexOfSubCollection:ifAbsent:' |
|
827 |
#'lastIndexOfSubCollection:startingAt:' |
|
828 |
#'lastIndexOfSubCollection:startingAt:ifAbsent:' |
|
1107 | 829 |
|
1108 | 830 |
"removing" |
831 |
"copying" |
|
832 |
, copyAfterLast: #'copyAt:put:' #'copyFrom:to:' #'copyReplaceAll:with:' #'copyReplaceFrom:to:with:' copyUpTo: copyUpToLast: copyWith: copyWithout: copyWithoutAll: #'forceTo:paddingWith:' shuffled sortBy: |
|
833 |
"enumerating" |
|
834 |
collectWithIndex: findFirst: findLast: pairsCollect: #'with:collect:' withIndexCollect: polynomialEval: |
|
835 |
"converting" |
|
836 |
asArray asDictionary asFloatArray asIntegerArray asStringWithCr asWordArray reversed |
|
837 |
"private" |
|
838 |
#'copyReplaceAll:with:asTokens:' |
|
1089 | 839 |
|
1108 | 840 |
"ST/X copying" |
3486 | 841 |
copyButLast: copyLast: copyFrom: copyTo: last: first: |
1108 | 842 |
"ST/X testing" |
843 |
longestCommonPrefix |
|
844 |
) do: [:sel | Approved add: sel]. |
|
845 |
||
846 |
#( swap:with: |
|
847 |
) do: [:sel | AddAndRemove add: sel]. |
|
1106 | 848 |
|
1089 | 849 |
"ArrayedCollection, Bag" |
1108 | 850 |
#( |
851 |
"private" |
|
852 |
defaultElement |
|
853 |
"sorting" |
|
854 |
isSorted |
|
855 |
"accessing" |
|
856 |
cumulativeCounts sortedCounts sortedElements |
|
857 |
"testing" "adding" |
|
858 |
#'add:withOccurrences:' |
|
859 |
"removing" "enumerating" |
|
1089 | 860 |
) do: [:sel | Approved add: sel]. |
1108 | 861 |
|
862 |
#( |
|
863 |
#'mergeSortFrom:to:by:' sort sort: add: #'add:withOccurrences:' |
|
864 |
"private" |
|
865 |
setDictionary |
|
866 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 867 |
|
868 |
"Other messages that modify the receiver" |
|
1108 | 869 |
#( |
870 |
#'atAll:put:' #'atAll:putAll:' atAllPut: #'atWrap:put:' |
|
871 |
#'replaceAll:with:' #'replaceFrom:to:with:' removeFirst removeLast |
|
872 |
"ST/X filling & replacing" |
|
873 |
reverse |
|
874 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 875 |
|
876 |
self initialize2. |
|
877 |
||
878 |
" |
|
879 |
MethodFinder new initialize. |
|
880 |
MethodFinder new organizationFiltered: Set |
|
881 |
" |
|
1106 | 882 |
|
2285 | 883 |
"Modified: / 02-08-2010 / 13:33:57 / cg" |
1089 | 884 |
! |
885 |
||
886 |
initialize2 |
|
887 |
"The methods we are allowed to use. (MethodFinder new initialize) " |
|
888 |
||
889 |
"Set" |
|
1108 | 890 |
#( |
891 |
"in class" |
|
892 |
sizeFor: |
|
893 |
"testing" "adding" "removing" "enumerating" |
|
894 |
"private" |
|
895 |
array findElementOrNil: |
|
896 |
"accessing" |
|
3690 | 897 |
"/ someElement anElement anyOne |
898 |
anElement anyOne |
|
1108 | 899 |
) do: [:sel | Approved add: sel]. |
1089 | 900 |
|
901 |
"Dictionary, IdentityDictionary, IdentitySet" |
|
1108 | 902 |
#( |
903 |
"accessing" |
|
904 |
associationAt: #'associationAt:ifAbsent:' #'at:ifPresent:' keyAtIdentityValue: #'keyAtIdentityValue:ifAbsent:' keyAtValue: #'keyAtValue:ifAbsent:' keys |
|
905 |
"testing" |
|
906 |
includesKey: |
|
907 |
) do: [:sel | Approved add: sel]. |
|
908 |
#( |
|
909 |
removeKey: #'removeKey:ifAbsent:' |
|
910 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 911 |
|
912 |
"LinkedList, Interval, MappedCollection" |
|
913 |
#( |
|
1108 | 914 |
"in class" |
915 |
#'from:to:' #'from:to:by:' |
|
916 |
"accessing" |
|
917 |
contents) do: [:sel | Approved add: sel]. |
|
918 |
#( |
|
919 |
"adding" |
|
920 |
addFirst: addLast:) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 921 |
|
922 |
"OrderedCollection, SortedCollection" |
|
1108 | 923 |
#( |
924 |
"accessing" |
|
925 |
after: before: |
|
926 |
"copying" |
|
927 |
copyEmpty |
|
928 |
"adding" |
|
929 |
growSize |
|
930 |
"removing" "enumerating" "private" |
|
931 |
"accessing" |
|
932 |
sortBlock) do: [:sel | Approved add: sel]. |
|
933 |
#( |
|
934 |
"adding" |
|
935 |
#'add:after:' #'add:afterIndex:' #'add:before:' addAllFirst: addAllLast: addFirst: addLast: |
|
936 |
"removing" |
|
937 |
removeAt: removeFirst removeLast |
|
938 |
"accessing" |
|
939 |
sortBlock:) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 940 |
|
941 |
"Character" |
|
1108 | 942 |
#( |
943 |
"in class, instance creation" |
|
944 |
allCharacters digitValue: new separators |
|
945 |
"accessing untypeable characters" |
|
946 |
backspace cr enter lf linefeed nbsp newPage space tab |
|
947 |
"constants" |
|
948 |
alphabet characterTable |
|
949 |
"accessing" |
|
950 |
asciiValue digitValue |
|
951 |
"comparing" |
|
2107 | 952 |
"queries" |
953 |
bitsPerCharacter |
|
1108 | 954 |
"testing" |
3773 | 955 |
isAlphaNumeric isDigit isLetter isLetterOrUnderline isLowercase isSafeForHTTP isSeparator isSpecial |
2107 | 956 |
isUppercase isVowel tokenish isNationalAlphaNumeric isNationalDigit isNationalLetter |
1108 | 957 |
"copying" |
958 |
"converting" |
|
2107 | 959 |
asIRCLowercase asLowercase asUppercase rot13 rot: |
1089 | 960 |
) do: [:sel | Approved add: sel]. |
961 |
||
962 |
"String" |
|
1108 | 963 |
#( |
964 |
"in class, instance creation" |
|
965 |
crlf fromPacked: |
|
966 |
"primitives" |
|
967 |
#'findFirstInString:inSet:startingAt:' #'indexOfAscii:inString:startingAt:' "internet" valueOfHtmlEntity: |
|
968 |
"accessing" |
|
969 |
byteAt: endsWithDigit #'findAnySubStr:startingAt:' findBetweenSubStrs: |
|
970 |
#'findDelimiters:startingAt:' |
|
971 |
#'findString:startingAt:' #'findString:startingAt:caseSensitive:' |
|
972 |
findTokens: #'findTokens:includes:' #'findTokens:keep:' |
|
973 |
includesSubString: #'includesSubstring:caseSensitive:' |
|
974 |
#'indexOf:startingAt:' |
|
975 |
indexOfAnyOf: #'indexOfAnyOf:ifAbsent:' #'indexOfAnyOf:startingAt:' #'indexOfAnyOf:startingAt:ifAbsent:' |
|
976 |
lineCorrespondingToIndex: lineCount lineNumber: |
|
977 |
#'skipAnySubStr:startingAt:' #'skipDelimiters:startingAt:' startsWithDigit |
|
978 |
"comparing" |
|
1109 | 979 |
alike: beginsWith: caseSensitiveLessOrEqual: charactersExactlyMatching: compare: crc16 |
980 |
endsWith: endsWithAnyOf: sameAs: |
|
981 |
#'startingAt:match:startingAt:' |
|
1108 | 982 |
"copying" |
983 |
#'copyReplaceTokens:with:' #'padded:to:with:' |
|
984 |
"converting" |
|
3951 | 985 |
asByteArray asDate asDisplayText asFilename asHtml asLegalSelector asPacked asParagraph asText asTime asUnHtml asUrl asUrlRelativeTo: |
1108 | 986 |
#capitalized compressWithTable: contractTo: correctAgainst: |
987 |
encodeForHTTP initialIntegerOrNil keywords quoted sansPeriodSuffix |
|
988 |
splitInteger stemAndNumericSuffix substrings surroundedBySingleQuotes |
|
989 |
truncateWithElipsisTo: withBlanksTrimmed withFirstCharacterDownshifted |
|
990 |
withNoLineLongerThan: withSeparatorsCompacted withoutLeadingDigits |
|
991 |
withoutTrailingBlanks |
|
992 |
"displaying" "printing" |
|
993 |
"system primitives" |
|
994 |
#'compare:with:collated:' |
|
995 |
"Celeste" |
|
996 |
withCRs |
|
997 |
"internet" |
|
998 |
decodeMimeHeader decodeQuotedPrintable replaceHtmlCharRefs unescapePercents withInternetLineEndings withSqueakLineEndings withoutQuoting |
|
999 |
"testing" |
|
2108 | 1000 |
isAllSeparators lastSpacePosition isBlank isEmpty |
1108 | 1001 |
"paragraph support" |
1002 |
indentationIfBlank: |
|
1109 | 1003 |
"arithmetic" |
2107 | 1004 |
"queries" |
2108 | 1005 |
bitsPerCharacter contains8BitCharacters knownAsSymbol |
1109 | 1006 |
"ST/X copying" |
1007 |
paddedTo: paddedTo:with: centerPaddedTo: centerPaddedTo:with: |
|
1008 |
decimalPaddedTo:and:at: |
|
1009 |
leftPaddedTo: leftPaddedTo:with: |
|
1010 |
chopTo: contractAtBeginningTo: contractAtEndTo: contractTo: |
|
1011 |
"ST/X comparing" |
|
1012 |
compareWith: sameCharacters: sameEmphasisAs: sameStringAndEmphasisAs: |
|
1013 |
"ST/X searching" |
|
1014 |
indexOfSeparator indexOfSeparatorStartingAt: |
|
1015 |
lastIndexOfSeparator lastIndexOfSeparatorStartingAt: |
|
1016 |
indexOfNonSeparatorStartingAt: |
|
2108 | 1017 |
"ST/X printing" |
2109 | 1018 |
sscanf: |
1019 |
printf: |
|
1109 | 1020 |
"ST/X converting" |
1021 |
asUppercaseFirst |
|
1022 |
asCollectionOfWords asCollectionOfLines |
|
1023 |
asCollectionOfSubstringsSeparatedBy: asCollectionOfSubstringsSeparatedByAny: |
|
1024 |
"Ansi" |
|
1025 |
addLineDelimiters |
|
1026 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1027 |
#(#'byteAt:put:' translateToLowercase match:) do: [:sel | AddAndRemove add: sel]. |
1028 |
||
1029 |
"Symbol" |
|
1108 | 1030 |
#( |
1031 |
"in class, private" |
|
1032 |
hasInterned:ifTrue: |
|
1033 |
"access" |
|
1034 |
morePossibleSelectorsFor: possibleSelectorsFor: selectorsContaining: #'thatStarts:skipping:' |
|
1035 |
"accessing" "comparing" "copying" "converting" "printing" |
|
1036 |
"testing" |
|
1037 |
isInfix isKeyword isPvtSelector isUnary) do: [:sel | Approved add: sel]. |
|
1089 | 1038 |
|
1039 |
"Array" |
|
1108 | 1040 |
#( |
1041 |
"comparing" |
|
1042 |
"converting" |
|
1043 |
evalStrings |
|
1044 |
"printing" "private" |
|
1045 |
hasLiteralSuchThat:) do: [:sel | Approved add: sel]. |
|
1089 | 1046 |
|
1047 |
"Array2D" |
|
1108 | 1048 |
#( |
1049 |
"access" |
|
1050 |
#'at:at:' atCol: #'atCol:put:' atRow: extent #'extent:fromArray:' height width #'width:height:type:' |
|
1051 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1052 |
#(#'at:at:add:' #'at:at:put:' #'atRow:put:' ) do: [:sel | AddAndRemove add: sel]. |
1053 |
||
1054 |
"ByteArray" |
|
1108 | 1055 |
#( |
1056 |
"accessing" |
|
1057 |
doubleWordAt: wordAt: |
|
1058 |
"platform independent access" |
|
1059 |
#'longAt:bigEndian:' #'shortAt:bigEndian:' #'unsignedLongAt:bigEndian:' #'unsignedShortAt:bigEndian:' |
|
1060 |
"converting") do: [:sel | Approved add: sel]. |
|
1089 | 1061 |
#(#'doubleWordAt:put:' #'wordAt:put:' #'longAt:put:bigEndian:' #'shortAt:put:bigEndian:' #'unsignedLongAt:put:bigEndian:' #'unsignedShortAt:put:bigEndian:' |
1062 |
) do: [:sel | AddAndRemove add: sel]. |
|
1063 |
||
4129 | 1064 |
"FloatArray" "Don't know what happens when prims not here" |
1108 | 1065 |
false ifTrue: [#( |
1066 |
"accessing" |
|
1067 |
"arithmetic" |
|
1068 |
*= += -= /= |
|
1069 |
"comparing" |
|
1070 |
"primitives-plugin" |
|
1071 |
primAddArray: primAddScalar: primDivArray: primDivScalar: primMulArray: primMulScalar: primSubArray: primSubScalar: |
|
1072 |
"primitives-translated" |
|
1073 |
#'primAddArray:withArray:from:to:' #'primMulArray:withArray:from:to:' #'primSubArray:withArray:from:to:' |
|
1074 |
"converting" "private" "user interface" |
|
1075 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1076 |
]. |
1077 |
||
1078 |
"IntegerArray, WordArray" |
|
1079 |
"RunArray" |
|
1108 | 1080 |
#( |
1081 |
"in class, instance creation" |
|
1082 |
#'runs:values:' scanFrom: |
|
1083 |
"accessing" |
|
1084 |
runLengthAt: |
|
1085 |
"adding" "copying" |
|
1086 |
"private" |
|
1087 |
runs values |
|
1088 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1089 |
#(coalesce #'addLast:times:' #'repeatLast:ifEmpty:' repeatLastIfEmpty: |
1090 |
) do: [:sel | AddAndRemove add: sel]. |
|
1091 |
||
1092 |
"Stream -- many operations change its state" |
|
1108 | 1093 |
#( |
1094 |
"testing" |
|
1095 |
atEnd) do: [:sel | Approved add: sel]. |
|
1096 |
#( |
|
1097 |
"accessing" |
|
1098 |
next: nextMatchAll: nextMatchFor: upToEnd |
|
1099 |
#'next:put:' nextPut: nextPutAll: |
|
1100 |
"printing" print: printHtml: |
|
1089 | 1101 |
) do: [:sel | AddAndRemove add: sel]. |
1102 |
||
1103 |
"PositionableStream" |
|
1108 | 1104 |
#( |
1105 |
"accessing" |
|
1106 |
contentsOfEntireFile originalContents peek peekFor: "testing" |
|
1107 |
"positioning" |
|
1108 |
position |
|
1109 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1110 |
#(nextDelimited: nextLine upTo: position: reset resetContents setToEnd skip: skipTo: upToAll: ) do: [:sel | AddAndRemove add: sel]. |
1108 | 1111 |
"Because it is so difficult to test the result of an operation on a Stream |
1112 |
(you have to supply another Stream in the same state), |
|
1113 |
we don't support Streams beyond the basics. |
|
1114 |
We want to find the messages that convert Streams to other things." |
|
1089 | 1115 |
|
1116 |
"ReadWriteStream" |
|
1108 | 1117 |
#( |
1118 |
"file status" |
|
1119 |
closed) do: [:sel | Approved add: sel]. |
|
1120 |
#( |
|
1121 |
"accessing" |
|
1122 |
next: on: ) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 1123 |
|
1124 |
"WriteStream" |
|
1108 | 1125 |
#( |
1126 |
"in class, instance creation" |
|
1127 |
on:from:to: with: with:from:to: |
|
1089 | 1128 |
) do: [:sel | Approved add: sel]. |
1108 | 1129 |
#( |
1130 |
"positioning" |
|
1131 |
resetToStart |
|
1132 |
"character writing" |
|
1133 |
crtab crtab:) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 1134 |
|
1135 |
"LookupKey, Association, Link" |
|
1108 | 1136 |
#( |
1137 |
"accessing" |
|
1138 |
key nextLink) do: [:sel | Approved add: sel]. |
|
1089 | 1139 |
#(key: #'key:value:' nextLink:) do: [:sel | AddAndRemove add: sel]. |
1140 |
||
1141 |
"Point" |
|
1108 | 1142 |
#( |
1143 |
"in class, instance creation" |
|
1144 |
#'r:degrees:' #'x:y:' |
|
1145 |
"accessing" |
|
1146 |
x y |
|
1147 |
"comparing" "arithmetic" "truncation and round off" |
|
1148 |
"polar coordinates" |
|
1149 |
degrees r theta |
|
1150 |
"point functions" |
|
1151 |
bearingToPoint: crossProduct: dist: dotProduct: eightNeighbors #'flipBy:centerAt:' fourNeighbors grid: |
|
1152 |
#'nearestPointAlongLineFrom:to:' #'nearestPointOnLineFrom:to:' |
|
1153 |
normal normalized octantOf: |
|
1154 |
#'onLineFrom:to:' #'onLineFrom:to:within:' |
|
1155 |
quadrantOf: #'rotateBy:centerAt:' transposed unitVector |
|
1156 |
"converting" |
|
1157 |
asFloatPoint asIntegerPoint corner: extent: rect: |
|
1158 |
"transforming" |
|
1159 |
adhereTo: #'rotateBy:about:' scaleBy: #'scaleFrom:to:' translateBy: "copying" |
|
1160 |
"interpolating" |
|
1161 |
#'interpolateTo:at:' |
|
1162 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1163 |
|
1164 |
"Rectangle" |
|
1165 |
#("in class, instance creation" #'center:extent:' encompassing: #'left:right:top:bottom:' |
|
1166 |
merging: #'origin:corner:' #'origin:extent:' |
|
1108 | 1167 |
"accessing" |
1168 |
area bottom bottomCenter bottomLeft bottomRight boundingBox center corner corners innerCorners |
|
1169 |
left leftCenter origin right rightCenter top topCenter topLeft topRight |
|
1170 |
"comparing" |
|
1171 |
"rectangle functions" |
|
1172 |
#'adjustTo:along:' amountToTranslateWithin: areasOutside: #'bordersOn:along:' encompass: |
|
1173 |
expandBy: extendBy: #'forPoint:closestSideDistLen:' |
|
1174 |
insetBy: #'insetOriginBy:cornerBy:' intersect: |
|
1175 |
merge: pointNearestTo: quickMerge: #'rectanglesAt:height:' |
|
1176 |
sideNearestTo: translatedToBeWithin: |
|
1177 |
withBottom: withHeight: withLeft: withRight: #'withSide:setTo:' withTop: withWidth: |
|
1178 |
"testing" |
|
1179 |
containsPoint: containsRect: hasPositiveExtent intersects: isTall isWide |
|
1180 |
"truncation and round off" |
|
1181 |
"transforming" |
|
1182 |
#'align:with:' centeredBeneath: newRectFrom: squishedWithin: "copying" |
|
1089 | 1183 |
) do: [:sel | Approved add: sel]. |
1184 |
||
1185 |
"Color" |
|
1108 | 1186 |
#( |
1187 |
"in class, instance creation" |
|
1188 |
colorFrom: #'colorFromPixelValue:depth:' fromRgbTriplet: gray: #'h:s:v:' #'r:g:b:' #'r:g:b:alpha:' #'r:g:b:range:' |
|
1189 |
"ST/X in class, instance creation" |
|
1190 |
colorNamed: |
|
1191 |
"named colors" |
|
1192 |
black blue brown cyan darkGray gray green lightBlue lightBrown lightCyan lightGray lightGreen lightMagenta lightOrange lightRed lightYellow |
|
1193 |
magenta orange red transparent veryDarkGray veryLightGray veryVeryDarkGray veryVeryLightGray white yellow |
|
1194 |
"other" |
|
1195 |
colorNames indexedColors pixelScreenForDepth: quickHighLight: |
|
1196 |
"access" |
|
1197 |
alpha blue brightness green hue luminance red saturation |
|
1198 |
"equality" |
|
1199 |
"queries" |
|
1200 |
isBitmapFill isBlack isGray isSolidFill isTranslucent isTranslucentColor |
|
1201 |
"transformations" |
|
1202 |
alpha: dansDarker darker lighter #'mixed:with:' muchLighter slightlyDarker slightlyLighter veryMuchLighter #'alphaMixed:with:' |
|
1203 |
"groups of shades" |
|
1204 |
darkShades: lightShades: #'mix:shades:' wheel: |
|
1205 |
"printing" |
|
1206 |
shortPrintString |
|
1207 |
"other" |
|
1208 |
colorForInsets rgbTriplet |
|
1209 |
"conversions" |
|
1210 |
asB3DColor asColor balancedPatternForDepth: bitPatternForDepth: closestPixelValue1 closestPixelValue2 closestPixelValue4 closestPixelValue8 dominantColor |
|
1211 |
halfTonePattern1 halfTonePattern2 indexInMap: pixelValueForDepth: #'pixelWordFor:filledWith:' pixelWordForDepth: scaledPixelValue32 |
|
1212 |
"private" |
|
1109 | 1213 |
privateAlpha privateBlue privateGreen privateRGB privateRed |
1214 |
"copying" |
|
1108 | 1215 |
"ST/X access" |
1109 | 1216 |
redByte greenByte blueByte alphaByte rgbValue almostSameAs: |
1089 | 1217 |
) do: [:sel | Approved add: sel]. |
1218 |
||
1219 |
" For each selector that requires a block argument, add (selector argNum) |
|
1220 |
to the set Blocks." |
|
1108 | 1221 |
"ourClasses _ #(Object Boolean True False UndefinedObject Behavior ClassDescription Class Metaclass MethodContext BlockContext Message Magnitude Date Time Number Integer |
1222 |
SmallInteger LargeNegativeInteger LargePositiveInteger Float Fraction Random Collection SequenceableCollection ArrayedCollection Bag Set |
|
1223 |
Dictionary IdentityDictionary IdentitySet LinkedList Interval MappedCollection OrderedCollection SortedCollection Character String Symbol Array |
|
1224 |
Array2D ByteArray FloatArray IntegerArray WordArray RunArray Stream PositionableStream ReadWriteStream WriteStream LookupKey Association Link Point Rectangle Color). |
|
1089 | 1225 |
ourClasses do: [:clsName | cls _ Smalltalk at: clsName. |
1226 |
(cls selectors) do: [:aSel | |
|
1227 |
((Approved includes: aSel) or: [AddAndRemove includes: aSel]) ifTrue: [ |
|
1228 |
(cls formalParametersAt: aSel) withIndexDo: [:tName :ind | |
|
1229 |
(tName endsWith: 'Block') ifTrue: [ |
|
1230 |
Blocks add: (Array with: aSel with: ind)]]]]]. |
|
1231 |
" |
|
1109 | 1232 |
#( |
1233 |
(timesRepeat: 1 ) (indexOf:ifAbsent: 2 ) (pairsCollect: 1 ) (#'mergeSortFrom:to:by:' 3 ) |
|
1234 |
(#'ifNotNil:ifNil:' 1 ) (#'ifNotNil:ifNil:' 2 ) (ifNil: 1 ) (#'at:ifAbsent:' 2 ) |
|
1235 |
(#'ifNil:ifNotNil:' 1 ) (#'ifNil:ifNotNil:' 2 ) (ifNotNil: 1 ) (#'at:modify:' 2 ) |
|
1236 |
(#'identityIndexOf:ifAbsent:' 2 ) (sort: 1 ) (sortBlock: 1 ) |
|
1237 |
(detectMax: 1 ) (repeatLastIfEmpty: 1 ) (#'allSubclassesWithLevelDo:startingLevel:' 1 ) |
|
1238 |
(#'keyAtValue:ifAbsent:' 2 ) (in: 1 ) |
|
1239 |
(ifTrue: 1 ) (or: 1 ) (select: 1 ) (inject:into: 2 ) (#'ifKindOf:thenDo:' 2 ) |
|
1240 |
(#'forPoint:closestSideDistLen:' 2 ) (#'value:ifError:' 2 ) (selectorsDo: 1 ) |
|
1241 |
(removeAllSuchThat: 1 ) (#'keyAtIdentityValue:ifAbsent:' 2 ) (detectMin: 1 ) |
|
1242 |
(#'detect:ifNone:' 1 ) (#'ifTrue:ifFalse:' 1 ) (#'ifTrue:ifFalse:' 2 ) |
|
1243 |
(#'detect:ifNone:' 2 ) (hasLiteralSuchThat: 1 ) (#'indexOfAnyOf:ifAbsent:' 2 ) |
|
1244 |
(reject: 1 ) (newRectFrom: 1 ) (#'removeKey:ifAbsent:' 2 ) (#'at:ifPresent:' 2 ) |
|
1245 |
(#'associationAt:ifAbsent:' 2 ) (withIndexCollect: 1 ) (#'repeatLast:ifEmpty:' 2 ) |
|
1246 |
(findLast: 1 ) (#'indexOf:startingAt:ifAbsent:' 3 ) (#'remove:ifAbsent:' 2 ) |
|
1247 |
(#'ifFalse:ifTrue:' 1 ) (#'ifFalse:ifTrue:' 2 ) (#'caseOf:otherwise:' 2 ) (count: 1 ) (collect: 1 ) (sortBy: 1 ) (and: 1 ) (asSortedCollection: 1 ) |
|
1248 |
(#'with:collect:' 2 ) (#'sourceCodeAt:ifAbsent:' 2 ) (detect: 1 ) (#'scopeHas:ifTrue:' 2 ) (collectWithIndex: 1 ) (#'compiledMethodAt:ifAbsent:' 2 ) |
|
1249 |
(bindWithTemp: 1 ) (detectSum: 1 ) (#'indexOfSubCollection:startingAt:ifAbsent:' 3 ) (findFirst: 1 ) (#'sourceMethodAt:ifAbsent:' 2 ) (#'collect:thenSelect:' 1 ) |
|
1250 |
(#'collect:thenSelect:' 2 ) (#'select:thenCollect:' 1 ) (#'select:thenCollect:' 2 ) (ifFalse: 1 ) (#'indexOfAnyOf:startingAt:ifAbsent:' 3 ) (#'indentationIfBlank:' 1 ) |
|
1108 | 1251 |
) do: [:anArray | |
1252 |
Blocks add: anArray]. |
|
1089 | 1253 |
|
1491 | 1254 |
#( |
1255 |
(ifFalse: 1 ) |
|
1256 |
(ifTrue: 1 ) |
|
1257 |
(#'ifFalse:ifTrue:' 1 ) (#'ifFalse:ifTrue:' 2 ) |
|
1258 |
(#'ifTrue:ifFalse:' 1 ) (#'ifTrue:ifFalse:' 2 ) |
|
1259 |
) do: [:anArray | |
|
1260 |
BlocksOptional add: anArray]. |
|
1089 | 1261 |
|
1262 |
" |
|
1263 |
MethodFinder new initialize. |
|
1264 |
MethodFinder new organizationFiltered: TranslucentColor class |
|
1265 |
" |
|
1266 |
"Do not forget class messages for each of these classes" |
|
1108 | 1267 |
|
1109 | 1268 |
"Modified: / 13.11.2001 / 19:28:41 / cg" |
1089 | 1269 |
! |
1270 |
||
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1271 |
load:dataWithAnswers |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1272 |
"Find a function that takes the data and gives the answers. Odd list entries are data for it, even ones are the answers. nil input means data and answers were supplied already." |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1273 |
" (MethodFinder new) load: #( (4 3) 7 (-10 5) -5 (-3 11) 8); |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1274 |
findMessage" |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1275 |
|
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1276 |
dataWithAnswers |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1277 |
ifNotNil:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1278 |
data := Array new:dataWithAnswers size // 2. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1279 |
1 to:data size do:[:ii | |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1280 |
data at:ii put:(dataWithAnswers at:ii * 2 - 1) |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1281 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1282 |
answers := Array new:data size. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1283 |
1 to:answers size do:[:ii | |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1284 |
answers at:ii put:(dataWithAnswers at:ii * 2) |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1285 |
] |
1089 | 1286 |
]. |
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1287 |
data do:[:list | |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1288 |
(list isSequenceable) ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1289 |
^ self warn:'first and third items are not Arrays' |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1290 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1291 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1292 |
argMap := (1 to:data first size) asArray. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1293 |
data do:[:list | |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1294 |
list size = argMap size ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1295 |
self warn:'data arrays must all be the same size' |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1296 |
] |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1297 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1298 |
argMap size > 4 ifTrue:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1299 |
self warn:'No more than a receiver and |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1300 |
three arguments allowed' |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1301 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1302 |
"Really only test receiver and three args." |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1303 |
thisData := data copy. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1304 |
mapStage := mapList := nil. |
1089 | 1305 |
! |
1306 |
||
1307 |
noteDangerous |
|
1104 | 1308 |
"Remember the methods with really bad side effects." |
1089 | 1309 |
|
1104 | 1310 |
Dangerous _ Set new. |
1089 | 1311 |
"Object accessing, testing, copying, dependent access, macpal, flagging" |
4252 | 1312 |
#(addInstanceVarNamed:withValue: |
1313 |
copyAddedStateFrom: veryDeepCopy veryDeepCopyWith: veryDeepFixupWith: veryDeepInner: addDependent: evaluate:wheneverChangeIn: codeStrippedOut: playSoundNamed: isThisEverCalled isThisEverCalled: logEntry logExecution logExit) |
|
1104 | 1314 |
do: [:sel | Dangerous add: sel]. |
1089 | 1315 |
|
1316 |
"Object error handling" |
|
4252 | 1317 |
#(cannotInterpret: caseError confirm: confirm:orCancel: doesNotUnderstand: error: |
1318 |
halt halt: haltIfNil haltIfTrue haltIfFalse |
|
1319 |
notify: notify:at: primitiveFailed shouldNotImplement subclassResponsibility tryToDefineVariableAccess:) |
|
1104 | 1320 |
do: [:sel | Dangerous add: sel]. |
1089 | 1321 |
|
1322 |
"Object user interface" |
|
1104 | 1323 |
#(basicInspect beep inform: inspect inspectWithLabel: notYetImplemented inspectElement ) |
1324 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1325 |
|
1326 |
"Object system primitives" |
|
2229 | 1327 |
#(become: becomeForward: becomeSameAs: changeClassTo: instVarAt:put: instVarNamed:put: nextInstance nextObject rootStubInImageSegment: someObject tryPrimitive:withArgs:) |
1104 | 1328 |
do: [:sel | Dangerous add: sel]. |
1089 | 1329 |
|
1330 |
"Object private" |
|
1104 | 1331 |
#(errorImproperStore errorNonIntegerIndex errorNotIndexable errorSubscriptBounds: mustBeBoolean primitiveError: species storeAt:inTempFrame:) |
1332 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1333 |
|
1334 |
"Object, translation support" |
|
1104 | 1335 |
#(cCode: cCode:inSmalltalk: cCoerce:to: export: inline: returnTypeC: sharedCodeNamed:inCase: var:declareC:) |
1336 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1337 |
|
1338 |
"Object, objects from disk, finalization. And UndefinedObject" |
|
1104 | 1339 |
#(comeFullyUpOnReload: objectForDataStream: readDataFrom:size: rehash saveOnFile storeDataOn: actAsExecutor executor finalize retryWithGC:until: suspend) |
1340 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1341 |
|
1342 |
"No Restrictions: Boolean, False, True, " |
|
1343 |
||
1344 |
"Morph" |
|
1104 | 1345 |
#(fullCopy copyRecordingIn:) |
1346 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1347 |
|
1348 |
"Behavior" |
|
1104 | 1349 |
#(obsolete confirmRemovalOf: copyOfMethodDictionary literalScannedAs:notifying: storeLiteral:on: addSubclass: removeSubclass: superclass: |
1089 | 1350 |
"creating method dictionary" addSelector:withMethod: compile: compile:notifying: compileAll compileAllFrom: compress decompile: defaultSelectorForMethod: methodDictionary: recompile:from: recompileChanges removeSelector: compressedSourceCodeAt: selectorAtMethod:setClass: allInstances allSubInstances inspectAllInstances inspectSubInstances thoroughWhichSelectorsReferTo:special:byte: "enumerating" allInstancesDo: allSubInstancesDo: allSubclassesDo: allSuperclassesDo: selectSubclasses: selectSuperclasses: subclassesDo: withAllSubclassesDo: |
1351 |
"user interface" allCallsOn: browse browseAllAccessesTo: browseAllCallsOn: browseAllStoresInto: "too slow->" crossReference removeUninstantiatedSubclassesSilently "too slow->" unreferencedInstanceVariables |
|
1352 |
"private" becomeCompact becomeUncompact flushCache format:variable:words:pointers: format:variable:words:pointers:weak: printSubclassesOn:level: removeSelectorSimply:) |
|
1104 | 1353 |
do: [:sel | Dangerous add: sel]. |
1089 | 1354 |
|
1355 |
"Others " |
|
1104 | 1356 |
#("no tangible result" do: associationsDo: |
1089 | 1357 |
"private" adaptToCollection:andSend: adaptToNumber:andSend: adaptToPoint:andSend: adaptToString:andSend: instVarAt:put: asDigitsToPower:do: combinations:atATimeDo: doWithIndex: pairsDo: permutationsDo: reverseDo: reverseWith:do: with:do: withIndexDo: asDigitsAt:in:do: combinationsAt:in:after:do: errorOutOfBounds permutationsStartingAt:do: fromUser) |
1104 | 1358 |
do: [:sel | Dangerous add: sel]. |
1089 | 1359 |
|
1360 |
||
1104 | 1361 |
#( fileOutPrototype addSpareFields makeFileOutFile ) |
1362 |
do: [:sel | Dangerous add: sel]. |
|
1363 |
#(recompile:from: recompileAllFrom: recompileChanges asPrototypeWithFields: asPrototype addInstanceVarNamed:withValue: addInstanceVariable addClassVarName: removeClassVarName: findOrAddClassVarName: tryToDefineVariableAccess: instanceVariableNames: ) |
|
1364 |
do: [:sel | Dangerous add: sel]. |
|
4252 | 1365 |
|
1366 |
"Modified: / 17-07-2017 / 17:59:32 / cg" |
|
1089 | 1367 |
! |
1368 |
||
1369 |
organizationFiltered: aClass |
|
1104 | 1370 |
"Return the organization of the class with all selectors defined in superclasses removed. (except those in Object)" |
1089 | 1371 |
|
1104 | 1372 |
| org str | |
1373 |
org _ aClass organization deepCopy. |
|
1374 |
Dangerous do: [:sel | |
|
1375 |
org removeElement: sel]. |
|
1376 |
Approved do: [:sel | |
|
1377 |
org removeElement: sel]. |
|
1378 |
AddAndRemove do: [:sel | |
|
1379 |
org removeElement: sel]. |
|
1380 |
str _ org printString copyWithout: $(. |
|
1381 |
str _ '(', (str copyWithout: $) ). |
|
1382 |
str _ str replaceAll: $' with: $". |
|
1383 |
^ str |
|
1089 | 1384 |
! |
1385 |
||
1386 |
test2: anArray |
|
1104 | 1387 |
"look for bad association" |
1089 | 1388 |
|
1104 | 1389 |
anArray do: [:sub | |
1390 |
sub class == Association ifTrue: [ |
|
1391 |
(#('true' '$a' '2' 'false') includes: sub value printString) ifFalse: [ |
|
1392 |
self error: 'bad assn']. |
|
1393 |
(#('3' '5.6' 'x' '''abcd''') includes: sub key printString) ifFalse: [ |
|
1394 |
self error: 'bad assn']. |
|
1089 | 1395 |
|
1104 | 1396 |
" sub value class == Association ifTrue: [ |
1397 |
self error: 'bad assn']. |
|
1398 |
(sub value isKindOf: Class) ifTrue: [ |
|
1399 |
self error: 'class in assn']. |
|
3444 | 1400 |
sub value class == Symbol ifTrue: [sub value codePoint = 204 '$' ifTrue: [ |
1104 | 1401 |
self error: 'Write into char']]. |
3444 | 1402 |
sub value == $ ifTrue: [ |
1104 | 1403 |
self error: 'Write into char'] |
1404 |
"]. |
|
1405 |
sub class == Array ifTrue: [ |
|
1406 |
sub do: [:element | |
|
3622 | 1407 |
element isString ifTrue: [element first codePoint < 32 ifTrue: [ |
1104 | 1408 |
self error: 'store into string in data']]. |
1409 |
element class == Association ifTrue: [ |
|
1410 |
element value class == Association ifTrue: [ |
|
1411 |
self error: 'bad assn']]]]. |
|
1412 |
sub class == Date ifTrue: [sub year isInteger ifFalse: [ |
|
1413 |
self error: 'stored into input date!!!!']]. |
|
1414 |
sub class == Dictionary ifTrue: [ |
|
4405 | 1415 |
sub size ~~ 0 ifTrue: [ |
1104 | 1416 |
self error: 'store into dictionary']]. |
1417 |
sub class == OrderedCollection ifTrue: [ |
|
1418 |
sub size > 4 ifTrue: [ |
|
1419 |
self error: 'store into OC']]. |
|
1420 |
]. |
|
4405 | 1421 |
|
1422 |
"Modified: / 01-03-2019 / 16:00:34 / Claus Gittinger" |
|
1089 | 1423 |
! |
1424 |
||
1425 |
test3 |
|
1104 | 1426 |
"find the modification of the caracter table" |
1089 | 1427 |
|
2058
c71d2ac1fbfe
asciiValue obsoleted by codePoint
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
1428 |
(#x at: 1) codePoint = 120 ifFalse: [self error: 'Character table mod']. |
1089 | 1429 |
! ! |
1430 |
||
1431 |
!MethodFinder methodsFor:'search'! |
|
1432 |
||
1433 |
exceptions |
|
1104 | 1434 |
"Handle some very slippery selectors. |
1435 |
asSymbol -- want to be able to produce it, but do not want to make every string submitted into a Symbol!!" |
|
1089 | 1436 |
|
1104 | 1437 |
| aSel | |
3622 | 1438 |
answers first isSymbol ifFalse: [^ self]. |
1439 |
thisData first first isString ifFalse: [^ self]. |
|
1440 |
aSel := #asSymbol. |
|
1104 | 1441 |
(self testPerfect: aSel) ifTrue: [ |
1442 |
selector add: aSel. |
|
1443 |
expressions add: (String streamContents: [:strm | |
|
1444 |
strm nextPutAll: 'data', argMap first printString. |
|
1445 |
aSel keywords doWithIndex: [:key :ind | |
|
1446 |
strm nextPutAll: ' ',key. |
|
2935 | 1447 |
((key last == $:) or:[ key first isLetter not ]) |
1104 | 1448 |
ifTrue: [strm nextPutAll: ' data', |
1449 |
(argMap at: ind+1) printString]]])]. |
|
1089 | 1450 |
! |
1451 |
||
1452 |
findMessage |
|
1453 |
"Control the search." |
|
1454 |
||
1455 |
data do: [:alist | |
|
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1456 |
(alist isSequenceable) ifFalse: [ |
1089 | 1457 |
^ OrderedCollection with: 'first and third items are not Arrays']]. |
1458 |
||
1491 | 1459 |
true "Approved isNil" ifTrue: [self initialize]. "Sets of allowed selectors" |
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1460 |
expressions := OrderedCollection new. |
1089 | 1461 |
self search: true. "multi" |
1462 |
expressions isEmpty ifTrue: [^ OrderedCollection with: 'no single method does that function']. |
|
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1463 |
expressions isString ifTrue: [^ OrderedCollection with: expressions]. |
1089 | 1464 |
^ expressions |
1465 |
! |
|
1466 |
||
1467 |
insertConstants |
|
1104 | 1468 |
"see if one of several known expressions will do it. C is the constant we discover here." |
1469 |
"C data1+C data1*C data1//C (data1*C1 + C2) (data1 = C) (data1 ~= C) (data1 <= C) (data1 >= C) |
|
1089 | 1470 |
(data1 mod C)" |
1471 |
||
1104 | 1472 |
thisData size >= 2 ifFalse: [^ self]. "need 2 examples" |
1473 |
(thisData at: 1) size = 1 ifFalse: [^ self]. "only one arg, data1" |
|
1089 | 1474 |
|
1104 | 1475 |
self const ifTrue: [^ self]. |
1491 | 1476 |
"/ self constEquiv ifTrue: [^ self]. " == ~= " |
1104 | 1477 |
self constLessThan ifTrue: [^ self]. " <= and >= " |
1089 | 1478 |
|
1104 | 1479 |
self allNumbers ifFalse: [^ self]. |
1480 |
self constMod ifTrue: [^ self]. |
|
1481 |
self constPlus ifTrue: [^ self]. |
|
1482 |
self constMult ifTrue: [^ self]. |
|
1483 |
self constDiv ifTrue: [^ self]. |
|
1484 |
self constLinear ifTrue: [^ self]. |
|
1089 | 1485 |
! |
1486 |
||
1487 |
search: multi |
|
1488 |
"if Multi is true, collect all selectors that work." |
|
1489 |
| old | |
|
1490 |
selector:=OrderedCollection new. "list of them" |
|
1491 |
||
1492 |
" old _ Preferences autoAccessors. |
|
1493 |
Preferences disableGently: #autoAccessors. " |
|
1494 |
Smalltalk isSmalltalkX ifTrue:[old:=false]. |
|
1495 |
||
1496 |
self simpleSearch. |
|
1497 |
multi not & (selector isEmpty not) ifTrue: |
|
1498 |
["old ifTrue: [Preferences enableGently: #autoAccessors]." |
|
1499 |
^ selector]. |
|
1500 |
||
1501 |
[self permuteArgs] whileTrue: |
|
1502 |
[self simpleSearch. |
|
1503 |
multi not & (selector isEmpty not) ifTrue: |
|
1504 |
["old ifTrue: [Preferences enableGently: #autoAccessors]." |
|
1505 |
^ selector]]. |
|
1506 |
||
1507 |
self insertConstants. |
|
1508 |
" old ifTrue: [Preferences enableGently: #autoAccessors]. " |
|
1491 | 1509 |
|
1089 | 1510 |
"/ (selector isEmpty not) ifTrue: [^ selector]]. " expression is the answer, not a selector" |
1511 |
^ #() |
|
1512 |
! |
|
1513 |
||
1514 |
searchForOne |
|
1104 | 1515 |
"Look for and return just one answer" |
1089 | 1516 |
|
1104 | 1517 |
expressions _ OrderedCollection new. |
1518 |
self search: false. "non-multi" |
|
1519 |
^ expressions |
|
1520 |
||
1089 | 1521 |
! |
1522 |
||
1523 |
simpleSearch |
|
1524 |
"Run through first arg's class' selectors, looking for one that works." |
|
1525 |
||
1526 |
| class supers listOfLists | |
|
1527 |
self exceptions. |
|
1528 |
class:=thisData first first class. |
|
1529 |
"Cache the selectors for the receiver class" |
|
1530 |
(class == cachedClass and: [cachedArgNum = ((argMap size) - 1)]) |
|
1531 |
ifTrue: [listOfLists:=cachedSelectorLists] |
|
1532 |
ifFalse: [supers:=class withAllSuperclasses. |
|
1533 |
listOfLists:=OrderedCollection new. |
|
1092 | 1534 |
supers do: [:cls | |
1089 | 1535 |
listOfLists add: (cls selectorsWithArgs: (argMap size) - 1)]. |
1536 |
cachedClass:=class. |
|
1537 |
cachedArgNum:=(argMap size) - 1. |
|
1538 |
cachedSelectorLists:=listOfLists]. |
|
1539 |
"/ self halt. |
|
1540 |
listOfLists do: [:selectorList | |
|
1541 |
selectorList do: [:aSel | |
|
1542 |
(selector includes: aSel) ifFalse: [ |
|
1543 |
((Approved includes: aSel) or: [AddAndRemove includes: aSel]) ifTrue: [ |
|
1544 |
(self testPerfect: aSel) ifTrue: [ |
|
1545 |
selector add: aSel. |
|
1546 |
expressions add: (String streamContents: [:strm | |
|
1547 |
strm nextPutAll: 'data', argMap first printString. |
|
1548 |
aSel keywords doWithIndex: [:key :ind | |
|
1549 |
strm nextPutAll: ' ',key. |
|
2935 | 1550 |
((key last == $:) or:[ key first isLetter not]) |
1089 | 1551 |
ifTrue: [strm nextPutAll: ' data', |
1552 |
(argMap at: ind+1) printString]]]) |
|
1553 |
]]]]]. |
|
1554 |
! |
|
1555 |
||
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1556 |
testPerfect:aSelector |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1557 |
"Try this selector!! Return true if it answers every example perfectly. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1558 |
Take the args in the order they are. Do not permute them. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1559 |
Survive errors. later cache arg lists." |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1560 |
|
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1561 |
|sz argList val rec activeSel perform argIsBlock expectedAnswer| |
1089 | 1562 |
|
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1563 |
"Transcript cr; show: aSelector. debug" |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1564 |
perform := aSelector beginsWith:'perform:'. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1565 |
sz := argMap size. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1566 |
1 to:thisData size do:[:ii | |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1567 |
"each example set of args" |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1568 |
argList := (thisData at:ii) copyFrom:2 to:sz. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1569 |
perform ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1570 |
activeSel := aSelector |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1571 |
] ifTrue:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1572 |
activeSel := argList first. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1573 |
((Approved includes:activeSel) or:[ AddAndRemove includes:activeSel ]) ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1574 |
^ false |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1575 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1576 |
aSelector == #perform:withArguments: ifTrue:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1577 |
activeSel numArgs = (argList at:2) basicSize "avoid error" ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1578 |
^ false |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1579 |
] |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1580 |
] ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1581 |
activeSel numArgs = (aSelector numArgs - 1) ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1582 |
^ false |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1583 |
] |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1584 |
] |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1585 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1586 |
1 to:sz do:[:num | |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1587 |
(Blocks includes:(Array with:activeSel with:num)) ifTrue:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1588 |
Smalltalk isSmalltalkX ifTrue:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1589 |
argIsBlock := (argList at:num) isBlock |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1590 |
] ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1591 |
argIsBlock := (argList at:num) class == BlockContext |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1592 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1593 |
argIsBlock ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1594 |
(BlocksOptional includes:(Array with:activeSel with:num)) ifFalse:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1595 |
^ false |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1596 |
] |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1597 |
] |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1598 |
] |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1599 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1600 |
" (activeSel = #capitalized) ifTrue:[self halt.]. " " used to test " |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1601 |
rec := (AddAndRemove includes:activeSel) ifTrue:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1602 |
(thisData at:ii) first class == Symbol ifTrue:[ |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1603 |
^ false |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1604 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1605 |
"vulnerable to modification" |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1606 |
(thisData at:ii) first copyTwoLevel "protect from damage" |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1607 |
] ifFalse:[ |
4231 | 1608 |
[(thisData at:ii) first] on:Error do:[ self halt ] |
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1609 |
]. |
4231 | 1610 |
expectedAnswer := answers at:ii. |
4025 | 1611 |
val := |
1612 |
[ |
|
1613 |
[ |
|
1614 |
rec copy perform:aSelector withArguments:argList |
|
4231 | 1615 |
] on:ObsoleteMethodCallWarning do:[ |
1616 |
^ false |
|
1617 |
]. |
|
1618 |
] on:Error do:[:ex | |
|
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1619 |
"/ Transcript showCR:aSignal description. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1620 |
"self test3." |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1621 |
"self test2: (thisData at: ii)." |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1622 |
^ false |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1623 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1624 |
"self test3." "self test2: (thisData at: ii)." |
4231 | 1625 |
(expectedAnswer isNumber) ifTrue:[ |
1626 |
(expectedAnswer closeTo:val) ifFalse:[ |
|
1627 |
^ false |
|
1628 |
] |
|
1629 |
] ifFalse:[ |
|
1630 |
(expectedAnswer isArray |
|
1631 |
and:[val isNonByteCollection |
|
1632 |
and:[[val asArray = expectedAnswer] on:Error do:false]]) ifTrue:[ |
|
1633 |
^ true |
|
2059
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1634 |
]. |
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1635 |
|
2061 | 1636 |
"/ would like to remember 'almost' same, and present in separate list. |
1637 |
"/ expectedAnswer isString ifTrue:[ |
|
1638 |
"/ (val isString) ifTrue:[ |
|
1639 |
"/ ([val sameAs: expectedAnswer] ifError:[false]) ifTrue:[self halt. ^ true]. |
|
1640 |
"/ ]. |
|
1641 |
"/ ]. |
|
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1642 |
|
4231 | 1643 |
([expectedAnswer = val] on:Error do:false) ifFalse:[ |
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1644 |
^ false |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1645 |
] |
1089 | 1646 |
]. |
2895
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1647 |
]. |
1d758d52e0d8
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2772
diff
changeset
|
1648 |
^ true |
1109 | 1649 |
|
4231 | 1650 |
"Modified: / 13-11-2001 / 19:08:39 / cg" |
1651 |
"Modified: / 18-03-2017 / 18:55:42 / stefan" |
|
2061 | 1652 |
! ! |
1653 |
||
1654 |
!MethodFinder methodsFor:'tests'! |
|
1089 | 1655 |
|
1656 |
verify |
|
1657 |
"Test a bunch of examples" |
|
1658 |
" MethodFinder new verify " |
|
1928 | 1659 |
Approved isNil ifTrue: [self initialize]. "Sets of allowed selectors" |
1089 | 1660 |
"/(MethodFinder new load: #( (0) 0 (30) 0.5 (45) 0.707106 (90) 1) |
1661 |
"/ ) searchForOne asArray = #('data1 degreeSin') ifFalse: [self error: 'should have found it']. "Squeak test" |
|
1491 | 1662 |
(MethodFinder new load: (Array with:(Array with:true with:[3] with:[4]) with:3 with:(Array with:false with:[0] with:[6]) with:6) |
1663 |
) searchForOne asArray = #('data1 ifTrue: data2 ifFalse: data3') ifFalse: [ |
|
1664 |
self error: 'should have found it']. |
|
1665 |
(MethodFinder new load: #(#(1) true #(2) false #(5) true #(10) false) |
|
1666 |
) searchForOne asArray = #('data1 odd' 'data1 isPrime') ifFalse: [self error: 'should have found it']. |
|
1089 | 1667 |
"will correct the date type of #true, and complain" |
1668 |
Smalltalk isSmalltalkX ifTrue:[ |
|
1491 | 1669 |
(MethodFinder new load: #((4 2) '2r100' (255 16) '16rFF' (14 8) '8r16') |
1089 | 1670 |
) searchForOne asArray = |
1671 |
#('data1 radixPrintStringRadix: data2' ) |
|
1672 |
ifFalse: [self error: 'should have found it']. |
|
1673 |
] ifFalse:[ |
|
1491 | 1674 |
(MethodFinder new load: #((4 2) '2r100' (255 16) '16rFF' (14 8) '8r16') |
1089 | 1675 |
) searchForOne asArray = |
1676 |
#('data1 radix: data2' 'data1 printStringBase: data2' 'data1 storeStringBase: data2') |
|
1677 |
ifFalse: [self error: 'should have found it']. |
|
1678 |
]. |
|
1679 |
"/(MethodFinder2 new load: #(#(3@4) 4 #(1@5) 5) |
|
1680 |
"/ ) searchForOne asArray = #('data1 y') ifFalse: [self error: 'should have found it']. |
|
1681 |
Smalltalk isSmalltalkX ifTrue:[ |
|
1491 | 1682 |
(MethodFinder new load: #(('abcd') $a ('TedK') $T) |
1089 | 1683 |
) searchForOne asArray = #('data1 first' 'data1 removeFirst' 'data1 anyOne') |
1684 |
ifFalse: [self error: 'should have found it']. |
|
1685 |
] ifFalse:[ |
|
1491 | 1686 |
(MethodFinder new load: #(('abcd') $a ('TedK') $T) |
1089 | 1687 |
) searchForOne asArray = #('data1 asCharacter' 'data1 first' 'data1 anyOne') |
1688 |
ifFalse: [self error: 'should have found it']. |
|
1689 |
]. |
|
1491 | 1690 |
(((MethodFinder new load: #(('abcd' 1) $a ('Ted ' 3) $d ) |
1089 | 1691 |
) searchForOne asArray) includesAll: #('data1 at: data2' 'data1 atPin: data2' 'data1 atWrap: data2')) |
1692 |
ifFalse: [self error: 'should have found it']. |
|
1491 | 1693 |
(MethodFinder new load: #(((12 4 8)) 24 ((1 3 6)) 10 ) |
1089 | 1694 |
) searchForOne asArray= #('data1 sum') ifFalse: [self error: 'should have found it']. |
1695 |
"note extra () needed for an Array object as an argument" |
|
1696 |
||
1491 | 1697 |
(MethodFinder new load: #((14 3) 11 (-10 5) -15 (4 -3) 7) |
1089 | 1698 |
) searchForOne asArray = #('data1 - data2') ifFalse: [self error: 'should have found it']. |
1491 | 1699 |
((MethodFinder new load: #((4) 4 (-10) 10 (-3) 3 (2) 2 (-6) 6 (612) 612) |
1089 | 1700 |
) searchForOne asArray includesAll: #('data1 abs')) ifFalse: [self error: 'should have found it']. |
1491 | 1701 |
(MethodFinder new load: #(#(4 3) true #(-7 3) false #(5 1) true #(5 5) false) |
1089 | 1702 |
) searchForOne asArray = #('data1 > data2') ifFalse: [self error: 'should have found it']. |
1491 | 1703 |
(MethodFinder new load: #((5) 0.2 (2) 0.5) |
1089 | 1704 |
) searchForOne asArray = #('data1 reciprocal') ifFalse: [self error: 'should have found it']. |
1491 | 1705 |
(MethodFinder new load: #((12 4 8) 2 (1 3 6) 2 (5 2 16) 8) |
1089 | 1706 |
) searchForOne asArray = #() " '(data3 / data2) ' want to be able to leave out args" |
1707 |
ifFalse: [self error: 'should have found it']. |
|
1491 | 1708 |
(MethodFinder new load: #((0.0) 0.0 (1.5) 0.997495 (0.75) 0.681639) |
1089 | 1709 |
) searchForOne asArray = #('data1 sin') ifFalse: [self error: 'should have found it']. |
1491 | 1710 |
(MethodFinder new load: #((7 5) 2 (4 5) 4 (-9 4) 3) |
1089 | 1711 |
) searchForOne asArray = #('data1 \\ data2') ifFalse: [self error: 'should have found it']. |
1712 |
! ! |
|
1713 |
||
1714 |
!MethodFinder class methodsFor:'documentation'! |
|
1715 |
||
1716 |
version |
|
3951 | 1717 |
^ '$Header$' |
2212 | 1718 |
! |
1719 |
||
1720 |
version_CVS |
|
3951 | 1721 |
^ '$Header$' |
1089 | 1722 |
! ! |
3316 | 1723 |