ReturnNode.st
author Claus Gittinger <cg@exept.de>
Wed, 04 Sep 2013 19:32:01 +0200
changeset 3317 55c8ae8f88e6
parent 3308 4c871ebd0def
child 3484 825bd64610a3
permissions -rw-r--r--
class: MessageNode changed: #codeAndOn:inBlock:valueNeeded:for: #codeOrOn:inBlock:valueNeeded:for:
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
1982
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
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
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    14
StatementNode subclass:#ReturnNode
2101
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
    15
	instanceVariableNames:'myHome blockHome'
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
    16
	classVariableNames:''
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
    17
	poolDictionaries:''
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
    18
	category:'System-Compiler-Support'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    19
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    20
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    21
!ReturnNode class methodsFor:'documentation'!
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    22
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    23
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    24
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    25
 COPYRIGHT (c) 1989 by Claus Gittinger
1982
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
    26
              All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    27
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    28
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    29
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    31
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    32
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    33
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    34
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    35
!
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    36
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    37
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    38
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    39
    node for parse-trees, representing return expressions
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
    40
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    41
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    44
"
f8dd8ba75205 *** empty log message ***
claus
parents: 13
diff changeset
    45
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    46
7ad01559b262 Initial revision
claus
parents:
diff changeset
    47
!ReturnNode methodsFor:'accessing'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    48
882
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    49
expression:e
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    50
    super expression:e.
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    51
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    52
    "/ any block, which is returned cannot be inlined.
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    53
    e isBlockNode ifTrue:[
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    54
        e possiblyInlined:false
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    55
    ]
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    56
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    57
!
0bc2a6ecdfad oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
    58
2398
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    59
home
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    60
    ^ myHome
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    61
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    62
    "Created: / 19-05-2010 / 15:46:55 / cg"
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    63
!
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    64
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    65
home:someOne blockHome:aBlockNode
7ad01559b262 Initial revision
claus
parents:
diff changeset
    66
    myHome := someOne.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    67
    blockHome := aBlockNode
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    68
!
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    69
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    70
lineNumber:something
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    71
    "set lineNr"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    72
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    73
    lineNr := something.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    74
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    75
    "Created: / 16-11-2006 / 14:38:51 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    76
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
    77
2530
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    78
!ReturnNode methodsFor:'checks'!
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    79
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    80
plausibilityCheckIn:aParser
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    81
    "check for return-in-return, as in
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    82
        ^ foo ifTrue:[ ^x]
3308
4c871ebd0def class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 3015
diff changeset
    83
     that is (currently) not compilable by stc (generates bad C-code for it).
4c871ebd0def class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 3015
diff changeset
    84
     TODO: rewite to use lint/lint rules and apply them before accepting"
2530
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    85
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    86
    |allow warn|
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    87
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    88
    allow := aParser parserFlags allowPossibleSTCCompilationProblems.
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    89
    warn := aParser parserFlags warnAboutPossibleSTCCompilationProblems.
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    90
    (allow not or:[warn]) ifTrue:[
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    91
        expression containsReturn ifTrue:[
3015
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    92
            (expression isMessage 
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    93
            and:[ #(
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    94
                      'ifTrue:' 'ifFalse:'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    95
                      'ifTrue:ifFalse:' 'ifFalse:ifTrue:'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    96
                      'whileTrue:' 'whileFalse:'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    97
                  ) includes:(expression selector)])
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    98
            ifTrue:[
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    99
                allow ifTrue:[
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   100
                    ^ 'stc will not compile return-in-return'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   101
                ].
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   102
                aParser
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   103
                    parseError:'stc will not compile return-in-return' 
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   104
                    position:startPosition to:endPosition
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   105
            ]
2530
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   106
        ].
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   107
    ].
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   108
    ^ nil.
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   109
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   110
    "Created: / 05-07-2011 / 17:59:48 / cg"
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   111
! !
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   112
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   113
!ReturnNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   114
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   115
basicCodeOn:aStream inBlock:b for:aCompiler
1593
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   116
    b isNil ifTrue:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   117
        self codeLocalReturnOn:aStream inBlock:b for:aCompiler.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   118
        ^ self.
29
5884a68a6226 new return bytecode semantics
claus
parents: 20
diff changeset
   119
    ].
5884a68a6226 new return bytecode semantics
claus
parents: 20
diff changeset
   120
1593
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   121
    "return from homeContext in a block"
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   122
    expression isNil ifTrue:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   123
        "/ nil-expression is not possible in smalltalk;
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   124
        "/ however, it might be in a subclass (i.e. JavaScript)
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   125
        aStream nextPut:#pushNil.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   126
    ] ifFalse:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   127
        expression codeOn:aStream inBlock:b for:aCompiler.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   128
    ].
374
84e2a53ae12b optionally code the lineNr.
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   129
    lineNr notNil ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   130
        self codeLineNumber:lineNr on:aStream for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   131
    ].
380
6bfa4056f202 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   132
    aStream nextPut:#homeRetTop.
374
84e2a53ae12b optionally code the lineNr.
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   133
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   134
    "Created: / 16-11-2006 / 14:05:27 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   135
!
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   136
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   137
codeForSideEffectOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   138
    "redefined - drop not needed since notreached"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   139
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   140
    ^ self basicCodeOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   141
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   142
    "Modified: / 16-11-2006 / 14:05:32 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   143
!
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   144
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   145
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   146
    "generate code to return myself as a simple method return"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   147
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   148
    self basicCodeOn:aStream inBlock:b for:aCompiler.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   149
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   150
    "as a ReturnNode, I did return, so retTop is not needed"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   151
"/    aStream nextPut:#retTop.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   152
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   153
    "Modified: / 16-11-2006 / 14:05:35 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   154
!
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   155
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   156
codeLocalReturnOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   157
    expression isNil ifTrue:[
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   158
        aStream nextPut:#retNil.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   159
        ^ self.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   160
    ].
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   161
    expression
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   162
        codeForSimpleReturnOn:aStream 
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   163
        inBlock:b 
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   164
        lineNumber:lineNr
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   165
        for:aCompiler.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   166
!
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   167
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   168
codeOn:aStream inBlock:b for:aCompiler
1982
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   169
"/    aCompiler parserFlags allowPossibleSTCCompilationProblems ifFalse:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   170
"/        aCompiler 
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   171
"/            parseError:'stc will not compile return within a return'
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   172
"/            line:lineNr.
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   173
"/    ] ifTrue:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   174
"/        aCompiler parserFlags warnAboutPossibleSTCCompilationProblems ifTrue:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   175
"/            aCompiler 
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   176
"/                warning:'stc will not compile return within a return'
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   177
"/                line:lineNr.
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   178
"/        ].
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   179
"/    ].
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   180
    self basicCodeOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   181
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   182
    "Modified: / 16-11-2006 / 14:34:15 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   183
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   184
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   185
!ReturnNode methodsFor:'enumerating'!
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   186
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   187
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   188
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   189
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   190
    ^ anEnumerator doReturn:self value:expression
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   191
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   192
    "Modified: 19.6.1997 / 16:42:40 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   193
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   194
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   195
!ReturnNode methodsFor:'evaluation'!
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   196
1383
3d485eefbb36 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   197
evaluateExpressionIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   198
    |val|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   199
1594
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   200
    expression notNil ifTrue:[
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   201
        val := expression evaluateIn:anEnvironment.
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   202
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   203
    myHome exitWith:val.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   204
    "when we arrive here, the parser context is already gone
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   205
     - try block-return"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   206
    blockHome notNil ifTrue:[blockHome exitWith:val].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   207
    "well - what else can be done"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   208
    ^ val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   209
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   210
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   211
!ReturnNode methodsFor:'printing & storing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   212
7ad01559b262 Initial revision
claus
parents:
diff changeset
   213
printOn:aStream indent:i
7ad01559b262 Initial revision
claus
parents:
diff changeset
   214
    aStream nextPutAll:'^ '.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   215
    expression printOn:aStream
7ad01559b262 Initial revision
claus
parents:
diff changeset
   216
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   217
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   218
!ReturnNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   219
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   220
isConstant
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   221
    ^ false
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   222
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   223
2397
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   224
isJavaScriptReturnNode
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   225
    ^ false
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   226
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   227
    "Created: / 19-05-2010 / 15:14:46 / cg"
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   228
!
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   229
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   230
isReturnNode
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   231
    ^ true
2101
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   232
!
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   233
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   234
isSimpleConstant
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   235
    ^ false
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   236
!
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   237
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   238
isSimpleExpression
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   239
    ^ false
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   240
!
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   241
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   242
isSimpleVariable
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   243
    ^ false
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   244
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   245
2595
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   246
!ReturnNode methodsFor:'visiting'!
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   247
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   248
acceptVisitor:aVisitor 
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   249
    "Double dispatch back to the visitor, passing my type encoded in
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   250
     the selector (visitor pattern)"
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   251
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   252
    "stub code automatically generated - please change if required"
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   253
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   254
    ^ aVisitor visitReturnNode:self
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   255
! !
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   256
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   257
!ReturnNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   258
2397
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   259
version_CVS
3308
4c871ebd0def class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 3015
diff changeset
   260
    ^ '$Header: /cvs/stx/stx/libcomp/ReturnNode.st,v 1.44 2013-08-31 11:30:15 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   261
! !
3015
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   262