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