author | Claus Gittinger <cg@exept.de> |
Sun, 17 May 1998 20:15:51 +0200 | |
changeset 720 | 6b3d43ba7273 |
parent 719 | 9ccbae6ba13e |
child 789 | d9bbb0970239 |
permissions | -rw-r--r-- |
14 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
53 | 3 |
All Rights Reserved |
14 | 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 |
PrimaryNode subclass:#VariableNode |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
14 |
instanceVariableNames:'name token index block' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
15 |
classVariableNames:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
16 |
poolDictionaries:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
17 |
category:'System-Compiler-Support' |
14 | 18 |
! |
19 |
||
360 | 20 |
!VariableNode class methodsFor:'documentation'! |
20 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
53 | 25 |
All Rights Reserved |
20 | 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 |
documentation |
|
37 |
" |
|
38 |
node for parse-trees, representing variables |
|
261 | 39 |
This is a helper class for the compiler. |
263 | 40 |
|
41 |
[author:] |
|
42 |
Claus Gittinger |
|
20 | 43 |
" |
44 |
! ! |
|
14 | 45 |
|
360 | 46 |
!VariableNode class methodsFor:'instance creation'! |
14 | 47 |
|
98 | 48 |
type:t class:class name:n |
49 |
^ (self basicNew) type:t class:class name:n |
|
50 |
! |
|
51 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
52 |
type:t context:aContext |
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
53 |
^ (self basicNew) type:t context:aContext |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
54 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
55 |
"Created: / 17.1.1998 / 04:00:35 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
56 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
57 |
|
140 | 58 |
type:t name:n |
59 |
^ (self basicNew) type:t name:n |
|
60 |
! |
|
61 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
62 |
type:t name:n context:aContext index:i |
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
63 |
^ (self basicNew) type:t name:n context:aContext index:i |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
64 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
65 |
"Created: / 17.1.1998 / 02:40:32 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
66 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
67 |
|
140 | 68 |
type:t name:n index:i selfClass:s |
69 |
^ (self basicNew) type:t name:n index:i selfClass:s |
|
70 |
! |
|
71 |
||
72 |
type:t name:n index:i selfValue:s |
|
73 |
^ (self basicNew) type:t name:n index:i selfValue:s |
|
14 | 74 |
! |
75 |
||
76 |
type:t name:n token:tok index:i |
|
77 |
^ (self basicNew) type:t name:n token:tok index:i |
|
78 |
! |
|
79 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
80 |
type:t name:n token:tok index:i block:b from:codeBlock |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
81 |
^ (self basicNew) type:t name:n token:tok index:i block:b from:codeBlock |
14 | 82 |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
83 |
"Modified: 2.7.1997 / 10:55:48 / cg" |
14 | 84 |
! ! |
85 |
||
86 |
!VariableNode methodsFor:'accessing'! |
|
87 |
||
577 | 88 |
block |
89 |
^ block |
|
90 |
||
91 |
"Created: 2.7.1997 / 18:53:38 / cg" |
|
92 |
! |
|
93 |
||
140 | 94 |
index |
95 |
^ index |
|
14 | 96 |
! |
97 |
||
140 | 98 |
name |
99 |
^ name |
|
14 | 100 |
! |
101 |
||
140 | 102 |
type:t class:class name:n |
14 | 103 |
type := t. |
140 | 104 |
name := n. |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
105 |
value := class |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
106 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
107 |
"Modified: / 17.1.1998 / 04:03:55 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
108 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
109 |
|
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
110 |
type:t context:aContext |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
111 |
type := t. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
112 |
value := aContext. |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
113 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
114 |
"Modified: / 17.1.1998 / 04:01:55 / cg" |
14 | 115 |
! |
116 |
||
140 | 117 |
type:t name:n |
98 | 118 |
type := t. |
119 |
value := nil. |
|
14 | 120 |
name := n |
121 |
! |
|
122 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
123 |
type:t name:n context:aContext index:i |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
124 |
type := t. |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
125 |
index := i. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
126 |
value := aContext. |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
127 |
name := n |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
128 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
129 |
"Created: / 17.1.1998 / 02:40:55 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
130 |
"Modified: / 17.1.1998 / 04:01:21 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
131 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
132 |
|
14 | 133 |
type:t name:n index:i selfClass:s |
134 |
type := t. |
|
135 |
index := i. |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
136 |
value := s. |
14 | 137 |
name := n |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
138 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
139 |
"Modified: / 17.1.1998 / 04:04:04 / cg" |
14 | 140 |
! |
141 |
||
140 | 142 |
type:t name:n index:i selfValue:s |
143 |
type := t. |
|
144 |
index := i. |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
145 |
value := s. |
140 | 146 |
name := n |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
147 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
148 |
"Modified: / 17.1.1998 / 04:02:58 / cg" |
140 | 149 |
! |
150 |
||
14 | 151 |
type:t name:n token:tok index:i |
152 |
type := t. |
|
153 |
index := i. |
|
154 |
token := tok. |
|
155 |
name := n |
|
156 |
! |
|
157 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
158 |
type:t name:n token:tok index:i block:variableBlock from:codeBlock |
14 | 159 |
type := t. |
160 |
index := i. |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
161 |
block := variableBlock. |
14 | 162 |
token := tok. |
535 | 163 |
name := n. |
164 |
(type == #BlockArg) ifTrue:[ |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
165 |
variableBlock blockArgAccessed:true. |
535 | 166 |
]. |
167 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
168 |
codeBlock ~~ variableBlock ifTrue:[ |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
169 |
codeBlock rememberOuterBlockVarAccess:self |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
170 |
] |
140 | 171 |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
172 |
"Created: 2.7.1997 / 10:54:50 / cg" |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
173 |
"Modified: 2.7.1997 / 11:12:58 / cg" |
14 | 174 |
! |
175 |
||
140 | 176 |
type:t token:tok index:i block:b |
177 |
type := t. |
|
178 |
index := i. |
|
179 |
block := b. |
|
535 | 180 |
token := tok. |
181 |
||
182 |
(type == #BlockArg) ifTrue:[ |
|
183 |
b blockArgAccessed:true. |
|
184 |
]. |
|
185 |
||
186 |
"Modified: 18.6.1997 / 11:41:05 / cg" |
|
14 | 187 |
! ! |
188 |
||
189 |
!VariableNode methodsFor:'code generation'! |
|
190 |
||
104 | 191 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
14 | 192 |
"no code at all" |
193 |
^ self |
|
194 |
! |
|
195 |
||
559 | 196 |
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler |
197 |
|theCode b deltaLevel litIndex specialGlobalIndex |
|
198 |
bvIdx bvTyp blocksCode| |
|
14 | 199 |
|
200 |
(type == #MethodArg) ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
201 |
(index <= 4) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
202 |
aStream nextPut:(#(pushMethodArg1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
203 |
pushMethodArg2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
204 |
pushMethodArg3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
205 |
pushMethodArg4) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
206 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
207 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
208 |
aStream nextPut:#pushMethodArg; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
209 |
^ self |
14 | 210 |
]. |
554 | 211 |
|
14 | 212 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
213 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
214 |
aStream nextPut:(#(pushMethodVar1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
215 |
pushMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
216 |
pushMethodVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
217 |
pushMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
218 |
pushMethodVar5 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
219 |
pushMethodVar6) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
220 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
221 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
222 |
aStream nextPut:#pushMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
223 |
^ self |
14 | 224 |
]. |
554 | 225 |
|
14 | 226 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
227 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
228 |
theCode := #(pushInstVar1 pushInstVar2 pushInstVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
229 |
pushInstVar4 pushInstVar5 pushInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
230 |
pushInstVar7 pushInstVar8 pushInstVar9 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
231 |
pushInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
232 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
233 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
234 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
235 |
aStream nextPut:#pushInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
236 |
^ self |
14 | 237 |
]. |
554 | 238 |
|
239 |
((type == #BlockArg) |
|
240 |
or:[type == #BlockVariable]) ifTrue:[ |
|
559 | 241 |
"/ compiling for codeBlock; accessing variable in block. |
242 |
||
243 |
bvIdx := index. |
|
244 |
bvTyp := type. |
|
245 |
||
246 |
"/ find the context where that variable is contained physically |
|
247 |
blocksCode := block. |
|
248 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
249 |
blocksCode := blocksCode home |
|
250 |
]. |
|
251 |
||
252 |
"/ find deltaLevel from code-context to the containing block |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
253 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
254 |
deltaLevel := 0. |
559 | 255 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 256 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
257 |
deltaLevel := deltaLevel + 1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
258 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
259 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
260 |
]. |
535 | 261 |
|
559 | 262 |
b isNil ifTrue:[ |
263 |
codeBlock isNil ifTrue:[ |
|
264 |
"/ a var of a block which is inlined in the method. |
|
265 |
"/ Generate a pushMVAR |
|
266 |
||
267 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
268 |
type == #BlockVariable ifTrue:[ |
|
269 |
bvIdx := bvIdx + block numArgs |
|
270 |
]. |
|
271 |
^ self |
|
272 |
codeLoadOn:aStream |
|
273 |
type:#MethodVariable |
|
274 |
index:bvIdx |
|
275 |
inBlock:codeBlock |
|
276 |
for:aCompiler |
|
277 |
]. |
|
278 |
||
279 |
"/ a var of a block which is inlined in the outer block. |
|
280 |
"/ Generate a pushBVAR |
|
281 |
||
282 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
283 |
type == #BlockVariable ifTrue:[ |
|
284 |
bvIdx := bvIdx + block numArgs |
|
285 |
]. |
|
286 |
bvTyp := #BlockVariable. |
|
287 |
] ifFalse:[ |
|
288 |
block isInlineBlock ifTrue:[ |
|
289 |
"/ a var of a block which is inlined in another block. |
|
290 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
291 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
292 |
type == #BlockVariable ifTrue:[ |
|
293 |
bvIdx := bvIdx + block numArgs |
|
294 |
]. |
|
295 |
bvTyp := #BlockVariable. |
|
296 |
] |
|
554 | 297 |
]. |
298 |
||
559 | 299 |
(bvTyp == #BlockVariable) ifTrue:[ |
554 | 300 |
(deltaLevel == 0) ifTrue:[ |
559 | 301 |
bvIdx <= 3 ifTrue:[ |
302 |
aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:bvIdx). |
|
554 | 303 |
^ self |
304 |
]. |
|
305 |
aStream nextPut:#pushBlockVar. |
|
306 |
] ifFalse:[ |
|
307 |
aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
308 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
309 |
] ifFalse:[ |
554 | 310 |
(deltaLevel == 0) ifTrue:[ |
559 | 311 |
(bvIdx <= 4) ifTrue:[ |
312 |
aStream nextPut:(#(pushBlockArg1 pushBlockArg2 pushBlockArg3 |
|
313 |
pushBlockArg4) at:bvIdx). |
|
554 | 314 |
^ self |
315 |
]. |
|
316 |
aStream nextPut:#pushBlockArg. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
317 |
] ifFalse:[ |
554 | 318 |
(deltaLevel == 1) ifTrue:[ |
319 |
aStream nextPut:#pushOuter1BlockArg |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
320 |
] ifFalse:[ |
554 | 321 |
(deltaLevel == 2) ifTrue:[ |
322 |
aStream nextPut:#pushOuter2BlockArg |
|
323 |
] ifFalse:[ |
|
324 |
aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel |
|
325 |
] |
|
326 |
]. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
327 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
328 |
]. |
559 | 329 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
330 |
^ self |
14 | 331 |
]. |
554 | 332 |
|
14 | 333 |
(type == #GlobalVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
334 |
litIndex := aCompiler addLiteral:name asSymbol. |
531 | 335 |
specialGlobalIndex := aCompiler specialGlobalCodeFor:name. |
336 |
specialGlobalIndex notNil ifTrue:[ |
|
337 |
aStream nextPut:#pushSpecialGlobal; nextPut:specialGlobalIndex. |
|
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
338 |
^ self |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
339 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
340 |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
341 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
342 |
aStream nextPut:#pushGlobalS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
343 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
344 |
aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
345 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
346 |
^ self |
14 | 347 |
]. |
554 | 348 |
|
360 | 349 |
(type == #ClassVariable) ifTrue:[ |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
350 |
litIndex := aCompiler addLiteral:(value name , ':' , name) asSymbol. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
351 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
352 |
aStream nextPut:#pushClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
353 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
354 |
aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
355 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
356 |
^ self |
14 | 357 |
]. |
554 | 358 |
|
360 | 359 |
(type == #PrivateClass) ifTrue:[ |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
360 |
litIndex := aCompiler addLiteral:(value name , '::' , name) asSymbol. |
360 | 361 |
litIndex < 256 ifTrue:[ |
362 |
aStream nextPut:#pushGlobalS; nextPut:litIndex |
|
363 |
] ifFalse:[ |
|
364 |
aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0 |
|
365 |
]. |
|
366 |
^ self |
|
367 |
]. |
|
14 | 368 |
|
369 |
(type == #ClassInstanceVariable) ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
370 |
aStream nextPut:#pushClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
371 |
^ self |
14 | 372 |
]. |
554 | 373 |
|
14 | 374 |
(type == #ThisContext) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
375 |
aStream nextPut:#pushThisContext. ^ self |
14 | 376 |
]. |
377 |
||
378 |
"not reached" |
|
379 |
self halt:'bad type'. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
380 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
381 |
"Created: / 25.6.1997 / 16:14:17 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
382 |
"Modified: / 17.1.1998 / 04:04:17 / cg" |
559 | 383 |
! |
384 |
||
385 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
|
386 |
self |
|
387 |
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler |
|
388 |
||
389 |
"Modified: 26.6.1997 / 10:06:10 / cg" |
|
14 | 390 |
! |
391 |
||
104 | 392 |
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
559 | 393 |
self |
394 |
codeStoreOn:aStream type:type index:index |
|
395 |
inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
396 |
||
397 |
"Modified: 25.6.1997 / 16:15:28 / cg" |
|
398 |
! |
|
399 |
||
400 |
codeStoreOn:aStream type:type index:index inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
401 |
|theCode b deltaLevel litIndex bvIdx blocksCode| |
|
14 | 402 |
|
403 |
valueNeeded ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
404 |
aStream nextPut:#dup |
14 | 405 |
]. |
554 | 406 |
|
14 | 407 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
408 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
409 |
theCode := #(storeMethodVar1 storeMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
410 |
storeMethodVar3 storeMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
411 |
storeMethodVar5 storeMethodVar6) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
412 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
413 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
414 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
415 |
aStream nextPut:#storeMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
416 |
^ self |
14 | 417 |
]. |
554 | 418 |
|
14 | 419 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
420 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
421 |
theCode := #(storeInstVar1 storeInstVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
422 |
storeInstVar3 storeInstVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
423 |
storeInstVar5 storeInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
424 |
storeInstVar7 storeInstVar8 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
425 |
storeInstVar9 storeInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
426 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
427 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
428 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
429 |
aStream nextPut:#storeInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
430 |
^ self |
14 | 431 |
]. |
554 | 432 |
|
14 | 433 |
(type == #BlockVariable) ifTrue:[ |
559 | 434 |
bvIdx := index. |
435 |
||
436 |
"/ find the context where that variable is contained physically |
|
437 |
blocksCode := block. |
|
438 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
439 |
blocksCode := blocksCode home |
|
440 |
]. |
|
441 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
442 |
"find deltaLevel to block, where variable was defined" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
443 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
444 |
deltaLevel := 0. |
559 | 445 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 446 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
447 |
deltaLevel := deltaLevel + 1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
448 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
449 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
450 |
]. |
14 | 451 |
|
559 | 452 |
b isNil ifTrue:[ |
453 |
codeBlock isNil ifTrue:[ |
|
454 |
"/ a block which is inlined in the method. |
|
455 |
"/ Generate a pushMVAR |
|
456 |
||
457 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
458 |
bvIdx := bvIdx + block numArgs. |
|
459 |
^ self |
|
460 |
codeStoreOn:aStream |
|
461 |
type:#MethodVariable index:bvIdx |
|
462 |
inBlock:codeBlock |
|
463 |
valueNeeded:false "/ already dupped if value is needed |
|
464 |
for:aCompiler |
|
465 |
]. |
|
466 |
"/ a var of a block which is inlined in the outer block. |
|
467 |
"/ Generate a pushBVAR |
|
468 |
||
469 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
470 |
bvIdx := bvIdx + block numArgs. |
|
471 |
] ifFalse:[ |
|
472 |
block isInlineBlock ifTrue:[ |
|
473 |
"/ a var of a block which is inlined in another block. |
|
474 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
475 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
476 |
bvIdx := bvIdx + block numArgs. |
|
477 |
] |
|
478 |
]. |
|
479 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
480 |
(deltaLevel == 0) ifTrue:[ |
559 | 481 |
bvIdx <= 3 ifTrue:[ |
482 |
aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:bvIdx). |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
483 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
484 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
485 |
aStream nextPut:#storeBlockVar |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
486 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
487 |
aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
488 |
]. |
559 | 489 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
490 |
^ self |
14 | 491 |
]. |
554 | 492 |
|
117 | 493 |
(type == #GlobalVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
494 |
litIndex := aCompiler addLiteral:name asSymbol. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
495 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
496 |
aStream nextPut:#storeGlobalS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
497 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
498 |
aStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
499 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
500 |
^ self |
117 | 501 |
]. |
554 | 502 |
|
14 | 503 |
(type == #ClassVariable) ifTrue:[ |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
504 |
litIndex := aCompiler addLiteral:(value name , ':' , name) asSymbol. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
505 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
506 |
aStream nextPut:#storeClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
507 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
508 |
aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
509 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
510 |
^ self |
14 | 511 |
]. |
554 | 512 |
|
14 | 513 |
(type == #ClassInstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
514 |
aStream nextPut:#storeClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
515 |
^ self |
14 | 516 |
]. |
554 | 517 |
|
106 | 518 |
"not reached" |
14 | 519 |
^ self error:'bad assignment' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
520 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
521 |
"Created: / 25.6.1997 / 16:14:40 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
522 |
"Modified: / 17.1.1998 / 04:04:23 / cg" |
14 | 523 |
! ! |
524 |
||
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
525 |
!VariableNode methodsFor:'enumeration'! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
526 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
527 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
528 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
529 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
530 |
^ anEnumerator doVariable:self name:name |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
531 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
532 |
"Created: 19.6.1997 / 16:41:35 / cg" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
533 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
534 |
|
140 | 535 |
!VariableNode methodsFor:'evaluating'! |
536 |
||
537 |
evaluate |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
538 |
(type == #ContextVariable) ifTrue:[ |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
539 |
^ value at:index |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
540 |
]. |
140 | 541 |
(type == #MethodVariable |
542 |
or:[type == #BlockArg |
|
543 |
or:[type == #BlockVariable]]) ifTrue:[ |
|
420 | 544 |
^ token variableValue |
140 | 545 |
]. |
546 |
(type == #InstanceVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
547 |
^ value instVarAt:index |
140 | 548 |
]. |
549 |
(type == #GlobalVariable) ifTrue:[ |
|
420 | 550 |
(Smalltalk includesKey:name) ifTrue:[ |
551 |
^ Smalltalk at:name |
|
552 |
]. |
|
140 | 553 |
" |
420 | 554 |
self error:('global ' , name , ' is undefined'). |
140 | 555 |
" |
556 |
||
420 | 557 |
^ UndefinedVariable name:name. |
558 |
^ nil |
|
140 | 559 |
]. |
560 |
(type == #ClassVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
561 |
^ Smalltalk at:(value name , ':' , name) asSymbol |
140 | 562 |
]. |
563 |
(type == #ClassInstanceVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
564 |
^ value instVarAt:index |
140 | 565 |
]. |
566 |
(type == #ThisContext) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
567 |
value notNil ifTrue:[ |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
568 |
^ value |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
569 |
]. |
420 | 570 |
^ thisContext |
571 |
]. |
|
572 |
(type == #PrivateClass) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
573 |
^ value privateClassesAt:name asSymbol |
140 | 574 |
]. |
719 | 575 |
|
576 |
"/ synthetic; for evaluation only |
|
577 |
(type == #EvaluationContextLocal) ifTrue:[ |
|
578 |
^ token variableValue |
|
579 |
]. |
|
580 |
||
581 |
||
140 | 582 |
"not reached" |
719 | 583 |
self halt:'internal error - bad variable type:' , type. |
140 | 584 |
^ value |
420 | 585 |
|
719 | 586 |
"Modified: / 16.5.1998 / 18:35:00 / cg" |
140 | 587 |
! |
588 |
||
589 |
store:aValue |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
590 |
(type == #ContextVariable) ifTrue:[ |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
591 |
value at:index put:aValue. ^ aValue |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
592 |
]. |
140 | 593 |
(type == #MethodVariable |
594 |
or:[type == #BlockVariable]) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
595 |
token value:aValue. ^ aValue |
140 | 596 |
]. |
597 |
(type == #InstanceVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
598 |
^ value instVarAt:index put:aValue |
140 | 599 |
]. |
600 |
(type == #GlobalVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
601 |
^ Smalltalk at:name put:aValue |
140 | 602 |
]. |
603 |
(type == #ClassVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
604 |
^ Smalltalk at:(value name , ':' , name) asSymbol put:aValue |
140 | 605 |
]. |
606 |
(type == #ClassInstanceVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
607 |
^ value instVarAt:index put:aValue |
140 | 608 |
]. |
719 | 609 |
|
610 |
"/ synthetic; for evaluation only |
|
611 |
(type == #EvaluationContextLocal) ifTrue:[ |
|
612 |
^ token value:aValue. ^ aValue |
|
613 |
]. |
|
614 |
||
140 | 615 |
"not reached" |
719 | 616 |
self halt:'internal error - bad variable type:' , type. |
140 | 617 |
^ aValue |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
618 |
|
719 | 619 |
"Modified: / 16.5.1998 / 18:35:03 / cg" |
140 | 620 |
! ! |
621 |
||
14 | 622 |
!VariableNode methodsFor:'printing'! |
623 |
||
624 |
displayString |
|
612 | 625 |
"return a string for display in inspectors etc." |
626 |
||
14 | 627 |
^ 'InterpreterVariable(' , self printString , ')' |
612 | 628 |
|
629 |
"Modified: 20.9.1997 / 11:42:07 / cg" |
|
14 | 630 |
! |
631 |
||
632 |
printOn:aStream indent:i |
|
98 | 633 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
634 |
"/ actually only a debug-check |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
635 |
( |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
636 |
type == #ContextVariable |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
637 |
or:[type == #MethodArg |
98 | 638 |
or:[type == #MethodVariable |
639 |
or:[type == #InstanceVariable |
|
640 |
or:[type == #BlockArg |
|
641 |
or:[type == #GlobalVariable |
|
642 |
or:[type == #ClassVariable |
|
643 |
or:[type == #BlockVariable |
|
465 | 644 |
or:[type == #PrivateClass |
720 | 645 |
or:[type == #EvaluationContextLocal |
646 |
or:[type == #ClassInstanceVariable]]]]]]]]]]) ifTrue:[ |
|
465 | 647 |
aStream nextPutAll:name. ^ self |
14 | 648 |
]. |
649 |
(type == #ThisContext) ifTrue:[ |
|
465 | 650 |
aStream nextPutAll:'thisContext'. ^ self |
14 | 651 |
]. |
652 |
"not reached" |
|
653 |
self halt:'bad type'. |
|
465 | 654 |
|
720 | 655 |
"Modified: / 17.5.1998 / 00:17:12 / cg" |
14 | 656 |
! ! |
140 | 657 |
|
658 |
!VariableNode methodsFor:'queries'! |
|
659 |
||
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
660 |
canReuseAsArg:anotherNode |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
661 |
anotherNode isVariable ifTrue:[ |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
662 |
anotherNode type ~~ type ifTrue:[^ false]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
663 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
664 |
(type == #ThisContext) ifTrue:[^ true]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
665 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
666 |
index notNil ifTrue:[ |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
667 |
anotherNode index ~~ index ifTrue:[^ false]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
668 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
669 |
(type == #MethodArg) ifTrue:[^ true]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
670 |
(type == #MethodVariable) ifTrue:[^ true]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
671 |
(type == #InstanceVariable) ifTrue:[^ true]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
672 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
673 |
name notNil ifTrue:[ |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
674 |
anotherNode name ~~ name ifTrue:[^ false]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
675 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
676 |
(type == #GlobalVariable) ifTrue:[^ true]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
677 |
(type == #ClassVariable) ifTrue:[^ true]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
678 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
679 |
^ false |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
680 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
681 |
"Created: 14.4.1996 / 00:46:18 / cg" |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
682 |
"Modified: 14.4.1996 / 00:55:25 / cg" |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
683 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
684 |
|
566 | 685 |
isArgument |
686 |
"return true, if this is a node for an argument (block or method)" |
|
687 |
||
688 |
^ (type == #MethodArg) or:[type == #BlockArg] |
|
689 |
||
690 |
"Created: 27.6.1997 / 13:07:05 / cg" |
|
691 |
"Modified: 27.6.1997 / 13:07:19 / cg" |
|
692 |
! |
|
693 |
||
140 | 694 |
isGlobal |
695 |
"return true, if this is a node for a global variable" |
|
696 |
||
697 |
^ (type == #GlobalVariable) and:[Smalltalk includesKey:name] |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
698 |
! |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
699 |
|
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
700 |
isLocal |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
701 |
"return true, if this is a node for a local (block or method) variable" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
702 |
|
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
703 |
^ (type == #MethodVariable) or:[type == #BlockVariable] |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
704 |
|
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
705 |
"Created: 1.3.1996 / 00:03:53 / cg" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
706 |
"Modified: 1.3.1996 / 00:04:46 / cg" |
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
707 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
708 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
709 |
isVariable |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
710 |
"return true, if this is a node for a variable" |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
711 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
712 |
^ true |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
713 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
714 |
"Created: 14.4.1996 / 00:46:32 / cg" |
140 | 715 |
! ! |
716 |
||
360 | 717 |
!VariableNode class methodsFor:'documentation'! |
148 | 718 |
|
719 |
version |
|
720 | 720 |
^ '$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.37 1998-05-17 18:15:51 cg Exp $' |
148 | 721 |
! ! |