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