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