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