41 " |
41 " |
42 Contexts represent the stack frame objects, which keep the processing |
42 Contexts represent the stack frame objects, which keep the processing |
43 state of a method or block (i.e. its local variables, temporaries etc.) |
43 state of a method or block (i.e. its local variables, temporaries etc.) |
44 Every message send adds a context to a chain, which can be traced back via |
44 Every message send adds a context to a chain, which can be traced back via |
45 the sender field. The context of the currently active method is always |
45 the sender field. The context of the currently active method is always |
46 accessable via the pseuodoVariable called 'thisContext'. |
46 accessible via the pseuodoVariable called 'thisContext'. |
47 The actual implementation uses the machines stack for this, building real |
47 The actual implementation uses the machines stack for this, building real |
48 contexts on demand only, whenever a contexts is needed. Also, initially these are |
48 contexts on demand only, whenever a contexts is needed. Also, initially these are |
49 allocated on the stack and only moved to the heap, when a context outlives its |
49 allocated on the stack and only moved to the heap, when a context outlives its |
50 activation. |
50 activation. |
51 |
51 |
105 releases. The blue book described this to be a noop, but other Smalltalk implementations |
105 releases. The blue book described this to be a noop, but other Smalltalk implementations |
106 changed this to be an invalid operation - a good decision, as it makes debugging much easier. |
106 changed this to be an invalid operation - a good decision, as it makes debugging much easier. |
107 |
107 |
108 |
108 |
109 [instance variables:] |
109 [instance variables:] |
110 flags <SmallInteger> used by the VM; never touch. |
110 flags <SmallInteger> used by the VM; never touch. |
111 contains info about number of args, |
111 contains info about number of args, |
112 locals and temporaries. |
112 locals and temporaries. |
113 |
113 |
114 sender <Context> the 'calling / sending' context |
114 sender <Context> the 'calling / sending' context |
115 This is not directly accessable, since it may |
115 This is not directly accessible, since it may |
116 be a lazy context (i.e. an empty frame). |
116 be a lazy context (i.e. an empty frame). |
117 The #sender method cares for this. |
117 The #sender method cares for this. |
118 |
118 |
119 home <Context> the context, where this block was |
119 home <Context> the context, where this block was |
120 created, or nil if its a method context |
120 created, or nil if its a method context |
121 There are also cheap blocks, which do |
121 There are also cheap blocks, which do |
122 not need a reference to the home context, |
122 not need a reference to the home context, |
123 for those, its nil too. |
123 for those, its nil too. |
124 |
124 |
125 receiver <Object> the receiver of this message |
125 receiver <Object> the receiver of this message |
126 |
126 |
127 selector <Symbol> the selector of this message |
127 selector <Symbol> the selector of this message |
128 |
128 |
129 searchClass <Class> the class, where the message lookup started |
129 searchClass <Class> the class, where the message lookup started |
130 (for super sends) or nil, for regular sends. |
130 (for super sends) or nil, for regular sends. |
131 |
131 |
132 lineNr <SmallInteger> the position where the context left off |
132 lineNr <SmallInteger> the position where the context left off |
133 (kind of p-counter). Only the low 16bits |
133 (kind of p-counter). Only the low 16bits |
134 are valid. |
134 are valid. |
135 |
135 |
136 retValTemp nil temporary - always nil, when you see the context |
136 retValTemp nil temporary - always nil, when you see the context |
137 (used in the VM as temporary) |
137 (used in the VM as temporary) |
138 |
138 |
139 handle *noObject* used by the VM; not accessable, not an object |
139 handle *noObject* used by the VM; not accessible, not an object |
140 |
140 |
141 method the corresponding method |
141 method the corresponding method |
142 |
142 |
143 <indexed> arguments of the send followed by |
143 <indexed> arguments of the send followed by |
144 locals of the method/block followed by |
144 locals of the method/block followed by |
145 temporaries. |
145 temporaries. |
146 |
146 |
147 [errors:] |
147 [errors:] |
148 CannotReturnError raised when a block tries |
148 CannotReturnError raised when a block tries |
149 to return ('^') from a method context |
149 to return ('^') from a method context |
150 which itself has already returned |
150 which itself has already returned |
151 (i.e. there is no place to return to) |
151 (i.e. there is no place to return to) |
152 |
152 |
153 WARNING: layout and size known by the compiler and runtime system - do not change. |
153 WARNING: layout and size known by the compiler and runtime system - do not change. |
154 |
154 |
155 |
155 |
156 [author:] |
156 [author:] |
157 Claus Gittinger |
157 Claus Gittinger |
158 |
158 |
159 [see also:] |
159 [see also:] |
160 Block Process Method |
160 Block Process Method |
161 ( contexts, stacks & unwinding : programming/contexts.html) |
161 ( contexts, stacks & unwinding : programming/contexts.html) |
162 " |
162 " |
163 ! ! |
163 ! ! |
164 |
164 |
165 !Context class methodsFor:'initialization'! |
165 !Context class methodsFor:'initialization'! |
166 |
166 |