author | Claus Gittinger <cg@exept.de> |
Thu, 02 Sep 1999 23:44:11 +0200 | |
changeset 4670 | 21eec331e1e9 |
parent 2694 | 46ba8cbdc013 |
permissions | -rw-r--r-- |
156 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
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 |
" |
|
12 |
||
13 |
Block subclass:#CheapBlock |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
14 |
instanceVariableNames:'selfValue method' |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
15 |
classVariableNames:'' |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
16 |
poolDictionaries:'' |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
17 |
category:'Kernel-Methods' |
156 | 18 |
! |
19 |
||
20 |
!CheapBlock class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
222 | 38 |
CheapBlocks are blocks which do not need their home-context |
1254 | 39 |
(i.e. blocks that do not access any method arguments |
40 |
or method locals). |
|
41 |
||
42 |
CheapBlocks are never created explicitely; the only creation |
|
43 |
is done by the compilers, when some sourceCode is compiled to either |
|
2243 | 44 |
machine or byteCode, and the generated block is found to neither access |
45 |
any variables from its homeContext nor does a method-return. |
|
46 |
CheapBlocks create less overhead to the runtime system, in that they |
|
47 |
do not keep the creating context from being reclaimed (but, dont expect |
|
48 |
too much of a difference ;-) |
|
1254 | 49 |
|
156 | 50 |
Since they have no reference to the home, they must store their |
1254 | 51 |
creating method explicitely - otherwise, the system had no |
52 |
chance of finding the source-position of the block. |
|
156 | 53 |
|
1293 | 54 |
[Instance variables:] |
156 | 55 |
|
1254 | 56 |
selfValue <Object> copied self value |
57 |
(if its a copying block) |
|
222 | 58 |
|
59 |
method <Method> method where block was created |
|
156 | 60 |
|
61 |
NOTICE: layout known by runtime system and compiler - do not change |
|
1293 | 62 |
|
63 |
[author:] |
|
64 |
Claus Gittinger |
|
65 |
||
66 |
[see also:] |
|
67 |
Block Context Method |
|
68 |
( contexts, stacks & unwinding :html: programming/contexts.html ) |
|
156 | 69 |
" |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
70 |
! ! |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
71 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
72 |
!CheapBlock class methodsFor:'queries'! |
623 | 73 |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
74 |
isBuiltInClass |
1264 | 75 |
"return true if this class is known by the run-time-system. |
76 |
Here, true is returned for myself, false for subclasses." |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
77 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
78 |
^ self == CheapBlock |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
79 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
80 |
"Created: 16.4.1996 / 11:25:23 / cg" |
1264 | 81 |
"Modified: 23.4.1996 / 15:56:46 / cg" |
156 | 82 |
! ! |
83 |
||
84 |
!CheapBlock methodsFor:'accessing'! |
|
85 |
||
2694
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
86 |
homeMethod |
213 | 87 |
"return the receivers home method. |
161 | 88 |
Thats the method where the block was created." |
89 |
||
90 |
^ method |
|
2694
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
91 |
|
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
92 |
"Created: 19.6.1997 / 16:14:35 / cg" |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
93 |
"Modified: 19.6.1997 / 16:15:44 / cg" |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
94 |
! |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
95 |
|
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
96 |
method |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
97 |
"return the receivers home method. |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
98 |
Thats the method where the block was created. |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
99 |
Obsolete: use #homeMethod for ST80 compatibility." |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
100 |
|
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
101 |
^ method |
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
102 |
|
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
103 |
"Modified: 19.6.1997 / 16:15:58 / cg" |
623 | 104 |
! |
105 |
||
106 |
selfValue |
|
107 |
"return the copied self" |
|
108 |
||
109 |
^ selfValue |
|
1796 | 110 |
! |
111 |
||
112 |
setMethod:aMethod |
|
113 |
"set the receivers home method. |
|
114 |
This is a private entry for the compiler" |
|
115 |
||
116 |
method := aMethod |
|
117 |
||
118 |
"Created: 21.10.1996 / 13:58:29 / cg" |
|
156 | 119 |
! ! |
120 |
||
2247 | 121 |
!CheapBlock methodsFor:'conversion'! |
122 |
||
123 |
beVarArg |
|
124 |
"convert myself into a varArg block; |
|
125 |
this one has 1 formal argument, which gets the list |
|
126 |
of actual arguments when evaluated." |
|
127 |
||
128 |
nargs ~~ 1 ifTrue:[ |
|
129 |
self error:'vararg blocks must take exactly 1 argument - the arg list'. |
|
130 |
^ nil |
|
131 |
]. |
|
132 |
||
133 |
self changeClassTo:VarArgCheapBlock. |
|
134 |
^ self |
|
135 |
||
136 |
" |
|
137 |
|b| |
|
138 |
||
139 |
b := [:argList | argList printCR] beVarArg. |
|
140 |
b value. |
|
141 |
b value:'arg1' value:'arg2' value:'arg3' value:'arg4' |
|
142 |
" |
|
143 |
||
144 |
"Created: 23.1.1997 / 13:35:28 / cg" |
|
145 |
"Modified: 23.1.1997 / 13:35:48 / cg" |
|
146 |
! ! |
|
147 |
||
156 | 148 |
!CheapBlock methodsFor:'printing & storing'! |
149 |
||
150 |
printOn:aStream |
|
151 |
"append a a printed representation of the block to aStream" |
|
152 |
||
1852
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
153 |
|who| |
156 | 154 |
|
155 |
" |
|
156 |
cheap blocks have no home context, but a method instead |
|
157 |
" |
|
158 |
||
159 |
aStream nextPutAll:'[] in '. |
|
160 |
" |
|
161 |
find out, for which class this method was for ... |
|
162 |
" |
|
163 |
method notNil ifTrue:[ |
|
1852
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
164 |
who := method who. |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
165 |
who notNil ifTrue:[ |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
166 |
aStream nextPutAll:(who methodClass name , '-' , who methodSelector). |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
167 |
aStream nextPutAll:' (optimized)'. |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
168 |
^ self |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
169 |
]. |
156 | 170 |
]. |
171 |
" |
|
172 |
currently, some cheap blocks don't know where they have been created |
|
173 |
" |
|
174 |
aStream nextPutAll:' ??? (optimized)'. |
|
175 |
^ self |
|
1852
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
176 |
|
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
177 |
"Modified: 1.11.1996 / 16:21:19 / cg" |
156 | 178 |
! ! |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
179 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
180 |
!CheapBlock class methodsFor:'documentation'! |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
181 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
182 |
version |
2694
46ba8cbdc013
added #homeMethod for ST80 compatibility
Claus Gittinger <cg@exept.de>
parents:
2247
diff
changeset
|
183 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/CheapBlk.st,v 1.19 1997-06-19 14:17:25 cg Exp $' |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
184 |
! ! |