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