UnaryNode.st
author Claus Gittinger <cg@exept.de>
Wed, 03 Apr 2019 22:40:09 +0200
changeset 4403 4649f9dd9614
parent 4270 0b40e4987029
permissions -rw-r--r--
#DOCUMENTATION by cg class: LazyMethod changed: #noByteCode
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
"
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    12
"{ Package: 'stx:libcomp' }"
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    13
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
    14
"{ NameSpace: Smalltalk }"
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
    15
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    16
MessageNode subclass:#UnaryNode
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 212
diff changeset
    17
	instanceVariableNames:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 212
diff changeset
    18
	classVariableNames:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 212
diff changeset
    19
	poolDictionaries:''
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 212
diff changeset
    20
	category:'System-Compiler-Support'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    21
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    22
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    23
!UnaryNode class methodsFor:'documentation'!
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    24
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    25
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    26
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    27
 COPYRIGHT (c) 1989 by Claus Gittinger
104
claus
parents: 103
diff changeset
    28
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    29
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    30
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    31
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    33
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    34
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    35
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    36
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    37
!
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    38
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    39
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    40
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    41
    node for parse-trees, representing unary messages
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 212
diff changeset
    42
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    44
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    45
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    46
"
f8dd8ba75205 *** empty log message ***
claus
parents: 17
diff changeset
    47
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    48
7ad01559b262 Initial revision
claus
parents:
diff changeset
    49
!UnaryNode class methodsFor:'instance creation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    50
7ad01559b262 Initial revision
claus
parents:
diff changeset
    51
receiver:r selector:s
11
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
    52
    "return a new UnaryNode for sending selector s to receiver r.
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
    53
     Fold constants."
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
    54
991
16411f243a75 compile-time-eval Smalltalk #isSmalltalkXXX messages.
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
    55
    ^ self receiver:r selector:s fold:true
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    56
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    57
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
    58
receiver:r selector:selectorString fold:folding
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
    59
    "return a new UnaryNode for sending selector selectorString to receiver r.
11
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
    60
     If folding is true, fold constant expressions."
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
    61
4159
c4e6052f03c7 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4155
diff changeset
    62
    |result recVal selector canFold globalName caughtErrorMessage|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    63
7ad01559b262 Initial revision
claus
parents:
diff changeset
    64
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    65
    The constant folding code can usually not optimize things - this may change
7ad01559b262 Initial revision
claus
parents:
diff changeset
    66
    when some kind of constant declaration is added to smalltalk.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    67
"
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    68
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    69
    canFold := false.
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    70
993
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
    71
    (folding notNil and:[folding ~~ false]) ifTrue:[
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    72
        selector := selectorString asSymbolIfInterned.
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    73
        selector notNil ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    74
            "/
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    75
            "/ do constant folding ...
2111
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    76
            "/ evaluate at compile time:
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    77
            "/      Character tab
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    78
            "/      Character cr
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
    79
            "/          ...
2111
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    80
            "/      Float pi
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    81
            "/      Float e
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
    82
            "/          ...
2111
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    83
            "/      String cr
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    84
            "/      String crlf
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
    85
            "/          ...
2111
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    86
            "/      #(...) asFloatArray
ecfcbcbe299f comment
Claus Gittinger <cg@exept.de>
parents: 2094
diff changeset
    87
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    88
            r isGlobal ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    89
                globalName := r name.
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    90
                recVal := r evaluate.
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    91
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    92
                (globalName = 'Character') ifTrue:[
2001
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
    93
                    ( #( tab cr lf return space backspace esc ) includes:selector)
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    94
                    ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    95
                        canFold := true
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    96
                    ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    97
                ].
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
    98
                (globalName = 'Float') ifTrue:[
2001
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
    99
                    ( #( pi e NaN unity zero ) includes:selector)
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   100
                    ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   101
                        (recVal respondsTo:selector) ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   102
                            canFold := true
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   103
                        ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   104
                    ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   105
                ].
2001
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   106
                (globalName = 'String') ifTrue:[
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   107
                    ( #( cr crlf lf ) includes:selector)
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   108
                    ifTrue:[
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   109
                        (recVal respondsTo:selector) ifTrue:[
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   110
                            canFold := true
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   111
                        ]
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   112
                    ]
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   113
                ].
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   114
1144
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   115
"/ no, this 'optimization' is not good -
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   116
"/ if bytecode is transported to another machine.
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   117
"/ However, the JIT compiler compensates for this ;-)
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   118
"/                (globalName = 'Smalltalk') ifTrue:[
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   119
"/                    ( #( isSmalltalkX isVisualWorks isSqueak
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
   120
"/                         isSmalltalkMT isDolphinSmalltalk isVisualAge
1144
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   121
"/                         isSmalltalkV) includes:selector)
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   122
"/                    ifTrue:[
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   123
"/                        (recVal respondsTo:selector) ifTrue:[
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   124
"/                            canFold := true
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   125
"/                        ]
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   126
"/                    ]
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   127
"/                ].
94739bcecd7b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   128
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   129
"/ no, this 'optimization' is not good -
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   130
"/ if bytecode is transported to another machine.
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   131
"/ However, the JIT compiler compensates for this ;-)
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   132
"/                (globalName = 'SmallInteger') ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   133
"/                    ( #( minVal maxVal ) includes:selector)
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   134
"/                    ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   135
"/                        (recVal respondsTo:selector) ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   136
"/                            canFold := true
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   137
"/                        ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   138
"/                    ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   139
"/                ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   140
            ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   141
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   142
            r isConstant ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   143
                "check if we can do it ..."
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   144
                recVal := r evaluate.
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   145
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   146
                "
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   147
                 we could do much more here - but then, we need a dependency from
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   148
                 the folded selectors method to the method we generate code for ...
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
   149
                 limit optimizations to those that will never change
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   150
                 (or, if you change them, it will crash badly anyway ...)
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   151
                "
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   152
                recVal respondsToArithmetic ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   153
                    (#( negated abs asPoint degreesToRadians radiansToDegrees
4270
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   154
                        reciprocal) includes:selector)
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   155
                    ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   156
                        canFold := true
4270
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   157
                    ] ifFalse:[
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   158
                        (#(exp ln log sqrt
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   159
                            arcCos arcSin arcTan sin cos tan) includes:selector)
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   160
                        ifTrue:[
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   161
                            (recVal isKindOf:LargeInteger) ifFalse:[
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   162
                                canFold := true
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   163
                            ]
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   164
                        ]
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   165
                    ].
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   166
                ].
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   167
                recVal isCharacter ifTrue:[
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
   168
                    (#( asciiValue asInteger digitValue asString) includes:selector)
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   169
                    ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   170
                        canFold := true
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   171
                    ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   172
                ].
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   173
                recVal isString ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   174
                    (selector == #withCRs) ifTrue:[
993
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   175
                        canFold := folding isSymbol
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   176
                                   and:[(folding >= #level2) or:[folding == #full]]
803
4d31ec53f65d constant fold 'string' size.
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   177
                    ].
4d31ec53f65d constant fold 'string' size.
Claus Gittinger <cg@exept.de>
parents: 711
diff changeset
   178
                    (selector == #size) ifTrue:[
993
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   179
                        canFold := folding isSymbol
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   180
                                   and:[(folding >= #level1) or:[folding == #full]]
1093
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   181
                    ].
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   182
                    (selector == #asSymbol) ifTrue:[
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   183
                        canFold := folding isSymbol
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   184
                                   and:[(folding >= #level1) or:[folding == #full]]
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   185
                    ].
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   186
                ].
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   187
                (recVal isMemberOf:Array) ifTrue:[
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   188
                    (#(asFloatArray asDoubleArray) includes:selector) ifTrue:[
993
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   189
                        canFold := folding isSymbol
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 991
diff changeset
   190
                                   and:[(folding >= #level2) or:[folding == #full]]
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   191
                    ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   192
                ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   193
            ]
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   194
        ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   195
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   196
        canFold ifTrue:[
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   197
            (recVal respondsTo:selector) ifTrue:[
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   198
                SignalSet anySignal "Number domainErrorSignal" handle:[:ex |
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   199
                    "in case of an error, abort fold and return original"
4159
c4e6052f03c7 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4155
diff changeset
   200
                    caughtErrorMessage := ex description.
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   201
                    ex return
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   202
                ] do:[
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   203
                    result := recVal perform:selector.
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   204
                    ^ ConstantNode type:(ConstantNode typeOfConstant:result) value:result
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   205
                ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   206
                "when we reach here, something went wrong (something like 0.0 log)"
4159
c4e6052f03c7 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4155
diff changeset
   207
                ^ ParseErrorNode 
c4e6052f03c7 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4155
diff changeset
   208
                    errorString:(caughtErrorMessage,' - error occurred while evaluating constant expression')
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   209
            ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   210
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   211
    ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   212
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   213
    ^ (self basicNew) receiver:r selector:selectorString args:nil lineno:0
625
0b93edcf1116 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   214
4159
c4e6052f03c7 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4155
diff changeset
   215
    "Modified: / 03-07-2017 / 13:56:31 / cg"
4270
0b40e4987029 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4159
diff changeset
   216
    "Modified: / 25-05-2018 / 16:05:52 / Claus Gittinger"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   217
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   218
3333
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   219
!UnaryNode methodsFor:'accessing'!
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   220
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   221
selectorPartPositions
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   222
    selectorPartPositions isNil ifTrue:[
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   223
        selectorPartPositions := Array with: (selectorPosition to: selectorPosition + selector size - 1).
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   224
    ].
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   225
    ^ selectorPartPositions
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   226
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   227
    "Created: / 19-10-2013 / 23:48:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   228
! !
fb37a7b53ed6 class: UnaryNode
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3309
diff changeset
   229
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   230
!UnaryNode methodsFor:'checks'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   231
2094
87201834a364 alreadyWarned selectors
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   232
plausibilityCheckIn:aParser
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   233
    "check for funny selector - careful to do string compare instead
4038
11950ee05d24 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   234
     of symbol identity compare: I don't want to introduce these as symbols
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   235
     into the system (would make the '... is nowhere implemented' warning
3309
cea9c487db04 class: UnaryNode
Claus Gittinger <cg@exept.de>
parents: 2881
diff changeset
   236
     go away.
cea9c487db04 class: UnaryNode
Claus Gittinger <cg@exept.de>
parents: 2881
diff changeset
   237
     TODO: rewite to use lint/lint rules and apply them before accepting"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   238
1502
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   239
    |selectorSymbol|
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   240
2881
ae13393d1096 - plausibilityCheckIn:aParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2866
diff changeset
   241
    "JV@2012-07-06: Do not check if receiver is Java package,
ae13393d1096 - plausibilityCheckIn:aParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2866
diff changeset
   242
     otherwise it reports false-positives when working with Java code"
ae13393d1096 - plausibilityCheckIn:aParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2866
diff changeset
   243
    receiver isJavaPackageReference ifTrue:[ ^ nil ].
ae13393d1096 - plausibilityCheckIn:aParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2866
diff changeset
   244
1502
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   245
    selectorSymbol := selector asSymbolIfInterned.
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   246
    selectorSymbol notNil ifTrue:[
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   247
        ((selectorSymbol == #self) or:[
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   248
         (selectorSymbol == #super) or:[
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   249
         (selectorSymbol == #thisContext) or:[
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   250
         (selectorSymbol == #nil) or:[
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   251
         (selectorSymbol == #true) or:[
2227
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   252
         (selectorSymbol == #false)]]]]]) 
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   253
        ifTrue:[
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   254
            (aParser alreadyWarnedUnimplementedSelectors includes:selectorSymbol) ifFalse:[
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   255
                aParser alreadyWarnedUnimplementedSelectors add:selectorSymbol.
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   256
                ^ 'funny selector: ',selectorSymbol allBold,'; possible missing ''.'' or keyword-colon.'
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   257
            ].
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   258
        ].
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   259
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   260
        (Smalltalk includesKey:selectorSymbol) ifTrue:[
4057
af2ccd5e7eca #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4038
diff changeset
   261
            ( #( void ) includes:selectorSymbol) ifFalse:[
af2ccd5e7eca #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4038
diff changeset
   262
                (aParser alreadyWarnedUnimplementedSelectors includes:selectorSymbol) ifFalse:[
af2ccd5e7eca #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4038
diff changeset
   263
                    aParser alreadyWarnedUnimplementedSelectors add:selectorSymbol.
af2ccd5e7eca #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4038
diff changeset
   264
                    ^ 'funny selector: ',selectorSymbol allBold,' (known as global); possible missing ''.'' or keyword-colon.'
af2ccd5e7eca #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 4038
diff changeset
   265
                ].
2094
87201834a364 alreadyWarned selectors
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   266
            ].
1502
de3c4e208b9f Avoid 'is not a symbol in globalKnown' debug messages from librun
Stefan Vogel <sv@exept.de>
parents: 1500
diff changeset
   267
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   268
    ].
17
f06d70d785dc *** empty log message ***
claus
parents: 15
diff changeset
   269
904
32b8cf2e577d plausibility checks
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
   270
    "
32b8cf2e577d plausibility checks
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
   271
     more to come 
32b8cf2e577d plausibility checks
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
   272
     ...
32b8cf2e577d plausibility checks
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
   273
    "
32b8cf2e577d plausibility checks
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
   274
2094
87201834a364 alreadyWarned selectors
Claus Gittinger <cg@exept.de>
parents: 2036
diff changeset
   275
    ^ super plausibilityCheckIn:aParser
1777
242e89fa2170 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   276
242e89fa2170 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1734
diff changeset
   277
    "Modified: / 16-07-2006 / 16:16:25 / cg"
2881
ae13393d1096 - plausibilityCheckIn:aParser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2866
diff changeset
   278
    "Modified: / 06-07-2012 / 10:46:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   279
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   280
7ad01559b262 Initial revision
claus
parents:
diff changeset
   281
!UnaryNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   282
104
claus
parents: 103
diff changeset
   283
codeOn:aStream inBlock:b for:aCompiler
11
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
   284
    "append bytecode for the receiver to aStream."
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
   285
626
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   286
    |rSel notSelector|
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   287
11
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
   288
    "
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
   289
     optimize 
626
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   290
        (a == b) not -> (a ~~ b)
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   291
        (a ~~ b) not -> (a == b)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   292
    "
7ad01559b262 Initial revision
claus
parents:
diff changeset
   293
    (selector == #not) ifTrue:[
626
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   294
        (receiver class == BinaryNode) ifTrue:[
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   295
            ((rSel := receiver selector) == #==) ifTrue:[
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   296
                notSelector := #~~
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   297
            ] ifFalse:[
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   298
                (rSel == #~~) ifTrue:[
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   299
                    notSelector := #==
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   300
                ]
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   301
            ].
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   302
            notSelector notNil ifTrue:[
1465
2b2eea66362a ensure literals of optimized messages are in lit-array
Claus Gittinger <cg@exept.de>
parents: 1387
diff changeset
   303
                aCompiler addLiteral:selector; addLiteral:rSel.
2b2eea66362a ensure literals of optimized messages are in lit-array
Claus Gittinger <cg@exept.de>
parents: 1387
diff changeset
   304
1998
6d71aa027bc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1777
diff changeset
   305
                (BinaryNode 
6d71aa027bc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1777
diff changeset
   306
                        receiver:(receiver receiver)
6d71aa027bc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1777
diff changeset
   307
                        selector:notSelector
6d71aa027bc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1777
diff changeset
   308
                        arg:(receiver arg)) 
6d71aa027bc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1777
diff changeset
   309
                    codeOn:aStream 
6d71aa027bc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1777
diff changeset
   310
                    inBlock:b 
6d71aa027bc4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1777
diff changeset
   311
                    for:aCompiler.
626
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   312
                ^ self
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   313
            ]
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   314
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   315
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   316
104
claus
parents: 103
diff changeset
   317
    ^ super codeOn:aStream inBlock:b for:aCompiler
626
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   318
2001
fd1703cee96f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1998
diff changeset
   319
    "Modified: / 05-03-2007 / 15:11:35 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   320
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   321
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   322
!UnaryNode methodsFor:'evaluation'!
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   323
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
   324
evaluateIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   325
    "evaluate the expression represented by the receiver"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   326
2036
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   327
    |r|
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   328
1500
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1465
diff changeset
   329
    selector := selector asSymbol.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   330
    receiver isSuper ifTrue:[
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1311
diff changeset
   331
        ^ super evaluateIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   332
    ].
2036
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   333
    r := receiver evaluateIn:anEnvironment.
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   334
    selector == #class ifTrue:[
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   335
        ^ r class.
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   336
    ].
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   337
    ^ r perform:selector
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   338
989b8836fc32 do #class inline to avoid #perform:
Claus Gittinger <cg@exept.de>
parents: 2001
diff changeset
   339
    "Modified: / 04-06-2007 / 17:46:31 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   340
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   341
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   342
!UnaryNode methodsFor:'printing & storing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   343
1589
e50e9f5bf31b printing
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   344
printOn:aStream indent:i 
11
60691e5007e3 *** empty log message ***
claus
parents: 4
diff changeset
   345
    "prettyprint the expression represented by the receiver"
1589
e50e9f5bf31b printing
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   346
    
e50e9f5bf31b printing
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   347
    receiver printOn:aStream indent:i parenthized:(receiver precedence < self precedence).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   348
    aStream space.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   349
    selector printString printOn:aStream.
1589
e50e9f5bf31b printing
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   350
e50e9f5bf31b printing
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   351
    "Modified: / 20-04-2005 / 14:36:26 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   352
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   353
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   354
!UnaryNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   355
2322
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   356
precedence
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   357
    ^ 100
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   358
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   359
    "Created: / 20-04-2005 / 14:10:34 / cg"
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   360
! !
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   361
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   362
!UnaryNode methodsFor:'testing'!
1b4c76322746 category change
Claus Gittinger <cg@exept.de>
parents: 2227
diff changeset
   363
2863
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   364
isJavaPackageReference
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   365
    "Return true, given node is JAVA class reference in form:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   366
        JAVA package1 package2
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   367
    "
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   368
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   369
    ^receiver isJavaPackageReference 
4155
801ff4adeef5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4057
diff changeset
   370
        and:[selector isLowercaseFirst
2866
21be09ac87b1 changed: #isJavaPackageReference
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2863
diff changeset
   371
            and:[selector isUnarySelector]]
2863
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   372
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   373
    "Created: / 19-04-2012 / 09:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4155
801ff4adeef5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4057
diff changeset
   374
    "Modified: / 22-06-2017 / 06:57:49 / cg"
2863
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   375
!
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2597
diff changeset
   376
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   377
isUnaryMessage
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   378
    "return true, if this node is one for a unary message"
626
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   379
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   380
    ^ true
626
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   381
7192fcd0a851 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 625
diff changeset
   382
    "Modified: 23.10.1997 / 02:05:18 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   383
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   384
2597
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   385
!UnaryNode methodsFor:'visiting'!
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   386
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   387
acceptVisitor:aVisitor 
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   388
    "Double dispatch back to the visitor, passing my type encoded in
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   389
     the selector (visitor pattern)"
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   390
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   391
    "stub code automatically generated - please change if required"
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   392
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   393
    ^ aVisitor visitUnaryNode:self
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   394
! !
cf2f79153a11 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2322
diff changeset
   395
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   396
!UnaryNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   397
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   398
version
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
   399
    ^ '$Header$'
2227
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   400
!
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   401
5b45a572dc15 changed: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2111
diff changeset
   402
version_CVS
3936
68f3c2d9d417 #OTHER by mawalch
mawalch
parents: 3333
diff changeset
   403
    ^ '$Header$'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   404
! !
3309
cea9c487db04 class: UnaryNode
Claus Gittinger <cg@exept.de>
parents: 2881
diff changeset
   405