author | Claus Gittinger <cg@exept.de> |
Thu, 23 Nov 1995 02:16:37 +0100 | |
changeset 605 | 8b17f96bf05a |
parent 528 | a083413dfbe8 |
child 623 | 6795a71e39d1 |
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 |
|
14 |
instanceVariableNames:'selfValue method' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Kernel-Methods' |
|
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 |
version |
|
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libbasic/CheapBlock.st,v 1.8 1995-11-11 14:27:49 cg Exp $' |
156 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
222 | 42 |
CheapBlocks are blocks which do not need their home-context |
43 |
(i.e. blocks that do not access any method arguments or method locals). |
|
156 | 44 |
Since they have no reference to the home, they must store their |
45 |
creating method explicitely - otherwise, the system had no chance of |
|
46 |
finding the source-position of the block. |
|
47 |
||
48 |
Instance variables: |
|
49 |
||
222 | 50 |
selfValue <Object> value to use for self if its a copying block |
51 |
||
52 |
method <Method> method where block was created |
|
156 | 53 |
|
54 |
NOTICE: layout known by runtime system and compiler - do not change |
|
55 |
" |
|
56 |
! ! |
|
57 |
||
58 |
!CheapBlock methodsFor:'accessing'! |
|
59 |
||
60 |
selfValue |
|
61 |
"return the copied self" |
|
62 |
||
63 |
^ selfValue |
|
161 | 64 |
! |
65 |
||
66 |
method |
|
213 | 67 |
"return the receivers home method. |
161 | 68 |
Thats the method where the block was created." |
69 |
||
70 |
^ method |
|
156 | 71 |
! ! |
72 |
||
73 |
!CheapBlock methodsFor:'printing & storing'! |
|
74 |
||
75 |
printOn:aStream |
|
76 |
"append a a printed representation of the block to aStream" |
|
77 |
||
78 |
|class selector pair| |
|
79 |
||
80 |
" |
|
81 |
cheap blocks have no home context, but a method instead |
|
82 |
" |
|
83 |
||
84 |
aStream nextPutAll:'[] in '. |
|
85 |
" |
|
86 |
find out, for which class this method was for ... |
|
87 |
" |
|
88 |
method notNil ifTrue:[ |
|
89 |
pair := method who. |
|
90 |
pair notNil ifTrue:[ |
|
91 |
class := pair at:1. |
|
92 |
selector := pair at:2. |
|
93 |
aStream nextPutAll:(class name , '-' , selector). |
|
94 |
aStream nextPutAll:' (optimized)'. |
|
95 |
^ self |
|
96 |
]. |
|
97 |
]. |
|
98 |
" |
|
99 |
currently, some cheap blocks don't know where they have been created |
|
100 |
" |
|
101 |
aStream nextPutAll:' ??? (optimized)'. |
|
102 |
^ self |
|
103 |
! ! |
|
104 |