1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
165
|
3 |
All Rights Reserved
|
1
|
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 |
Context subclass:#BlockContext
|
|
14 |
instanceVariableNames:'' "do not add instvars here"
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Kernel-Methods'
|
|
18 |
!
|
|
19 |
|
|
20 |
BlockContext comment:'
|
88
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
165
|
22 |
All Rights Reserved
|
92
|
23 |
|
281
|
24 |
$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.12 1995-02-24 16:32:32 claus Exp $
|
88
|
25 |
'!
|
1
|
26 |
|
88
|
27 |
!BlockContext class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
165
|
32 |
All Rights Reserved
|
1
|
33 |
|
88
|
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 |
!
|
1
|
42 |
|
88
|
43 |
version
|
|
44 |
"
|
281
|
45 |
$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.12 1995-02-24 16:32:32 claus Exp $
|
88
|
46 |
"
|
|
47 |
!
|
1
|
48 |
|
88
|
49 |
documentation
|
|
50 |
"
|
|
51 |
BlockContexts represent the stack context objects of blocks.
|
|
52 |
The layout is the same as for other contexts - this class has been added
|
|
53 |
to avoid a flag in an instance variable.
|
|
54 |
(has become necessary with cheap blocks, which have no home).
|
|
55 |
|
|
56 |
WARNING: layout and size known by compiler and runtime system -
|
165
|
57 |
do not change.
|
88
|
58 |
"
|
|
59 |
! !
|
1
|
60 |
|
|
61 |
!BlockContext methodsFor:'accessing'!
|
|
62 |
|
|
63 |
isBlockContext
|
|
64 |
"return true, iff the receiver is a BlockContext, false otherwise"
|
|
65 |
|
|
66 |
^ true
|
|
67 |
!
|
|
68 |
|
|
69 |
methodHome
|
|
70 |
"return the method-home for block contexts"
|
|
71 |
|
|
72 |
|con h|
|
|
73 |
|
|
74 |
home isNil ifTrue:[^ nil]. "XXX will change soon"
|
|
75 |
home isContext ifFalse:[^ nil]. "copying blocks have no method home"
|
|
76 |
|
|
77 |
con := self.
|
|
78 |
h := home.
|
|
79 |
[h notNil] whileTrue:[
|
165
|
80 |
con := h.
|
|
81 |
h := con home
|
1
|
82 |
].
|
|
83 |
^ con
|
|
84 |
!
|
|
85 |
|
216
|
86 |
method
|
|
87 |
"return the method in which the current contexts block was created."
|
|
88 |
|
|
89 |
home notNil ifTrue:[^ home method].
|
|
90 |
^ nil
|
|
91 |
!
|
|
92 |
|
1
|
93 |
home
|
|
94 |
"return the immediate home of the receiver.
|
|
95 |
normally this is the methodcontext, where the block was created,
|
|
96 |
for nested block contexts, this is the surrounding blocks context."
|
|
97 |
|
|
98 |
home isContext ifFalse:[^ nil]. "copying blocks have no home"
|
|
99 |
^ home
|
|
100 |
!
|
|
101 |
|
|
102 |
selector
|
|
103 |
"return the selector of the context - which is one of the value
|
281
|
104 |
selectors. This selector is not found in the context, but synthesized."
|
1
|
105 |
|
|
106 |
|nargs|
|
|
107 |
|
154
|
108 |
nargs := self numArgs.
|
1
|
109 |
(nargs == 0) ifTrue:[^ #value].
|
|
110 |
(nargs == 1) ifTrue:[^ #value:].
|
|
111 |
(nargs == 2) ifTrue:[^ #value:value:].
|
|
112 |
(nargs == 3) ifTrue:[^ #value:value:value:].
|
|
113 |
(nargs == 4) ifTrue:[^ #value:value:value:value:].
|
|
114 |
(nargs == 5) ifTrue:[^ #value:value:value:value:value:].
|
|
115 |
^ nil
|
|
116 |
! !
|
|
117 |
|
92
|
118 |
!BlockContext methodsFor:'printing & storing'!
|
1
|
119 |
|
|
120 |
receiverPrintString
|
281
|
121 |
"return a printString describing the contexts receiver.
|
|
122 |
Since this is called from the debugger, be very careful to
|
|
123 |
return something useful, even in case internals of the system
|
|
124 |
got corrupted ... (i.e. avoid messageNotUnderstood here)"
|
|
125 |
|
|
126 |
|cls who mHome m className|
|
241
|
127 |
|
1
|
128 |
home isNil ifTrue:[
|
165
|
129 |
^ '[] optimized'
|
1
|
130 |
].
|
|
131 |
home isContext ifFalse:[
|
165
|
132 |
"a copying block"
|
1
|
133 |
|
281
|
134 |
"/ receiverClassName := home selfValue class name.
|
165
|
135 |
^ '[] optimized'
|
1
|
136 |
].
|
281
|
137 |
mHome := self methodHome.
|
|
138 |
mHome isNil ifTrue:[
|
|
139 |
'BCONTEXT: no methodHome' errorPrintNL.
|
|
140 |
^ '[] in ???'
|
|
141 |
].
|
|
142 |
|
|
143 |
m := mHome method.
|
|
144 |
m isNil ifTrue:[
|
|
145 |
'BCONTEXT: no method' errorPrintNL.
|
|
146 |
^ '[] in ???'
|
|
147 |
].
|
|
148 |
who := m who.
|
241
|
149 |
who notNil ifTrue:[
|
|
150 |
cls := who at:1
|
|
151 |
] ifFalse:[
|
|
152 |
cls := receiver class.
|
|
153 |
].
|
281
|
154 |
className := cls name.
|
|
155 |
className isNil ifTrue:[
|
|
156 |
'BCONTEXT: nameless class' errorPrintNL.
|
|
157 |
className := '???'
|
|
158 |
].
|
|
159 |
^ '[] in ' , className , '-' , mHome selector printString
|
1
|
160 |
! !
|