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