author | Claus Gittinger <cg@exept.de> |
Thu, 23 Jan 1997 13:45:23 +0100 | |
changeset 2243 | adf9680a593e |
parent 1852 | 89b2328f4203 |
child 2247 | 3e227e6ea1fb |
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 |
||
161 | 86 |
method |
213 | 87 |
"return the receivers home method. |
161 | 88 |
Thats the method where the block was created." |
89 |
||
90 |
^ method |
|
623 | 91 |
! |
92 |
||
93 |
selfValue |
|
94 |
"return the copied self" |
|
95 |
||
96 |
^ selfValue |
|
1796 | 97 |
! |
98 |
||
99 |
setMethod:aMethod |
|
100 |
"set the receivers home method. |
|
101 |
This is a private entry for the compiler" |
|
102 |
||
103 |
method := aMethod |
|
104 |
||
105 |
"Created: 21.10.1996 / 13:58:29 / cg" |
|
156 | 106 |
! ! |
107 |
||
108 |
!CheapBlock methodsFor:'printing & storing'! |
|
109 |
||
110 |
printOn:aStream |
|
111 |
"append a a printed representation of the block to aStream" |
|
112 |
||
1852
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
113 |
|who| |
156 | 114 |
|
115 |
" |
|
116 |
cheap blocks have no home context, but a method instead |
|
117 |
" |
|
118 |
||
119 |
aStream nextPutAll:'[] in '. |
|
120 |
" |
|
121 |
find out, for which class this method was for ... |
|
122 |
" |
|
123 |
method notNil ifTrue:[ |
|
1852
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
124 |
who := method who. |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
125 |
who notNil ifTrue:[ |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
126 |
aStream nextPutAll:(who methodClass name , '-' , who methodSelector). |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
127 |
aStream nextPutAll:' (optimized)'. |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
128 |
^ self |
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
129 |
]. |
156 | 130 |
]. |
131 |
" |
|
132 |
currently, some cheap blocks don't know where they have been created |
|
133 |
" |
|
134 |
aStream nextPutAll:' ??? (optimized)'. |
|
135 |
^ self |
|
1852
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
136 |
|
89b2328f4203
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
137 |
"Modified: 1.11.1996 / 16:21:19 / cg" |
156 | 138 |
! ! |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
139 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
140 |
!CheapBlock class methodsFor:'documentation'! |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
141 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
142 |
version |
2243 | 143 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/CheapBlk.st,v 1.17 1997-01-23 12:45:23 cg Exp $' |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
144 |
! ! |