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