eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MethodFinder':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: MethodFinder


Inheritance:

   Object
   |
   +--MethodFinder

Package:
stx:libbasic3
Category:
Interface-Tools
Version:
rev: 1.132 date: 2024/04/24 07:33:23
user: stefan
file: MethodFinder.st directory: libbasic3
module: stx stc-classLibrary: libbasic3

Description:


a utility to find implementing methods by example.
Give it values for a receiver, optional arguments and a desired result,
and it will find methods which do that for you.
Please read the online documentation for details,
or open the MethodFinderView GUI.

[example:]
  which message, answers 7, given to 4 with an argument of 3,
  and also answers 5, if sent with an arg of 5 to 0
  and 10, if send to 5 with an argument of 5:    
  
    MethodFinder methodFor: #(
                              (4 3) 7
                              (0 5) 5
                              (5 5) 10
                            )
  You guessed it; it's the '+' message. 
                            
[example:]
    MethodFinder methodFor: #(
                              (4) 8
                              (0) 0
                              (5) 10
                            )

copyright

Copyright (C) Original Authors (Kaehler, Scott Wallace and Dan Ingalls) Copyright (C) 2001 eXept Software AG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Class protocol:

Signal constants
o  abortAllSignal
return the value of the static variable 'AbortAllSignal' (automatically generated)

o  abortAllSignal: something
set the value of the static variable 'AbortAllSignal' (automatically generated)

accessing
o  addAndRemove
return the value of the static variable 'AddAndRemove' (automatically generated)

o  addAndRemove: something
set the value of the static variable 'AddAndRemove' (automatically generated)

o  approved
return the value of the static variable 'Approved' (automatically generated)

o  approved: something
set the value of the static variable 'Approved' (automatically generated)

o  blocks
return the value of the static variable 'Blocks' (automatically generated)

o  blocks: something
set the value of the static variable 'Blocks' (automatically generated)

o  dangerous
return the value of the static variable 'Dangerous' (automatically generated)

o  dangerous: something
set the value of the static variable 'Dangerous' (automatically generated)

initialization
o  initClassVars
The methods we are allowed to use. (MethodFinder initClassVars)

Usage example(s):

MethodFinder initClassVars.
MethodFinder new organizationFiltered: Set

o  initClassVars2
Additional methods we are allowed to use.
(invoked by MethodFinder initClassVars)

o  initClassVars3
Additional methods we are allowed to use.
(invoked by MethodFinder initClassVars2)

instance creation
o  new
return an initialized instance

utilities
o  methodFor: dataAndAnswers
Return a Smalltalk expression that computes these answers.


Instance protocol:

accessing
o  answers

o  data

o  doInsertConversions

o  doPermute: aBoolean

o  expressions

o  realAnswers

o  selectors
Note the inst var does not have an S on the end

arg maps
o  argMap

o  makeAllMaps
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.

o  mapData
Force the data through the map (permutation) to create the data to test.

o  permuteArgs
Run through ALL the permutations.
First one was as presented.

o  thisData

find a constant
o  allNumbers
Return true if all answers and all data are numbers.

o  const
See if (^ constant) is the answer

o  constDiv
See if (data1 // C) is the answer

o  constLessThan
See if (data1 <= C) or (data1 >= C) is the answer

o  constLinear
See if (data1 * C1) + C2 is the answer. In the form #(C2 C1) polynomialEval: data1

o  constModulo
See if mod, (data1 \\ C) is the answer

o  constMult
See if (data1 * C) is the answer

o  constPlus
See if (data1 + C) is the answer

initialization
o  cleanInputs: dataAndAnswerString
Find and remove common mistakes.
Complain when ill formed.

o  copyFrom: aMethodFinder
|m1 m2|

m1 := MethodFinder new.
m2 := MethodFinder new copy:m1

o  copyFrom: aMethodFinder addArg: arg
|m1 m2|

m1 := MethodFinder new.
m2 := MethodFinder new copyFrom:m1

o  copyFrom: aMethodFinder data: newData answers: newAnswers
aMethodFinder expressions copy.

o  doInsertConversions: aBoolean
Modified (format): / 10-03-2024 / 16:26:07 / exept MBP

o  initialize
(comment from inherited method)
just to ignore initialize to objects which do not need it

o  load: dataWithAnswers
prepare to 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.

Usage example(s):

(MethodFinder new) 
          load: #( (4 3) 7  
                   (-10 5) -5  
                   (-3 11) 8
                 );
          findMessage

o  noteDangerous
Remember the methods with really bad side effects.

o  organizationFiltered: aClass
Return the organization of the class with all selectors defined in superclasses removed. (except those in Object)

o  strictClassCompare: aBoolean

o  strictCompare: aBoolean

o  test2: anArray
look for bad association

o  test3
find the modification of the caracter table

o  warnTooManyArguments

search
o  exceptions
Handle some very slippery selectors.
asSymbol -- want to be able to produce it,
but do not want to make every string submitted into a Symbol!

o  findMessage
Control the search.

o  insertConstants
see if one of several known expressions will do it.
C is the constant we discover here.
Needs 2 examples

o  insertConversions
see if a conversion will do it;
<rcvr> asFilename <selector> <args> -> <string rslt> asFilename
<rcvr> asFilename <selector> <args> -> <boolean rslt>

o  insertConversions: triples
see if a conversion will do it;
<rcvr> <aSelector> <selector> <args> -> <string rslt> <aSelector>
<rcvr> <aSelector> <selector> <args> -> <boolean rslt>

o  isArrayOfStrings: someObject

o  isByteArray: someObject

o  isCharacter: someObject

o  isFilename: someObject

o  isInteger: someObject

o  isNumber: someObject

o  isString: someObject

o  isStringCollection: someObject

o  search: multi
if Multi is true, collect all selectors that work.

o  searchForOne
Look for and return just one answer

o  simpleSearch
Run through first arg's class' selectors, looking for one that works.

o  testPerfect: aSelector
Try this selector!
Return true if it answers every example perfectly.
Take the args in the order they are.
Do not permute them.
Survive errors; later cache arg lists.

answers: a vector of expected results
argMap: a vector of arg-orders
thisData: current rcvr+args vector



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 14 Dec 2024 19:28:22 GMT