UnaryNode.st
changeset 4159 c4e6052f03c7
parent 4155 801ff4adeef5
child 4270 0b40e4987029
equal deleted inserted replaced
4158:a52be3648cb6 4159:c4e6052f03c7
    57 
    57 
    58 receiver:r selector:selectorString fold:folding
    58 receiver:r selector:selectorString fold:folding
    59     "return a new UnaryNode for sending selector selectorString to receiver r.
    59     "return a new UnaryNode for sending selector selectorString to receiver r.
    60      If folding is true, fold constant expressions."
    60      If folding is true, fold constant expressions."
    61 
    61 
    62     |result recVal selector canFold globalName|
    62     |result recVal selector canFold globalName caughtErrorMessage|
    63 
    63 
    64 "
    64 "
    65     The constant folding code can usually not optimize things - this may change
    65     The constant folding code can usually not optimize things - this may change
    66     when some kind of constant declaration is added to smalltalk.
    66     when some kind of constant declaration is added to smalltalk.
    67 "
    67 "
   188 
   188 
   189         canFold ifTrue:[
   189         canFold ifTrue:[
   190             (recVal respondsTo:selector) ifTrue:[
   190             (recVal respondsTo:selector) ifTrue:[
   191                 SignalSet anySignal "Number domainErrorSignal" handle:[:ex |
   191                 SignalSet anySignal "Number domainErrorSignal" handle:[:ex |
   192                     "in case of an error, abort fold and return original"
   192                     "in case of an error, abort fold and return original"
       
   193                     caughtErrorMessage := ex description.
   193                     ex return
   194                     ex return
   194                 ] do:[
   195                 ] do:[
   195                     result := recVal perform:selector.
   196                     result := recVal perform:selector.
   196                     ^ ConstantNode type:(ConstantNode typeOfConstant:result) value:result
   197                     ^ ConstantNode type:(ConstantNode typeOfConstant:result) value:result
   197                 ].
   198                 ].
   198                 "when we reach here, something went wrong (something like 0.0 log)"
   199                 "when we reach here, something went wrong (something like 0.0 log)"
   199                 ^ ParseErrorNode errorString:'error occurred while evaluating constant expression'
   200                 ^ ParseErrorNode 
       
   201                     errorString:(caughtErrorMessage,' - error occurred while evaluating constant expression')
   200             ].
   202             ].
   201         ].
   203         ].
   202     ].
   204     ].
   203 
   205 
   204     ^ (self basicNew) receiver:r selector:selectorString args:nil lineno:0
   206     ^ (self basicNew) receiver:r selector:selectorString args:nil lineno:0
   205 
   207 
   206     "Modified: / 05-03-2007 / 15:11:26 / cg"
   208     "Modified: / 03-07-2017 / 13:56:31 / cg"
   207 ! !
   209 ! !
   208 
   210 
   209 !UnaryNode methodsFor:'accessing'!
   211 !UnaryNode methodsFor:'accessing'!
   210 
   212 
   211 selectorPartPositions
   213 selectorPartPositions