author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 16:31:47 +0100 | |
changeset 135 | aa4f7b8f121e |
parent 104 | 2016bfa4cd45 |
child 140 | 1ef1d1395146 |
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 |
||
13 |
MessageNode subclass:#CascadeNode |
|
14 |
instanceVariableNames:'' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'System-Compiler-Support' |
|
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 |
version |
|
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
104
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libcomp/CascadeNode.st,v 1.11 1995-11-11 15:30:15 cg Exp $' |
20 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
node for parse-trees, representing cascade message sends |
|
43 |
" |
|
44 |
! ! |
|
0 | 45 |
|
46 |
!CascadeNode methodsFor: 'code generation'! |
|
47 |
||
104 | 48 |
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler |
49 |
receiver codeForCascadeOn:aStream inBlock:b for:aCompiler. |
|
50 |
self codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler |
|
0 | 51 |
! |
52 |
||
104 | 53 |
codeForCascadeOn:aStream inBlock:b for:aCompiler |
54 |
receiver codeForCascadeOn:aStream inBlock:b for:aCompiler. |
|
0 | 55 |
aStream nextPut:#dup. |
104 | 56 |
self codeSendOn:aStream inBlock:b valueNeeded:false for:aCompiler |
0 | 57 |
! ! |
58 |
||
15 | 59 |
!CascadeNode methodsFor: 'printing'! |
60 |
||
61 |
printOn:aStream indent:i |
|
62 |
|needParen selectorParts index index2 arg nargs| |
|
63 |
||
64 |
index := 1. |
|
65 |
selectorParts := OrderedCollection new. |
|
66 |
[index == 0] whileFalse:[ |
|
104 | 67 |
index2 := selector indexOf:$: startingAt:index. |
68 |
index2 ~~ 0 ifTrue:[ |
|
69 |
selectorParts add:(selector copyFrom:index to:index2). |
|
70 |
index2 := index2 + 1 |
|
71 |
]. |
|
72 |
index := index2 |
|
15 | 73 |
]. |
74 |
||
75 |
receiver printOn:aStream indent:i. |
|
76 |
aStream nextPutAll:'; '. |
|
77 |
||
78 |
nargs := argArray size. |
|
79 |
nargs == 0 ifTrue:[ |
|
104 | 80 |
selector printOn:aStream |
15 | 81 |
] ifFalse:[ |
104 | 82 |
1 to:nargs do:[:argIndex | |
83 |
aStream space. |
|
84 |
(selectorParts at:argIndex) printOn:aStream. |
|
85 |
aStream space. |
|
86 |
arg := argArray at:argIndex. |
|
87 |
needParen := false. |
|
88 |
arg isMessage ifTrue:[ |
|
89 |
arg isBinaryMessage ifFalse:[ |
|
90 |
arg isUnaryMessage ifFalse:[ |
|
91 |
needParen := true |
|
92 |
] |
|
93 |
]. |
|
94 |
]. |
|
95 |
needParen ifTrue:[ |
|
96 |
aStream nextPutAll:'(' |
|
97 |
]. |
|
98 |
arg printOn:aStream indent:i. |
|
99 |
needParen ifTrue:[ |
|
100 |
aStream nextPutAll:') ' |
|
101 |
]. |
|
102 |
] |
|
15 | 103 |
] |
104 |
! ! |
|
105 |
||
0 | 106 |
!CascadeNode methodsFor: 'evaluating'! |
107 |
||
108 |
evaluate |
|
3 | 109 |
|t argValueArray| |
0 | 110 |
|
13 | 111 |
receiver isSuper ifTrue:[ |
104 | 112 |
^ super evaluate |
13 | 113 |
]. |
114 |
||
0 | 115 |
t := receiver evaluateForCascade. |
116 |
argArray isNil ifTrue:[ |
|
104 | 117 |
t perform:selector. |
118 |
^ t |
|
0 | 119 |
]. |
3 | 120 |
argValueArray := argArray collect:[:arg | arg evaluate]. |
0 | 121 |
^ t perform:selector withArguments:argValueArray |
122 |
! |
|
123 |
||
124 |
evaluateForCascade |
|
3 | 125 |
|t argValueArray| |
0 | 126 |
|
13 | 127 |
receiver isSuper ifTrue:[ |
104 | 128 |
^ super evaluateForCascade |
13 | 129 |
]. |
130 |
||
0 | 131 |
t := receiver evaluateForCascade. |
132 |
argArray isNil ifTrue:[ |
|
104 | 133 |
t perform:selector. |
134 |
^ t |
|
0 | 135 |
]. |
3 | 136 |
argValueArray := argArray collect:[:arg | arg evaluate]. |
0 | 137 |
t perform:selector withArguments:argValueArray. |
138 |
^ t |
|
139 |
! ! |