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