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