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