author | Claus Gittinger <cg@exept.de> |
Thu, 25 Nov 2004 15:30:33 +0100 | |
changeset 1561 | 175735dcd732 |
parent 1500 | 3c4cb012b24b |
child 1588 | 4c3183dfaa5f |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
104 | 3 |
All Rights Reserved |
0 | 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 |
||
1079 | 13 |
"{ Package: 'stx:libcomp' }" |
14 |
||
0 | 15 |
MessageNode subclass:#CascadeNode |
261 | 16 |
instanceVariableNames:'' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'System-Compiler-Support' |
|
0 | 20 |
! |
21 |
||
20 | 22 |
!CascadeNode class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
104 | 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 cascade message sends |
|
261 | 41 |
This is a helper class for the compiler. |
263 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
20 | 45 |
" |
46 |
! ! |
|
0 | 47 |
|
140 | 48 |
!CascadeNode methodsFor:'code generation'! |
0 | 49 |
|
104 | 50 |
codeForCascadeOn:aStream inBlock:b for:aCompiler |
51 |
receiver codeForCascadeOn:aStream inBlock:b for:aCompiler. |
|
0 | 52 |
aStream nextPut:#dup. |
104 | 53 |
self codeSendOn:aStream inBlock:b valueNeeded:false for:aCompiler |
140 | 54 |
! |
55 |
||
56 |
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler |
|
57 |
receiver codeForCascadeOn:aStream inBlock:b for:aCompiler. |
|
58 |
self codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler |
|
0 | 59 |
! ! |
60 |
||
1035 | 61 |
!CascadeNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
62 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
63 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
64 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
65 |
|
542 | 66 |
"/ sigh; ST/X encodes things differently ... |
67 |
||
68 |
|r nd msgs msg| |
|
69 |
||
70 |
msgs := OrderedCollection new. |
|
71 |
||
72 |
r := receiver. |
|
819 | 73 |
[r isCascade] whileTrue:[ |
542 | 74 |
r := r receiver. |
75 |
]. |
|
76 |
r := r receiver. |
|
77 |
||
78 |
nd := self. |
|
819 | 79 |
[nd isCascade] whileTrue:[ |
542 | 80 |
msg := MessageNode new. |
81 |
msg receiver:r selector:nd selector args:nd args lineno:nd lineNumber. |
|
82 |
msgs addFirst:msg. |
|
83 |
nd := nd receiver. |
|
84 |
]. |
|
85 |
msg := MessageNode new. |
|
86 |
msg receiver:r selector:nd selector args:nd args lineno:nd lineNumber. |
|
87 |
msgs addFirst:msg. |
|
88 |
||
89 |
^ anEnumerator doCascade:self receiver:r messages:msgs |
|
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
90 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
91 |
"Created: 19.6.1997 / 16:39:17 / cg" |
542 | 92 |
"Modified: 19.6.1997 / 17:32:47 / cg" |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
93 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
94 |
|
1035 | 95 |
!CascadeNode methodsFor:'evaluation'! |
140 | 96 |
|
1384 | 97 |
evaluateForCascadeIn:anEnvironment |
98 |
|t argValueArray| |
|
99 |
||
1500
3c4cb012b24b
Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
100 |
selector := selector asSymbol. |
3c4cb012b24b
Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
101 |
|
1384 | 102 |
receiver isSuper ifTrue:[ |
103 |
^ super evaluateForCascadeIn:anEnvironment |
|
104 |
]. |
|
105 |
||
106 |
t := receiver evaluateForCascadeIn:anEnvironment. |
|
107 |
argArray isNil ifTrue:[ |
|
108 |
t perform:selector. |
|
109 |
^ t |
|
110 |
]. |
|
111 |
argValueArray := argArray collect:[:arg | arg evaluateIn:anEnvironment]. |
|
112 |
t perform:selector withArguments:argValueArray. |
|
113 |
^ t |
|
114 |
! |
|
115 |
||
116 |
evaluateIn:anEnvironment |
|
140 | 117 |
|t argValueArray| |
118 |
||
1500
3c4cb012b24b
Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
119 |
selector := selector asSymbol. |
3c4cb012b24b
Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
120 |
|
140 | 121 |
receiver isSuper ifTrue:[ |
1384 | 122 |
^ super evaluateIn:anEnvironment |
140 | 123 |
]. |
124 |
||
1384 | 125 |
t := receiver evaluateForCascadeIn:anEnvironment. |
140 | 126 |
argArray isNil ifTrue:[ |
1344
e181501d8aa0
oops - cascade-evaluation did not return last value
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
127 |
^ t perform:selector. |
e181501d8aa0
oops - cascade-evaluation did not return last value
Claus Gittinger <cg@exept.de>
parents:
1079
diff
changeset
|
128 |
"/ t perform:selector. ^ t |
140 | 129 |
]. |
1384 | 130 |
argValueArray := argArray collect:[:arg | arg evaluateIn:anEnvironment]. |
140 | 131 |
^ t perform:selector withArguments:argValueArray |
132 |
! ! |
|
133 |
||
1079 | 134 |
!CascadeNode methodsFor:'printing & storing'! |
15 | 135 |
|
136 |
printOn:aStream indent:i |
|
137 |
|needParen selectorParts index index2 arg nargs| |
|
138 |
||
139 |
index := 1. |
|
140 |
selectorParts := OrderedCollection new. |
|
141 |
[index == 0] whileFalse:[ |
|
104 | 142 |
index2 := selector indexOf:$: startingAt:index. |
143 |
index2 ~~ 0 ifTrue:[ |
|
144 |
selectorParts add:(selector copyFrom:index to:index2). |
|
145 |
index2 := index2 + 1 |
|
146 |
]. |
|
147 |
index := index2 |
|
15 | 148 |
]. |
149 |
||
150 |
receiver printOn:aStream indent:i. |
|
151 |
aStream nextPutAll:'; '. |
|
152 |
||
153 |
nargs := argArray size. |
|
154 |
nargs == 0 ifTrue:[ |
|
104 | 155 |
selector printOn:aStream |
15 | 156 |
] ifFalse:[ |
104 | 157 |
1 to:nargs do:[:argIndex | |
158 |
aStream space. |
|
159 |
(selectorParts at:argIndex) printOn:aStream. |
|
160 |
aStream space. |
|
161 |
arg := argArray at:argIndex. |
|
162 |
needParen := false. |
|
163 |
arg isMessage ifTrue:[ |
|
164 |
arg isBinaryMessage ifFalse:[ |
|
165 |
arg isUnaryMessage ifFalse:[ |
|
166 |
needParen := true |
|
167 |
] |
|
168 |
]. |
|
169 |
]. |
|
170 |
needParen ifTrue:[ |
|
171 |
aStream nextPutAll:'(' |
|
172 |
]. |
|
173 |
arg printOn:aStream indent:i. |
|
174 |
needParen ifTrue:[ |
|
175 |
aStream nextPutAll:') ' |
|
176 |
]. |
|
177 |
] |
|
15 | 178 |
] |
179 |
! ! |
|
180 |
||
744
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
181 |
!CascadeNode methodsFor:'queries'! |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
182 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
183 |
isCascade |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
184 |
^ true |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
185 |
|
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
186 |
"Created: / 16.7.1998 / 20:03:51 / cg" |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
187 |
! ! |
e871f9f072f8
changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents:
542
diff
changeset
|
188 |
|
148 | 189 |
!CascadeNode class methodsFor:'documentation'! |
190 |
||
191 |
version |
|
1500
3c4cb012b24b
Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents:
1387
diff
changeset
|
192 |
^ '$Header: /cvs/stx/stx/libcomp/CascadeNode.st,v 1.26 2004-03-19 13:25:46 stefan Exp $' |
148 | 193 |
! ! |