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 comment:'
|
|
21 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
22 |
All Rights Reserved
|
|
23 |
|
213
|
24 |
$Header: /cvs/stx/stx/libbasic/CheapBlock.st,v 1.3 1994-11-28 20:32:35 claus Exp $
|
156
|
25 |
'!
|
|
26 |
|
|
27 |
!CheapBlock class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
32 |
All Rights Reserved
|
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
213
|
45 |
$Header: /cvs/stx/stx/libbasic/CheapBlock.st,v 1.3 1994-11-28 20:32:35 claus Exp $
|
156
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
CheapBlocks are blocks which do not need their home-context(i.e.
|
|
52 |
those that do not access any arguments or locals).
|
|
53 |
Since they have no reference to the home, they must store their
|
|
54 |
creating method explicitely - otherwise, the system had no chance of
|
|
55 |
finding the source-position of the block.
|
|
56 |
|
|
57 |
Instance variables:
|
|
58 |
|
|
59 |
selfValue <Object> value to use for self if its a copying block
|
|
60 |
method <Method> method where block was created (cheap blocks only)
|
|
61 |
|
|
62 |
NOTICE: layout known by runtime system and compiler - do not change
|
|
63 |
"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!CheapBlock class methodsFor:'instance creation'!
|
|
67 |
|
|
68 |
code:codeAddress byteCode:bCode numArgs:numArgs sourcePosition:sourcePos initialPC:initialPC literals:literals dynamic:dynamic
|
|
69 |
"create a new cheap (homeless) block.
|
|
70 |
Not for public use - special hook for the compiler."
|
|
71 |
|
|
72 |
|newBlock|
|
|
73 |
|
|
74 |
newBlock := super basicNew code:codeAddress
|
|
75 |
byteCode:bCode
|
|
76 |
numArgs:numArgs
|
|
77 |
sourcePosition:sourcePos
|
|
78 |
initialPC:initialPC
|
|
79 |
literals:literals
|
|
80 |
dynamic:dynamic.
|
|
81 |
^ newBlock
|
|
82 |
! !
|
|
83 |
|
|
84 |
!CheapBlock methodsFor:'private accessing'!
|
|
85 |
|
|
86 |
code:codeAddress byteCode:bCode numArgs:numArgs sourcePosition:srcPos initialPC:iPC literals:lits dynamic:dynamic
|
|
87 |
"set all relevant internals"
|
|
88 |
|
|
89 |
self code:codeAddress.
|
|
90 |
byteCode := bCode.
|
|
91 |
nargs := numArgs.
|
|
92 |
sourcePos := srcPos.
|
|
93 |
initialPC := iPC.
|
|
94 |
literals := lits.
|
|
95 |
self dynamic:dynamic
|
|
96 |
! !
|
|
97 |
|
|
98 |
!CheapBlock methodsFor:'accessing'!
|
|
99 |
|
|
100 |
selfValue
|
|
101 |
"return the copied self"
|
|
102 |
|
|
103 |
^ selfValue
|
161
|
104 |
!
|
|
105 |
|
|
106 |
method
|
213
|
107 |
"return the receivers home method.
|
161
|
108 |
Thats the method where the block was created."
|
|
109 |
|
|
110 |
^ method
|
156
|
111 |
! !
|
|
112 |
|
|
113 |
!CheapBlock methodsFor:'printing & storing'!
|
|
114 |
|
|
115 |
printOn:aStream
|
|
116 |
"append a a printed representation of the block to aStream"
|
|
117 |
|
|
118 |
|class selector pair|
|
|
119 |
|
|
120 |
"
|
|
121 |
cheap blocks have no home context, but a method instead
|
|
122 |
"
|
|
123 |
|
|
124 |
aStream nextPutAll:'[] in '.
|
|
125 |
"
|
|
126 |
find out, for which class this method was for ...
|
|
127 |
"
|
|
128 |
method notNil ifTrue:[
|
|
129 |
pair := method who.
|
|
130 |
pair notNil ifTrue:[
|
|
131 |
class := pair at:1.
|
|
132 |
selector := pair at:2.
|
|
133 |
aStream nextPutAll:(class name , '-' , selector).
|
|
134 |
aStream nextPutAll:' (optimized)'.
|
|
135 |
^ self
|
|
136 |
].
|
|
137 |
].
|
|
138 |
"
|
|
139 |
currently, some cheap blocks don't know where they have been created
|
|
140 |
"
|
|
141 |
aStream nextPutAll:' ??? (optimized)'.
|
|
142 |
^ self
|
|
143 |
! !
|
|
144 |
|