author | Claus Gittinger <cg@exept.de> |
Mon, 22 Apr 1996 16:38:21 +0200 | |
changeset 1254 | 48c2748b5197 |
parent 1181 | 6637fee79d7b |
child 1264 | 8d916aa63bce |
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 |
|
44 |
machine or byteCode. |
|
45 |
||
156 | 46 |
Since they have no reference to the home, they must store their |
1254 | 47 |
creating method explicitely - otherwise, the system had no |
48 |
chance of finding the source-position of the block. |
|
156 | 49 |
|
50 |
Instance variables: |
|
51 |
||
1254 | 52 |
selfValue <Object> copied self value |
53 |
(if its a copying block) |
|
222 | 54 |
|
55 |
method <Method> method where block was created |
|
156 | 56 |
|
57 |
NOTICE: layout known by runtime system and compiler - do not change |
|
58 |
" |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
59 |
! ! |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
60 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
61 |
!CheapBlock class methodsFor:'queries'! |
623 | 62 |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
63 |
isBuiltInClass |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
64 |
"this class is known by the run-time-system" |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
65 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
66 |
^ self == CheapBlock |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
67 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
68 |
"Created: 16.4.1996 / 11:25:23 / cg" |
156 | 69 |
! ! |
70 |
||
71 |
!CheapBlock methodsFor:'accessing'! |
|
72 |
||
161 | 73 |
method |
213 | 74 |
"return the receivers home method. |
161 | 75 |
Thats the method where the block was created." |
76 |
||
77 |
^ method |
|
623 | 78 |
! |
79 |
||
80 |
selfValue |
|
81 |
"return the copied self" |
|
82 |
||
83 |
^ selfValue |
|
156 | 84 |
! ! |
85 |
||
86 |
!CheapBlock methodsFor:'printing & storing'! |
|
87 |
||
88 |
printOn:aStream |
|
89 |
"append a a printed representation of the block to aStream" |
|
90 |
||
91 |
|class selector pair| |
|
92 |
||
93 |
" |
|
94 |
cheap blocks have no home context, but a method instead |
|
95 |
" |
|
96 |
||
97 |
aStream nextPutAll:'[] in '. |
|
98 |
" |
|
99 |
find out, for which class this method was for ... |
|
100 |
" |
|
101 |
method notNil ifTrue:[ |
|
102 |
pair := method who. |
|
103 |
pair notNil ifTrue:[ |
|
104 |
class := pair at:1. |
|
105 |
selector := pair at:2. |
|
106 |
aStream nextPutAll:(class name , '-' , selector). |
|
107 |
aStream nextPutAll:' (optimized)'. |
|
108 |
^ self |
|
109 |
]. |
|
110 |
]. |
|
111 |
" |
|
112 |
currently, some cheap blocks don't know where they have been created |
|
113 |
" |
|
114 |
aStream nextPutAll:' ??? (optimized)'. |
|
115 |
^ self |
|
116 |
! ! |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
117 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
118 |
!CheapBlock class methodsFor:'documentation'! |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
119 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
120 |
version |
1254 | 121 |
^ '$Header: /cvs/stx/stx/libbasic/CheapBlock.st,v 1.12 1996-04-22 14:38:21 cg Exp $' |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
920
diff
changeset
|
122 |
! ! |