CascadeNode.st
author Claus Gittinger <cg@exept.de>
Wed, 28 May 2008 11:42:30 +0200
changeset 2098 a03891b6fc30
parent 1588 4c3183dfaa5f
child 2319 636647549e7c
permissions -rw-r--r--
more intelligent genertion of missing method
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     1
"
4
f6fd83437415 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
104
claus
parents: 103
diff changeset
     3
	      All Rights Reserved
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     4
7ad01559b262 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
7ad01559b262 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
7ad01559b262 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7ad01559b262 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7ad01559b262 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
7ad01559b262 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    11
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    12
1079
2a996e0def30 category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    13
"{ Package: 'stx:libcomp' }"
2a996e0def30 category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    14
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    15
MessageNode subclass:#CascadeNode
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    16
	instanceVariableNames:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    17
	classVariableNames:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    18
	poolDictionaries:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    19
	category:'System-Compiler-Support'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    20
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    21
20
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    22
!CascadeNode class methodsFor:'documentation'!
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    23
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    24
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    25
"
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    26
 COPYRIGHT (c) 1989 by Claus Gittinger
104
claus
parents: 103
diff changeset
    27
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    28
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    29
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    30
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    33
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    34
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    35
"
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    36
!
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    37
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    38
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    39
"
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    40
    node for parse-trees, representing cascade message sends
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    41
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    44
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    45
"
f8dd8ba75205 *** empty log message ***
claus
parents: 15
diff changeset
    46
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    47
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    48
!CascadeNode methodsFor:'code generation'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    49
104
claus
parents: 103
diff changeset
    50
codeForCascadeOn:aStream inBlock:b for:aCompiler
claus
parents: 103
diff changeset
    51
    receiver codeForCascadeOn:aStream inBlock:b for:aCompiler.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    52
    aStream nextPut:#dup.
104
claus
parents: 103
diff changeset
    53
    self codeSendOn:aStream inBlock:b valueNeeded:false for:aCompiler
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    54
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    55
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    56
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    57
    receiver codeForCascadeOn:aStream inBlock:b for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    58
    self codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    59
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
    60
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 861
diff changeset
    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
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    66
    "/ sigh; ST/X encodes things differently ...
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    67
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    68
    |r nd msgs msg|
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    69
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    70
    msgs := OrderedCollection new.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    71
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    72
    r := receiver.
819
83f614a5a77d eliminated isKindOf
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
    73
    [r isCascade] whileTrue:[
542
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    74
        r := r receiver.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    75
    ].
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    76
    r := r receiver.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    77
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    78
    nd := self.
819
83f614a5a77d eliminated isKindOf
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
    79
    [nd isCascade] whileTrue:[
542
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    80
        msg := MessageNode new.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    81
        msg receiver:r selector:nd selector args:nd args lineno:nd lineNumber.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    82
        msgs addFirst:msg.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    83
        nd := nd receiver.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    84
    ].
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    85
    msg := MessageNode new.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    86
    msg receiver:r selector:nd selector args:nd args lineno:nd lineNumber.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    87
    msgs addFirst:msg.
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    88
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    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
728300bd8861 more ST80 compatibility
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
    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
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 861
diff changeset
    95
!CascadeNode methodsFor:'evaluation'!
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    96
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    97
evaluateForCascadeIn:anEnvironment
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    98
    |t argValueArray|
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
    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
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   102
    receiver isSuper ifTrue:[
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   103
        ^ super evaluateForCascadeIn:anEnvironment
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   104
    ].
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   105
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   106
    t := receiver evaluateForCascadeIn:anEnvironment.
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   107
    argArray isNil ifTrue:[
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   108
        t perform:selector.
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   109
        ^ t
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   110
    ].
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   111
    argValueArray := argArray collect:[:arg | arg evaluateIn:anEnvironment]. 
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   112
    t perform:selector withArguments:argValueArray.
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   113
    ^ t
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   114
!
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   115
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   116
evaluateIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   117
    |t argValueArray|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   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
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   121
    receiver isSuper ifTrue:[
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   122
        ^ super evaluateIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   123
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   124
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   125
    t := receiver evaluateForCascadeIn:anEnvironment.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   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
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   129
    ].
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1344
diff changeset
   130
    argValueArray := argArray collect:[:arg | arg evaluateIn:anEnvironment].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   131
    ^ t perform:selector withArguments:argValueArray
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   132
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   133
1079
2a996e0def30 category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   134
!CascadeNode methodsFor:'printing & storing'!
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   135
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   136
printOn:aStream indent:i 
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   137
    |selectorParts|
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   138
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   139
    selectorParts := selector asCollectionOfSubstringsSeparatedBy:$:.
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   140
    receiver printOn:aStream indent:i.
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   141
    aStream nextPutAll:'; '.
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   142
    argArray size == 0 ifTrue:[
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   143
        selector printOn:aStream
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   144
    ] ifFalse:[
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   145
        argArray 
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   146
            with:selectorParts
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   147
            do:[:arg :selPart | 
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   148
                aStream 
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   149
                    space;
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   150
                    nextPutAll:selPart;
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   151
                    nextPutAll:': '.
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   152
                arg printOn:aStream indent:i + 4 parenthized:(arg precedence <= self precedence).
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   153
            ]
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   154
    ]
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   155
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   156
    "Modified: / 20-04-2005 / 14:35:39 / cg"
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   157
! !
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   158
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   159
!CascadeNode methodsFor:'queries'!
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   160
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   161
isCascade
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   162
    ^ true
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   163
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   164
    "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
   165
! !
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 542
diff changeset
   166
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   167
!CascadeNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   168
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   169
version
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1500
diff changeset
   170
    ^ '$Header: /cvs/stx/stx/libcomp/CascadeNode.st,v 1.27 2005-04-20 14:41:24 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   171
! !