author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 13 Feb 2012 19:20:09 +0000 | |
branch | jv |
changeset 3021 | 956028a9df3d |
parent 3012 | 4f40b8304d54 |
child 3025 | 0d2ac7263c07 |
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 |
||
3021 | 127 |
!MethodFinder methodsFor:'accessing'! |
1089 | 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 |
||
2248 | 331 |
!MethodFinder methodsFor:'initialization'! |
1089 | 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 |
|
2212 | 352 |
fixed ifTrue: [self information: '#(true false) are Symbols, not Booleans. |
1089 | 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 |
|
2212 | 362 |
fixed ifTrue: [self information: '#nil is a Symbol, not the authentic UndefinedObject. |
1089 | 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" |
2285 | 627 |
@ asInteger asNumber asPoint asSmallAngleDegrees degreesToRadians radiansToDegrees |
628 |
asFixedPoint asFixedPoint: asFixedPointRoundedToScale asFixedPointRoundedToScale: |
|
629 |
asFloat asFraction |
|
1108 | 630 |
"intervals" |
631 |
to: #'to:by:' |
|
632 |
"printing" |
|
633 |
printStringBase: storeStringBase: |
|
634 |
||
635 |
"ST/X in class" |
|
636 |
#'readFrom:base:' |
|
637 |
"ST/X intervals" |
|
638 |
downTo: #'downTo:by:' |
|
639 |
"ST/X printing" |
|
2061 | 640 |
radixPrintStringRadix: printStringRadix: storeStringRadix: romanPrintString |
1108 | 641 |
) do: [:sel | Approved add: sel]. |
642 |
||
1089 | 643 |
"Integer" |
1108 | 644 |
#( |
645 |
"in class" |
|
646 |
primesUpTo: |
|
647 |
"testing" |
|
2061 | 648 |
isPowerOfTwo digitBytes isPrime nextPrime |
1108 | 649 |
"arithmetic" |
650 |
alignedTo: |
|
651 |
"comparing" |
|
652 |
"truncation and round off" |
|
653 |
atRandom normalize |
|
654 |
"enumerating" |
|
655 |
timesRepeat: |
|
656 |
"mathematical functions" |
|
2061 | 657 |
degreeCos degreeSin factorial gcd: lcm: binco: take: primeFactors |
1108 | 658 |
"bit manipulation" |
2061 | 659 |
<< >> allMask: anyMask: bitAnd: bitClear: bitInvert bitInvert32 bitOr: bitShift: bitXor: |
660 |
highBit lowBit bitCount noMask: |
|
1108 | 661 |
"converting" |
662 |
asCharacter asColorOfDepth: asFloat asFraction asHexDigit |
|
663 |
"printing" |
|
664 |
asStringWithCommas hex hex8 radix: |
|
665 |
"system primitives" |
|
666 |
lastDigit #'replaceFrom:to:with:startingAt:' |
|
667 |
"private" "benchmarks" |
|
1089 | 668 |
|
1108 | 669 |
"ST/X printing" |
2061 | 670 |
hexPrintString |
1108 | 671 |
|
672 |
) do: [:sel | Approved add: sel]. |
|
1106 | 673 |
|
1089 | 674 |
"SmallInteger, LargeNegativeInteger, LargePositiveInteger" |
1108 | 675 |
#( |
676 |
"arithmetic" |
|
677 |
"bit manipulation" |
|
678 |
"testing" "comparing" "copying" "converting" "printing" |
|
679 |
"system primitives" |
|
680 |
digitAt: digitLength |
|
681 |
"private" |
|
682 |
#'fromString:radix:' |
|
683 |
) do: [:sel | Approved add: sel]. |
|
2059
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
684 |
|
1089 | 685 |
#((#'digitAt:put:') ) do: [:sel | AddAndRemove add: sel]. |
686 |
||
687 |
"Float" |
|
1108 | 688 |
#( |
689 |
"arithmetic" |
|
690 |
"mathematical functions" |
|
691 |
reciprocalFloorLog: reciprocalLogBase2 timesTwoPower: |
|
692 |
"comparing" "testing" |
|
693 |
"truncation and round off" |
|
694 |
exponent fractionPart integerPart significand significandAsInteger |
|
695 |
"converting" |
|
696 |
asApproximateFraction asIEEE32BitWord asTrueFraction |
|
697 |
"copying" |
|
698 |
) do: [:sel | Approved add: sel]. |
|
1089 | 699 |
|
700 |
"Fraction, Random" |
|
1108 | 701 |
#( |
702 |
denominator numerator reduced next nextValue |
|
703 |
) do: [:sel | Approved add: sel]. |
|
704 |
#( |
|
705 |
#'setNumerator:denominator:' |
|
706 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 707 |
|
708 |
"Collection" |
|
1108 | 709 |
#( |
710 |
"accessing" |
|
711 |
anyOne |
|
712 |
"testing" |
|
713 |
includes: includesAllOf: includesAnyOf: includesSubstringAnywhere: isEmpty notEmpty isSequenceable occurrencesOf: |
|
714 |
"enumerating" |
|
715 |
collect: #'collect:thenSelect:' count: detect: #'detect:ifNone:' detectMax: detectMin: detectSum: #'inject:into:' reject: select: #'select:thenCollect:' |
|
716 |
"converting" |
|
717 |
asBag asCharacterSet asSet asSortedArray asSortedCollection asSortedCollection: |
|
1491 | 718 |
asStringWith: |
1108 | 719 |
"printing" |
720 |
"private" |
|
721 |
maxSize |
|
722 |
"arithmetic" |
|
723 |
"math functions" |
|
724 |
average max median min range sum |
|
725 |
) do: [:sel | Approved add: sel]. |
|
726 |
||
727 |
#( |
|
728 |
"adding" |
|
729 |
add: addAll: addIfNotPresent: |
|
730 |
"removing" |
|
731 |
remove: #'remove:ifAbsent:' removeAll: removeAllFoundIn: removeAllSuchThat: #'remove:ifAbsent:' |
|
732 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 733 |
|
734 |
"SequenceableCollection" |
|
1108 | 735 |
#( |
736 |
"comparing" |
|
737 |
hasEqualElements: |
|
738 |
"accessing" allButFirst allButLast at:ifAbsent: atAll: atPin: atRandom: atWrap: |
|
739 |
fifth first fourth last second sixth third |
|
740 |
identityIndexOf: #'identityIndexOf:startingAt:' #'identityIndexOf:ifAbsent:' #'identityIndexOf:startingAt:ifAbsent:' |
|
741 |
indexOf: #'indexOf:startingAt:' #'indexOf:ifAbsent:' #'indexOf:startingAt:ifAbsent:' |
|
742 |
lastIndexOf: #'lastIndexOf:startingAt:' #'lastIndexOf:ifAbsent:' #'lastIndexOf:startingAt:ifAbsent:' |
|
743 |
#'indexOfSubCollection:' |
|
744 |
#'indexOfSubCollection:ifAbsent:' |
|
745 |
#'indexOfSubCollection:startingAt:' |
|
746 |
#'indexOfSubCollection:startingAt:ifAbsent:' |
|
747 |
#'lastIndexOfSubCollection:' |
|
748 |
#'lastIndexOfSubCollection:ifAbsent:' |
|
749 |
#'lastIndexOfSubCollection:startingAt:' |
|
750 |
#'lastIndexOfSubCollection:startingAt:ifAbsent:' |
|
1107 | 751 |
|
1108 | 752 |
"removing" |
753 |
"copying" |
|
754 |
, copyAfterLast: #'copyAt:put:' #'copyFrom:to:' #'copyReplaceAll:with:' #'copyReplaceFrom:to:with:' copyUpTo: copyUpToLast: copyWith: copyWithout: copyWithoutAll: #'forceTo:paddingWith:' shuffled sortBy: |
|
755 |
"enumerating" |
|
756 |
collectWithIndex: findFirst: findLast: pairsCollect: #'with:collect:' withIndexCollect: polynomialEval: |
|
757 |
"converting" |
|
758 |
asArray asDictionary asFloatArray asIntegerArray asStringWithCr asWordArray reversed |
|
759 |
"private" |
|
760 |
#'copyReplaceAll:with:asTokens:' |
|
1089 | 761 |
|
1108 | 762 |
"ST/X copying" |
763 |
copyWithoutLast: copyLast: copyFrom: copyTo: |
|
764 |
"ST/X testing" |
|
765 |
longestCommonPrefix |
|
766 |
) do: [:sel | Approved add: sel]. |
|
767 |
||
768 |
#( swap:with: |
|
769 |
) do: [:sel | AddAndRemove add: sel]. |
|
1106 | 770 |
|
1089 | 771 |
"ArrayedCollection, Bag" |
1108 | 772 |
#( |
773 |
"private" |
|
774 |
defaultElement |
|
775 |
"sorting" |
|
776 |
isSorted |
|
777 |
"accessing" |
|
778 |
cumulativeCounts sortedCounts sortedElements |
|
779 |
"testing" "adding" |
|
780 |
#'add:withOccurrences:' |
|
781 |
"removing" "enumerating" |
|
1089 | 782 |
) do: [:sel | Approved add: sel]. |
1108 | 783 |
|
784 |
#( |
|
785 |
#'mergeSortFrom:to:by:' sort sort: add: #'add:withOccurrences:' |
|
786 |
"private" |
|
787 |
setDictionary |
|
788 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 789 |
|
790 |
"Other messages that modify the receiver" |
|
1108 | 791 |
#( |
792 |
#'atAll:put:' #'atAll:putAll:' atAllPut: #'atWrap:put:' |
|
793 |
#'replaceAll:with:' #'replaceFrom:to:with:' removeFirst removeLast |
|
794 |
"ST/X filling & replacing" |
|
795 |
reverse |
|
796 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 797 |
|
798 |
self initialize2. |
|
799 |
||
800 |
" |
|
801 |
MethodFinder new initialize. |
|
802 |
MethodFinder new organizationFiltered: Set |
|
803 |
" |
|
1106 | 804 |
|
2285 | 805 |
"Modified: / 02-08-2010 / 13:33:57 / cg" |
1089 | 806 |
! |
807 |
||
808 |
initialize2 |
|
809 |
"The methods we are allowed to use. (MethodFinder new initialize) " |
|
810 |
||
811 |
"Set" |
|
1108 | 812 |
#( |
813 |
"in class" |
|
814 |
sizeFor: |
|
815 |
"testing" "adding" "removing" "enumerating" |
|
816 |
"private" |
|
817 |
array findElementOrNil: |
|
818 |
"accessing" |
|
819 |
someElement |
|
820 |
) do: [:sel | Approved add: sel]. |
|
1089 | 821 |
|
822 |
"Dictionary, IdentityDictionary, IdentitySet" |
|
1108 | 823 |
#( |
824 |
"accessing" |
|
825 |
associationAt: #'associationAt:ifAbsent:' #'at:ifPresent:' keyAtIdentityValue: #'keyAtIdentityValue:ifAbsent:' keyAtValue: #'keyAtValue:ifAbsent:' keys |
|
826 |
"testing" |
|
827 |
includesKey: |
|
828 |
) do: [:sel | Approved add: sel]. |
|
829 |
#( |
|
830 |
removeKey: #'removeKey:ifAbsent:' |
|
831 |
) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 832 |
|
833 |
"LinkedList, Interval, MappedCollection" |
|
834 |
#( |
|
1108 | 835 |
"in class" |
836 |
#'from:to:' #'from:to:by:' |
|
837 |
"accessing" |
|
838 |
contents) do: [:sel | Approved add: sel]. |
|
839 |
#( |
|
840 |
"adding" |
|
841 |
addFirst: addLast:) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 842 |
|
843 |
"OrderedCollection, SortedCollection" |
|
1108 | 844 |
#( |
845 |
"accessing" |
|
846 |
after: before: |
|
847 |
"copying" |
|
848 |
copyEmpty |
|
849 |
"adding" |
|
850 |
growSize |
|
851 |
"removing" "enumerating" "private" |
|
852 |
"accessing" |
|
853 |
sortBlock) do: [:sel | Approved add: sel]. |
|
854 |
#( |
|
855 |
"adding" |
|
856 |
#'add:after:' #'add:afterIndex:' #'add:before:' addAllFirst: addAllLast: addFirst: addLast: |
|
857 |
"removing" |
|
858 |
removeAt: removeFirst removeLast |
|
859 |
"accessing" |
|
860 |
sortBlock:) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 861 |
|
862 |
"Character" |
|
1108 | 863 |
#( |
864 |
"in class, instance creation" |
|
865 |
allCharacters digitValue: new separators |
|
866 |
"accessing untypeable characters" |
|
867 |
backspace cr enter lf linefeed nbsp newPage space tab |
|
868 |
"constants" |
|
869 |
alphabet characterTable |
|
870 |
"accessing" |
|
871 |
asciiValue digitValue |
|
872 |
"comparing" |
|
2107 | 873 |
"queries" |
874 |
bitsPerCharacter |
|
1108 | 875 |
"testing" |
2107 | 876 |
isAlphaNumeric isDigit isLetter isLowercase isSafeForHTTP isSeparator isSpecial |
877 |
isUppercase isVowel tokenish isNationalAlphaNumeric isNationalDigit isNationalLetter |
|
1108 | 878 |
"copying" |
879 |
"converting" |
|
2107 | 880 |
asIRCLowercase asLowercase asUppercase rot13 rot: |
1089 | 881 |
) do: [:sel | Approved add: sel]. |
882 |
||
883 |
"String" |
|
1108 | 884 |
#( |
885 |
"in class, instance creation" |
|
886 |
crlf fromPacked: |
|
887 |
"primitives" |
|
888 |
#'findFirstInString:inSet:startingAt:' #'indexOfAscii:inString:startingAt:' "internet" valueOfHtmlEntity: |
|
889 |
"accessing" |
|
890 |
byteAt: endsWithDigit #'findAnySubStr:startingAt:' findBetweenSubStrs: |
|
891 |
#'findDelimiters:startingAt:' |
|
892 |
#'findString:startingAt:' #'findString:startingAt:caseSensitive:' |
|
893 |
findTokens: #'findTokens:includes:' #'findTokens:keep:' |
|
894 |
includesSubString: #'includesSubstring:caseSensitive:' |
|
895 |
#'indexOf:startingAt:' |
|
896 |
indexOfAnyOf: #'indexOfAnyOf:ifAbsent:' #'indexOfAnyOf:startingAt:' #'indexOfAnyOf:startingAt:ifAbsent:' |
|
897 |
lineCorrespondingToIndex: lineCount lineNumber: |
|
898 |
#'skipAnySubStr:startingAt:' #'skipDelimiters:startingAt:' startsWithDigit |
|
899 |
"comparing" |
|
1109 | 900 |
alike: beginsWith: caseSensitiveLessOrEqual: charactersExactlyMatching: compare: crc16 |
901 |
endsWith: endsWithAnyOf: sameAs: |
|
902 |
#'startingAt:match:startingAt:' |
|
1108 | 903 |
"copying" |
904 |
#'copyReplaceTokens:with:' #'padded:to:with:' |
|
905 |
"converting" |
|
906 |
asByteArray asDate asDisplayText asFileName asHtml asLegalSelector asPacked asParagraph asText asTime asUnHtml asUrl asUrlRelativeTo: |
|
907 |
#capitalized compressWithTable: contractTo: correctAgainst: |
|
908 |
encodeForHTTP initialIntegerOrNil keywords quoted sansPeriodSuffix |
|
909 |
splitInteger stemAndNumericSuffix substrings surroundedBySingleQuotes |
|
910 |
truncateWithElipsisTo: withBlanksTrimmed withFirstCharacterDownshifted |
|
911 |
withNoLineLongerThan: withSeparatorsCompacted withoutLeadingDigits |
|
912 |
withoutTrailingBlanks |
|
913 |
"displaying" "printing" |
|
914 |
"system primitives" |
|
915 |
#'compare:with:collated:' |
|
916 |
"Celeste" |
|
917 |
withCRs |
|
918 |
"internet" |
|
919 |
decodeMimeHeader decodeQuotedPrintable replaceHtmlCharRefs unescapePercents withInternetLineEndings withSqueakLineEndings withoutQuoting |
|
920 |
"testing" |
|
2108 | 921 |
isAllSeparators lastSpacePosition isBlank isEmpty |
1108 | 922 |
"paragraph support" |
923 |
indentationIfBlank: |
|
1109 | 924 |
"arithmetic" |
2107 | 925 |
"queries" |
2108 | 926 |
bitsPerCharacter contains8BitCharacters knownAsSymbol |
1109 | 927 |
"ST/X copying" |
928 |
paddedTo: paddedTo:with: centerPaddedTo: centerPaddedTo:with: |
|
929 |
decimalPaddedTo:and:at: |
|
930 |
leftPaddedTo: leftPaddedTo:with: |
|
931 |
chopTo: contractAtBeginningTo: contractAtEndTo: contractTo: |
|
932 |
"ST/X comparing" |
|
933 |
compareWith: sameCharacters: sameEmphasisAs: sameStringAndEmphasisAs: |
|
934 |
"ST/X searching" |
|
935 |
indexOfSeparator indexOfSeparatorStartingAt: |
|
936 |
lastIndexOfSeparator lastIndexOfSeparatorStartingAt: |
|
937 |
indexOfNonSeparatorStartingAt: |
|
2108 | 938 |
"ST/X printing" |
2109 | 939 |
sscanf: |
940 |
printf: |
|
1109 | 941 |
"ST/X converting" |
942 |
asUppercaseFirst |
|
943 |
asCollectionOfWords asCollectionOfLines |
|
944 |
asCollectionOfSubstringsSeparatedBy: asCollectionOfSubstringsSeparatedByAny: |
|
945 |
"Ansi" |
|
946 |
addLineDelimiters |
|
947 |
) do: [:sel | Approved add: sel]. |
|
1089 | 948 |
#(#'byteAt:put:' translateToLowercase match:) do: [:sel | AddAndRemove add: sel]. |
949 |
||
950 |
"Symbol" |
|
1108 | 951 |
#( |
952 |
"in class, private" |
|
953 |
hasInterned:ifTrue: |
|
954 |
"access" |
|
955 |
morePossibleSelectorsFor: possibleSelectorsFor: selectorsContaining: #'thatStarts:skipping:' |
|
956 |
"accessing" "comparing" "copying" "converting" "printing" |
|
957 |
"testing" |
|
958 |
isInfix isKeyword isPvtSelector isUnary) do: [:sel | Approved add: sel]. |
|
1089 | 959 |
|
960 |
"Array" |
|
1108 | 961 |
#( |
962 |
"comparing" |
|
963 |
"converting" |
|
964 |
evalStrings |
|
965 |
"printing" "private" |
|
966 |
hasLiteralSuchThat:) do: [:sel | Approved add: sel]. |
|
1089 | 967 |
|
968 |
"Array2D" |
|
1108 | 969 |
#( |
970 |
"access" |
|
971 |
#'at:at:' atCol: #'atCol:put:' atRow: extent #'extent:fromArray:' height width #'width:height:type:' |
|
972 |
) do: [:sel | Approved add: sel]. |
|
1089 | 973 |
#(#'at:at:add:' #'at:at:put:' #'atRow:put:' ) do: [:sel | AddAndRemove add: sel]. |
974 |
||
975 |
"ByteArray" |
|
1108 | 976 |
#( |
977 |
"accessing" |
|
978 |
doubleWordAt: wordAt: |
|
979 |
"platform independent access" |
|
980 |
#'longAt:bigEndian:' #'shortAt:bigEndian:' #'unsignedLongAt:bigEndian:' #'unsignedShortAt:bigEndian:' |
|
981 |
"converting") do: [:sel | Approved add: sel]. |
|
1089 | 982 |
#(#'doubleWordAt:put:' #'wordAt:put:' #'longAt:put:bigEndian:' #'shortAt:put:bigEndian:' #'unsignedLongAt:put:bigEndian:' #'unsignedShortAt:put:bigEndian:' |
983 |
) do: [:sel | AddAndRemove add: sel]. |
|
984 |
||
985 |
"FloatArray" "Dont know what happens when prims not here" |
|
1108 | 986 |
false ifTrue: [#( |
987 |
"accessing" |
|
988 |
"arithmetic" |
|
989 |
*= += -= /= |
|
990 |
"comparing" |
|
991 |
"primitives-plugin" |
|
992 |
primAddArray: primAddScalar: primDivArray: primDivScalar: primMulArray: primMulScalar: primSubArray: primSubScalar: |
|
993 |
"primitives-translated" |
|
994 |
#'primAddArray:withArray:from:to:' #'primMulArray:withArray:from:to:' #'primSubArray:withArray:from:to:' |
|
995 |
"converting" "private" "user interface" |
|
996 |
) do: [:sel | Approved add: sel]. |
|
1089 | 997 |
]. |
998 |
||
999 |
"IntegerArray, WordArray" |
|
1000 |
"RunArray" |
|
1108 | 1001 |
#( |
1002 |
"in class, instance creation" |
|
1003 |
#'runs:values:' scanFrom: |
|
1004 |
"accessing" |
|
1005 |
runLengthAt: |
|
1006 |
"adding" "copying" |
|
1007 |
"private" |
|
1008 |
runs values |
|
1009 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1010 |
#(coalesce #'addLast:times:' #'repeatLast:ifEmpty:' repeatLastIfEmpty: |
1011 |
) do: [:sel | AddAndRemove add: sel]. |
|
1012 |
||
1013 |
"Stream -- many operations change its state" |
|
1108 | 1014 |
#( |
1015 |
"testing" |
|
1016 |
atEnd) do: [:sel | Approved add: sel]. |
|
1017 |
#( |
|
1018 |
"accessing" |
|
1019 |
next: nextMatchAll: nextMatchFor: upToEnd |
|
1020 |
#'next:put:' nextPut: nextPutAll: |
|
1021 |
"printing" print: printHtml: |
|
1089 | 1022 |
) do: [:sel | AddAndRemove add: sel]. |
1023 |
||
1024 |
"PositionableStream" |
|
1108 | 1025 |
#( |
1026 |
"accessing" |
|
1027 |
contentsOfEntireFile originalContents peek peekFor: "testing" |
|
1028 |
"positioning" |
|
1029 |
position |
|
1030 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1031 |
#(nextDelimited: nextLine upTo: position: reset resetContents setToEnd skip: skipTo: upToAll: ) do: [:sel | AddAndRemove add: sel]. |
1108 | 1032 |
"Because it is so difficult to test the result of an operation on a Stream |
1033 |
(you have to supply another Stream in the same state), |
|
1034 |
we don't support Streams beyond the basics. |
|
1035 |
We want to find the messages that convert Streams to other things." |
|
1089 | 1036 |
|
1037 |
"ReadWriteStream" |
|
1108 | 1038 |
#( |
1039 |
"file status" |
|
1040 |
closed) do: [:sel | Approved add: sel]. |
|
1041 |
#( |
|
1042 |
"accessing" |
|
1043 |
next: on: ) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 1044 |
|
1045 |
"WriteStream" |
|
1108 | 1046 |
#( |
1047 |
"in class, instance creation" |
|
1048 |
on:from:to: with: with:from:to: |
|
1089 | 1049 |
) do: [:sel | Approved add: sel]. |
1108 | 1050 |
#( |
1051 |
"positioning" |
|
1052 |
resetToStart |
|
1053 |
"character writing" |
|
1054 |
crtab crtab:) do: [:sel | AddAndRemove add: sel]. |
|
1089 | 1055 |
|
1056 |
"LookupKey, Association, Link" |
|
1108 | 1057 |
#( |
1058 |
"accessing" |
|
1059 |
key nextLink) do: [:sel | Approved add: sel]. |
|
1089 | 1060 |
#(key: #'key:value:' nextLink:) do: [:sel | AddAndRemove add: sel]. |
1061 |
||
1062 |
"Point" |
|
1108 | 1063 |
#( |
1064 |
"in class, instance creation" |
|
1065 |
#'r:degrees:' #'x:y:' |
|
1066 |
"accessing" |
|
1067 |
x y |
|
1068 |
"comparing" "arithmetic" "truncation and round off" |
|
1069 |
"polar coordinates" |
|
1070 |
degrees r theta |
|
1071 |
"point functions" |
|
1072 |
bearingToPoint: crossProduct: dist: dotProduct: eightNeighbors #'flipBy:centerAt:' fourNeighbors grid: |
|
1073 |
#'nearestPointAlongLineFrom:to:' #'nearestPointOnLineFrom:to:' |
|
1074 |
normal normalized octantOf: |
|
1075 |
#'onLineFrom:to:' #'onLineFrom:to:within:' |
|
1076 |
quadrantOf: #'rotateBy:centerAt:' transposed unitVector |
|
1077 |
"converting" |
|
1078 |
asFloatPoint asIntegerPoint corner: extent: rect: |
|
1079 |
"transforming" |
|
1080 |
adhereTo: #'rotateBy:about:' scaleBy: #'scaleFrom:to:' translateBy: "copying" |
|
1081 |
"interpolating" |
|
1082 |
#'interpolateTo:at:' |
|
1083 |
) do: [:sel | Approved add: sel]. |
|
1089 | 1084 |
|
1085 |
"Rectangle" |
|
1086 |
#("in class, instance creation" #'center:extent:' encompassing: #'left:right:top:bottom:' |
|
1087 |
merging: #'origin:corner:' #'origin:extent:' |
|
1108 | 1088 |
"accessing" |
1089 |
area bottom bottomCenter bottomLeft bottomRight boundingBox center corner corners innerCorners |
|
1090 |
left leftCenter origin right rightCenter top topCenter topLeft topRight |
|
1091 |
"comparing" |
|
1092 |
"rectangle functions" |
|
1093 |
#'adjustTo:along:' amountToTranslateWithin: areasOutside: #'bordersOn:along:' encompass: |
|
1094 |
expandBy: extendBy: #'forPoint:closestSideDistLen:' |
|
1095 |
insetBy: #'insetOriginBy:cornerBy:' intersect: |
|
1096 |
merge: pointNearestTo: quickMerge: #'rectanglesAt:height:' |
|
1097 |
sideNearestTo: translatedToBeWithin: |
|
1098 |
withBottom: withHeight: withLeft: withRight: #'withSide:setTo:' withTop: withWidth: |
|
1099 |
"testing" |
|
1100 |
containsPoint: containsRect: hasPositiveExtent intersects: isTall isWide |
|
1101 |
"truncation and round off" |
|
1102 |
"transforming" |
|
1103 |
#'align:with:' centeredBeneath: newRectFrom: squishedWithin: "copying" |
|
1089 | 1104 |
) do: [:sel | Approved add: sel]. |
1105 |
||
1106 |
"Color" |
|
1108 | 1107 |
#( |
1108 |
"in class, instance creation" |
|
1109 |
colorFrom: #'colorFromPixelValue:depth:' fromRgbTriplet: gray: #'h:s:v:' #'r:g:b:' #'r:g:b:alpha:' #'r:g:b:range:' |
|
1110 |
"ST/X in class, instance creation" |
|
1111 |
colorNamed: |
|
1112 |
"named colors" |
|
1113 |
black blue brown cyan darkGray gray green lightBlue lightBrown lightCyan lightGray lightGreen lightMagenta lightOrange lightRed lightYellow |
|
1114 |
magenta orange red transparent veryDarkGray veryLightGray veryVeryDarkGray veryVeryLightGray white yellow |
|
1115 |
"other" |
|
1116 |
colorNames indexedColors pixelScreenForDepth: quickHighLight: |
|
1117 |
"access" |
|
1118 |
alpha blue brightness green hue luminance red saturation |
|
1119 |
"equality" |
|
1120 |
"queries" |
|
1121 |
isBitmapFill isBlack isGray isSolidFill isTranslucent isTranslucentColor |
|
1122 |
"transformations" |
|
1123 |
alpha: dansDarker darker lighter #'mixed:with:' muchLighter slightlyDarker slightlyLighter veryMuchLighter #'alphaMixed:with:' |
|
1124 |
"groups of shades" |
|
1125 |
darkShades: lightShades: #'mix:shades:' wheel: |
|
1126 |
"printing" |
|
1127 |
shortPrintString |
|
1128 |
"other" |
|
1129 |
colorForInsets rgbTriplet |
|
1130 |
"conversions" |
|
1131 |
asB3DColor asColor balancedPatternForDepth: bitPatternForDepth: closestPixelValue1 closestPixelValue2 closestPixelValue4 closestPixelValue8 dominantColor |
|
1132 |
halfTonePattern1 halfTonePattern2 indexInMap: pixelValueForDepth: #'pixelWordFor:filledWith:' pixelWordForDepth: scaledPixelValue32 |
|
1133 |
"private" |
|
1109 | 1134 |
privateAlpha privateBlue privateGreen privateRGB privateRed |
1135 |
"copying" |
|
1108 | 1136 |
"ST/X access" |
1109 | 1137 |
redByte greenByte blueByte alphaByte rgbValue almostSameAs: |
1089 | 1138 |
) do: [:sel | Approved add: sel]. |
1139 |
||
1140 |
" For each selector that requires a block argument, add (selector argNum) |
|
1141 |
to the set Blocks." |
|
1108 | 1142 |
"ourClasses _ #(Object Boolean True False UndefinedObject Behavior ClassDescription Class Metaclass MethodContext BlockContext Message Magnitude Date Time Number Integer |
1143 |
SmallInteger LargeNegativeInteger LargePositiveInteger Float Fraction Random Collection SequenceableCollection ArrayedCollection Bag Set |
|
1144 |
Dictionary IdentityDictionary IdentitySet LinkedList Interval MappedCollection OrderedCollection SortedCollection Character String Symbol Array |
|
1145 |
Array2D ByteArray FloatArray IntegerArray WordArray RunArray Stream PositionableStream ReadWriteStream WriteStream LookupKey Association Link Point Rectangle Color). |
|
1089 | 1146 |
ourClasses do: [:clsName | cls _ Smalltalk at: clsName. |
1147 |
(cls selectors) do: [:aSel | |
|
1148 |
((Approved includes: aSel) or: [AddAndRemove includes: aSel]) ifTrue: [ |
|
1149 |
(cls formalParametersAt: aSel) withIndexDo: [:tName :ind | |
|
1150 |
(tName endsWith: 'Block') ifTrue: [ |
|
1151 |
Blocks add: (Array with: aSel with: ind)]]]]]. |
|
1152 |
" |
|
1109 | 1153 |
#( |
1154 |
(timesRepeat: 1 ) (indexOf:ifAbsent: 2 ) (pairsCollect: 1 ) (#'mergeSortFrom:to:by:' 3 ) |
|
1155 |
(#'ifNotNil:ifNil:' 1 ) (#'ifNotNil:ifNil:' 2 ) (ifNil: 1 ) (#'at:ifAbsent:' 2 ) |
|
1156 |
(#'ifNil:ifNotNil:' 1 ) (#'ifNil:ifNotNil:' 2 ) (ifNotNil: 1 ) (#'at:modify:' 2 ) |
|
1157 |
(#'identityIndexOf:ifAbsent:' 2 ) (sort: 1 ) (sortBlock: 1 ) |
|
1158 |
(detectMax: 1 ) (repeatLastIfEmpty: 1 ) (#'allSubclassesWithLevelDo:startingLevel:' 1 ) |
|
1159 |
(#'keyAtValue:ifAbsent:' 2 ) (in: 1 ) |
|
1160 |
(ifTrue: 1 ) (or: 1 ) (select: 1 ) (inject:into: 2 ) (#'ifKindOf:thenDo:' 2 ) |
|
1161 |
(#'forPoint:closestSideDistLen:' 2 ) (#'value:ifError:' 2 ) (selectorsDo: 1 ) |
|
1162 |
(removeAllSuchThat: 1 ) (#'keyAtIdentityValue:ifAbsent:' 2 ) (detectMin: 1 ) |
|
1163 |
(#'detect:ifNone:' 1 ) (#'ifTrue:ifFalse:' 1 ) (#'ifTrue:ifFalse:' 2 ) |
|
1164 |
(#'detect:ifNone:' 2 ) (hasLiteralSuchThat: 1 ) (#'indexOfAnyOf:ifAbsent:' 2 ) |
|
1165 |
(reject: 1 ) (newRectFrom: 1 ) (#'removeKey:ifAbsent:' 2 ) (#'at:ifPresent:' 2 ) |
|
1166 |
(#'associationAt:ifAbsent:' 2 ) (withIndexCollect: 1 ) (#'repeatLast:ifEmpty:' 2 ) |
|
1167 |
(findLast: 1 ) (#'indexOf:startingAt:ifAbsent:' 3 ) (#'remove:ifAbsent:' 2 ) |
|
1168 |
(#'ifFalse:ifTrue:' 1 ) (#'ifFalse:ifTrue:' 2 ) (#'caseOf:otherwise:' 2 ) (count: 1 ) (collect: 1 ) (sortBy: 1 ) (and: 1 ) (asSortedCollection: 1 ) |
|
1169 |
(#'with:collect:' 2 ) (#'sourceCodeAt:ifAbsent:' 2 ) (detect: 1 ) (#'scopeHas:ifTrue:' 2 ) (collectWithIndex: 1 ) (#'compiledMethodAt:ifAbsent:' 2 ) |
|
1170 |
(bindWithTemp: 1 ) (detectSum: 1 ) (#'indexOfSubCollection:startingAt:ifAbsent:' 3 ) (findFirst: 1 ) (#'sourceMethodAt:ifAbsent:' 2 ) (#'collect:thenSelect:' 1 ) |
|
1171 |
(#'collect:thenSelect:' 2 ) (#'select:thenCollect:' 1 ) (#'select:thenCollect:' 2 ) (ifFalse: 1 ) (#'indexOfAnyOf:startingAt:ifAbsent:' 3 ) (#'indentationIfBlank:' 1 ) |
|
1108 | 1172 |
) do: [:anArray | |
1173 |
Blocks add: anArray]. |
|
1089 | 1174 |
|
1491 | 1175 |
#( |
1176 |
(ifFalse: 1 ) |
|
1177 |
(ifTrue: 1 ) |
|
1178 |
(#'ifFalse:ifTrue:' 1 ) (#'ifFalse:ifTrue:' 2 ) |
|
1179 |
(#'ifTrue:ifFalse:' 1 ) (#'ifTrue:ifFalse:' 2 ) |
|
1180 |
) do: [:anArray | |
|
1181 |
BlocksOptional add: anArray]. |
|
1089 | 1182 |
|
1183 |
" |
|
1184 |
MethodFinder new initialize. |
|
1185 |
MethodFinder new organizationFiltered: TranslucentColor class |
|
1186 |
" |
|
1187 |
"Do not forget class messages for each of these classes" |
|
1108 | 1188 |
|
1109 | 1189 |
"Modified: / 13.11.2001 / 19:28:41 / cg" |
1089 | 1190 |
! |
1191 |
||
1192 |
load: dataWithAnswers |
|
1193 |
"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." |
|
1194 |
" (MethodFinder new) load: #( (4 3) 7 (-10 5) -5 (-3 11) 8); |
|
1195 |
findMessage " |
|
1196 |
||
1197 |
dataWithAnswers ifNotNil: [ |
|
1198 |
data _ Array new: dataWithAnswers size // 2. |
|
1199 |
1 to: data size do: [:ii | data at: ii put: (dataWithAnswers at: ii*2-1)]. |
|
1200 |
answers _ Array new: data size. |
|
1201 |
1 to: answers size do: [:ii | answers at: ii put: (dataWithAnswers at: ii*2)]]. |
|
1202 |
data do: [:list | |
|
1203 |
(list isKindOf: SequenceableCollection) ifFalse: [ |
|
1204 |
^ self warn: 'first and third items are not Arrays']. |
|
1205 |
]. |
|
1206 |
argMap _ (1 to: data first size) asArray. |
|
1207 |
data do: [:list | list size = argMap size ifFalse: [ |
|
1208 |
self warn: 'data arrays must all be the same size']]. |
|
1209 |
argMap size > 4 ifTrue: [self warn: 'No more than a receiver and |
|
1210 |
three arguments allowed']. |
|
1211 |
"Really only test receiver and three args." |
|
1212 |
thisData _ data copy. |
|
1213 |
mapStage _ mapList _ nil. |
|
1214 |
! |
|
1215 |
||
1216 |
noteDangerous |
|
1104 | 1217 |
"Remember the methods with really bad side effects." |
1089 | 1218 |
|
1104 | 1219 |
Dangerous _ Set new. |
1089 | 1220 |
"Object accessing, testing, copying, dependent access, macpal, flagging" |
1104 | 1221 |
#(addInstanceVarNamed:withValue: haltIfNil copyAddedStateFrom: veryDeepCopy veryDeepCopyWith: veryDeepFixupWith: veryDeepInner: addDependent: evaluate:wheneverChangeIn: codeStrippedOut: playSoundNamed: isThisEverCalled isThisEverCalled: logEntry logExecution logExit) |
1222 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1223 |
|
1224 |
"Object error handling" |
|
1104 | 1225 |
#(cannotInterpret: caseError confirm: confirm:orCancel: doesNotUnderstand: error: halt halt: notify: notify:at: primitiveFailed shouldNotImplement subclassResponsibility tryToDefineVariableAccess:) |
1226 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1227 |
|
1228 |
"Object user interface" |
|
1104 | 1229 |
#(basicInspect beep inform: inspect inspectWithLabel: notYetImplemented inspectElement ) |
1230 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1231 |
|
1232 |
"Object system primitives" |
|
2229 | 1233 |
#(become: becomeForward: becomeSameAs: changeClassTo: instVarAt:put: instVarNamed:put: nextInstance nextObject rootStubInImageSegment: someObject tryPrimitive:withArgs:) |
1104 | 1234 |
do: [:sel | Dangerous add: sel]. |
1089 | 1235 |
|
1236 |
"Object private" |
|
1104 | 1237 |
#(errorImproperStore errorNonIntegerIndex errorNotIndexable errorSubscriptBounds: mustBeBoolean primitiveError: species storeAt:inTempFrame:) |
1238 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1239 |
|
1240 |
"Object, translation support" |
|
1104 | 1241 |
#(cCode: cCode:inSmalltalk: cCoerce:to: export: inline: returnTypeC: sharedCodeNamed:inCase: var:declareC:) |
1242 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1243 |
|
1244 |
"Object, objects from disk, finalization. And UndefinedObject" |
|
1104 | 1245 |
#(comeFullyUpOnReload: objectForDataStream: readDataFrom:size: rehash saveOnFile storeDataOn: actAsExecutor executor finalize retryWithGC:until: suspend) |
1246 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1247 |
|
1248 |
"No Restrictions: Boolean, False, True, " |
|
1249 |
||
1250 |
"Morph" |
|
1104 | 1251 |
#(fullCopy copyRecordingIn:) |
1252 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1253 |
|
1254 |
"Behavior" |
|
1104 | 1255 |
#(obsolete confirmRemovalOf: copyOfMethodDictionary literalScannedAs:notifying: storeLiteral:on: addSubclass: removeSubclass: superclass: |
1089 | 1256 |
"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: |
1257 |
"user interface" allCallsOn: browse browseAllAccessesTo: browseAllCallsOn: browseAllStoresInto: "too slow->" crossReference removeUninstantiatedSubclassesSilently "too slow->" unreferencedInstanceVariables |
|
1258 |
"private" becomeCompact becomeUncompact flushCache format:variable:words:pointers: format:variable:words:pointers:weak: printSubclassesOn:level: removeSelectorSimply:) |
|
1104 | 1259 |
do: [:sel | Dangerous add: sel]. |
1089 | 1260 |
|
1261 |
"Others " |
|
1104 | 1262 |
#("no tangible result" do: associationsDo: |
1089 | 1263 |
"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 | 1264 |
do: [:sel | Dangerous add: sel]. |
1089 | 1265 |
|
1266 |
||
1104 | 1267 |
#( fileOutPrototype addSpareFields makeFileOutFile ) |
1268 |
do: [:sel | Dangerous add: sel]. |
|
1269 |
#(recompile:from: recompileAllFrom: recompileChanges asPrototypeWithFields: asPrototype addInstanceVarNamed:withValue: addInstanceVariable addClassVarName: removeClassVarName: findOrAddClassVarName: tryToDefineVariableAccess: instanceVariableNames: ) |
|
1270 |
do: [:sel | Dangerous add: sel]. |
|
1089 | 1271 |
! |
1272 |
||
1273 |
organizationFiltered: aClass |
|
1104 | 1274 |
"Return the organization of the class with all selectors defined in superclasses removed. (except those in Object)" |
1089 | 1275 |
|
1104 | 1276 |
| org str | |
1277 |
org _ aClass organization deepCopy. |
|
1278 |
Dangerous do: [:sel | |
|
1279 |
org removeElement: sel]. |
|
1280 |
Approved do: [:sel | |
|
1281 |
org removeElement: sel]. |
|
1282 |
AddAndRemove do: [:sel | |
|
1283 |
org removeElement: sel]. |
|
1284 |
str _ org printString copyWithout: $(. |
|
1285 |
str _ '(', (str copyWithout: $) ). |
|
1286 |
str _ str replaceAll: $' with: $". |
|
1287 |
^ str |
|
1089 | 1288 |
! |
1289 |
||
1290 |
test2: anArray |
|
1104 | 1291 |
"look for bad association" |
1089 | 1292 |
|
1104 | 1293 |
anArray do: [:sub | |
1294 |
sub class == Association ifTrue: [ |
|
1295 |
(#('true' '$a' '2' 'false') includes: sub value printString) ifFalse: [ |
|
1296 |
self error: 'bad assn']. |
|
1297 |
(#('3' '5.6' 'x' '''abcd''') includes: sub key printString) ifFalse: [ |
|
1298 |
self error: 'bad assn']. |
|
1089 | 1299 |
|
1104 | 1300 |
" sub value class == Association ifTrue: [ |
1301 |
self error: 'bad assn']. |
|
1302 |
(sub value isKindOf: Class) ifTrue: [ |
|
1303 |
self error: 'class in assn']. |
|
3021 | 1304 |
sub value class == Symbol ifTrue: [sub value codePoint = 204 '$' ifTrue: [ |
1104 | 1305 |
self error: 'Write into char']]. |
3021 | 1306 |
sub value == $ ifTrue: [ |
1104 | 1307 |
self error: 'Write into char'] |
1308 |
"]. |
|
1309 |
sub class == Array ifTrue: [ |
|
1310 |
sub do: [:element | |
|
2058
c71d2ac1fbfe
asciiValue obsoleted by codePoint
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
1311 |
element class == String ifTrue: [element first codePoint < 32 ifTrue: [ |
1104 | 1312 |
self error: 'store into string in data']]. |
1313 |
element class == Association ifTrue: [ |
|
1314 |
element value class == Association ifTrue: [ |
|
1315 |
self error: 'bad assn']]]]. |
|
1316 |
sub class == Date ifTrue: [sub year isInteger ifFalse: [ |
|
1317 |
self error: 'stored into input date!!!!']]. |
|
1318 |
sub class == Dictionary ifTrue: [ |
|
1319 |
sub size > 0 ifTrue: [ |
|
1320 |
self error: 'store into dictionary']]. |
|
1321 |
sub class == OrderedCollection ifTrue: [ |
|
1322 |
sub size > 4 ifTrue: [ |
|
1323 |
self error: 'store into OC']]. |
|
1324 |
]. |
|
1089 | 1325 |
! |
1326 |
||
1327 |
test3 |
|
1104 | 1328 |
"find the modification of the caracter table" |
1089 | 1329 |
|
2058
c71d2ac1fbfe
asciiValue obsoleted by codePoint
Claus Gittinger <cg@exept.de>
parents:
2054
diff
changeset
|
1330 |
(#x at: 1) codePoint = 120 ifFalse: [self error: 'Character table mod']. |
1089 | 1331 |
! ! |
1332 |
||
1333 |
!MethodFinder methodsFor:'search'! |
|
1334 |
||
1335 |
exceptions |
|
1104 | 1336 |
"Handle some very slippery selectors. |
1337 |
asSymbol -- want to be able to produce it, but do not want to make every string submitted into a Symbol!!" |
|
1089 | 1338 |
|
1104 | 1339 |
| aSel | |
1340 |
answers first class == Symbol ifFalse: [^ self]. |
|
1341 |
thisData first first class == String ifFalse: [^ self]. |
|
1342 |
aSel _ #asSymbol. |
|
1343 |
(self testPerfect: aSel) ifTrue: [ |
|
1344 |
selector add: aSel. |
|
1345 |
expressions add: (String streamContents: [:strm | |
|
1346 |
strm nextPutAll: 'data', argMap first printString. |
|
1347 |
aSel keywords doWithIndex: [:key :ind | |
|
1348 |
strm nextPutAll: ' ',key. |
|
1349 |
(key last == $:) | (key first isLetter not) |
|
1350 |
ifTrue: [strm nextPutAll: ' data', |
|
1351 |
(argMap at: ind+1) printString]]])]. |
|
1089 | 1352 |
! |
1353 |
||
1354 |
findMessage |
|
1355 |
"Control the search." |
|
1356 |
||
1357 |
data do: [:alist | |
|
1358 |
(alist isKindOf: SequenceableCollection) ifFalse: [ |
|
1359 |
^ OrderedCollection with: 'first and third items are not Arrays']]. |
|
1360 |
||
1491 | 1361 |
true "Approved isNil" ifTrue: [self initialize]. "Sets of allowed selectors" |
1089 | 1362 |
expressions _ OrderedCollection new. |
1363 |
self search: true. "multi" |
|
1364 |
expressions isEmpty ifTrue: [^ OrderedCollection with: 'no single method does that function']. |
|
1365 |
expressions class = String ifTrue: [^ OrderedCollection with: expressions]. |
|
1366 |
^ expressions |
|
1367 |
! |
|
1368 |
||
1369 |
insertConstants |
|
1104 | 1370 |
"see if one of several known expressions will do it. C is the constant we discover here." |
1371 |
"C data1+C data1*C data1//C (data1*C1 + C2) (data1 = C) (data1 ~= C) (data1 <= C) (data1 >= C) |
|
1089 | 1372 |
(data1 mod C)" |
1373 |
||
1104 | 1374 |
thisData size >= 2 ifFalse: [^ self]. "need 2 examples" |
1375 |
(thisData at: 1) size = 1 ifFalse: [^ self]. "only one arg, data1" |
|
1089 | 1376 |
|
1104 | 1377 |
self const ifTrue: [^ self]. |
1491 | 1378 |
"/ self constEquiv ifTrue: [^ self]. " == ~= " |
1104 | 1379 |
self constLessThan ifTrue: [^ self]. " <= and >= " |
1089 | 1380 |
|
1104 | 1381 |
self allNumbers ifFalse: [^ self]. |
1382 |
self constMod ifTrue: [^ self]. |
|
1383 |
self constPlus ifTrue: [^ self]. |
|
1384 |
self constMult ifTrue: [^ self]. |
|
1385 |
self constDiv ifTrue: [^ self]. |
|
1386 |
self constLinear ifTrue: [^ self]. |
|
1089 | 1387 |
! |
1388 |
||
1389 |
search: multi |
|
1390 |
"if Multi is true, collect all selectors that work." |
|
1391 |
| old | |
|
1392 |
selector:=OrderedCollection new. "list of them" |
|
1393 |
||
1394 |
" old _ Preferences autoAccessors. |
|
1395 |
Preferences disableGently: #autoAccessors. " |
|
1396 |
Smalltalk isSmalltalkX ifTrue:[old:=false]. |
|
1397 |
||
1398 |
self simpleSearch. |
|
1399 |
multi not & (selector isEmpty not) ifTrue: |
|
1400 |
["old ifTrue: [Preferences enableGently: #autoAccessors]." |
|
1401 |
^ selector]. |
|
1402 |
||
1403 |
[self permuteArgs] whileTrue: |
|
1404 |
[self simpleSearch. |
|
1405 |
multi not & (selector isEmpty not) ifTrue: |
|
1406 |
["old ifTrue: [Preferences enableGently: #autoAccessors]." |
|
1407 |
^ selector]]. |
|
1408 |
||
1409 |
self insertConstants. |
|
1410 |
" old ifTrue: [Preferences enableGently: #autoAccessors]. " |
|
1491 | 1411 |
|
1089 | 1412 |
"/ (selector isEmpty not) ifTrue: [^ selector]]. " expression is the answer, not a selector" |
1413 |
^ #() |
|
1414 |
! |
|
1415 |
||
1416 |
searchForOne |
|
1104 | 1417 |
"Look for and return just one answer" |
1089 | 1418 |
|
1104 | 1419 |
expressions _ OrderedCollection new. |
1420 |
self search: false. "non-multi" |
|
1421 |
^ expressions |
|
1422 |
||
1089 | 1423 |
! |
1424 |
||
1425 |
simpleSearch |
|
1426 |
"Run through first arg's class' selectors, looking for one that works." |
|
1427 |
||
1428 |
| class supers listOfLists | |
|
1429 |
self exceptions. |
|
1430 |
class:=thisData first first class. |
|
1431 |
"Cache the selectors for the receiver class" |
|
1432 |
(class == cachedClass and: [cachedArgNum = ((argMap size) - 1)]) |
|
1433 |
ifTrue: [listOfLists:=cachedSelectorLists] |
|
1434 |
ifFalse: [supers:=class withAllSuperclasses. |
|
1435 |
listOfLists:=OrderedCollection new. |
|
1092 | 1436 |
supers do: [:cls | |
1089 | 1437 |
listOfLists add: (cls selectorsWithArgs: (argMap size) - 1)]. |
1438 |
cachedClass:=class. |
|
1439 |
cachedArgNum:=(argMap size) - 1. |
|
1440 |
cachedSelectorLists:=listOfLists]. |
|
1441 |
"/ self halt. |
|
1442 |
listOfLists do: [:selectorList | |
|
1443 |
selectorList do: [:aSel | |
|
1444 |
(selector includes: aSel) ifFalse: [ |
|
1445 |
((Approved includes: aSel) or: [AddAndRemove includes: aSel]) ifTrue: [ |
|
1446 |
(self testPerfect: aSel) ifTrue: [ |
|
1447 |
selector add: aSel. |
|
1448 |
expressions add: (String streamContents: [:strm | |
|
1449 |
strm nextPutAll: 'data', argMap first printString. |
|
1450 |
aSel keywords doWithIndex: [:key :ind | |
|
1451 |
strm nextPutAll: ' ',key. |
|
1452 |
(key last == $:) | (key first isLetter not) |
|
1453 |
ifTrue: [strm nextPutAll: ' data', |
|
1454 |
(argMap at: ind+1) printString]]]) |
|
1455 |
]]]]]. |
|
1456 |
! |
|
1457 |
||
1458 |
testPerfect: aSelector |
|
2059
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1459 |
"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
|
1460 |
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
|
1461 |
Survive errors. later cache arg lists." |
1089 | 1462 |
|
1463 |
| sz argList val rec activeSel perform argIsBlock expectedAnswer| |
|
1464 |
"Transcript cr; show: aSelector. debug" |
|
1465 |
perform:=aSelector beginsWith: 'perform:'. |
|
1466 |
sz:=argMap size. |
|
1467 |
1 to: thisData size do: [:ii | "each example set of args" |
|
1468 |
argList:=(thisData at: ii) copyFrom: 2 to: sz. |
|
1469 |
perform |
|
1470 |
ifFalse: [activeSel:=aSelector] |
|
1471 |
ifTrue: [activeSel:=argList first. "what will be performed" |
|
1472 |
((Approved includes: activeSel) or: [AddAndRemove includes: activeSel]) |
|
1473 |
ifFalse: [^ false]. "not approved" |
|
1474 |
aSelector == #perform:withArguments: |
|
1475 |
ifTrue: [activeSel numArgs = (argList at: 2) basicSize "avoid error" |
|
1476 |
ifFalse: [^ false]] |
|
1477 |
ifFalse: [activeSel numArgs = (aSelector numArgs - 1) |
|
1478 |
ifFalse: [^ false]]]. |
|
1479 |
||
1480 |
||
1481 |
1 to: sz do: [:num | |
|
1482 |
(Blocks includes: (Array with: activeSel with: num)) ifTrue: [ |
|
1483 |
Smalltalk isSmalltalkX ifTrue:[ |
|
1484 |
argIsBlock := (argList at: num) isBlock |
|
1485 |
] ifFalse:[ |
|
1486 |
argIsBlock := (argList at: num) class == BlockContext |
|
1487 |
]. |
|
1491 | 1488 |
argIsBlock ifFalse: [ |
1489 |
(BlocksOptional includes: (Array with: activeSel with: num)) ifFalse: [ |
|
1490 |
^ false |
|
1491 |
] |
|
1492 |
]]]. |
|
1089 | 1493 |
" (activeSel = #capitalized) ifTrue:[self halt.]. " " used to test " |
1494 |
||
1495 |
rec:=(AddAndRemove includes: activeSel) |
|
1496 |
ifTrue: [(thisData at: ii) first class == Symbol ifTrue: [^ false]. |
|
1497 |
"vulnerable to modification" |
|
1498 |
(thisData at: ii) first copyTwoLevel] "protect from damage" |
|
1499 |
ifFalse: [[(thisData at: ii) first]ifError:[self halt.]] . |
|
1500 |
||
1501 |
expectedAnswer := (answers at: ii). |
|
1502 |
val:= [ rec copy perform: aSelector withArguments: argList] |
|
1503 |
ifError: [:aSignal| |
|
1109 | 1504 |
"/ Transcript showCR:aSignal description. |
1089 | 1505 |
"self test3." |
1506 |
"self test2: (thisData at: ii)." |
|
1507 |
^ false]. |
|
1508 |
"self test3." |
|
1509 |
"self test2: (thisData at: ii)." |
|
1510 |
(expectedAnswer isKindOf: Number) |
|
2059
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1511 |
ifFalse:[ |
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1512 |
expectedAnswer isArray ifTrue:[ |
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1513 |
(val isCollection and:[val isString not]) ifTrue:[ |
2060 | 1514 |
([val asArray = expectedAnswer] ifError:[false]) ifTrue:[^ true]. |
2059
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1515 |
]. |
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1516 |
]. |
2061 | 1517 |
"/ would like to remember 'almost' same, and present in separate list. |
1518 |
"/ expectedAnswer isString ifTrue:[ |
|
1519 |
"/ (val isString) ifTrue:[ |
|
1520 |
"/ ([val sameAs: expectedAnswer] ifError:[false]) ifTrue:[self halt. ^ true]. |
|
1521 |
"/ ]. |
|
1522 |
"/ ]. |
|
2059
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1523 |
([ (expectedAnswer = val) ] ifError:[ false]) ifFalse: [^ false] |
9e0592033093
allow search for collection results
Claus Gittinger <cg@exept.de>
parents:
2058
diff
changeset
|
1524 |
] |
1089 | 1525 |
ifTrue:[ |
1526 |
(expectedAnswer closeTo: val) ifFalse: [^ false]]. |
|
1527 |
]. |
|
1528 |
^ true |
|
1109 | 1529 |
|
1530 |
"Modified: / 13.11.2001 / 19:08:39 / cg" |
|
2061 | 1531 |
! ! |
1532 |
||
1533 |
!MethodFinder methodsFor:'tests'! |
|
1089 | 1534 |
|
1535 |
verify |
|
1536 |
"Test a bunch of examples" |
|
1537 |
" MethodFinder new verify " |
|
1928 | 1538 |
Approved isNil ifTrue: [self initialize]. "Sets of allowed selectors" |
1089 | 1539 |
"/(MethodFinder new load: #( (0) 0 (30) 0.5 (45) 0.707106 (90) 1) |
1540 |
"/ ) searchForOne asArray = #('data1 degreeSin') ifFalse: [self error: 'should have found it']. "Squeak test" |
|
1491 | 1541 |
(MethodFinder new load: (Array with:(Array with:true with:[3] with:[4]) with:3 with:(Array with:false with:[0] with:[6]) with:6) |
1542 |
) searchForOne asArray = #('data1 ifTrue: data2 ifFalse: data3') ifFalse: [ |
|
1543 |
self error: 'should have found it']. |
|
1544 |
(MethodFinder new load: #(#(1) true #(2) false #(5) true #(10) false) |
|
1545 |
) searchForOne asArray = #('data1 odd' 'data1 isPrime') ifFalse: [self error: 'should have found it']. |
|
1089 | 1546 |
"will correct the date type of #true, and complain" |
1547 |
Smalltalk isSmalltalkX ifTrue:[ |
|
1491 | 1548 |
(MethodFinder new load: #((4 2) '2r100' (255 16) '16rFF' (14 8) '8r16') |
1089 | 1549 |
) searchForOne asArray = |
1550 |
#('data1 radixPrintStringRadix: data2' ) |
|
1551 |
ifFalse: [self error: 'should have found it']. |
|
1552 |
] ifFalse:[ |
|
1491 | 1553 |
(MethodFinder new load: #((4 2) '2r100' (255 16) '16rFF' (14 8) '8r16') |
1089 | 1554 |
) searchForOne asArray = |
1555 |
#('data1 radix: data2' 'data1 printStringBase: data2' 'data1 storeStringBase: data2') |
|
1556 |
ifFalse: [self error: 'should have found it']. |
|
1557 |
]. |
|
1558 |
"/(MethodFinder2 new load: #(#(3@4) 4 #(1@5) 5) |
|
1559 |
"/ ) searchForOne asArray = #('data1 y') ifFalse: [self error: 'should have found it']. |
|
1560 |
Smalltalk isSmalltalkX ifTrue:[ |
|
1491 | 1561 |
(MethodFinder new load: #(('abcd') $a ('TedK') $T) |
1089 | 1562 |
) searchForOne asArray = #('data1 first' 'data1 removeFirst' 'data1 anyOne') |
1563 |
ifFalse: [self error: 'should have found it']. |
|
1564 |
] ifFalse:[ |
|
1491 | 1565 |
(MethodFinder new load: #(('abcd') $a ('TedK') $T) |
1089 | 1566 |
) searchForOne asArray = #('data1 asCharacter' 'data1 first' 'data1 anyOne') |
1567 |
ifFalse: [self error: 'should have found it']. |
|
1568 |
]. |
|
1491 | 1569 |
(((MethodFinder new load: #(('abcd' 1) $a ('Ted ' 3) $d ) |
1089 | 1570 |
) searchForOne asArray) includesAll: #('data1 at: data2' 'data1 atPin: data2' 'data1 atWrap: data2')) |
1571 |
ifFalse: [self error: 'should have found it']. |
|
1491 | 1572 |
(MethodFinder new load: #(((12 4 8)) 24 ((1 3 6)) 10 ) |
1089 | 1573 |
) searchForOne asArray= #('data1 sum') ifFalse: [self error: 'should have found it']. |
1574 |
"note extra () needed for an Array object as an argument" |
|
1575 |
||
1491 | 1576 |
(MethodFinder new load: #((14 3) 11 (-10 5) -15 (4 -3) 7) |
1089 | 1577 |
) searchForOne asArray = #('data1 - data2') ifFalse: [self error: 'should have found it']. |
1491 | 1578 |
((MethodFinder new load: #((4) 4 (-10) 10 (-3) 3 (2) 2 (-6) 6 (612) 612) |
1089 | 1579 |
) searchForOne asArray includesAll: #('data1 abs')) ifFalse: [self error: 'should have found it']. |
1491 | 1580 |
(MethodFinder new load: #(#(4 3) true #(-7 3) false #(5 1) true #(5 5) false) |
1089 | 1581 |
) searchForOne asArray = #('data1 > data2') ifFalse: [self error: 'should have found it']. |
1491 | 1582 |
(MethodFinder new load: #((5) 0.2 (2) 0.5) |
1089 | 1583 |
) searchForOne asArray = #('data1 reciprocal') ifFalse: [self error: 'should have found it']. |
1491 | 1584 |
(MethodFinder new load: #((12 4 8) 2 (1 3 6) 2 (5 2 16) 8) |
1089 | 1585 |
) searchForOne asArray = #() " '(data3 / data2) ' want to be able to leave out args" |
1586 |
ifFalse: [self error: 'should have found it']. |
|
1491 | 1587 |
(MethodFinder new load: #((0.0) 0.0 (1.5) 0.997495 (0.75) 0.681639) |
1089 | 1588 |
) searchForOne asArray = #('data1 sin') ifFalse: [self error: 'should have found it']. |
1491 | 1589 |
(MethodFinder new load: #((7 5) 2 (4 5) 4 (-9 4) 3) |
1089 | 1590 |
) searchForOne asArray = #('data1 \\ data2') ifFalse: [self error: 'should have found it']. |
1591 |
! ! |
|
1592 |
||
1593 |
!MethodFinder class methodsFor:'documentation'! |
|
1594 |
||
1595 |
version |
|
3021 | 1596 |
^ '$Header: /cvs/stx/stx/libbasic3/MethodFinder.st,v 1.28 2012/01/31 09:47:40 cg Exp $' |
2212 | 1597 |
! |
1598 |
||
1599 |
version_CVS |
|
3021 | 1600 |
^ 'Header: /cvs/stx/stx/libbasic3/MethodFinder.st,v 1.28 2012/01/31 09:47:40 cg Exp ' |
3012 | 1601 |
! |
1602 |
||
1603 |
version_SVN |
|
3021 | 1604 |
^ '$Id: MethodFinder.st 1884 2012-02-13 19:20:09Z vranyj1 $' |
3012 | 1605 |
! ! |
3021 | 1606 |