author | Claus Gittinger <cg@exept.de> |
Mon, 09 Oct 2000 12:42:06 +0200 | |
changeset 1092 | 77de350f525c |
parent 1088 | 029b67b39d1b |
child 1101 | 84db57980ac5 |
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 |
" |
|
12 |
||
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
13 |
"{ Package: 'stx:libcomp' }" |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
14 |
|
14 | 15 |
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
|
16 |
instanceVariableNames:'name token index block' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
17 |
classVariableNames:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
18 |
poolDictionaries:'' |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
19 |
category:'System-Compiler-Support' |
14 | 20 |
! |
21 |
||
360 | 22 |
!VariableNode class methodsFor:'documentation'! |
20 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
53 | 27 |
All Rights Reserved |
20 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
node for parse-trees, representing variables |
|
261 | 41 |
This is a helper class for the compiler. |
263 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
20 | 45 |
" |
46 |
! ! |
|
14 | 47 |
|
360 | 48 |
!VariableNode class methodsFor:'instance creation'! |
14 | 49 |
|
98 | 50 |
type:t class:class name:n |
51 |
^ (self basicNew) type:t class:class name:n |
|
52 |
! |
|
53 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
54 |
type:t context:aContext |
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
55 |
^ (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
|
56 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
57 |
"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
|
58 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
59 |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
60 |
type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
61 |
^ (self basicNew) type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
62 |
! |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
63 |
|
140 | 64 |
type:t name:n |
65 |
^ (self basicNew) type:t name:n |
|
66 |
! |
|
67 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
68 |
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
|
69 |
^ (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
|
70 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
71 |
"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
|
72 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
73 |
|
140 | 74 |
type:t name:n index:i selfClass:s |
75 |
^ (self basicNew) type:t name:n index:i selfClass:s |
|
76 |
! |
|
77 |
||
78 |
type:t name:n index:i selfValue:s |
|
79 |
^ (self basicNew) type:t name:n index:i selfValue:s |
|
14 | 80 |
! |
81 |
||
82 |
type:t name:n token:tok index:i |
|
83 |
^ (self basicNew) type:t name:n token:tok index:i |
|
84 |
! |
|
85 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
86 |
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
|
87 |
^ (self basicNew) type:t name:n token:tok index:i block:b from:codeBlock |
14 | 88 |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
89 |
"Modified: 2.7.1997 / 10:55:48 / cg" |
14 | 90 |
! ! |
91 |
||
92 |
!VariableNode methodsFor:'accessing'! |
|
93 |
||
577 | 94 |
block |
95 |
^ block |
|
96 |
||
97 |
"Created: 2.7.1997 / 18:53:38 / cg" |
|
98 |
! |
|
99 |
||
140 | 100 |
index |
101 |
^ index |
|
14 | 102 |
! |
103 |
||
140 | 104 |
name |
105 |
^ name |
|
14 | 106 |
! |
107 |
||
875 | 108 |
token |
109 |
^ token |
|
110 |
||
111 |
"Created: 2.7.1997 / 18:53:38 / cg" |
|
112 |
! |
|
113 |
||
869 | 114 |
type |
115 |
^ type |
|
116 |
! |
|
117 |
||
140 | 118 |
type:t class:class name:n |
14 | 119 |
type := t. |
140 | 120 |
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
|
121 |
value := class |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
122 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
123 |
"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
|
124 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
125 |
|
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
126 |
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
|
127 |
type := t. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
128 |
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
|
129 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
130 |
"Modified: / 17.1.1998 / 04:01:55 / cg" |
14 | 131 |
! |
132 |
||
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
133 |
type:t holder:holder name:n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
134 |
type := t. |
875 | 135 |
token := holder. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
136 |
name := n |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
137 |
! |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
138 |
|
140 | 139 |
type:t name:n |
98 | 140 |
type := t. |
141 |
value := nil. |
|
14 | 142 |
name := n |
143 |
! |
|
144 |
||
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
145 |
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
|
146 |
type := t. |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
147 |
index := i. |
642
de97c93c4f49
renamed con to aContext - stc has problems with it.
Claus Gittinger <cg@exept.de>
parents:
641
diff
changeset
|
148 |
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
|
149 |
name := n |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
150 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
151 |
"Created: / 17.1.1998 / 02:40:55 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
152 |
"Modified: / 17.1.1998 / 04:01:21 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
153 |
! |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
154 |
|
14 | 155 |
type:t name:n index:i selfClass:s |
156 |
type := t. |
|
157 |
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
|
158 |
value := s. |
14 | 159 |
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
|
160 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
161 |
"Modified: / 17.1.1998 / 04:04:04 / cg" |
14 | 162 |
! |
163 |
||
140 | 164 |
type:t name:n index:i selfValue:s |
165 |
type := t. |
|
166 |
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
|
167 |
value := s. |
140 | 168 |
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
|
169 |
|
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
170 |
"Modified: / 17.1.1998 / 04:02:58 / cg" |
140 | 171 |
! |
172 |
||
14 | 173 |
type:t name:n token:tok index:i |
174 |
type := t. |
|
175 |
index := i. |
|
176 |
token := tok. |
|
177 |
name := n |
|
178 |
! |
|
179 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
180 |
type:t name:n token:tok index:i block:variableBlock from:codeBlock |
14 | 181 |
type := t. |
182 |
index := i. |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
183 |
block := variableBlock. |
14 | 184 |
token := tok. |
535 | 185 |
name := n. |
186 |
(type == #BlockArg) ifTrue:[ |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
187 |
variableBlock blockArgAccessed:true. |
535 | 188 |
]. |
189 |
||
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
190 |
codeBlock ~~ variableBlock ifTrue:[ |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
191 |
codeBlock rememberOuterBlockVarAccess:self |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
192 |
] |
140 | 193 |
|
574
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
194 |
"Created: 2.7.1997 / 10:54:50 / cg" |
993d1182782b
fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents:
566
diff
changeset
|
195 |
"Modified: 2.7.1997 / 11:12:58 / cg" |
14 | 196 |
! |
197 |
||
140 | 198 |
type:t token:tok index:i block:b |
199 |
type := t. |
|
200 |
index := i. |
|
201 |
block := b. |
|
535 | 202 |
token := tok. |
203 |
||
204 |
(type == #BlockArg) ifTrue:[ |
|
205 |
b blockArgAccessed:true. |
|
206 |
]. |
|
207 |
||
208 |
"Modified: 18.6.1997 / 11:41:05 / cg" |
|
14 | 209 |
! ! |
210 |
||
211 |
!VariableNode methodsFor:'code generation'! |
|
212 |
||
104 | 213 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
14 | 214 |
"no code at all" |
215 |
^ self |
|
216 |
! |
|
217 |
||
843
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
218 |
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
219 |
|code| |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
220 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
221 |
lineNrOrNil notNil ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
222 |
self codeLineNumber:lineNrOrNil on:aStream for:aCompiler |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
223 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
224 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
225 |
(type == #InstanceVariable) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
226 |
(index <= 8) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
227 |
code := #( retInstVar1 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
228 |
retInstVar2 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
229 |
retInstVar3 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
230 |
retInstVar4 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
231 |
retInstVar5 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
232 |
retInstVar6 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
233 |
retInstVar7 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
234 |
retInstVar8) at:index. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
235 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
236 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
237 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
238 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
239 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
240 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
241 |
(type == #MethodVariable) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
242 |
(index <= 6) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
243 |
code := #( retMethodVar1 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
244 |
retMethodVar2 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
245 |
retMethodVar3 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
246 |
retMethodVar4 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
247 |
retMethodVar5 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
248 |
retMethodVar6) at:index. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
249 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
250 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
251 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
252 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
253 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
254 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
255 |
(type == #MethodArg) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
256 |
(index <= 2) ifTrue:[ |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
257 |
code := #(retMethodArg1 |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
258 |
retMethodArg2) at:index. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
259 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
260 |
aStream nextPut:code. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
261 |
^ self |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
262 |
] |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
263 |
]. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
264 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
265 |
"/ anything else must be pushed, then top rturned |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
266 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
267 |
self codeOn:aStream inBlock:b for:aCompiler. |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
268 |
aStream nextPut:#retTop |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
269 |
|
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
270 |
! |
522c116f86d9
boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
271 |
|
559 | 272 |
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler |
273 |
|theCode b deltaLevel litIndex specialGlobalIndex |
|
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
274 |
bvIdx bvTyp blocksCode selLitIdx | |
14 | 275 |
|
276 |
(type == #MethodArg) ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
277 |
(index <= 4) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
278 |
aStream nextPut:(#(pushMethodArg1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
279 |
pushMethodArg2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
280 |
pushMethodArg3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
281 |
pushMethodArg4) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
282 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
283 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
284 |
aStream nextPut:#pushMethodArg; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
285 |
^ self |
14 | 286 |
]. |
554 | 287 |
|
14 | 288 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
289 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
290 |
aStream nextPut:(#(pushMethodVar1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
291 |
pushMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
292 |
pushMethodVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
293 |
pushMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
294 |
pushMethodVar5 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
295 |
pushMethodVar6) at:index). |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
296 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
297 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
298 |
aStream nextPut:#pushMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
299 |
^ self |
14 | 300 |
]. |
554 | 301 |
|
14 | 302 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
303 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
304 |
theCode := #(pushInstVar1 pushInstVar2 pushInstVar3 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
305 |
pushInstVar4 pushInstVar5 pushInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
306 |
pushInstVar7 pushInstVar8 pushInstVar9 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
307 |
pushInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
308 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
309 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
310 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
311 |
aStream nextPut:#pushInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
312 |
^ self |
14 | 313 |
]. |
554 | 314 |
|
315 |
((type == #BlockArg) |
|
316 |
or:[type == #BlockVariable]) ifTrue:[ |
|
559 | 317 |
"/ compiling for codeBlock; accessing variable in block. |
318 |
||
319 |
bvIdx := index. |
|
320 |
bvTyp := type. |
|
321 |
||
322 |
"/ find the context where that variable is contained physically |
|
323 |
blocksCode := block. |
|
324 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
325 |
blocksCode := blocksCode home |
|
326 |
]. |
|
327 |
||
328 |
"/ find deltaLevel from code-context to the containing block |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
329 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
330 |
deltaLevel := 0. |
559 | 331 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 332 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
333 |
deltaLevel := deltaLevel + 1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
334 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
335 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
336 |
]. |
535 | 337 |
|
559 | 338 |
b isNil ifTrue:[ |
339 |
codeBlock isNil ifTrue:[ |
|
340 |
"/ a var of a block which is inlined in the method. |
|
341 |
"/ Generate a pushMVAR |
|
342 |
||
343 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
344 |
type == #BlockVariable ifTrue:[ |
|
345 |
bvIdx := bvIdx + block numArgs |
|
346 |
]. |
|
347 |
^ self |
|
348 |
codeLoadOn:aStream |
|
349 |
type:#MethodVariable |
|
350 |
index:bvIdx |
|
351 |
inBlock:codeBlock |
|
352 |
for:aCompiler |
|
353 |
]. |
|
354 |
||
355 |
"/ a var of a block which is inlined in the outer block. |
|
356 |
"/ Generate a pushBVAR |
|
357 |
||
358 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
359 |
type == #BlockVariable ifTrue:[ |
|
360 |
bvIdx := bvIdx + block numArgs |
|
361 |
]. |
|
362 |
bvTyp := #BlockVariable. |
|
363 |
] ifFalse:[ |
|
364 |
block isInlineBlock ifTrue:[ |
|
365 |
"/ a var of a block which is inlined in another block. |
|
366 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
367 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
368 |
type == #BlockVariable ifTrue:[ |
|
369 |
bvIdx := bvIdx + block numArgs |
|
370 |
]. |
|
371 |
bvTyp := #BlockVariable. |
|
372 |
] |
|
554 | 373 |
]. |
374 |
||
559 | 375 |
(bvTyp == #BlockVariable) ifTrue:[ |
554 | 376 |
(deltaLevel == 0) ifTrue:[ |
559 | 377 |
bvIdx <= 3 ifTrue:[ |
378 |
aStream nextPut:(#(pushBlockVar1 pushBlockVar2 pushBlockVar3) at:bvIdx). |
|
554 | 379 |
^ self |
380 |
]. |
|
381 |
aStream nextPut:#pushBlockVar. |
|
382 |
] ifFalse:[ |
|
383 |
aStream nextPut:#pushOuterBlockVar; nextPut:deltaLevel. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
384 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
385 |
] ifFalse:[ |
554 | 386 |
(deltaLevel == 0) ifTrue:[ |
559 | 387 |
(bvIdx <= 4) ifTrue:[ |
388 |
aStream nextPut:(#(pushBlockArg1 pushBlockArg2 pushBlockArg3 |
|
389 |
pushBlockArg4) at:bvIdx). |
|
554 | 390 |
^ self |
391 |
]. |
|
392 |
aStream nextPut:#pushBlockArg. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
393 |
] ifFalse:[ |
554 | 394 |
(deltaLevel == 1) ifTrue:[ |
395 |
aStream nextPut:#pushOuter1BlockArg |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
396 |
] ifFalse:[ |
554 | 397 |
(deltaLevel == 2) ifTrue:[ |
398 |
aStream nextPut:#pushOuter2BlockArg |
|
399 |
] ifFalse:[ |
|
400 |
aStream nextPut:#pushOuterBlockArg; nextPut:deltaLevel |
|
401 |
] |
|
402 |
]. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
403 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
404 |
]. |
559 | 405 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
406 |
^ self |
14 | 407 |
]. |
554 | 408 |
|
14 | 409 |
(type == #GlobalVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
410 |
litIndex := aCompiler addLiteral:name asSymbol. |
531 | 411 |
specialGlobalIndex := aCompiler specialGlobalCodeFor:name. |
412 |
specialGlobalIndex notNil ifTrue:[ |
|
413 |
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
|
414 |
^ self |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
415 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
416 |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
417 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
418 |
aStream nextPut:#pushGlobalS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
419 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
420 |
aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
421 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
422 |
^ self |
14 | 423 |
]. |
554 | 424 |
|
360 | 425 |
(type == #ClassVariable) ifTrue:[ |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
426 |
litIndex := aCompiler addLiteral:(value name , ':' , name) asSymbol. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
427 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
428 |
aStream nextPut:#pushClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
429 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
430 |
aStream nextPut:#pushClassVarL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
431 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
432 |
^ self |
14 | 433 |
]. |
554 | 434 |
|
360 | 435 |
(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
|
436 |
litIndex := aCompiler addLiteral:(value name , '::' , name) asSymbol. |
360 | 437 |
litIndex < 256 ifTrue:[ |
438 |
aStream nextPut:#pushGlobalS; nextPut:litIndex |
|
439 |
] ifFalse:[ |
|
440 |
aStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0 |
|
441 |
]. |
|
442 |
^ self |
|
443 |
]. |
|
14 | 444 |
|
445 |
(type == #ClassInstanceVariable) ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
446 |
aStream nextPut:#pushClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
447 |
^ self |
14 | 448 |
]. |
554 | 449 |
|
14 | 450 |
(type == #ThisContext) ifTrue:[ |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
451 |
aStream nextPut:#pushThisContext. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
452 |
^ self |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
453 |
]. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
454 |
|
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
455 |
(type == #WorkspaceVariable) ifTrue:[ |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
456 |
"/ this is done by keeping the valueHolder in the literalArray, |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
457 |
"/ and coding a #value message here. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
458 |
|
875 | 459 |
litIndex := aCompiler addLiteral:token. |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
460 |
aStream nextPut:#pushLitS; nextPut:litIndex. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
461 |
|
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
462 |
selLitIdx := aCompiler addLiteral:#value. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
463 |
selLitIdx <= 255 ifTrue:[ |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
464 |
aStream nextPut:#send0; nextPut:("lineNr ?" 1); nextPut:selLitIdx. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
465 |
] ifFalse:[ |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
466 |
aStream nextPut:#sendL; nextPut:("lineNr ?" 1); nextPut:selLitIdx; nextPut:0; nextPut:1 "nargs". |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
467 |
]. |
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
468 |
^ self |
14 | 469 |
]. |
470 |
||
471 |
"not reached" |
|
472 |
self halt:'bad type'. |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
473 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
474 |
"Created: / 25.6.1997 / 16:14:17 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
475 |
"Modified: / 17.1.1998 / 04:04:17 / cg" |
559 | 476 |
! |
477 |
||
478 |
codeOn:aStream inBlock:codeBlock for:aCompiler |
|
479 |
self |
|
480 |
codeLoadOn:aStream type:type index:index inBlock:codeBlock for:aCompiler |
|
481 |
||
482 |
"Modified: 26.6.1997 / 10:06:10 / cg" |
|
14 | 483 |
! |
484 |
||
104 | 485 |
codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
559 | 486 |
self |
487 |
codeStoreOn:aStream type:type index:index |
|
488 |
inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
489 |
||
490 |
"Modified: 25.6.1997 / 16:15:28 / cg" |
|
491 |
! |
|
492 |
||
493 |
codeStoreOn:aStream type:type index:index inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler |
|
494 |
|theCode b deltaLevel litIndex bvIdx blocksCode| |
|
14 | 495 |
|
496 |
valueNeeded ifTrue:[ |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
497 |
aStream nextPut:#dup |
14 | 498 |
]. |
554 | 499 |
|
14 | 500 |
(type == #MethodVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
501 |
(index <= 6) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
502 |
theCode := #(storeMethodVar1 storeMethodVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
503 |
storeMethodVar3 storeMethodVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
504 |
storeMethodVar5 storeMethodVar6) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
505 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
506 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
507 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
508 |
aStream nextPut:#storeMethodVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
509 |
^ self |
14 | 510 |
]. |
554 | 511 |
|
14 | 512 |
(type == #InstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
513 |
(index <= 10) ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
514 |
theCode := #(storeInstVar1 storeInstVar2 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
515 |
storeInstVar3 storeInstVar4 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
516 |
storeInstVar5 storeInstVar6 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
517 |
storeInstVar7 storeInstVar8 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
518 |
storeInstVar9 storeInstVar10) at:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
519 |
aStream nextPut:theCode. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
520 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
521 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
522 |
aStream nextPut:#storeInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
523 |
^ self |
14 | 524 |
]. |
554 | 525 |
|
14 | 526 |
(type == #BlockVariable) ifTrue:[ |
559 | 527 |
bvIdx := index. |
528 |
||
529 |
"/ find the context where that variable is contained physically |
|
530 |
blocksCode := block. |
|
531 |
[blocksCode notNil and:[blocksCode isInlineBlock]] whileTrue:[ |
|
532 |
blocksCode := blocksCode home |
|
533 |
]. |
|
534 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
535 |
"find deltaLevel to block, where variable was defined" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
536 |
b := codeBlock. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
537 |
deltaLevel := 0. |
559 | 538 |
[b notNil and:[b ~~ blocksCode]] whileTrue:[ |
554 | 539 |
b isInlineBlock ifFalse:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
540 |
deltaLevel := deltaLevel + 1 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
541 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
542 |
b := b home |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
543 |
]. |
14 | 544 |
|
559 | 545 |
b isNil ifTrue:[ |
546 |
codeBlock isNil ifTrue:[ |
|
547 |
"/ a block which is inlined in the method. |
|
548 |
"/ Generate a pushMVAR |
|
549 |
||
550 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
551 |
bvIdx := bvIdx + block numArgs. |
|
552 |
^ self |
|
553 |
codeStoreOn:aStream |
|
554 |
type:#MethodVariable index:bvIdx |
|
555 |
inBlock:codeBlock |
|
556 |
valueNeeded:false "/ already dupped if value is needed |
|
557 |
for:aCompiler |
|
558 |
]. |
|
559 |
"/ a var of a block which is inlined in the outer block. |
|
560 |
"/ Generate a pushBVAR |
|
561 |
||
562 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
563 |
bvIdx := bvIdx + block numArgs. |
|
564 |
] ifFalse:[ |
|
565 |
block isInlineBlock ifTrue:[ |
|
566 |
"/ a var of a block which is inlined in another block. |
|
567 |
"/ Generate a pushBVAR / pushOuterBVAR |
|
568 |
bvIdx := block indexOfFirstTemp + index - 1. |
|
569 |
bvIdx := bvIdx + block numArgs. |
|
570 |
] |
|
571 |
]. |
|
572 |
||
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
573 |
(deltaLevel == 0) ifTrue:[ |
559 | 574 |
bvIdx <= 3 ifTrue:[ |
575 |
aStream nextPut:(#(storeBlockVar1 storeBlockVar2 storeBlockVar3) at:bvIdx). |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
576 |
^ self |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
577 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
578 |
aStream nextPut:#storeBlockVar |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
579 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
580 |
aStream nextPut:#storeOuterBlockVar; nextPut:deltaLevel |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
581 |
]. |
559 | 582 |
aStream nextPut:bvIdx. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
583 |
^ self |
14 | 584 |
]. |
554 | 585 |
|
117 | 586 |
(type == #GlobalVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
587 |
litIndex := aCompiler addLiteral:name asSymbol. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
588 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
589 |
aStream nextPut:#storeGlobalS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
590 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
591 |
aStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
592 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
593 |
^ self |
117 | 594 |
]. |
554 | 595 |
|
14 | 596 |
(type == #ClassVariable) ifTrue:[ |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
597 |
litIndex := aCompiler addLiteral:(value name , ':' , name) asSymbol. |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
598 |
litIndex < 256 ifTrue:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
599 |
aStream nextPut:#storeClassVarS; nextPut:litIndex |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
600 |
] ifFalse:[ |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
601 |
aStream nextPut:#storeClassVarL; nextPut:litIndex; nextPut:0 |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
602 |
]. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
603 |
^ self |
14 | 604 |
]. |
554 | 605 |
|
14 | 606 |
(type == #ClassInstanceVariable) ifTrue:[ |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
607 |
aStream nextPut:#storeClassInstVar; nextPut:index. |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
608 |
^ self |
14 | 609 |
]. |
554 | 610 |
|
106 | 611 |
"not reached" |
941 | 612 |
self error:'bad assignment' |
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
613 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
614 |
"Created: / 25.6.1997 / 16:14:40 / cg" |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
615 |
"Modified: / 17.1.1998 / 04:04:23 / cg" |
14 | 616 |
! ! |
617 |
||
1035 | 618 |
!VariableNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
619 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
620 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
621 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
622 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
623 |
^ anEnumerator doVariable:self name:name |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
624 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
625 |
"Created: 19.6.1997 / 16:41:35 / cg" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
626 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
535
diff
changeset
|
627 |
|
1035 | 628 |
!VariableNode methodsFor:'evaluation'! |
140 | 629 |
|
630 |
evaluate |
|
980 | 631 |
|nameSym| |
632 |
||
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
633 |
(type == #ContextVariable) ifTrue:[ |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
634 |
^ 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
|
635 |
]. |
140 | 636 |
(type == #MethodVariable |
637 |
or:[type == #BlockArg |
|
638 |
or:[type == #BlockVariable]]) ifTrue:[ |
|
420 | 639 |
^ token variableValue |
140 | 640 |
]. |
641 |
(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
|
642 |
^ value instVarAt:index |
140 | 643 |
]. |
1088 | 644 |
(type == #JavaVariable) ifTrue:[ |
645 |
nameSym := name asSymbolIfInterned. |
|
646 |
nameSym notNil ifTrue:[ |
|
647 |
^ JAVA at:name |
|
648 |
]. |
|
649 |
^ UndefinedVariable name:name. |
|
650 |
"/ ^ nil |
|
651 |
]. |
|
140 | 652 |
(type == #GlobalVariable) ifTrue:[ |
980 | 653 |
nameSym := name asSymbolIfInterned. |
654 |
nameSym notNil ifTrue:[ |
|
655 |
(Smalltalk includesKey:nameSym) ifTrue:[ |
|
656 |
^ Smalltalk at:name |
|
657 |
] |
|
420 | 658 |
]. |
140 | 659 |
" |
420 | 660 |
self error:('global ' , name , ' is undefined'). |
140 | 661 |
" |
662 |
||
420 | 663 |
^ UndefinedVariable name:name. |
1088 | 664 |
"/ ^ nil |
140 | 665 |
]. |
666 |
(type == #ClassVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
667 |
^ Smalltalk at:(value name , ':' , name) asSymbol |
140 | 668 |
]. |
669 |
(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
|
670 |
^ value instVarAt:index |
140 | 671 |
]. |
672 |
(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
|
673 |
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
|
674 |
^ value |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
675 |
]. |
420 | 676 |
^ thisContext |
677 |
]. |
|
678 |
(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
|
679 |
^ value privateClassesAt:name asSymbol |
140 | 680 |
]. |
719 | 681 |
|
682 |
"/ synthetic; for evaluation only |
|
683 |
(type == #EvaluationContextLocal) ifTrue:[ |
|
684 |
^ token variableValue |
|
685 |
]. |
|
1092 | 686 |
"/ synthetic; for evaluation only |
687 |
(type == #WorkspaceVariable) ifTrue:[ |
|
688 |
^ token value |
|
689 |
]. |
|
719 | 690 |
|
140 | 691 |
"not reached" |
719 | 692 |
self halt:'internal error - bad variable type:' , type. |
140 | 693 |
^ value |
420 | 694 |
|
980 | 695 |
"Modified: / 26.9.1999 / 13:04:42 / cg" |
140 | 696 |
! |
697 |
||
698 |
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
|
699 |
(type == #ContextVariable) ifTrue:[ |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
700 |
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
|
701 |
]. |
140 | 702 |
(type == #MethodVariable |
703 |
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
|
704 |
token value:aValue. ^ aValue |
140 | 705 |
]. |
706 |
(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
|
707 |
^ value instVarAt:index put:aValue |
140 | 708 |
]. |
709 |
(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
|
710 |
^ Smalltalk at:name put:aValue |
140 | 711 |
]. |
712 |
(type == #ClassVariable) ifTrue:[ |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
713 |
^ Smalltalk at:(value name , ':' , name) asSymbol put:aValue |
140 | 714 |
]. |
715 |
(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
|
716 |
^ value instVarAt:index put:aValue |
140 | 717 |
]. |
719 | 718 |
|
719 |
"/ synthetic; for evaluation only |
|
720 |
(type == #EvaluationContextLocal) ifTrue:[ |
|
875 | 721 |
token value:aValue. ^ aValue |
722 |
]. |
|
723 |
(type == #WorkspaceVariable) ifTrue:[ |
|
724 |
token value:aValue. ^ aValue |
|
719 | 725 |
]. |
726 |
||
140 | 727 |
"not reached" |
719 | 728 |
self halt:'internal error - bad variable type:' , type. |
140 | 729 |
^ aValue |
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
730 |
|
719 | 731 |
"Modified: / 16.5.1998 / 18:35:03 / cg" |
140 | 732 |
! ! |
733 |
||
1080 | 734 |
!VariableNode methodsFor:'printing & storing'! |
14 | 735 |
|
736 |
displayString |
|
612 | 737 |
"return a string for display in inspectors etc." |
738 |
||
14 | 739 |
^ 'InterpreterVariable(' , self printString , ')' |
612 | 740 |
|
741 |
"Modified: 20.9.1997 / 11:42:07 / cg" |
|
14 | 742 |
! |
743 |
||
744 |
printOn:aStream indent:i |
|
98 | 745 |
|
641
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
746 |
"/ 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
|
747 |
( |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
748 |
type == #ContextVariable |
e18daf10662c
added support for context-vars (for evaluation in the debuggers code-frame)
Claus Gittinger <cg@exept.de>
parents:
612
diff
changeset
|
749 |
or:[type == #MethodArg |
98 | 750 |
or:[type == #MethodVariable |
751 |
or:[type == #InstanceVariable |
|
752 |
or:[type == #BlockArg |
|
753 |
or:[type == #GlobalVariable |
|
1088 | 754 |
or:[type == #JavaVariable |
98 | 755 |
or:[type == #ClassVariable |
756 |
or:[type == #BlockVariable |
|
465 | 757 |
or:[type == #PrivateClass |
872
7cf38a8125e6
support for workspace variables.
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
758 |
or:[type == #WorkspaceVariable |
720 | 759 |
or:[type == #EvaluationContextLocal |
1088 | 760 |
or:[type == #ClassInstanceVariable]]]]]]]]]]]]) ifTrue:[ |
465 | 761 |
aStream nextPutAll:name. ^ self |
14 | 762 |
]. |
763 |
(type == #ThisContext) ifTrue:[ |
|
465 | 764 |
aStream nextPutAll:'thisContext'. ^ self |
14 | 765 |
]. |
766 |
"not reached" |
|
767 |
self halt:'bad type'. |
|
465 | 768 |
|
720 | 769 |
"Modified: / 17.5.1998 / 00:17:12 / cg" |
14 | 770 |
! ! |
140 | 771 |
|
772 |
!VariableNode methodsFor:'queries'! |
|
773 |
||
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
774 |
canReuseAsArg:anotherNode |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
775 |
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
|
776 |
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
|
777 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
778 |
(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
|
779 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
780 |
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
|
781 |
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
|
782 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
783 |
(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
|
784 |
(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
|
785 |
(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
|
786 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
787 |
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
|
788 |
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
|
789 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
790 |
(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
|
791 |
(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
|
792 |
]. |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
793 |
^ false |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
794 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
795 |
"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
|
796 |
"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
|
797 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
798 |
|
566 | 799 |
isArgument |
800 |
"return true, if this is a node for an argument (block or method)" |
|
801 |
||
802 |
^ (type == #MethodArg) or:[type == #BlockArg] |
|
803 |
||
804 |
"Created: 27.6.1997 / 13:07:05 / cg" |
|
805 |
"Modified: 27.6.1997 / 13:07:19 / cg" |
|
806 |
! |
|
807 |
||
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
808 |
isClassVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
809 |
^ type == #ClassVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
810 |
! |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
811 |
|
140 | 812 |
isGlobal |
813 |
"return true, if this is a node for a global variable" |
|
814 |
||
789 | 815 |
|
816 |
^ (type == #GlobalVariable) |
|
817 |
and:[name isSymbol |
|
818 |
and:[Smalltalk includesKey:name]] |
|
819 |
||
820 |
"Modified: / 19.10.1998 / 19:43:04 / cg" |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
821 |
! |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
822 |
|
1076
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
823 |
isInstanceVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
824 |
^ type == #InstanceVariable |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
825 |
! |
b393dc61463e
added #isClassVariable and #isInstanceVariable
Claus Gittinger <cg@exept.de>
parents:
1035
diff
changeset
|
826 |
|
218
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
827 |
isLocal |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
828 |
"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
|
829 |
|
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
830 |
^ (type == #MethodVariable) or:[type == #BlockVariable] |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
831 |
|
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
832 |
"Created: 1.3.1996 / 00:03:53 / cg" |
748b4c509a51
use new BlockVar instructions
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
833 |
"Modified: 1.3.1996 / 00:04:46 / cg" |
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
834 |
! |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
835 |
|
965 | 836 |
isUndeclared |
837 |
type == #PrivateClass ifTrue:[ |
|
838 |
^ (Smalltalk includesKey:(value name , '::' , name) asSymbol) not |
|
839 |
]. |
|
840 |
type == #GlobalVariable ifTrue:[ |
|
841 |
^ (Smalltalk includesKey:name) not |
|
842 |
]. |
|
843 |
^ false |
|
844 |
! |
|
845 |
||
243
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
846 |
isVariable |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
847 |
"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
|
848 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
849 |
^ true |
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
850 |
|
cdc1424ddaac
use dup if possible when pushing args / faster access to common globals
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
851 |
"Created: 14.4.1996 / 00:46:32 / cg" |
140 | 852 |
! ! |
853 |
||
360 | 854 |
!VariableNode class methodsFor:'documentation'! |
148 | 855 |
|
856 |
version |
|
1092 | 857 |
^ '$Header: /cvs/stx/stx/libcomp/VariableNode.st,v 1.50 2000-10-09 10:42:06 cg Exp $' |
148 | 858 |
! ! |