1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 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 |
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
|
|
22 |
All Rights Reserved
|
92
|
23 |
|
154
|
24 |
$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.8 1994-10-10 00:19:46 claus Exp $
|
88
|
25 |
'!
|
1
|
26 |
|
88
|
27 |
!BlockContext class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
1
|
32 |
All Rights Reserved
|
|
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 |
"
|
154
|
45 |
$Header: /cvs/stx/stx/libbasic/BlockContext.st,v 1.8 1994-10-10 00:19:46 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 -
|
|
57 |
do not change.
|
|
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:[
|
|
80 |
con := h.
|
|
81 |
h := con home
|
|
82 |
].
|
|
83 |
^ con
|
|
84 |
!
|
|
85 |
|
|
86 |
home
|
|
87 |
"return the immediate home of the receiver.
|
|
88 |
normally this is the methodcontext, where the block was created,
|
|
89 |
for nested block contexts, this is the surrounding blocks context."
|
|
90 |
|
|
91 |
home isContext ifFalse:[^ nil]. "copying blocks have no home"
|
|
92 |
^ home
|
|
93 |
!
|
|
94 |
|
|
95 |
selector
|
|
96 |
"return the selector of the context - which is one of the value
|
|
97 |
selectors"
|
|
98 |
|
|
99 |
|nargs|
|
|
100 |
|
154
|
101 |
nargs := self numArgs.
|
1
|
102 |
(nargs == 0) ifTrue:[^ #value].
|
|
103 |
(nargs == 1) ifTrue:[^ #value:].
|
|
104 |
(nargs == 2) ifTrue:[^ #value:value:].
|
|
105 |
(nargs == 3) ifTrue:[^ #value:value:value:].
|
|
106 |
(nargs == 4) ifTrue:[^ #value:value:value:value:].
|
|
107 |
(nargs == 5) ifTrue:[^ #value:value:value:value:value:].
|
|
108 |
^ nil
|
|
109 |
! !
|
|
110 |
|
92
|
111 |
!BlockContext methodsFor:'printing & storing'!
|
1
|
112 |
|
|
113 |
receiverPrintString
|
|
114 |
home isNil ifTrue:[
|
54
|
115 |
^ '[] optimized'
|
1
|
116 |
].
|
|
117 |
home isContext ifFalse:[
|
54
|
118 |
"a copying block"
|
1
|
119 |
|
54
|
120 |
"receiverClassName := home selfValue class name."
|
|
121 |
^ '[] optimized'
|
1
|
122 |
].
|
|
123 |
|
68
|
124 |
^ '[] in ' , receiver class name , '-' , self methodHome selector printString
|
1
|
125 |
!
|
|
126 |
|
|
127 |
printReceiver
|
|
128 |
self receiverPrintString print
|
|
129 |
!
|
|
130 |
|
|
131 |
printString
|
|
132 |
^ self receiverPrintString , ' ' , self selector printString
|
|
133 |
! !
|