author | Claus Gittinger <cg@exept.de> |
Tue, 25 Feb 2020 13:40:16 +0100 | |
changeset 4643 | e305b814a348 |
parent 4628 | 39c66e861653 |
child 4723 | 524785227024 |
permissions | -rw-r--r-- |
4628 | 1 |
"{ Encoding: utf8 }" |
2 |
||
14 | 3 |
" |
4 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
53 | 5 |
All Rights Reserved |
14 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
14 |
"{ Package: 'stx:libcomp' }" |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
15 |
|
3562 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
14 | 18 |
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
|
19 |
instanceVariableNames:'name token index block' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
20 |
classVariableNames:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
21 |
poolDictionaries:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
22 |
category:'System-Compiler-Support' |
14 | 23 |
! |
24 |
||
360 | 25 |
!VariableNode class methodsFor:'documentation'! |
20 | 26 |
|
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
53 | 30 |
All Rights Reserved |
20 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
node for parse-trees, representing variables |
|
261 | 44 |
This is a helper class for the compiler. |
263 | 45 |
|
46 |
[author:] |
|
47 |
Claus Gittinger |
|
20 | 48 |
" |
49 |
! ! |
|
14 | 50 |
|
360 | 51 |
!VariableNode class methodsFor:'instance creation'! |
14 | 52 |
|
1932 | 53 |
blockArgumentNamed:n |
54 |
^ (self basicNew) type:#BlockArg name:n asSymbol |
|
55 |
||
56 |
"Created: / 22-10-2006 / 11:59:10 / cg" |
|
57 |
! |
|
58 |
||
3301 | 59 |
globalNamed:n |
60 |
"because this is called even for invalid (partial) names, |
|
61 |
and we do not want to create zillions of unused symbols, |
|
62 |
no asSymbol is done here. So the name kept is actually a string. |
|
63 |
A symbol will be created when code is actually created for it" |
|
64 |
||
65 |
^ (self basicNew) type:#GlobalVariable name:n "asSymbol" |
|
66 |
||
67 |
"Modified (comment): / 29-08-2013 / 01:10:02 / cg" |
|
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
68 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
69 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
70 |
methodArgumentNamed:n |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
71 |
^ (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
|
72 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
73 |
"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
|
74 |
! |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
75 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
76 |
methodLocalNamed:n |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
77 |
^ (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
|
78 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
79 |
"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
|
80 |
! |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
81 |
|
98 | 82 |
type:t class:class name:n |
83 |
^ (self basicNew) type:t class:class name:n |
|
84 |
! |
|
85 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
86 |
type:t context:aContext |
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
87 |
^ (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
|
88 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
89 |
"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
|
90 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
91 |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
92 |
type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
93 |
^ (self basicNew) type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
94 |
! |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
95 |
|
140 | 96 |
type:t name:n |
97 |
^ (self basicNew) type:t name:n |
|
98 |
! |
|
99 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
100 |
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
|
101 |
^ (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
|
102 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
103 |
"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
|
104 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
105 |
|
140 | 106 |
type:t name:n index:i selfClass:s |
107 |
^ (self basicNew) type:t name:n index:i selfClass:s |
|
108 |
! |
|
109 |
||
110 |
type:t name:n index:i selfValue:s |
|
111 |
^ (self basicNew) type:t name:n index:i selfValue:s |
|
14 | 112 |
! |
113 |
||
114 |
type:t name:n token:tok index:i |
|
115 |
^ (self basicNew) type:t name:n token:tok index:i |
|
116 |
! |
|
117 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
118 |
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
|
119 |
^ (self basicNew) type:t name:n token:tok index:i block:b from:codeBlock |
14 | 120 |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
121 |
"Modified: 2.7.1997 / 10:55:48 / cg" |
14 | 122 |
! ! |
123 |
||
124 |
!VariableNode methodsFor:'accessing'! |
|
125 |
||
577 | 126 |
block |
127 |
^ block |
|
128 |
||
129 |
"Created: 2.7.1997 / 18:53:38 / cg" |
|
130 |
! |
|
131 |
||
2507 | 132 |
block:something |
133 |
block := something. |
|
134 |
! |
|
135 |
||
140 | 136 |
index |
137 |
^ index |
|
14 | 138 |
! |
139 |
||
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
140 |
index:anIntegerIndex |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
141 |
"/ self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]). |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
142 |
index := anIntegerIndex. |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
143 |
|
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
144 |
"Modified: / 15-11-2011 / 19:10:08 / cg" |
2507 | 145 |
! |
146 |
||
140 | 147 |
name |
3510 | 148 |
type == #ThisContext ifTrue:[ ^ 'thisContext' ]. |
140 | 149 |
^ name |
3510 | 150 |
|
151 |
"Modified: / 23-09-2014 / 14:08:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14 | 152 |
! |
153 |
||
2507 | 154 |
name:something |
155 |
name := something. |
|
156 |
||
157 |
"Modified: / 28-06-2011 / 22:14:40 / cg" |
|
158 |
! |
|
159 |
||
875 | 160 |
token |
161 |
^ token |
|
162 |
||
163 |
"Created: 2.7.1997 / 18:53:38 / cg" |
|
164 |
! |
|
165 |
||
2507 | 166 |
token:something |
167 |
token := something. |
|
168 |
! |
|
169 |
||
869 | 170 |
type |
171 |
^ type |
|
172 |
! |
|
173 |
||
140 | 174 |
type:t class:class name:n |
2116 | 175 |
"/ type == #PoolVariable ifTrue:[self breakPoint:#cg]. |
14 | 176 |
type := t. |
140 | 177 |
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
|
178 |
value := class |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
179 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
180 |
"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
|
181 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
182 |
|
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
183 |
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
|
184 |
type := t. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
185 |
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
|
186 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
187 |
"Modified: / 17.1.1998 / 04:01:55 / cg" |
14 | 188 |
! |
189 |
||
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
190 |
type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
191 |
type := t. |
875 | 192 |
token := holder. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
193 |
name := n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
194 |
! |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
195 |
|
140 | 196 |
type:t name:n |
98 | 197 |
type := t. |
198 |
value := nil. |
|
14 | 199 |
name := n |
200 |
! |
|
201 |
||
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
202 |
type:t name:n context:aContext index:anIntegerIndex |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
203 |
type := t. |
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
204 |
"/ self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]). |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
205 |
index := anIntegerIndex. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
206 |
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
|
207 |
name := n |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
208 |
|
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
209 |
"Created: / 17-01-1998 / 02:40:55 / cg" |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
210 |
"Modified: / 15-11-2011 / 19:10:18 / cg" |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
211 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
212 |
|
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
213 |
type:t name:n index:anIntegerIndex selfClass:s |
14 | 214 |
type := t. |
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
215 |
"/ self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]). |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
216 |
index := anIntegerIndex. |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
217 |
value := s. |
14 | 218 |
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
|
219 |
|
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
220 |
"Modified: / 15-11-2011 / 19:10:21 / cg" |
14 | 221 |
! |
222 |
||
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
223 |
type:t name:n index:anIntegerIndex selfValue:s |
140 | 224 |
type := t. |
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
225 |
"/ self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]). |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
226 |
index := anIntegerIndex. |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
227 |
value := s. |
140 | 228 |
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
|
229 |
|
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
230 |
"Modified: / 15-11-2011 / 19:10:24 / cg" |
140 | 231 |
! |
232 |
||
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
233 |
type:t name:n token:tok index:anIntegerIndex |
14 | 234 |
type := t. |
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
235 |
"/ self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]). |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
236 |
index := anIntegerIndex. |
14 | 237 |
token := tok. |
238 |
name := n |
|
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
239 |
|
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
240 |
"Modified: / 15-11-2011 / 19:10:30 / cg" |
14 | 241 |
! |
242 |
||
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
243 |
type:t name:n token:tok index:anIntegerIndex block:variableBlock from:codeBlock |
14 | 244 |
type := t. |
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
245 |
"/ self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]). |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
246 |
index := anIntegerIndex. |
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
247 |
block := variableBlock. |
14 | 248 |
token := tok. |
535 | 249 |
name := n. |
250 |
(type == #BlockArg) ifTrue:[ |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
251 |
variableBlock blockArgAccessed:true. |
535 | 252 |
]. |
253 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
254 |
codeBlock ~~ variableBlock ifTrue:[ |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
255 |
codeBlock rememberOuterBlockVarAccess:self |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
256 |
] |
140 | 257 |
|
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
258 |
"Created: / 02-07-1997 / 10:54:50 / cg" |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
259 |
"Modified: / 15-11-2011 / 19:10:35 / cg" |
14 | 260 |
! |
261 |
||
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
262 |
type:t token:tok index:anIntegerIndex block:b |
140 | 263 |
type := t. |
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
264 |
"/ self assert:(anIntegerIndex isNil or:[anIntegerIndex ~~ 0]). |
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
265 |
index := anIntegerIndex. |
140 | 266 |
block := b. |
535 | 267 |
token := tok. |
268 |
||
269 |
(type == #BlockArg) ifTrue:[ |
|
270 |
b blockArgAccessed:true. |
|
271 |
]. |
|
272 |
||
2757
a86f78669293
comment/format in: #type:name:token:index:block:from:
Claus Gittinger <cg@exept.de>
parents:
2755
diff
changeset
|
273 |
"Modified: / 15-11-2011 / 19:10:04 / cg" |
14 | 274 |
! ! |
275 |
||
276 |
!VariableNode methodsFor:'code generation'! |
|
277 |
||
104 | 278 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
14 | 279 |
"no code at all" |
2066 | 280 |
|
3458 | 281 |
aCompiler |
282 |
warning:'Useless variable reference' |
|
283 |
position:startPosition to:endPosition. |
|
284 |
||
14 | 285 |
^ self |
286 |
! |
|
287 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
288 |
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
|
289 |
|code idx| |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
290 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
291 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
292 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
293 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
294 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
295 |
(type == #InstanceVariable) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
296 |
(index <= 8) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
297 |
code := #( retInstVar1 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
298 |
retInstVar2 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
299 |
retInstVar3 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
300 |
retInstVar4 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
301 |
retInstVar5 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
302 |
retInstVar6 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
303 |
retInstVar7 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
304 |
retInstVar8) at:index. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
305 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
306 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
307 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
308 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
309 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
310 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
311 |
(type == #MethodVariable) ifTrue:[ |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
312 |
idx := index. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
313 |
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
|
314 |
(idx <= 6) ifTrue:[ |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
315 |
code := #( retMethodVar1 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
316 |
retMethodVar2 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
317 |
retMethodVar3 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
318 |
retMethodVar4 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
319 |
retMethodVar5 |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
320 |
retMethodVar6) at:idx. |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
321 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
322 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
323 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
324 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
325 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
326 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
327 |
(type == #MethodArg) ifTrue:[ |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
328 |
idx := index. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
329 |
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
|
330 |
(idx <= 2) ifTrue:[ |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
331 |
code := #(retMethodArg1 |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
332 |
retMethodArg2) at:idx. |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
333 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
334 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
335 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
336 |
] |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
337 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
338 |
|
4213 | 339 |
"/ anything else must be pushed, then top returned |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
340 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
341 |
self codeOn:aStream inBlock:b for:aCompiler. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
342 |
aStream nextPut:#retTop |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
343 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
344 |
"Modified: / 06-08-2006 / 22:59:28 / cg" |
4213 | 345 |
"Modified (comment): / 25-01-2018 / 19:26:46 / mawalch" |
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
346 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
347 |
|
559 | 348 |
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler |
349 |
|theCode b deltaLevel litIndex specialGlobalIndex |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
350 |
bvIdx bvTyp blocksCode selLitIdx | |
14 | 351 |
|
352 |
(type == #MethodArg) ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
353 |
(index <= 4) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
354 |
aStream nextPut:(#(pushMethodArg1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
355 |
pushMethodArg2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
356 |
pushMethodArg3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
357 |
pushMethodArg4) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
358 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
359 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
360 |
aStream nextPut:#pushMethodArg; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
361 |
^ self |
14 | 362 |
]. |
554 | 363 |
|
14 | 364 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
365 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
366 |
aStream nextPut:(#(pushMethodVar1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
367 |
pushMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
368 |
pushMethodVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
369 |
pushMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
370 |
pushMethodVar5 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
371 |
pushMethodVar6) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
372 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
373 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
374 |
aStream nextPut:#pushMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
375 |
^ self |
14 | 376 |
]. |
554 | 377 |
|
14 | 378 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
379 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
380 |
theCode := #(pushInstVar1 pushInstVar2 pushInstVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
381 |
pushInstVar4 pushInstVar5 pushInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
382 |
pushInstVar7 pushInstVar8 pushInstVar9 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
383 |
pushInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
384 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
385 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
386 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
387 |
aStream nextPut:#pushInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
388 |
^ self |
14 | 389 |
]. |
554 | 390 |
|
391 |
((type == #BlockArg) |
|
392 |
or:[type == #BlockVariable]) ifTrue:[ |
|
559 | 393 |
"/ compiling for codeBlock; accessing variable in block. |
394 |
||
395 |
bvIdx := index. |
|
396 |
bvTyp := type. |
|
397 |
||
398 |
"/ find the context where that variable is contained physically |
|
399 |
blocksCode := block. |
|
400 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
401 |
blocksCode := blocksCode home |
|
402 |
]. |
|
403 |
||
404 |
"/ find deltaLevel from code-context to the containing block |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
405 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
406 |
deltaLevel := 0. |
559 | 407 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 408 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
409 |
deltaLevel := deltaLevel + 1 |
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 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
412 |
]. |
535 | 413 |
|
559 | 414 |
b isNil ifTrue:[ |
415 |
codeBlock isNil ifTrue:[ |
|
416 |
"/ a var of a block which is inlined in the method. |
|
417 |
"/ Generate a pushMVAR |
|
418 |
||
419 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
420 |
type == #BlockVariable ifTrue:[ |
|
421 |
bvIdx := bvIdx + block numArgs |
|
422 |
]. |
|
423 |
^ self |
|
424 |
codeLoadOn:aStream |
|
425 |
type:#MethodVariable |
|
426 |
index:bvIdx |
|
427 |
inBlock:codeBlock |
|
428 |
for:aCompiler |
|
429 |
]. |
|
430 |
||
431 |
"/ a var of a block which is inlined in the outer block. |
|
432 |
"/ Generate a pushBVAR |
|
433 |
||
434 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
435 |
type == #BlockVariable ifTrue:[ |
|
436 |
bvIdx := bvIdx + block numArgs |
|
437 |
]. |
|
438 |
bvTyp := #BlockVariable. |
|
439 |
] ifFalse:[ |
|
440 |
block isInlineBlock ifTrue:[ |
|
441 |
"/ a var of a block which is inlined in another block. |
|
442 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
443 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
444 |
type == #BlockVariable ifTrue:[ |
|
445 |
bvIdx := bvIdx + block numArgs |
|
446 |
]. |
|
447 |
bvTyp := #BlockVariable. |
|
448 |
] |
|
554 | 449 |
]. |
450 |
||
559 | 451 |
(bvTyp == #BlockVariable) ifTrue:[ |
554 | 452 |
(deltaLevel == 0) ifTrue:[ |
559 | 453 |
bvIdx <= 3 ifTrue:[ |
454 |
aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:bvIdx). |
|
554 | 455 |
^ self |
456 |
]. |
|
457 |
aStream nextPut:#pushBlockVar. |
|
458 |
] ifFalse:[ |
|
459 |
aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
460 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
461 |
] ifFalse:[ |
554 | 462 |
(deltaLevel == 0) ifTrue:[ |
559 | 463 |
(bvIdx <= 4) ifTrue:[ |
464 |
aStream nextPut:(#(pushBlockArg1 pushBlockArg2 pushBlockArg3 |
|
465 |
pushBlockArg4) at:bvIdx). |
|
554 | 466 |
^ self |
467 |
]. |
|
468 |
aStream nextPut:#pushBlockArg. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
469 |
] ifFalse:[ |
554 | 470 |
(deltaLevel == 1) ifTrue:[ |
471 |
aStream nextPut:#pushOuter1BlockArg |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
472 |
] ifFalse:[ |
554 | 473 |
(deltaLevel == 2) ifTrue:[ |
474 |
aStream nextPut:#pushOuter2BlockArg |
|
475 |
] ifFalse:[ |
|
476 |
aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel |
|
477 |
] |
|
478 |
]. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
479 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
480 |
]. |
559 | 481 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
482 |
^ self |
14 | 483 |
]. |
554 | 484 |
|
14 | 485 |
(type == #GlobalVariable) ifTrue:[ |
4124 | 486 |
"for browsing, we put it into the literal-array; even if it's a specal global" |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
487 |
litIndex := aCompiler addLiteral:name asSymbol. |
531 | 488 |
specialGlobalIndex := aCompiler specialGlobalCodeFor:name. |
489 |
specialGlobalIndex notNil ifTrue:[ |
|
490 |
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
|
491 |
^ self |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
492 |
]. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
493 |
self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
494 |
^ self |
14 | 495 |
]. |
554 | 496 |
|
1553 | 497 |
((type == #ClassVariable) or:[ type == #PoolVariable ]) ifTrue:[ |
1314
782d4cc1d588
slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
498 |
litIndex := aCompiler addLiteral:(value globalKeyForClassVar:name). |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
499 |
litIndex <= 255 ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
500 |
aStream nextPut:#pushClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
501 |
] ifFalse:[ |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
502 |
litIndex <= 16rFFFF ifTrue:[ |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
503 |
aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0 |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
504 |
] ifFalse:[ |
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
505 |
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
|
506 |
]. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
507 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
508 |
^ self |
14 | 509 |
]. |
554 | 510 |
|
360 | 511 |
(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
|
512 |
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
|
513 |
self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
360 | 514 |
^ self |
515 |
]. |
|
14 | 516 |
|
517 |
(type == #ClassInstanceVariable) ifTrue:[ |
|
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
518 |
"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
|
519 |
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
|
520 |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
521 |
aStream nextPut:#pushClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
522 |
^ self |
14 | 523 |
]. |
554 | 524 |
|
14 | 525 |
(type == #ThisContext) ifTrue:[ |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
526 |
aStream nextPut:#pushThisContext. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
527 |
^ self |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
528 |
]. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
529 |
|
1296 | 530 |
(type == #WorkspaceVariable |
531 |
or:[type == #DoItTemporary]) ifTrue:[ |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
532 |
"/ this is done by keeping the valueHolder in the literalArray, |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
533 |
"/ and coding a #value message here. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
534 |
|
875 | 535 |
litIndex := aCompiler addLiteral:token. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
536 |
self emitPushLiteralIndex:litIndex on:aStream for:aCompiler. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
537 |
|
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
538 |
selLitIdx := aCompiler addLiteral:#value. |
3166
6d6abf8f4439
Do not generate #lineno16 byte codes if still on the same line
Stefan Vogel <sv@exept.de>
parents:
3148
diff
changeset
|
539 |
self emitSendLiteralIndex:selLitIdx numArgs:0 line:("lineNr ?" 1) on:aStream for:aCompiler. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
540 |
^ self |
14 | 541 |
]. |
3725 | 542 |
(type == #ThreadLocal) ifTrue:[ |
543 |
litIndex := aCompiler addLiteral:#Processor. |
|
544 |
self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
|
545 |
selLitIdx := aCompiler addLiteral:#activeProcess. |
|
546 |
self emitSendLiteralIndex:selLitIdx numArgs:0 line:("lineNr ?" 1) on:aStream for:aCompiler. |
|
547 |
litIndex := aCompiler addLiteral:name asSymbol. |
|
548 |
self emitPushLiteralIndex:litIndex on:aStream for:aCompiler. |
|
549 |
selLitIdx := aCompiler addLiteral:#environmentAt:. |
|
550 |
self emitSendLiteralIndex:selLitIdx numArgs:1 line:("lineNr ?" 1) on:aStream for:aCompiler. |
|
551 |
^ self |
|
552 |
]. |
|
14 | 553 |
|
554 |
"not reached" |
|
1462 | 555 |
self error:'bad type'. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
556 |
|
4124 | 557 |
"Created: / 25-06-1997 / 16:14:17 / cg" |
558 |
"Modified: / 17-01-1998 / 04:04:17 / cg" |
|
559 |
"Modified (format): / 13-02-2017 / 20:34:16 / cg" |
|
559 | 560 |
! |
561 |
||
562 |
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
|
563 |
|idx| |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
564 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
565 |
idx := (index isNil) |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
566 |
ifTrue:[ self indexIn: aCompiler ] |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
567 |
ifFalse:[ index ]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
568 |
|
559 | 569 |
self |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
570 |
codeLoadOn:aStream type:type index:idx inBlock:codeBlock for:aCompiler |
559 | 571 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
572 |
"Modified: / 06-08-2006 / 16:04:54 / cg" |
14 | 573 |
! |
574 |
||
104 | 575 |
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
|
576 |
|idx| |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
577 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
578 |
idx := (index isNil) |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
579 |
ifTrue:[ self indexIn: aCompiler ] |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
580 |
ifFalse:[ index ]. |
1821 | 581 |
idx == 0 ifTrue:[ |
582 |
self error |
|
583 |
]. |
|
559 | 584 |
self |
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
585 |
codeStoreOn:aStream type:type index:idx |
559 | 586 |
inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
587 |
||
1821 | 588 |
"Modified: / 12-08-2006 / 15:54:52 / cg" |
559 | 589 |
! |
590 |
||
591 |
codeStoreOn:aStream type:type index:index inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
1296 | 592 |
|theCode b deltaLevel litIndex bvIdx blocksCode selLitIdx| |
14 | 593 |
|
1296 | 594 |
"/ value to be stored is on TOP of stack. |
14 | 595 |
valueNeeded ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
596 |
aStream nextPut:#dup |
14 | 597 |
]. |
554 | 598 |
|
14 | 599 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
600 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
601 |
theCode := #(storeMethodVar1 storeMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
602 |
storeMethodVar3 storeMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
603 |
storeMethodVar5 storeMethodVar6) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
604 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
605 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
606 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
607 |
aStream nextPut:#storeMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
608 |
^ self |
14 | 609 |
]. |
554 | 610 |
|
14 | 611 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
612 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
613 |
theCode := #(storeInstVar1 storeInstVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
614 |
storeInstVar3 storeInstVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
615 |
storeInstVar5 storeInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
616 |
storeInstVar7 storeInstVar8 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
617 |
storeInstVar9 storeInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
618 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
619 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
620 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
621 |
aStream nextPut:#storeInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
622 |
^ self |
14 | 623 |
]. |
554 | 624 |
|
2754
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
625 |
((type == #BlockVariable) |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
626 |
"/ the following cannot be encountered with Smalltalk code; |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
627 |
"/ however, the VM supports it for other languages (JavaScript, in particular) |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
628 |
or:[(type == #BlockArg)]) ifTrue:[ |
559 | 629 |
bvIdx := index. |
630 |
||
631 |
"/ find the context where that variable is contained physically |
|
632 |
blocksCode := block. |
|
633 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
634 |
blocksCode := blocksCode home |
|
635 |
]. |
|
636 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
637 |
"find deltaLevel to block, where variable was defined" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
638 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
639 |
deltaLevel := 0. |
559 | 640 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 641 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
642 |
deltaLevel := deltaLevel + 1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
643 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
644 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
645 |
]. |
14 | 646 |
|
559 | 647 |
b isNil ifTrue:[ |
648 |
codeBlock isNil ifTrue:[ |
|
649 |
"/ a block which is inlined in the method. |
|
2754
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
650 |
"/ Generate a storeMVAR |
559 | 651 |
|
652 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
653 |
bvIdx := bvIdx + block numArgs. |
|
654 |
^ self |
|
655 |
codeStoreOn:aStream |
|
656 |
type:#MethodVariable index:bvIdx |
|
657 |
inBlock:codeBlock |
|
658 |
valueNeeded:false "/ already dupped if value is needed |
|
659 |
for:aCompiler |
|
660 |
]. |
|
661 |
"/ a var of a block which is inlined in the outer block. |
|
662 |
"/ Generate a pushBVAR |
|
663 |
||
664 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
665 |
bvIdx := bvIdx + block numArgs. |
|
666 |
] ifFalse:[ |
|
667 |
block isInlineBlock ifTrue:[ |
|
668 |
"/ a var of a block which is inlined in another block. |
|
669 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
670 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
671 |
bvIdx := bvIdx + block numArgs. |
|
672 |
] |
|
673 |
]. |
|
674 |
||
2754
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
675 |
(type == #BlockArg) ifTrue:[ |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
676 |
(deltaLevel == 0) ifTrue:[ |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
677 |
aStream nextPut:#storeBlockLocal |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
678 |
] ifFalse:[ |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
679 |
aStream nextPut:#storeOuterBlockLocal; nextPut:deltaLevel |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
680 |
]. |
2755
a59c6adef58f
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
681 |
aStream nextPut:bvIdx-1. |
2754
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
682 |
^ self |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
683 |
]. |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
684 |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
685 |
(deltaLevel == 0) ifTrue:[ |
559 | 686 |
bvIdx <= 3 ifTrue:[ |
687 |
aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:bvIdx). |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
688 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
689 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
690 |
aStream nextPut:#storeBlockVar |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
691 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
692 |
aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
693 |
]. |
559 | 694 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
695 |
^ self |
14 | 696 |
]. |
554 | 697 |
|
117 | 698 |
(type == #GlobalVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
699 |
litIndex := aCompiler addLiteral:name asSymbol. |
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
700 |
self emitStoreGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
701 |
^ self |
117 | 702 |
]. |
554 | 703 |
|
1553 | 704 |
((type == #ClassVariable) or:[type == #PoolVariable]) ifTrue:[ |
3441 | 705 |
value isNil ifTrue:[ |
706 |
"/ class not set in node - use the compiler's class. |
|
707 |
"/ this happens, when a JavaScript class definition is read, |
|
708 |
"/ where the class has not yet been created when the classVars are specified. |
|
709 |
litIndex := aCompiler addLiteral:(aCompiler targetClass globalKeyForClassVar:name). |
|
710 |
] ifFalse:[ |
|
711 |
litIndex := aCompiler addLiteral:(value globalKeyForClassVar:name). |
|
712 |
]. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
713 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
714 |
aStream nextPut:#storeClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
715 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
716 |
aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
717 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
718 |
^ self |
14 | 719 |
]. |
554 | 720 |
|
14 | 721 |
(type == #ClassInstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
722 |
aStream nextPut:#storeClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
723 |
^ self |
14 | 724 |
]. |
554 | 725 |
|
1296 | 726 |
(type == #WorkspaceVariable |
727 |
or:[type == #DoItTemporary]) ifTrue:[ |
|
728 |
"/ this is done by keeping the valueHolder in the literalArray, |
|
729 |
"/ and coding a #value: message here. |
|
730 |
||
731 |
litIndex := aCompiler addLiteral:token. |
|
1808
29b197bc6939
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1784
diff
changeset
|
732 |
self emitPushLiteralIndex:litIndex on:aStream for:aCompiler. |
1296 | 733 |
|
734 |
"/ need to exchange top 2 items (sigh - there is no exch instruction) |
|
735 |
"/ now, we have: |
|
736 |
"/ TOS: holder |
|
737 |
"/ NOS: value |
|
738 |
"/ |
|
739 |
"/ for the send, I need them as: |
|
740 |
"/ TOS: value |
|
741 |
"/ NOS: holder |
|
742 |
aStream nextPut:#over. |
|
743 |
"/ now, we have: |
|
744 |
"/ TOS: value |
|
745 |
"/ NOS: holder |
|
746 |
"/ value |
|
747 |
selLitIdx := aCompiler addLiteral:#'value:'. |
|
3166
6d6abf8f4439
Do not generate #lineno16 byte codes if still on the same line
Stefan Vogel <sv@exept.de>
parents:
3148
diff
changeset
|
748 |
self emitSendLiteralIndex:selLitIdx numArgs:1 line:("lineNr ?" 1) on:aStream for:aCompiler. |
1296 | 749 |
"/ now, we have: |
750 |
"/ TOS: retVal from value: |
|
751 |
"/ NOS: value |
|
752 |
aStream nextPut:#drop. |
|
753 |
aStream nextPut:#drop. |
|
754 |
^ self |
|
755 |
]. |
|
756 |
||
3725 | 757 |
(type == #ThreadLocal) ifTrue:[ |
758 |
aStream nextPut:#dup. |
|
759 |
litIndex := aCompiler addLiteral:#Processor. |
|
760 |
self emitPushGlobalWithLiteralIndex:litIndex on:aStream for:aCompiler. |
|
761 |
selLitIdx := aCompiler addLiteral:#activeProcess. |
|
762 |
self emitSendLiteralIndex:selLitIdx numArgs:0 line:("lineNr ?" 1) on:aStream for:aCompiler. |
|
763 |
"/ now, we have: |
|
764 |
"/ TOS: process |
|
765 |
"/ NOS: value |
|
766 |
"/ value |
|
767 |
aStream nextPut:#swap. |
|
768 |
"/ now, we have: |
|
769 |
"/ TOS: value |
|
770 |
"/ NOS: process |
|
771 |
"/ value |
|
772 |
litIndex := aCompiler addLiteral:name asSymbol. |
|
773 |
self emitPushLiteralIndex:litIndex on:aStream for:aCompiler. |
|
774 |
"/ now, we have: |
|
775 |
"/ TOS: key |
|
776 |
"/ NOS: value |
|
777 |
"/ process |
|
778 |
"/ value |
|
779 |
aStream nextPut:#swap. |
|
780 |
"/ now, we have: |
|
781 |
"/ TOS: value |
|
782 |
"/ NOS: key |
|
783 |
"/ process |
|
784 |
"/ value |
|
785 |
selLitIdx := aCompiler addLiteral:#environmentAt:put:. |
|
786 |
self emitSendLiteralIndex:selLitIdx numArgs:1 line:("lineNr ?" 1) on:aStream for:aCompiler. |
|
787 |
aStream nextPut:#drop. |
|
788 |
"/ leave value on top |
|
789 |
^ self |
|
790 |
]. |
|
791 |
||
2754
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
792 |
"/ the following cannot be encountered with Smalltalk code; |
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
793 |
"/ however, the VM supports it for other languages (JavaScript, in particular) |
1821 | 794 |
(type == #MethodArg) ifTrue:[ |
2754
81d1bb6dd8d6
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2677
diff
changeset
|
795 |
aStream nextPut:#storeMethodLocal; nextPut:index-1. |
1821 | 796 |
^ self |
797 |
]. |
|
798 |
||
106 | 799 |
"not reached" |
941 | 800 |
self error:'bad assignment' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
801 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
802 |
"Created: / 25-06-1997 / 16:14:40 / cg" |
2755
a59c6adef58f
changed: #codeStoreOn:type:index:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
803 |
"Modified: / 25-10-2011 / 23:41:59 / cg" |
14 | 804 |
! ! |
805 |
||
1035 | 806 |
!VariableNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
807 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
808 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
809 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
810 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
811 |
^ anEnumerator doVariable:self name:name |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
812 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
813 |
"Created: 19.6.1997 / 16:41:35 / cg" |
3316 | 814 |
! |
815 |
||
816 |
variableNodesDo:aBlock |
|
817 |
"helper for parse tree walking" |
|
818 |
||
819 |
aBlock value:self |
|
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
820 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
821 |
|
1035 | 822 |
!VariableNode methodsFor:'evaluation'! |
140 | 823 |
|
1384 | 824 |
evaluateIn:anEnvironment |
980 | 825 |
|nameSym| |
826 |
||
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
827 |
(type == #ContextVariable) ifTrue:[ |
1137 | 828 |
"/ value method isWrapped ifTrue:[^ nil]. |
1178
f8065fd945a8
care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
829 |
index > value size ifTrue:[ |
f8065fd945a8
care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
830 |
"/ 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
|
831 |
^ nil |
f8065fd945a8
care for wrapped methods context
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
832 |
]. |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
833 |
^ 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
|
834 |
]. |
140 | 835 |
(type == #MethodVariable |
1384 | 836 |
or:[type == #MethodArg |
140 | 837 |
or:[type == #BlockArg |
1384 | 838 |
or:[type == #BlockVariable]]]) ifTrue:[ |
420 | 839 |
^ token variableValue |
140 | 840 |
]. |
841 |
(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
|
842 |
^ value instVarAt:index |
140 | 843 |
]. |
1088 | 844 |
(type == #JavaVariable) ifTrue:[ |
845 |
nameSym := name asSymbolIfInterned. |
|
846 |
nameSym notNil ifTrue:[ |
|
847 |
^ JAVA at:name |
|
848 |
]. |
|
2420
914eb1c66bda
Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents:
2126
diff
changeset
|
849 |
"/ ^ nil. |
914eb1c66bda
Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents:
2126
diff
changeset
|
850 |
^ Parser undefinedVariableError raiseRequestWith:name errorString:('undefined: ',name). |
1088 | 851 |
]. |
140 | 852 |
(type == #GlobalVariable) ifTrue:[ |
980 | 853 |
nameSym := name asSymbolIfInterned. |
854 |
nameSym notNil ifTrue:[ |
|
855 |
(Smalltalk includesKey:nameSym) ifTrue:[ |
|
3303 | 856 |
^ Smalltalk at:nameSym |
980 | 857 |
] |
420 | 858 |
]. |
2420
914eb1c66bda
Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents:
2126
diff
changeset
|
859 |
"/ ^ nil. |
914eb1c66bda
Raise UndefinedVariableError - not raising is caused class method patches for non-existing
Stefan Vogel <sv@exept.de>
parents:
2126
diff
changeset
|
860 |
^ Parser undefinedVariableError raiseRequestWith:name errorString:('undefined: ',name). |
140 | 861 |
]. |
862 |
(type == #ClassVariable) ifTrue:[ |
|
1314
782d4cc1d588
slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
863 |
^ value classVarAt:name asSymbol |
140 | 864 |
]. |
865 |
(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
|
866 |
^ value instVarAt:index |
140 | 867 |
]. |
868 |
(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
|
869 |
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
|
870 |
^ value |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
871 |
]. |
420 | 872 |
^ thisContext |
873 |
]. |
|
874 |
(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
|
875 |
^ value privateClassesAt:name asSymbol |
140 | 876 |
]. |
1918 | 877 |
(type == #PoolVariable) ifTrue:[ |
878 |
^ value classVarAt:name asSymbol |
|
879 |
]. |
|
719 | 880 |
|
881 |
"/ synthetic; for evaluation only |
|
1179 | 882 |
(type == #EvaluationContextLocal |
883 |
or:[type == #EvaluationContextVar |
|
884 |
or:[type == #EvaluationContextArg]]) ifTrue:[ |
|
3389 | 885 |
(token isKindOf:Variable) ifFalse:[^ token ]. |
719 | 886 |
^ token variableValue |
887 |
]. |
|
1179 | 888 |
|
1092 | 889 |
"/ synthetic; for evaluation only |
1606 | 890 |
((type == #WorkspaceVariable) or:[type == #DoItTemporary]) ifTrue:[ |
1092 | 891 |
^ token value |
892 |
]. |
|
3725 | 893 |
"/ synthetic; for evaluation only |
894 |
(type == #ThreadLocal) ifTrue:[ |
|
895 |
^ Processor activeProcess environmentAt:name asSymbol |
|
896 |
]. |
|
719 | 897 |
|
140 | 898 |
"not reached" |
1320 | 899 |
self error:'internal error - bad variable type:' , type mayProceed:true. |
140 | 900 |
^ value |
420 | 901 |
|
1918 | 902 |
"Modified: / 11-09-2006 / 14:22:38 / User" |
3303 | 903 |
"Modified: / 29-08-2013 / 01:19:53 / cg" |
140 | 904 |
! |
905 |
||
906 |
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
|
907 |
(type == #ContextVariable) ifTrue:[ |
1137 | 908 |
"/ value method isWrapped ifTrue:[ |
909 |
"/ self warn:'The method has not yet been entered (in breakpoint stub)\Please perform a singleStep first' withCRs. |
|
910 |
"/ ^ aValue |
|
911 |
"/ ]. |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
912 |
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
|
913 |
]. |
140 | 914 |
(type == #MethodVariable |
915 |
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
|
916 |
token value:aValue. ^ aValue |
140 | 917 |
]. |
918 |
(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
|
919 |
^ value instVarAt:index put:aValue |
140 | 920 |
]. |
921 |
(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
|
922 |
^ Smalltalk at:name put:aValue |
140 | 923 |
]. |
924 |
(type == #ClassVariable) ifTrue:[ |
|
1314
782d4cc1d588
slight code beautification: use classVarAt: / classVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
1310
diff
changeset
|
925 |
^ value classVarAt:name asSymbol put:aValue |
140 | 926 |
]. |
927 |
(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
|
928 |
^ value instVarAt:index put:aValue |
140 | 929 |
]. |
719 | 930 |
|
931 |
"/ synthetic; for evaluation only |
|
932 |
(type == #EvaluationContextLocal) ifTrue:[ |
|
875 | 933 |
token value:aValue. ^ aValue |
934 |
]. |
|
2764 | 935 |
((type == #WorkspaceVariable) or:[type == #DoItTemporary]) ifTrue:[ |
875 | 936 |
token value:aValue. ^ aValue |
719 | 937 |
]. |
3725 | 938 |
(type == #ThreadLocal) ifTrue:[ |
4628 | 939 |
^ Processor activeProcess environmentAt:name asSymbol put:aValue. |
3725 | 940 |
]. |
719 | 941 |
|
140 | 942 |
"not reached" |
1320 | 943 |
self error:'bad variable node type' mayProceed:true. |
140 | 944 |
^ aValue |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
945 |
|
2764 | 946 |
"Modified: / 05-12-2011 / 18:43:56 / cg" |
4628 | 947 |
"Modified: / 05-02-2020 / 16:59:34 / Stefan Vogel" |
140 | 948 |
! ! |
949 |
||
4464 | 950 |
|
1080 | 951 |
!VariableNode methodsFor:'printing & storing'! |
14 | 952 |
|
2898
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
953 |
displayOn:aGCOrStream |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
954 |
"Compatibility |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
955 |
append a printed desription on some stream (Dolphin, Squeak) |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
956 |
OR: |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
957 |
display the receiver in a graphicsContext at 0@0 (ST80). |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
958 |
This method allows for any object to be displayed in some view |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
959 |
(although the fallBack is to display its printString ...)" |
612 | 960 |
|
2898
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
961 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
4133 | 962 |
"/ old ST80 means: draw-yourself on a GC. |
2898
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
963 |
aGCOrStream isStream ifFalse:[ |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
964 |
^ super displayOn:aGCOrStream. |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
965 |
]. |
612 | 966 |
|
2898
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
967 |
aGCOrStream |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
968 |
nextPutAll:self class name; |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
969 |
nextPut:$(. |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
970 |
self printOn:aGCOrStream. |
bb61af1f77a1
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
2864
diff
changeset
|
971 |
aGCOrStream nextPut:$) |
4133 | 972 |
|
973 |
"Modified (comment): / 22-02-2017 / 16:49:57 / cg" |
|
14 | 974 |
! |
975 |
||
976 |
printOn:aStream indent:i |
|
98 | 977 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
978 |
"/ 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
|
979 |
( |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
980 |
type == #ContextVariable |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
981 |
or:[type == #MethodArg |
98 | 982 |
or:[type == #MethodVariable |
983 |
or:[type == #InstanceVariable |
|
984 |
or:[type == #BlockArg |
|
985 |
or:[type == #GlobalVariable |
|
1088 | 986 |
or:[type == #JavaVariable |
98 | 987 |
or:[type == #ClassVariable |
2066 | 988 |
or:[type == #PoolVariable |
98 | 989 |
or:[type == #BlockVariable |
465 | 990 |
or:[type == #PrivateClass |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
991 |
or:[type == #WorkspaceVariable |
1101 | 992 |
or:[type == #EvaluationContextArg |
720 | 993 |
or:[type == #EvaluationContextLocal |
2066 | 994 |
or:[type == #ClassInstanceVariable]]]]]]]]]]]]]]) ifTrue:[ |
465 | 995 |
aStream nextPutAll:name. ^ self |
14 | 996 |
]. |
997 |
(type == #ThisContext) ifTrue:[ |
|
465 | 998 |
aStream nextPutAll:'thisContext'. ^ self |
14 | 999 |
]. |
1000 |
"not reached" |
|
1320 | 1001 |
self error:'bad variable node type' mayProceed:true. |
465 | 1002 |
|
720 | 1003 |
"Modified: / 17.5.1998 / 00:17:12 / cg" |
14 | 1004 |
! ! |
140 | 1005 |
|
1006 |
!VariableNode methodsFor:'queries'! |
|
1007 |
||
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1008 |
canReuseAsArg:anotherNode |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1009 |
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
|
1010 |
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
|
1011 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1012 |
(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
|
1013 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1014 |
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
|
1015 |
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
|
1016 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1017 |
(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
|
1018 |
(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
|
1019 |
(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
|
1020 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1021 |
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
|
1022 |
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
|
1023 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1024 |
(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
|
1025 |
(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
|
1026 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1027 |
^ false |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1028 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1029 |
"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
|
1030 |
"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
|
1031 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1032 |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1033 |
indexIn: aCompiler |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1034 |
(type == #MethodVariable) ifTrue:[ |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1035 |
^ aCompiler methodVars indexOf:name. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1036 |
]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1037 |
(type == #MethodArg) ifTrue:[ |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1038 |
^ aCompiler methodArgs indexOf:name. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1039 |
]. |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1040 |
^ index |
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1041 |
|
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1042 |
"Created: / 06-08-2006 / 16:03:56 / cg" |
3622 | 1043 |
! ! |
1044 |
||
1045 |
!VariableNode methodsFor:'testing'! |
|
1784
4380f89e1a91
allow for lazy index of locals and arguments.
Claus Gittinger <cg@exept.de>
parents:
1606
diff
changeset
|
1046 |
|
566 | 1047 |
isArgument |
1048 |
"return true, if this is a node for an argument (block or method)" |
|
1049 |
||
1050 |
^ (type == #MethodArg) or:[type == #BlockArg] |
|
1051 |
||
1052 |
"Created: 27.6.1997 / 13:07:05 / cg" |
|
1053 |
"Modified: 27.6.1997 / 13:07:19 / cg" |
|
1054 |
! |
|
1055 |
||
3473 | 1056 |
isBlockArg |
1057 |
^ type == #BlockArg |
|
1058 |
! |
|
1059 |
||
3472 | 1060 |
isBlockVariable |
1061 |
^ type == #BlockVariable |
|
1062 |
! |
|
1063 |
||
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1064 |
isClassVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1065 |
^ type == #ClassVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1066 |
! |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1067 |
|
140 | 1068 |
isGlobal |
2957 | 1069 |
"return true, if this is a node for an existing!! global variable" |
789 | 1070 |
|
1071 |
^ (type == #GlobalVariable) |
|
1072 |
and:[name isSymbol |
|
1073 |
and:[Smalltalk includesKey:name]] |
|
1074 |
||
1075 |
"Modified: / 19.10.1998 / 19:43:04 / cg" |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1076 |
! |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1077 |
|
1997 | 1078 |
isGlobalNamed:nameWanted |
4306 | 1079 |
"return true, if this is a node for a particular |
1080 |
(and existing) global variable" |
|
1996 | 1081 |
|
4306 | 1082 |
|sym| |
1083 |
||
1996 | 1084 |
^ (type == #GlobalVariable) |
1085 |
and:[name = nameWanted |
|
4306 | 1086 |
and:[(sym := name asSymbolIfInterned) isSymbol |
1996 | 1087 |
and:[Smalltalk includesKey:name]]] |
1088 |
||
1997 | 1089 |
"Created: / 05-03-2007 / 13:35:07 / cg" |
4306 | 1090 |
"Modified: / 22-09-2018 / 17:27:58 / Claus Gittinger" |
1996 | 1091 |
! |
1092 |
||
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1093 |
isGlobalVariable |
2957 | 1094 |
"return true, if this is a node for global variable" |
1095 |
||
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1096 |
^ type == #GlobalVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1097 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1098 |
|
4306 | 1099 |
isGlobalVariableNamed:nameWanted |
1100 |
"return true, if this is a node for a particular |
|
1101 |
global variable (existing or not) " |
|
1102 |
||
1103 |
^ (type == #GlobalVariable) |
|
1104 |
and:[name = nameWanted] |
|
1105 |
||
1106 |
"Created: / 22-09-2018 / 17:26:50 / Claus Gittinger" |
|
1107 |
! |
|
1108 |
||
3622 | 1109 |
isInstance |
1110 |
<resource: #obsolete> |
|
1111 |
||
1112 |
self obsoleteMethodWarning. |
|
1113 |
^ self isInstanceVariable |
|
1114 |
! |
|
1115 |
||
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1116 |
isInstanceVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1117 |
^ type == #InstanceVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1118 |
! |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
1119 |
|
3851 | 1120 |
isInstanceVariableNamed:aString |
1121 |
^ (type == #InstanceVariable) and:[ name = aString ] |
|
1122 |
! |
|
1123 |
||
2864 | 1124 |
isJAVA |
1125 |
"Return true, if receiver is global variable node JAVA. |
|
1126 |
Used to highlight Java class references." |
|
1127 |
||
1128 |
^ (type == #GlobalVariable) and:[name = 'JAVA'] |
|
1129 |
||
1130 |
"Created: / 19-04-2012 / 09:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1131 |
! |
|
1132 |
||
3622 | 1133 |
isJavaPackageReference |
1134 |
"Return true, given node is JAVA package reference in form: |
|
1135 |
JAVA package1 package2 |
|
1136 |
" |
|
1137 |
||
1138 |
^self isJAVA |
|
1139 |
||
1140 |
"Created: / 19-04-2012 / 09:53:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1141 |
! |
|
1142 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1143 |
isLocal |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
1144 |
"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
|
1145 |
|
3476 | 1146 |
^ self isLocalVariable |
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1147 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1148 |
|
3475 | 1149 |
isLocalVariable |
1150 |
"return true, if this is a node for a local (block or method) variable" |
|
1151 |
||
3476 | 1152 |
^ (type == #MethodVariable) or:[type == #BlockVariable] |
3475 | 1153 |
! |
1154 |
||
1310
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1155 |
isMethodArg |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1156 |
^ type == #MethodArg |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1157 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1158 |
|
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1159 |
isMethodVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1160 |
^ type == #MethodVariable |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1161 |
! |
feb30ab0c221
better variabletype queries.
Claus Gittinger <cg@exept.de>
parents:
1296
diff
changeset
|
1162 |
|
2957 | 1163 |
isPoolVariable |
1164 |
^ type == #PoolVariable |
|
1165 |
! |
|
1166 |
||
965 | 1167 |
isUndeclared |
3408 | 1168 |
|sym| |
1169 |
||
965 | 1170 |
type == #PrivateClass ifTrue:[ |
3408 | 1171 |
sym := (value name , '::' , name) asSymbolIfInterned. |
1172 |
^ sym isNil or:[(Smalltalk includesKey:sym) not]. |
|
965 | 1173 |
]. |
1174 |
type == #GlobalVariable ifTrue:[ |
|
3408 | 1175 |
sym := name asSymbolIfInterned. |
1176 |
^ sym isNil or:[(Smalltalk includesKey:sym) not] |
|
965 | 1177 |
]. |
1178 |
^ false |
|
3318
b944b8684bbf
Fix in VariableNode>>#isUndeclared
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3316
diff
changeset
|
1179 |
|
b944b8684bbf
Fix in VariableNode>>#isUndeclared
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3316
diff
changeset
|
1180 |
"Modified: / 05-09-2013 / 02:35:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
965 | 1181 |
! |
1182 |
||
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1183 |
isVariable |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1184 |
"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
|
1185 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1186 |
^ true |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1187 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
1188 |
"Created: 14.4.1996 / 00:46:32 / cg" |
140 | 1189 |
! ! |
1190 |
||
2599 | 1191 |
!VariableNode methodsFor:'visiting'! |
1192 |
||
1193 |
acceptVisitor:aVisitor |
|
1194 |
"Double dispatch back to the visitor, passing my type encoded in |
|
1195 |
the selector (visitor pattern)" |
|
1196 |
||
1197 |
"stub code automatically generated - please change if required" |
|
1198 |
||
1199 |
^ aVisitor visitVariableNode:self |
|
1200 |
! ! |
|
1201 |
||
360 | 1202 |
!VariableNode class methodsFor:'documentation'! |
148 | 1203 |
|
1204 |
version |
|
3725 | 1205 |
^ '$Header$' |
2507 | 1206 |
! |
1207 |
||
1208 |
version_CVS |
|
3725 | 1209 |
^ '$Header$' |
148 | 1210 |
! ! |
3148 | 1211 |