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