author | Claus Gittinger <cg@exept.de> |
Mon, 05 Mar 2007 13:35:32 +0100 | |
changeset 1997 | 4ec97f7ce416 |
parent 1996 | 6d70e53e9f14 |
child 2066 | 9873763eb1f8 |
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 |
" |
|
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
12 |
"{ Package: 'stx:libcomp' }" |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
13 |
|
14 | 14 |
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
|
15 |
instanceVariableNames:'name token index block' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
16 |
classVariableNames:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
17 |
poolDictionaries:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
18 |
category:'System-Compiler-Support' |
14 | 19 |
! |
20 |
||
360 | 21 |
!VariableNode class methodsFor:'documentation'! |
20 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
53 | 26 |
All Rights Reserved |
20 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
node for parse-trees, representing variables |
|
261 | 40 |
This is a helper class for the compiler. |
263 | 41 |
|
42 |
[author:] |
|
43 |
Claus Gittinger |
|
20 | 44 |
" |
45 |
! ! |
|
14 | 46 |
|
360 | 47 |
!VariableNode class methodsFor:'instance creation'! |
14 | 48 |
|
1932 | 49 |
blockArgumentNamed:n |
50 |
^ (self basicNew) type:#BlockArg name:n asSymbol |
|
51 |
||
52 |
"Created: / 22-10-2006 / 11:59:10 / cg" |
|
53 |
! |
|
54 |
||
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
55 |
globalNamed:n |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
56 |
^ (self basicNew) type:#GlobalVariable name:n asSymbol |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
57 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
58 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
59 |
methodArgumentNamed:n |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
60 |
^ (self basicNew) type:#MethodArg name:n asSymbol |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
61 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
62 |
"Created: / 06-08-2006 / 01:12:55 / cg" |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
63 |
! |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
64 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
65 |
methodLocalNamed:n |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
66 |
^ (self basicNew) type:#MethodVariable name:n asSymbol |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
67 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
68 |
"Created: / 06-08-2006 / 13:43:41 / cg" |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
69 |
! |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
70 |
|
98 | 71 |
type:t class:class name:n |
72 |
^ (self basicNew) type:t class:class name:n |
|
73 |
! |
|
74 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
75 |
type:t context:aContext |
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
76 |
^ (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
|
77 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
78 |
"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
|
79 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
80 |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
81 |
type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
82 |
^ (self basicNew) type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
83 |
! |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
84 |
|
140 | 85 |
type:t name:n |
86 |
^ (self basicNew) type:t name:n |
|
87 |
! |
|
88 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
89 |
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
|
90 |
^ (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
|
91 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
92 |
"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
|
93 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
94 |
|
140 | 95 |
type:t name:n index:i selfClass:s |
96 |
^ (self basicNew) type:t name:n index:i selfClass:s |
|
97 |
! |
|
98 |
||
99 |
type:t name:n index:i selfValue:s |
|
100 |
^ (self basicNew) type:t name:n index:i selfValue:s |
|
14 | 101 |
! |
102 |
||
103 |
type:t name:n token:tok index:i |
|
104 |
^ (self basicNew) type:t name:n token:tok index:i |
|
105 |
! |
|
106 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
107 |
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
|
108 |
^ (self basicNew) type:t name:n token:tok index:i block:b from:codeBlock |
14 | 109 |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
110 |
"Modified: 2.7.1997 / 10:55:48 / cg" |
14 | 111 |
! ! |
112 |
||
113 |
!VariableNode methodsFor:'accessing'! |
|
114 |
||
577 | 115 |
block |
116 |
^ block |
|
117 |
||
118 |
"Created: 2.7.1997 / 18:53:38 / cg" |
|
119 |
! |
|
120 |
||
140 | 121 |
index |
122 |
^ index |
|
14 | 123 |
! |
124 |
||
140 | 125 |
name |
126 |
^ name |
|
14 | 127 |
! |
128 |
||
875 | 129 |
token |
130 |
^ token |
|
131 |
||
132 |
"Created: 2.7.1997 / 18:53:38 / cg" |
|
133 |
! |
|
134 |
||
869 | 135 |
type |
136 |
^ type |
|
137 |
! |
|
138 |
||
140 | 139 |
type:t class:class name:n |
14 | 140 |
type := t. |
140 | 141 |
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
|
142 |
value := class |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
143 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
144 |
"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
|
145 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
146 |
|
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
147 |
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
|
148 |
type := t. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
149 |
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
|
150 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
151 |
"Modified: / 17.1.1998 / 04:01:55 / cg" |
14 | 152 |
! |
153 |
||
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
154 |
type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
155 |
type := t. |
875 | 156 |
token := holder. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
157 |
name := n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
158 |
! |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
159 |
|
140 | 160 |
type:t name:n |
98 | 161 |
type := t. |
162 |
value := nil. |
|
14 | 163 |
name := n |
164 |
! |
|
165 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
166 |
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
|
167 |
type := t. |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
168 |
index := i. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
169 |
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
|
170 |
name := n |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
171 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
172 |
"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
|
173 |
"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
|
174 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
175 |
|
14 | 176 |
type:t name:n index:i selfClass:s |
177 |
type := t. |
|
178 |
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
|
179 |
value := s. |
14 | 180 |
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
|
181 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
182 |
"Modified: / 17.1.1998 / 04:04:04 / cg" |
14 | 183 |
! |
184 |
||
140 | 185 |
type:t name:n index:i selfValue:s |
186 |
type := t. |
|
187 |
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
|
188 |
value := s. |
140 | 189 |
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
|
190 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
191 |
"Modified: / 17.1.1998 / 04:02:58 / cg" |
140 | 192 |
! |
193 |
||
14 | 194 |
type:t name:n token:tok index:i |
195 |
type := t. |
|
196 |
index := i. |
|
197 |
token := tok. |
|
198 |
name := n |
|
199 |
! |
|
200 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
201 |
type:t name:n token:tok index:i block:variableBlock from:codeBlock |
14 | 202 |
type := t. |
203 |
index := i. |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
204 |
block := variableBlock. |
14 | 205 |
token := tok. |
535 | 206 |
name := n. |
207 |
(type == #BlockArg) ifTrue:[ |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
208 |
variableBlock blockArgAccessed:true. |
535 | 209 |
]. |
210 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
211 |
codeBlock ~~ variableBlock ifTrue:[ |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
212 |
codeBlock rememberOuterBlockVarAccess:self |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
213 |
] |
140 | 214 |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
215 |
"Created: 2.7.1997 / 10:54:50 / cg" |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
216 |
"Modified: 2.7.1997 / 11:12:58 / cg" |
14 | 217 |
! |
218 |
||
140 | 219 |
type:t token:tok index:i block:b |
220 |
type := t. |
|
221 |
index := i. |
|
222 |
block := b. |
|
535 | 223 |
token := tok. |
224 |
||
225 |
(type == #BlockArg) ifTrue:[ |
|
226 |
b blockArgAccessed:true. |
|
227 |
]. |
|
228 |
||
229 |
"Modified: 18.6.1997 / 11:41:05 / cg" |
|
14 | 230 |
! ! |
231 |
||
232 |
!VariableNode methodsFor:'code generation'! |
|
233 |
||
104 | 234 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
14 | 235 |
"no code at all" |
236 |
^ self |
|
237 |
! |
|
238 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
239 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
240 |
|code idx| |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
241 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
242 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
243 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
244 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
245 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
246 |
(type == #InstanceVariable) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
247 |
(index <= 8) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
248 |
code := #( retInstVar1 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
249 |
retInstVar2 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
250 |
retInstVar3 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
251 |
retInstVar4 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
252 |
retInstVar5 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
253 |
retInstVar6 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
254 |
retInstVar7 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
255 |
retInstVar8) at:index. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
256 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
257 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
258 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
259 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
260 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
261 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
262 |
(type == #MethodVariable) ifTrue:[ |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
263 |
idx := index. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
264 |
idx isNil ifTrue:[ idx := self indexIn: aCompiler ]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
265 |
(idx <= 6) ifTrue:[ |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
266 |
code := #( retMethodVar1 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
267 |
retMethodVar2 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
268 |
retMethodVar3 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
269 |
retMethodVar4 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
270 |
retMethodVar5 |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
271 |
retMethodVar6) at:idx. |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
272 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
273 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
274 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
275 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
276 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
277 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
278 |
(type == #MethodArg) ifTrue:[ |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
279 |
idx := index. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
280 |
idx isNil ifTrue:[ idx := self indexIn: aCompiler ]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
281 |
(idx <= 2) ifTrue:[ |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
282 |
code := #(retMethodArg1 |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
283 |
retMethodArg2) at:idx. |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
284 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
285 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
286 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
287 |
] |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
288 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
289 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
290 |
"/ anything else must be pushed, then top rturned |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
291 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
292 |
self codeOn:aStream inBlock:b for:aCompiler. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
293 |
aStream nextPut:#retTop |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
294 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
295 |
"Modified: / 06-08-2006 / 22:59:28 / cg" |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
296 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
297 |
|
559 | 298 |
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler |
299 |
|theCode b deltaLevel litIndex specialGlobalIndex |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
300 |
bvIdx bvTyp blocksCode selLitIdx | |
14 | 301 |
|
302 |
(type == #MethodArg) ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
303 |
(index <= 4) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
304 |
aStream nextPut:(#(pushMethodArg1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
305 |
pushMethodArg2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
306 |
pushMethodArg3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
307 |
pushMethodArg4) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
308 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
309 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
310 |
aStream nextPut:#pushMethodArg; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
311 |
^ self |
14 | 312 |
]. |
554 | 313 |
|
14 | 314 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
315 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
316 |
aStream nextPut:(#(pushMethodVar1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
317 |
pushMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
318 |
pushMethodVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
319 |
pushMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
320 |
pushMethodVar5 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
321 |
pushMethodVar6) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
322 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
323 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
324 |
aStream nextPut:#pushMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
325 |
^ self |
14 | 326 |
]. |
554 | 327 |
|
14 | 328 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
329 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
330 |
theCode := #(pushInstVar1 pushInstVar2 pushInstVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
331 |
pushInstVar4 pushInstVar5 pushInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
332 |
pushInstVar7 pushInstVar8 pushInstVar9 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
333 |
pushInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
334 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
335 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
336 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
337 |
aStream nextPut:#pushInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
338 |
^ self |
14 | 339 |
]. |
554 | 340 |
|
341 |
((type == #BlockArg) |
|
342 |
or:[type == #BlockVariable]) ifTrue:[ |
|
559 | 343 |
"/ compiling for codeBlock; accessing variable in block. |
344 |
||
345 |
bvIdx := index. |
|
346 |
bvTyp := type. |
|
347 |
||
348 |
"/ find the context where that variable is contained physically |
|
349 |
blocksCode := block. |
|
350 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
351 |
blocksCode := blocksCode home |
|
352 |
]. |
|
353 |
||
354 |
"/ find deltaLevel from code-context to the containing block |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
355 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
356 |
deltaLevel := 0. |
559 | 357 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 358 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
359 |
deltaLevel := deltaLevel + 1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
360 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
361 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
362 |
]. |
535 | 363 |
|
559 | 364 |
b isNil ifTrue:[ |
365 |
codeBlock isNil ifTrue:[ |
|
366 |
"/ a var of a block which is inlined in the method. |
|
367 |
"/ Generate a pushMVAR |
|
368 |
||
369 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
370 |
type == #BlockVariable ifTrue:[ |
|
371 |
bvIdx := bvIdx + block numArgs |
|
372 |
]. |
|
373 |
^ self |
|
374 |
codeLoadOn:aStream |
|
375 |
type:#MethodVariable |
|
376 |
index:bvIdx |
|
377 |
inBlock:codeBlock |
|
378 |
for:aCompiler |
|
379 |
]. |
|
380 |
||
381 |
"/ a var of a block which is inlined in the outer block. |
|
382 |
"/ Generate a pushBVAR |
|
383 |
||
384 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
385 |
type == #BlockVariable ifTrue:[ |
|
386 |
bvIdx := bvIdx + block numArgs |
|
387 |
]. |
|
388 |
bvTyp := #BlockVariable. |
|
389 |
] ifFalse:[ |
|
390 |
block isInlineBlock ifTrue:[ |
|
391 |
"/ a var of a block which is inlined in another block. |
|
392 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
393 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
394 |
type == #BlockVariable ifTrue:[ |
|
395 |
bvIdx := bvIdx + block numArgs |
|
396 |
]. |
|
397 |
bvTyp := #BlockVariable. |
|
398 |
] |
|
554 | 399 |
]. |
400 |
||
559 | 401 |
(bvTyp == #BlockVariable) ifTrue:[ |
554 | 402 |
(deltaLevel == 0) ifTrue:[ |
559 | 403 |
bvIdx <= 3 ifTrue:[ |
404 |
aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:bvIdx). |
|
554 | 405 |
^ self |
406 |
]. |
|
407 |
aStream nextPut:#pushBlockVar. |
|
408 |
] ifFalse:[ |
|
409 |
aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
410 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
411 |
] ifFalse:[ |
554 | 412 |
(deltaLevel == 0) ifTrue:[ |
559 | 413 |
(bvIdx <= 4) ifTrue:[ |
414 |
aStream nextPut:(#(pushBlockArg1 pushBlockArg2 pushBlockArg3 |
|
415 |
pushBlockArg4) at:bvIdx). |
|
554 | 416 |
^ self |
417 |
]. |
|
418 |
aStream nextPut:#pushBlockArg. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
419 |
] ifFalse:[ |
554 | 420 |
(deltaLevel == 1) ifTrue:[ |
421 |
aStream nextPut:#pushOuter1BlockArg |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
422 |
] ifFalse:[ |
554 | 423 |
(deltaLevel == 2) ifTrue:[ |
424 |
aStream nextPut:#pushOuter2BlockArg |
|
425 |
] ifFalse:[ |
|
426 |
aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel |
|
427 |
] |
|
428 |
]. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
429 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
430 |
]. |
559 | 431 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
432 |
^ self |
14 | 433 |
]. |
554 | 434 |
|
14 | 435 |
(type == #GlobalVariable) ifTrue:[ |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
436 |
"for browsing, we put it into the literal-array; even if its a specal global" |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
437 |
litIndex := aCompiler addLiteral:name asSymbol. |
531 | 438 |
specialGlobalIndex := aCompiler specialGlobalCodeFor:name. |
439 |
specialGlobalIndex notNil ifTrue:[ |
|
440 |
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
|
441 |
^ self |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
442 |
]. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
443 |
self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
444 |
^ self |
14 | 445 |
]. |
554 | 446 |
|
1553 | 447 |
((type == #ClassVariable) or:[ type == #PoolVariable ]) ifTrue:[ |
1314
782d4cc1d588
slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
448 |
litIndex := aCompiler addLiteral:(value globalKeyForClassVar:name). |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
449 |
litIndex <= 255 ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
450 |
aStream nextPut:#pushClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
451 |
] ifFalse:[ |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
452 |
litIndex <= 16rFFFF ifTrue:[ |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
453 |
aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0 |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
454 |
] ifFalse:[ |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
455 |
aStream nextPut:#pushClassVarVL; nextPut:0; nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0 |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
456 |
]. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
457 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
458 |
^ self |
14 | 459 |
]. |
554 | 460 |
|
360 | 461 |
(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
|
462 |
litIndex := aCompiler addLiteral:(value name , '::' , name) asSymbol. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
463 |
self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
360 | 464 |
^ self |
465 |
]. |
|
14 | 466 |
|
467 |
(type == #ClassInstanceVariable) ifTrue:[ |
|
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
468 |
"theoretically, this allows for an instance method to access a classInstVar; |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
469 |
However, the parser blocks this and we never arrive here." |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
470 |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
471 |
aStream nextPut:#pushClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
472 |
^ self |
14 | 473 |
]. |
554 | 474 |
|
14 | 475 |
(type == #ThisContext) ifTrue:[ |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
476 |
aStream nextPut:#pushThisContext. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
477 |
^ self |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
478 |
]. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
479 |
|
1296 | 480 |
(type == #WorkspaceVariable |
481 |
or:[type == #DoItTemporary]) ifTrue:[ |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
482 |
"/ this is done by keeping the valueHolder in the literalArray, |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
483 |
"/ and coding a #value message here. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
484 |
|
875 | 485 |
litIndex := aCompiler addLiteral:token. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
486 |
self emitPushLiteralIndex:litIndex on:aStream for:aCompiler. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
487 |
|
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
488 |
selLitIdx := aCompiler addLiteral:#value. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
489 |
self emitSendLiteralIndex:selLitIdx numArgs:0 line:("lineNr ?" 1) on:aStream. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
490 |
^ self |
14 | 491 |
]. |
492 |
||
493 |
"not reached" |
|
1462 | 494 |
self error:'bad type'. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
495 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
496 |
"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
|
497 |
"Modified: / 17.1.1998 / 04:04:17 / cg" |
559 | 498 |
! |
499 |
||
500 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
501 |
|idx| |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
502 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
503 |
idx := (index isNil) |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
504 |
ifTrue:[ self indexIn: aCompiler ] |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
505 |
ifFalse:[ index ]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
506 |
|
559 | 507 |
self |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
508 |
codeLoadOn:aStream type:type index:idx inBlock:codeBlock for:aCompiler |
559 | 509 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
510 |
"Modified: / 06-08-2006 / 16:04:54 / cg" |
14 | 511 |
! |
512 |
||
104 | 513 |
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
514 |
|idx| |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
515 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
516 |
idx := (index isNil) |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
517 |
ifTrue:[ self indexIn: aCompiler ] |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
518 |
ifFalse:[ index ]. |
1821 | 519 |
idx == 0 ifTrue:[ |
520 |
self error |
|
521 |
]. |
|
559 | 522 |
self |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
523 |
codeStoreOn:aStream type:type index:idx |
559 | 524 |
inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
525 |
||
1821 | 526 |
"Modified: / 12-08-2006 / 15:54:52 / cg" |
559 | 527 |
! |
528 |
||
529 |
codeStoreOn:aStream type:type index:index inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
1296 | 530 |
|theCode b deltaLevel litIndex bvIdx blocksCode selLitIdx| |
14 | 531 |
|
1296 | 532 |
"/ value to be stored is on TOP of stack. |
14 | 533 |
valueNeeded ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
534 |
aStream nextPut:#dup |
14 | 535 |
]. |
554 | 536 |
|
14 | 537 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
538 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
539 |
theCode := #(storeMethodVar1 storeMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
540 |
storeMethodVar3 storeMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
541 |
storeMethodVar5 storeMethodVar6) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
542 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
543 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
544 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
545 |
aStream nextPut:#storeMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
546 |
^ self |
14 | 547 |
]. |
554 | 548 |
|
14 | 549 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
550 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
551 |
theCode := #(storeInstVar1 storeInstVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
552 |
storeInstVar3 storeInstVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
553 |
storeInstVar5 storeInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
554 |
storeInstVar7 storeInstVar8 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
555 |
storeInstVar9 storeInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
556 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
557 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
558 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
559 |
aStream nextPut:#storeInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
560 |
^ self |
14 | 561 |
]. |
554 | 562 |
|
14 | 563 |
(type == #BlockVariable) ifTrue:[ |
559 | 564 |
bvIdx := index. |
565 |
||
566 |
"/ find the context where that variable is contained physically |
|
567 |
blocksCode := block. |
|
568 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
569 |
blocksCode := blocksCode home |
|
570 |
]. |
|
571 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
572 |
"find deltaLevel to block, where variable was defined" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
573 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
574 |
deltaLevel := 0. |
559 | 575 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 576 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
577 |
deltaLevel := deltaLevel + 1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
578 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
579 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
580 |
]. |
14 | 581 |
|
559 | 582 |
b isNil ifTrue:[ |
583 |
codeBlock isNil ifTrue:[ |
|
584 |
"/ a block which is inlined in the method. |
|
585 |
"/ Generate a pushMVAR |
|
586 |
||
587 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
588 |
bvIdx := bvIdx + block numArgs. |
|
589 |
^ self |
|
590 |
codeStoreOn:aStream |
|
591 |
type:#MethodVariable index:bvIdx |
|
592 |
inBlock:codeBlock |
|
593 |
valueNeeded:false "/ already dupped if value is needed |
|
594 |
for:aCompiler |
|
595 |
]. |
|
596 |
"/ a var of a block which is inlined in the outer block. |
|
597 |
"/ Generate a pushBVAR |
|
598 |
||
599 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
600 |
bvIdx := bvIdx + block numArgs. |
|
601 |
] ifFalse:[ |
|
602 |
block isInlineBlock ifTrue:[ |
|
603 |
"/ a var of a block which is inlined in another block. |
|
604 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
605 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
606 |
bvIdx := bvIdx + block numArgs. |
|
607 |
] |
|
608 |
]. |
|
609 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
610 |
(deltaLevel == 0) ifTrue:[ |
559 | 611 |
bvIdx <= 3 ifTrue:[ |
612 |
aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:bvIdx). |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
613 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
614 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
615 |
aStream nextPut:#storeBlockVar |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
616 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
617 |
aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
618 |
]. |
559 | 619 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
620 |
^ self |
14 | 621 |
]. |
554 | 622 |
|
117 | 623 |
(type == #GlobalVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
624 |
litIndex := aCompiler addLiteral:name asSymbol. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
625 |
self emitStoreGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
626 |
^ self |
117 | 627 |
]. |
554 | 628 |
|
1553 | 629 |
((type == #ClassVariable) or:[type == #PoolVariable]) ifTrue:[ |
1314
782d4cc1d588
slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
630 |
litIndex := aCompiler addLiteral:(value globalKeyForClassVar:name). |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
631 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
632 |
aStream nextPut:#storeClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
633 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
634 |
aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
635 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
636 |
^ self |
14 | 637 |
]. |
554 | 638 |
|
14 | 639 |
(type == #ClassInstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
640 |
aStream nextPut:#storeClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
641 |
^ self |
14 | 642 |
]. |
554 | 643 |
|
1296 | 644 |
(type == #WorkspaceVariable |
645 |
or:[type == #DoItTemporary]) ifTrue:[ |
|
646 |
"/ this is done by keeping the valueHolder in the literalArray, |
|
647 |
"/ and coding a #value: message here. |
|
648 |
||
649 |
litIndex := aCompiler addLiteral:token. |
|
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
650 |
self emitPushLiteralIndex:litIndex on:aStream for:aCompiler. |
1296 | 651 |
|
652 |
"/ need to exchange top 2 items (sigh - there is no exch instruction) |
|
653 |
"/ now, we have: |
|
654 |
"/ TOS: holder |
|
655 |
"/ NOS: value |
|
656 |
"/ |
|
657 |
"/ for the send, I need them as: |
|
658 |
"/ TOS: value |
|
659 |
"/ NOS: holder |
|
660 |
aStream nextPut:#over. |
|
661 |
"/ now, we have: |
|
662 |
"/ TOS: value |
|
663 |
"/ NOS: holder |
|
664 |
"/ value |
|
665 |
selLitIdx := aCompiler addLiteral:#'value:'. |
|
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
666 |
self emitSendLiteralIndex:selLitIdx numArgs:1 line:("lineNr ?" 1) on:aStream. |
1296 | 667 |
"/ now, we have: |
668 |
"/ TOS: retVal from value: |
|
669 |
"/ NOS: value |
|
670 |
aStream nextPut:#drop. |
|
671 |
aStream nextPut:#drop. |
|
672 |
^ self |
|
673 |
]. |
|
674 |
||
1821 | 675 |
(type == #MethodArg) ifTrue:[ |
676 |
aStream nextPut:#storeLocal; nextPut:index-1. |
|
677 |
^ self |
|
678 |
]. |
|
679 |
||
106 | 680 |
"not reached" |
941 | 681 |
self error:'bad assignment' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
682 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
683 |
"Created: / 25-06-1997 / 16:14:40 / cg" |
1821 | 684 |
"Modified: / 12-08-2006 / 15:53:23 / cg" |
14 | 685 |
! ! |
686 |
||
1035 | 687 |
!VariableNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
688 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
689 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
690 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
691 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
692 |
^ anEnumerator doVariable:self name:name |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
693 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
694 |
"Created: 19.6.1997 / 16:41:35 / cg" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
695 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
696 |
|
1035 | 697 |
!VariableNode methodsFor:'evaluation'! |
140 | 698 |
|
1384 | 699 |
evaluateIn:anEnvironment |
980 | 700 |
|nameSym| |
701 |
||
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
702 |
(type == #ContextVariable) ifTrue:[ |
1137 | 703 |
"/ value method isWrapped ifTrue:[^ nil]. |
1178
f8065fd945a8
care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
704 |
index > value size ifTrue:[ |
f8065fd945a8
care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
705 |
"/ this can happen ,if a wrapped method is not yet entered |
f8065fd945a8
care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
706 |
^ nil |
f8065fd945a8
care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
707 |
]. |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
708 |
^ 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
|
709 |
]. |
140 | 710 |
(type == #MethodVariable |
1384 | 711 |
or:[type == #MethodArg |
140 | 712 |
or:[type == #BlockArg |
1384 | 713 |
or:[type == #BlockVariable]]]) ifTrue:[ |
420 | 714 |
^ token variableValue |
140 | 715 |
]. |
716 |
(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
|
717 |
^ value instVarAt:index |
140 | 718 |
]. |
1088 | 719 |
(type == #JavaVariable) ifTrue:[ |
720 |
nameSym := name asSymbolIfInterned. |
|
721 |
nameSym notNil ifTrue:[ |
|
722 |
^ JAVA at:name |
|
723 |
]. |
|
724 |
^ UndefinedVariable name:name. |
|
725 |
"/ ^ nil |
|
726 |
]. |
|
140 | 727 |
(type == #GlobalVariable) ifTrue:[ |
980 | 728 |
nameSym := name asSymbolIfInterned. |
729 |
nameSym notNil ifTrue:[ |
|
730 |
(Smalltalk includesKey:nameSym) ifTrue:[ |
|
731 |
^ Smalltalk at:name |
|
732 |
] |
|
420 | 733 |
]. |
140 | 734 |
" |
420 | 735 |
self error:('global ' , name , ' is undefined'). |
140 | 736 |
" |
737 |
||
420 | 738 |
^ UndefinedVariable name:name. |
1088 | 739 |
"/ ^ nil |
140 | 740 |
]. |
741 |
(type == #ClassVariable) ifTrue:[ |
|
1314
782d4cc1d588
slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
742 |
^ value classVarAt:name asSymbol |
140 | 743 |
]. |
744 |
(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
|
745 |
^ value instVarAt:index |
140 | 746 |
]. |
747 |
(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
|
748 |
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
|
749 |
^ value |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
750 |
]. |
420 | 751 |
^ thisContext |
752 |
]. |
|
753 |
(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
|
754 |
^ value privateClassesAt:name asSymbol |
140 | 755 |
]. |
1918 | 756 |
(type == #PoolVariable) ifTrue:[ |
757 |
^ value classVarAt:name asSymbol |
|
758 |
]. |
|
719 | 759 |
|
760 |
"/ synthetic; for evaluation only |
|
1179 | 761 |
(type == #EvaluationContextLocal |
762 |
or:[type == #EvaluationContextVar |
|
763 |
or:[type == #EvaluationContextArg]]) ifTrue:[ |
|
719 | 764 |
^ token variableValue |
765 |
]. |
|
1179 | 766 |
|
1092 | 767 |
"/ synthetic; for evaluation only |
1606 | 768 |
((type == #WorkspaceVariable) or:[type == #DoItTemporary]) ifTrue:[ |
1092 | 769 |
^ token value |
770 |
]. |
|
719 | 771 |
|
140 | 772 |
"not reached" |
1320 | 773 |
self error:'internal error - bad variable type:' , type mayProceed:true. |
140 | 774 |
^ value |
420 | 775 |
|
1918 | 776 |
"Modified: / 26-09-1999 / 13:04:42 / cg" |
777 |
"Modified: / 11-09-2006 / 14:22:38 / User" |
|
140 | 778 |
! |
779 |
||
780 |
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
|
781 |
(type == #ContextVariable) ifTrue:[ |
1137 | 782 |
"/ value method isWrapped ifTrue:[ |
783 |
"/ self warn:'The method has not yet been entered (in breakpoint stub)\Please perform a singleStep first' withCRs. |
|
784 |
"/ ^ aValue |
|
785 |
"/ ]. |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
786 |
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
|
787 |
]. |
140 | 788 |
(type == #MethodVariable |
789 |
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
|
790 |
token value:aValue. ^ aValue |
140 | 791 |
]. |
792 |
(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
|
793 |
^ value instVarAt:index put:aValue |
140 | 794 |
]. |
795 |
(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
|
796 |
^ Smalltalk at:name put:aValue |
140 | 797 |
]. |
798 |
(type == #ClassVariable) ifTrue:[ |
|
1314
782d4cc1d588
slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
799 |
^ value classVarAt:name asSymbol put:aValue |
140 | 800 |
]. |
801 |
(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
|
802 |
^ value instVarAt:index put:aValue |
140 | 803 |
]. |
719 | 804 |
|
805 |
"/ synthetic; for evaluation only |
|
806 |
(type == #EvaluationContextLocal) ifTrue:[ |
|
875 | 807 |
token value:aValue. ^ aValue |
808 |
]. |
|
809 |
(type == #WorkspaceVariable) ifTrue:[ |
|
810 |
token value:aValue. ^ aValue |
|
719 | 811 |
]. |
812 |
||
140 | 813 |
"not reached" |
1320 | 814 |
self error:'bad variable node type' mayProceed:true. |
140 | 815 |
^ aValue |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
816 |
|
719 | 817 |
"Modified: / 16.5.1998 / 18:35:03 / cg" |
140 | 818 |
! ! |
819 |
||
1080 | 820 |
!VariableNode methodsFor:'printing & storing'! |
14 | 821 |
|
822 |
displayString |
|
612 | 823 |
"return a string for display in inspectors etc." |
824 |
||
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
825 |
^ 'Variable(' , self printString , ')' |
612 | 826 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
827 |
"Modified: / 06-08-2006 / 15:45:18 / cg" |
14 | 828 |
! |
829 |
||
830 |
printOn:aStream indent:i |
|
98 | 831 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
832 |
"/ 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
|
833 |
( |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
834 |
type == #ContextVariable |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
835 |
or:[type == #MethodArg |
98 | 836 |
or:[type == #MethodVariable |
837 |
or:[type == #InstanceVariable |
|
838 |
or:[type == #BlockArg |
|
839 |
or:[type == #GlobalVariable |
|
1088 | 840 |
or:[type == #JavaVariable |
98 | 841 |
or:[type == #ClassVariable |
842 |
or:[type == #BlockVariable |
|
465 | 843 |
or:[type == #PrivateClass |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
844 |
or:[type == #WorkspaceVariable |
1101 | 845 |
or:[type == #EvaluationContextArg |
720 | 846 |
or:[type == #EvaluationContextLocal |
1101 | 847 |
or:[type == #ClassInstanceVariable]]]]]]]]]]]]]) ifTrue:[ |
465 | 848 |
aStream nextPutAll:name. ^ self |
14 | 849 |
]. |
850 |
(type == #ThisContext) ifTrue:[ |
|
465 | 851 |
aStream nextPutAll:'thisContext'. ^ self |
14 | 852 |
]. |
853 |
"not reached" |
|
1320 | 854 |
self error:'bad variable node type' mayProceed:true. |
465 | 855 |
|
720 | 856 |
"Modified: / 17.5.1998 / 00:17:12 / cg" |
14 | 857 |
! ! |
140 | 858 |
|
859 |
!VariableNode methodsFor:'queries'! |
|
860 |
||
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
861 |
canReuseAsArg:anotherNode |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
862 |
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
|
863 |
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
|
864 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
865 |
(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
|
866 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
867 |
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
|
868 |
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
|
869 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
870 |
(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
|
871 |
(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
|
872 |
(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
|
873 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
874 |
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
|
875 |
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
|
876 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
877 |
(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
|
878 |
(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
|
879 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
880 |
^ false |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
881 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
882 |
"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
|
883 |
"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
|
884 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
885 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
886 |
indexIn: aCompiler |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
887 |
(type == #MethodVariable) ifTrue:[ |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
888 |
^ aCompiler methodVars indexOf:name. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
889 |
]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
890 |
(type == #MethodArg) ifTrue:[ |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
891 |
^ aCompiler methodArgs indexOf:name. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
892 |
]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
893 |
^ index |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
894 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
895 |
"Created: / 06-08-2006 / 16:03:56 / cg" |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
896 |
! |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
897 |
|
566 | 898 |
isArgument |
899 |
"return true, if this is a node for an argument (block or method)" |
|
900 |
||
901 |
^ (type == #MethodArg) or:[type == #BlockArg] |
|
902 |
||
903 |
"Created: 27.6.1997 / 13:07:05 / cg" |
|
904 |
"Modified: 27.6.1997 / 13:07:19 / cg" |
|
905 |
! |
|
906 |
||
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
907 |
isClassVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
908 |
^ type == #ClassVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
909 |
! |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
910 |
|
140 | 911 |
isGlobal |
912 |
"return true, if this is a node for a global variable" |
|
913 |
||
789 | 914 |
|
915 |
^ (type == #GlobalVariable) |
|
916 |
and:[name isSymbol |
|
917 |
and:[Smalltalk includesKey:name]] |
|
918 |
||
919 |
"Modified: / 19.10.1998 / 19:43:04 / cg" |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
920 |
! |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
921 |
|
1997 | 922 |
isGlobalNamed:nameWanted |
1996 | 923 |
"return true, if this is a node for a particular global variable" |
924 |
||
925 |
^ (type == #GlobalVariable) |
|
926 |
and:[name = nameWanted |
|
927 |
and:[name isSymbol |
|
928 |
and:[Smalltalk includesKey:name]]] |
|
929 |
||
1997 | 930 |
"Created: / 05-03-2007 / 13:35:07 / cg" |
1996 | 931 |
! |
932 |
||
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
933 |
isGlobalVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
934 |
^ type == #GlobalVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
935 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
936 |
|
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
937 |
isInstanceVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
938 |
^ type == #InstanceVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
939 |
! |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
940 |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
941 |
isLocal |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
942 |
"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
|
943 |
|
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
944 |
^ (type == #MethodVariable) or:[type == #BlockVariable] |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
945 |
|
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
946 |
"Created: 1.3.1996 / 00:03:53 / cg" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
947 |
"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
|
948 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
949 |
|
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
950 |
isMethodArg |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
951 |
^ type == #MethodArg |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
952 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
953 |
|
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
954 |
isMethodVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
955 |
^ type == #MethodVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
956 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
957 |
|
965 | 958 |
isUndeclared |
959 |
type == #PrivateClass ifTrue:[ |
|
960 |
^ (Smalltalk includesKey:(value name , '::' , name) asSymbol) not |
|
961 |
]. |
|
962 |
type == #GlobalVariable ifTrue:[ |
|
963 |
^ (Smalltalk includesKey:name) not |
|
964 |
]. |
|
965 |
^ false |
|
966 |
! |
|
967 |
||
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
968 |
isVariable |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
969 |
"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
|
970 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
971 |
^ true |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
972 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
973 |
"Created: 14.4.1996 / 00:46:32 / cg" |
140 | 974 |
! ! |
975 |
||
360 | 976 |
!VariableNode class methodsFor:'documentation'! |
148 | 977 |
|
978 |
version |
|
1997 | 979 |
^ '$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.70 2007-03-05 12:35:32 cg Exp $' |
148 | 980 |
! ! |