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