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
|
15957
|
109 |
|
|
110 |
<resource: #obsolete>
|
|
111 |
|
|
112 |
"
|
|
113 |
This method is no longer sent by the VM as it nows pass
|
|
114 |
inline/poly cache object.
|
|
115 |
"
|
|
116 |
|
|
117 |
|
13401
|
118 |
"invoked by the VM to ask me for a method to call.
|
|
119 |
The arguments are: the selector, receiver and arguments,
|
|
120 |
the class to start the search in (for here-, super and directed sends)
|
|
121 |
the sending context.
|
|
122 |
|
|
123 |
The returned method object will be put into the inline- and polyCache
|
|
124 |
at the call site; it might therefore be called more than once for the
|
|
125 |
same receiver-class/selector combination (once for each call site).
|
|
126 |
If I return nil, a doesNotUnderstand will be invoked."
|
|
127 |
|
|
128 |
|cls md method|
|
|
129 |
|
|
130 |
"Following C code is just a performance optimization.
|
|
131 |
It is not neccessary, however it speeds up UI code,
|
|
132 |
since it heavily uses perform:"
|
|
133 |
%{
|
|
134 |
RETURN ( __lookup(initialSearchClass, selector) );
|
|
135 |
%}.
|
|
136 |
^ self lookupMethodForSelector: selector
|
|
137 |
directedTo: initialSearchClass
|
|
138 |
|
|
139 |
|
15957
|
140 |
!
|
|
141 |
|
|
142 |
lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilcCache
|
|
143 |
|
|
144 |
"Invoked by the VM to ask me for a method to call.
|
|
145 |
The arguments are: the selector, receiver and arguments,
|
|
146 |
the class to start the search in (for here-, super and directed sends)
|
|
147 |
the sending context and the inline/poly cache (instance of
|
|
148 |
PolymorphicInlineCache).
|
|
149 |
|
|
150 |
The returned method object will NOT be put into the inline- and
|
|
151 |
polyCache bu default. To update the call site's cache, you have to
|
|
152 |
call ilcCache bindTo: method forClass: initialSearch class. If you
|
|
153 |
dont call it, inline/poly cache won't be updated and next call
|
|
154 |
won't be cached (therefore it will be relatively slow.
|
|
155 |
|
|
156 |
If I return nil, a doesNotUnderstand: will be send."
|
|
157 |
|
|
158 |
|
|
159 |
| method |
|
|
160 |
|
|
161 |
"Following C code is just a performance optimization.
|
|
162 |
It is not neccessary, however it speeds up UI code,
|
|
163 |
since it heavily uses perform:"
|
|
164 |
|
|
165 |
%{
|
|
166 |
method = __lookup(initialSearchClass, selector);
|
|
167 |
if ( method ) {
|
|
168 |
__ilcBind(ilcCache, initialSearchClass, method, selector);
|
|
169 |
}
|
|
170 |
RETURN (method);
|
|
171 |
%}.
|
|
172 |
|
|
173 |
method := self lookupMethodForSelector:selector directedTo:initialSearchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext.
|
|
174 |
ilcCache bindTo: method forClass: initialSearchClass.
|
|
175 |
^ method.
|
|
176 |
|
|
177 |
"Created: / 01-10-2011 / 13:18:40 / Jan Kurs <kursjan@fit.cvut.cz>"
|
13401
|
178 |
! !
|
|
179 |
|
|
180 |
!Lookup class methodsFor:'documentation'!
|
|
181 |
|
13405
|
182 |
version_CVS
|
15957
|
183 |
^ '$Header: /cvs/stx/stx/libbasic/Lookup.st,v 1.3 2014-02-05 17:17:53 cg Exp $'
|
13405
|
184 |
!
|
|
185 |
|
13401
|
186 |
version_SVN
|
15957
|
187 |
^ '$Id: Lookup.st,v 1.3 2014-02-05 17:17:53 cg Exp $'
|
13401
|
188 |
! !
|
|
189 |
|
15957
|
190 |
|
13401
|
191 |
Lookup initialize!
|