ReturnNode.st
author Claus Gittinger <cg@exept.de>
Sat, 20 Oct 2012 21:17:14 +0200
changeset 2951 340d0405f582
parent 2595 1cb0ec5ebec6
child 3015 c62355a28ef2
permissions -rw-r--r--
comment/format in:5 methods
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]
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    83
     that is (currently) not compilable by stc (generates bad C-code for it)"
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:[
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    91
            allow ifTrue:[
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    92
                ^ 'stc will not compile return-in-return'
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    93
            ].
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    94
            aParser
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    95
                parseError:'stc will not compile return-in-return' 
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    96
                position:startPosition to:endPosition
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    97
        ].
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    98
    ].
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
    99
    ^ nil.
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   100
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   101
    "Created: / 05-07-2011 / 17:59:48 / cg"
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   102
! !
246794569e0c added: #plausibilityCheckIn:
Claus Gittinger <cg@exept.de>
parents: 2398
diff changeset
   103
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   104
!ReturnNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   105
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   106
basicCodeOn:aStream inBlock:b for:aCompiler
1593
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   107
    b isNil ifTrue:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   108
        self codeLocalReturnOn:aStream inBlock:b for:aCompiler.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   109
        ^ self.
29
5884a68a6226 new return bytecode semantics
claus
parents: 20
diff changeset
   110
    ].
5884a68a6226 new return bytecode semantics
claus
parents: 20
diff changeset
   111
1593
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   112
    "return from homeContext in a block"
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   113
    expression isNil ifTrue:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   114
        "/ nil-expression is not possible in smalltalk;
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   115
        "/ however, it might be in a subclass (i.e. JavaScript)
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   116
        aStream nextPut:#pushNil.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   117
    ] ifFalse:[
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   118
        expression codeOn:aStream inBlock:b for:aCompiler.
40c32bd334d9 return from outer method
Claus Gittinger <cg@exept.de>
parents: 1579
diff changeset
   119
    ].
374
84e2a53ae12b optionally code the lineNr.
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   120
    lineNr notNil ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   121
        self codeLineNumber:lineNr on:aStream for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   122
    ].
380
6bfa4056f202 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 374
diff changeset
   123
    aStream nextPut:#homeRetTop.
374
84e2a53ae12b optionally code the lineNr.
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   124
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   125
    "Created: / 16-11-2006 / 14:05:27 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   126
!
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   127
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   128
codeForSideEffectOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   129
    "redefined - drop not needed since notreached"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   130
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   131
    ^ self basicCodeOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   132
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   133
    "Modified: / 16-11-2006 / 14:05:32 / 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
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   137
    "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
   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
    "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
   142
"/    aStream nextPut:#retTop.
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
    "Modified: / 16-11-2006 / 14:05:35 / cg"
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   145
!
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
codeLocalReturnOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   148
    expression isNil ifTrue:[
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   149
        aStream nextPut:#retNil.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   150
        ^ self.
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
    expression
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   153
        codeForSimpleReturnOn:aStream 
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   154
        inBlock:b 
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   155
        lineNumber:lineNr
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   156
        for:aCompiler.
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   157
!
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   158
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   159
codeOn:aStream inBlock:b for:aCompiler
1982
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   160
"/    aCompiler parserFlags allowPossibleSTCCompilationProblems ifFalse:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   161
"/        aCompiler 
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   162
"/            parseError:'stc will not compile return within a return'
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   163
"/            line:lineNr.
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   164
"/    ] ifTrue:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   165
"/        aCompiler parserFlags warnAboutPossibleSTCCompilationProblems ifTrue:[
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   166
"/            aCompiler 
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   167
"/                warning:'stc will not compile return within a return'
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   168
"/                line:lineNr.
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   169
"/        ].
2098c5e965ce changed #codeOn:inBlock:for:
Claus Gittinger <cg@exept.de>
parents: 1980
diff changeset
   170
"/    ].
1945
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   171
    self basicCodeOn:aStream inBlock:b for:aCompiler
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   172
5c08a14f6269 warn about stc-uncompilable code
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
   173
    "Modified: / 16-11-2006 / 14:34:15 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   174
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   175
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   176
!ReturnNode methodsFor:'enumerating'!
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   177
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   178
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   179
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   180
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   181
    ^ anEnumerator doReturn:self value:expression
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   182
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   183
    "Modified: 19.6.1997 / 16:42:40 / cg"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   184
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 393
diff changeset
   185
1035
8848672cb893 category rename
Claus Gittinger <cg@exept.de>
parents: 882
diff changeset
   186
!ReturnNode methodsFor:'evaluation'!
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   187
1383
3d485eefbb36 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1381
diff changeset
   188
evaluateExpressionIn:anEnvironment
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   189
    |val|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   190
1594
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   191
    expression notNil ifTrue:[
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   192
        val := expression evaluateIn:anEnvironment.
d99ea853d052 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1593
diff changeset
   193
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   194
    myHome exitWith:val.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   195
    "when we arrive here, the parser context is already gone
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   196
     - try block-return"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   197
    blockHome notNil ifTrue:[blockHome exitWith:val].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   198
    "well - what else can be done"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   199
    ^ val
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   200
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   201
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   202
!ReturnNode methodsFor:'printing & storing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   203
7ad01559b262 Initial revision
claus
parents:
diff changeset
   204
printOn:aStream indent:i
7ad01559b262 Initial revision
claus
parents:
diff changeset
   205
    aStream nextPutAll:'^ '.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   206
    expression printOn:aStream
7ad01559b262 Initial revision
claus
parents:
diff changeset
   207
! !
140
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
!ReturnNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   210
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   211
isConstant
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   212
    ^ false
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   213
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   214
2397
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   215
isJavaScriptReturnNode
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   216
    ^ false
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   217
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   218
    "Created: / 19-05-2010 / 15:14:46 / cg"
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   219
!
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   220
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   221
isReturnNode
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   222
    ^ true
2101
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   223
!
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   224
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   225
isSimpleConstant
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   226
    ^ false
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   227
!
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   228
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   229
isSimpleExpression
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   230
    ^ false
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
isSimpleVariable
3ce4958aab99 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 1982
diff changeset
   234
    ^ false
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   235
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   236
2595
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   237
!ReturnNode methodsFor:'visiting'!
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   238
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   239
acceptVisitor:aVisitor 
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   240
    "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
   241
     the selector (visitor pattern)"
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   242
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   243
    "stub code automatically generated - please change if required"
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   244
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   245
    ^ aVisitor visitReturnNode:self
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
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   248
!ReturnNode class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   249
2397
6aea7415db4f added: #isJavaScriptReturnNode
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
   250
version_CVS
2595
1cb0ec5ebec6 - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2530
diff changeset
   251
    ^ '$Header: /cvs/stx/stx/libcomp/ReturnNode.st,v 1.42 2011-07-25 22:32:54 vrany Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
   252
! !