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