ReturnNode.st
author convert-repo
Mon, 13 Feb 2017 04:34:40 +0000
changeset 4120 7cb0d66f736c
parent 3484 825bd64610a3
child 4507 f61494fda739
permissions -rw-r--r--
update tags
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.
3484
825bd64610a3 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 3308
diff changeset
    53
    e realNode isBlockNode ifTrue:[
825bd64610a3 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 3308
diff changeset
    54
        e realNode possiblyInlined:false
882
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
2398
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    58
home
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    59
    ^ myHome
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    60
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    61
    "Created: / 19-05-2010 / 15:46:55 / cg"
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    62
!
f4fb7f5746dd care for block vs. method return.
Claus Gittinger <cg@exept.de>
parents: 2397
diff changeset
    63
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    64
home:someOne blockHome:aBlockNode
7ad01559b262 Initial revision
claus
parents:
diff changeset
    65
    myHome := someOne.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    66
    blockHome := aBlockNode
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    67
!
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
lineNumber:something
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    70
    "set lineNr"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    71
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    72
    lineNr := something.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    73
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
    74
    "Created: / 16-11-2006 / 14:38:51 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    75
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
    76
2530
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    77
!ReturnNode methodsFor:'checks'!
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    78
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    79
plausibilityCheckIn:aParser
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    80
    "check for return-in-return, as in
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    81
        ^ foo ifTrue:[ ^x]
3308
4c871ebd0def class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 3015
diff changeset
    82
     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
    83
     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
    84
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    85
    |allow warn|
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    86
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    87
    allow := aParser parserFlags allowPossibleSTCCompilationProblems.
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    88
    warn := aParser parserFlags warnAboutPossibleSTCCompilationProblems.
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    89
    (allow not or:[warn]) ifTrue:[
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    90
        expression containsReturn ifTrue:[
3015
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    91
            (expression isMessage 
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    92
            and:[ #(
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    93
                      'ifTrue:' 'ifFalse:'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    94
                      'ifTrue:ifFalse:' 'ifFalse:ifTrue:'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    95
                      'whileTrue:' 'whileFalse:'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    96
                  ) includes:(expression selector)])
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    97
            ifTrue:[
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    98
                allow ifTrue:[
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
    99
                    ^ 'stc will not compile return-in-return'
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   100
                ].
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   101
                aParser
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   102
                    parseError:'stc will not compile return-in-return' 
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   103
                    position:startPosition to:endPosition
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   104
            ]
2530
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   105
        ].
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
    ^ nil.
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   108
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   109
    "Created: / 05-07-2011 / 17:59:48 / cg"
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   110
! !
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   111
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   112
!ReturnNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   113
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   114
basicCodeOn:aStream inBlock:b for:aCompiler
1593
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   115
    b isNil ifTrue:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   116
        self codeLocalReturnOn:aStream inBlock:b for:aCompiler.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   117
        ^ self.
29
5884a68a6226 new return bytecode semantics
claus
parents: 20
diff changeset
   118
    ].
5884a68a6226 new return bytecode semantics
claus
parents: 20
diff changeset
   119
1593
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   120
    "return from homeContext in a block"
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   121
    expression isNil ifTrue:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   122
        "/ nil-expression is not possible in smalltalk;
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   123
        "/ however, it might be in a subclass (i.e. JavaScript)
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   124
        aStream nextPut:#pushNil.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   125
    ] ifFalse:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   126
        expression codeOn:aStream inBlock:b for:aCompiler.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   127
    ].
374
84e2a53ae12b optionally code the lineNr.
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   128
    lineNr notNil ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   129
        self codeLineNumber:lineNr on:aStream for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   130
    ].
380
6bfa4056f202 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   131
    aStream nextPut:#homeRetTop.
374
84e2a53ae12b optionally code the lineNr.
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   132
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   133
    "Created: / 16-11-2006 / 14:05:27 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   134
!
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
codeForSideEffectOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   137
    "redefined - drop not needed since notreached"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   138
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   139
    ^ self basicCodeOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   140
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   141
    "Modified: / 16-11-2006 / 14:05:32 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   142
!
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
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   145
    "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
   146
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   147
    self basicCodeOn:aStream inBlock:b for:aCompiler.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   148
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   149
    "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
   150
"/    aStream nextPut:#retTop.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   151
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   152
    "Modified: / 16-11-2006 / 14:05:35 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   153
!
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
codeLocalReturnOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   156
    expression isNil ifTrue:[
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   157
        aStream nextPut:#retNil.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   158
        ^ self.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   159
    ].
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   160
    expression
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   161
        codeForSimpleReturnOn:aStream 
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   162
        inBlock:b 
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   163
        lineNumber:lineNr
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   164
        for:aCompiler.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   165
!
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
codeOn:aStream inBlock:b for:aCompiler
1982
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   168
"/    aCompiler parserFlags allowPossibleSTCCompilationProblems ifFalse:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   169
"/        aCompiler 
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   170
"/            parseError:'stc will not compile return within a return'
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   171
"/            line:lineNr.
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   172
"/    ] ifTrue:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   173
"/        aCompiler parserFlags warnAboutPossibleSTCCompilationProblems ifTrue:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   174
"/            aCompiler 
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   175
"/                warning:'stc will not compile return within a return'
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   176
"/                line:lineNr.
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   177
"/        ].
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   178
"/    ].
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   179
    self basicCodeOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   180
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   181
    "Modified: / 16-11-2006 / 14:34:15 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   182
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   183
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   184
!ReturnNode methodsFor:'enumerating'!
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   185
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   186
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   187
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   188
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   189
    ^ anEnumerator doReturn:self value:expression
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   190
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   191
    "Modified: 19.6.1997 / 16:42:40 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   192
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   193
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   194
!ReturnNode methodsFor:'evaluation'!
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   195
1383
3d485eefbb36 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   196
evaluateExpressionIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   197
    |val|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   198
1594
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   199
    expression notNil ifTrue:[
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   200
        val := expression evaluateIn:anEnvironment.
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   201
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   202
    myHome exitWith:val.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   203
    "when we arrive here, the parser context is already gone
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   204
     - try block-return"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   205
    blockHome notNil ifTrue:[blockHome exitWith:val].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   206
    "well - what else can be done"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   207
    ^ val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   208
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   209
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   210
!ReturnNode methodsFor:'printing & storing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   211
7ad01559b262 Initial revision
claus
parents:
diff changeset
   212
printOn:aStream indent:i
7ad01559b262 Initial revision
claus
parents:
diff changeset
   213
    aStream nextPutAll:'^ '.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   214
    expression printOn:aStream
7ad01559b262 Initial revision
claus
parents:
diff changeset
   215
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   216
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   217
!ReturnNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   218
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   219
isConstant
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   220
    ^ false
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   221
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   222
2397
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   223
isJavaScriptReturnNode
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   224
    ^ false
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   225
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   226
    "Created: / 19-05-2010 / 15:14:46 / cg"
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   227
!
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   228
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   229
isReturnNode
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   230
    ^ true
2101
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   231
!
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
isSimpleConstant
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   234
    ^ false
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   235
!
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
isSimpleExpression
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   238
    ^ false
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   239
!
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
isSimpleVariable
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   242
    ^ false
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   243
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   244
2595
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   245
!ReturnNode methodsFor:'visiting'!
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   246
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   247
acceptVisitor:aVisitor 
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   248
    "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
   249
     the selector (visitor pattern)"
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   250
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   251
    "stub code automatically generated - please change if required"
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   252
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   253
    ^ aVisitor visitReturnNode:self
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   254
! !
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   255
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   256
!ReturnNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   257
2397
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   258
version_CVS
3484
825bd64610a3 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 3308
diff changeset
   259
    ^ '$Header: /cvs/stx/stx/libcomp/ReturnNode.st,v 1.45 2014-06-13 10:24:03 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   260
! !
3015
c62355a28ef2 class: ReturnNode
Claus Gittinger <cg@exept.de>
parents: 2595
diff changeset
   261