Lookup.st
author Stefan Vogel <sv@exept.de>
Sat, 26 May 2012 22:02:59 +0200
changeset 14146 94acb9d1afc8
parent 13405 13dea24362ff
child 15957 b8ad4b672f8a
child 18011 deb0c3355881
permissions -rw-r--r--
changed:9 methods - lint
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
     1
"
13405
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
     2
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
     3
              All Rights Reserved
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
     4
13405
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
     5
Permission is hereby granted, free of charge, to any person
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
     6
obtaining a copy of this software and associated documentation
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
     7
files (the 'Software'), to deal in the Software without
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
     8
restriction, including without limitation the rights to use,
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
     9
copy, modify, merge, publish, distribute, sublicense, and/or sell
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    10
copies of the Software, and to permit persons to whom the
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    11
Software is furnished to do so, subject to the following
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    12
conditions:
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    13
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    14
The above copyright notice and this permission notice shall be
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    15
included in all copies or substantial portions of the Software.
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    16
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    17
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    18
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    19
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    20
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    21
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    22
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    23
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    24
OTHER DEALINGS IN THE SOFTWARE.
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    25
"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    26
"{ Package: 'stx:libbasic' }"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    27
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    28
Object subclass:#Lookup
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    29
	instanceVariableNames:''
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    30
	classVariableNames:''
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    31
	poolDictionaries:''
13405
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    32
	category:'Kernel-Extensions'
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    33
!
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    34
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    35
!Lookup class methodsFor:'documentation'!
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    36
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    37
copyright
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    38
"
13405
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    39
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    40
              All Rights Reserved
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    41
13405
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    42
Permission is hereby granted, free of charge, to any person
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    43
obtaining a copy of this software and associated documentation
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    44
files (the 'Software'), to deal in the Software without
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    45
restriction, including without limitation the rights to use,
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    46
copy, modify, merge, publish, distribute, sublicense, and/or sell
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    47
copies of the Software, and to permit persons to whom the
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    48
Software is furnished to do so, subject to the following
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    49
conditions:
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    50
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    51
The above copyright notice and this permission notice shall be
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    52
included in all copies or substantial portions of the Software.
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    53
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    54
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    55
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    56
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    57
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    58
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    59
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    60
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
    61
OTHER DEALINGS IN THE SOFTWARE.
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    62
"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    63
! !
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    64
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    65
!Lookup class methodsFor:'initialization'!
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    66
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    67
initialize
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    68
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    69
    self lookupObject: Lookup builtin
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    70
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    71
    "Created: / 26-04-2010 / 21:15:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    72
! !
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    73
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    74
!Lookup class methodsFor:'accessing'!
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    75
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    76
builtin
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    77
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    78
    ^BuiltinLookup instance
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    79
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    80
    "Created: / 26-04-2010 / 19:26:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    81
! !
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    82
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    83
!Lookup methodsFor:'lookup'!
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    84
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    85
lookupMethodForSelector: selector directedTo: initialSearchClass
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    86
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    87
     |cls md method|
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    88
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    89
	"Following C code is just a performance optimization.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    90
	 It is not neccessary, however it speeds up UI code,
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    91
	 since it heavily uses perform:"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    92
%{
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    93
	RETURN (  __lookup(initialSearchClass, selector) );
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    94
%}.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    95
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    96
     cls := initialSearchClass.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    97
     [ cls notNil ] whileTrue:[
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    98
        md := cls methodDictionary.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
    99
        method := md at:selector ifAbsent:nil.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   100
        method notNil ifTrue:[^ method ].
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   101
        cls := cls superclass.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   102
     ].
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   103
     ^ nil
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   104
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   105
    "Created: / 27-04-2010 / 15:30:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   106
!
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   107
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   108
lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   109
    "invoked by the VM to ask me for a method to call.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   110
     The arguments are: the selector, receiver and arguments,
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   111
     the class to start the search in (for here-, super and directed sends)
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   112
     the sending context.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   113
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   114
     The returned method object will be put into the inline- and polyCache
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   115
     at the call site; it might therefore be called more than once for the
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   116
     same receiver-class/selector combination (once for each call site).
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   117
     If I return nil, a doesNotUnderstand will be invoked."
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   118
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   119
     |cls md method|
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   120
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   121
	"Following C code is just a performance optimization.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   122
	 It is not neccessary, however it speeds up UI code,
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   123
	 since it heavily uses perform:"
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   124
%{
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   125
	RETURN (  __lookup(initialSearchClass, selector) );
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   126
%}.
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   127
    ^ self lookupMethodForSelector: selector 
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   128
		   directedTo: initialSearchClass
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   129
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   130
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   131
! !
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   132
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   133
!Lookup class methodsFor:'documentation'!
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   134
13405
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
   135
version_CVS
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
   136
    ^ '$Header: /cvs/stx/stx/libbasic/Lookup.st,v 1.2 2011-06-28 11:04:17 cg Exp $'
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
   137
!
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
   138
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   139
version_SVN
13405
13dea24362ff initial checkin
Claus Gittinger <cg@exept.de>
parents: 13401
diff changeset
   140
    ^ '§Id: Lookup.st,v 1.1 2011/06/28 10:51:38 vrany Exp §'
13401
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   141
! !
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   142
36713d9bc967 Added Lookup.st BuiltinLookup.st
vrany
parents:
diff changeset
   143
Lookup initialize!