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 |
|
|
13 |
MessageNode subclass:#CascadeNode
|
261
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'System-Compiler-Support'
|
0
|
18 |
!
|
|
19 |
|
20
|
20 |
!CascadeNode class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
104
|
25 |
All Rights Reserved
|
20
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
|
38 |
node for parse-trees, representing cascade message sends
|
261
|
39 |
This is a helper class for the compiler.
|
263
|
40 |
|
|
41 |
[author:]
|
|
42 |
Claus Gittinger
|
20
|
43 |
"
|
|
44 |
! !
|
0
|
45 |
|
140
|
46 |
!CascadeNode methodsFor:'code generation'!
|
0
|
47 |
|
104
|
48 |
codeForCascadeOn:aStream inBlock:b for:aCompiler
|
|
49 |
receiver codeForCascadeOn:aStream inBlock:b for:aCompiler.
|
0
|
50 |
aStream nextPut:#dup.
|
104
|
51 |
self codeSendOn:aStream inBlock:b valueNeeded:false for:aCompiler
|
140
|
52 |
!
|
|
53 |
|
|
54 |
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
|
|
55 |
receiver codeForCascadeOn:aStream inBlock:b for:aCompiler.
|
|
56 |
self codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
|
0
|
57 |
! !
|
|
58 |
|
140
|
59 |
!CascadeNode methodsFor:'evaluating'!
|
|
60 |
|
|
61 |
evaluate
|
|
62 |
|t argValueArray|
|
|
63 |
|
|
64 |
receiver isSuper ifTrue:[
|
|
65 |
^ super evaluate
|
|
66 |
].
|
|
67 |
|
|
68 |
t := receiver evaluateForCascade.
|
|
69 |
argArray isNil ifTrue:[
|
|
70 |
t perform:selector.
|
|
71 |
^ t
|
|
72 |
].
|
|
73 |
argValueArray := argArray collect:[:arg | arg evaluate].
|
|
74 |
^ t perform:selector withArguments:argValueArray
|
|
75 |
!
|
|
76 |
|
|
77 |
evaluateForCascade
|
|
78 |
|t argValueArray|
|
|
79 |
|
|
80 |
receiver isSuper ifTrue:[
|
|
81 |
^ super evaluateForCascade
|
|
82 |
].
|
|
83 |
|
|
84 |
t := receiver evaluateForCascade.
|
|
85 |
argArray isNil ifTrue:[
|
|
86 |
t perform:selector.
|
|
87 |
^ t
|
|
88 |
].
|
|
89 |
argValueArray := argArray collect:[:arg | arg evaluate].
|
|
90 |
t perform:selector withArguments:argValueArray.
|
|
91 |
^ t
|
|
92 |
! !
|
|
93 |
|
|
94 |
!CascadeNode methodsFor:'printing'!
|
15
|
95 |
|
|
96 |
printOn:aStream indent:i
|
|
97 |
|needParen selectorParts index index2 arg nargs|
|
|
98 |
|
|
99 |
index := 1.
|
|
100 |
selectorParts := OrderedCollection new.
|
|
101 |
[index == 0] whileFalse:[
|
104
|
102 |
index2 := selector indexOf:$: startingAt:index.
|
|
103 |
index2 ~~ 0 ifTrue:[
|
|
104 |
selectorParts add:(selector copyFrom:index to:index2).
|
|
105 |
index2 := index2 + 1
|
|
106 |
].
|
|
107 |
index := index2
|
15
|
108 |
].
|
|
109 |
|
|
110 |
receiver printOn:aStream indent:i.
|
|
111 |
aStream nextPutAll:'; '.
|
|
112 |
|
|
113 |
nargs := argArray size.
|
|
114 |
nargs == 0 ifTrue:[
|
104
|
115 |
selector printOn:aStream
|
15
|
116 |
] ifFalse:[
|
104
|
117 |
1 to:nargs do:[:argIndex |
|
|
118 |
aStream space.
|
|
119 |
(selectorParts at:argIndex) printOn:aStream.
|
|
120 |
aStream space.
|
|
121 |
arg := argArray at:argIndex.
|
|
122 |
needParen := false.
|
|
123 |
arg isMessage ifTrue:[
|
|
124 |
arg isBinaryMessage ifFalse:[
|
|
125 |
arg isUnaryMessage ifFalse:[
|
|
126 |
needParen := true
|
|
127 |
]
|
|
128 |
].
|
|
129 |
].
|
|
130 |
needParen ifTrue:[
|
|
131 |
aStream nextPutAll:'('
|
|
132 |
].
|
|
133 |
arg printOn:aStream indent:i.
|
|
134 |
needParen ifTrue:[
|
|
135 |
aStream nextPutAll:') '
|
|
136 |
].
|
|
137 |
]
|
15
|
138 |
]
|
|
139 |
! !
|
|
140 |
|
148
|
141 |
!CascadeNode class methodsFor:'documentation'!
|
|
142 |
|
|
143 |
version
|
263
|
144 |
^ '$Header: /cvs/stx/stx/libcomp/Attic/CascadeNd.st,v 1.15 1996-04-25 17:09:25 cg Exp $'
|
148
|
145 |
! !
|