MessageNode.st
author Claus Gittinger <cg@exept.de>
Thu, 13 Feb 2014 00:47:06 +0100
changeset 3356 3c0e828c3f36
parent 3336 1b4396f06cbf
child 3385 0c211183027f
permissions -rw-r--r--
class: MessageNode changed: #codeCaseOfOn: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
1727
58820b0c1e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
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
"
1045
ee448a958d19 migration support
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    12
"{ Package: 'stx:libcomp' }"
ee448a958d19 migration support
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    13
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    14
ParseNode subclass:#MessageNode
2496
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
    15
	instanceVariableNames:'receiver selector argArray lineNr selectorPosition lines
3290
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
    16
		endLineNr endCharPosition selectorPartPositions'
1791
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
    17
	classVariableNames:''
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
    18
	poolDictionaries:''
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
    19
	category:'System-Compiler-Support'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    20
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    21
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
    22
!MessageNode class methodsFor:'documentation'!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    23
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    24
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    25
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    26
 COPYRIGHT (c) 1989 by Claus Gittinger
1727
58820b0c1e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
    27
              All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    28
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    29
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    30
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    33
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    34
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    35
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    36
!
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    37
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    38
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    39
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    40
    node for parse-trees, representing message sends
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    41
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    42
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    43
    [author:]
1727
58820b0c1e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
    44
        Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    45
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    46
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    47
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
    48
!MessageNode class methodsFor:'instance creation'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    49
7ad01559b262 Initial revision
claus
parents:
diff changeset
    50
receiver:recNode selector:selectorString 
7ad01559b262 Initial revision
claus
parents:
diff changeset
    51
    ^ (self basicNew) receiver:recNode selector:selectorString args:nil lineno:0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    52
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    53
1266
35e2c67fbdd9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1248
diff changeset
    54
receiver:recNode selector:selectorString arg1:arg1Node arg2:arg2Node
35e2c67fbdd9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1248
diff changeset
    55
    ^ self receiver:recNode selector:selectorString arg1:arg1Node arg2:arg2Node fold:nil
35e2c67fbdd9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1248
diff changeset
    56
!
35e2c67fbdd9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1248
diff changeset
    57
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    58
receiver:recNode selector:selectorString arg1:argNode1 arg2:argNode2 fold:folding
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    59
    |result recVal argVal selector|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    60
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    61
    "
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    62
     This is just a demonstration - of how complex constants can be folded.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    63
     This was inspired by some discussion in c.l.s about enhancing the language - I prefer
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    64
     enhancing the compiler ....
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    65
     The following optimization will convert '#(...) with:#(...) collect:[...]' into an array constant,
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
    66
     allowing constant arrays of complex objects.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    67
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    68
     Notice: this method is normally disabled - its just a demo after all.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    69
    "
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
    70
    folding notNil ifTrue:[
1397
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    71
        "/
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    72
        "/ do constant folding ...
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    73
        "/
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    74
        (recNode isConstant and:[argNode1 isConstant]) ifTrue:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    75
            "check if we can do it ..."
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    76
            selector := selectorString asSymbolIfInterned.
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    77
            selector notNil ifTrue:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    78
                recVal := recNode evaluate.
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    79
                (recVal respondsTo:selector) ifTrue:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    80
                    "
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    81
                     we could do much more here - but then, we need a dependency from
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    82
                     the folded selectors method to the method we generate code for ...
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    83
                     limit optimizations to those that will never change
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    84
                     (or - if you change them - you will crash so bad ...)
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    85
                    "
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    86
                    argVal := argNode1 evaluate.
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    87
                    ((recVal isMemberOf:Array) and:[argVal isMemberOf:Array]) ifTrue:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    88
                        folding == #full ifTrue:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    89
                            (selector == #with:collect:) ifTrue:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    90
                                (argNode2 isBlock) ifTrue:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    91
                                    SignalSet anySignal handle:[:ex |
1533
bff4a03d6d48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
    92
                                        ^ ParseErrorNode errorString:'error in constant expression (' , ex description , ')'
1397
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    93
                                    ] do:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    94
                                        result := recVal perform:selector with:argVal with:(argNode2 evaluate).
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    95
                                    ].
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    96
                                    ^ ConstantNode type:(ConstantNode typeOfConstant:result) value:result
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    97
                                ]
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    98
                            ]
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
    99
                        ]
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
   100
                    ]
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
   101
                ]
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
   102
            ]
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
   103
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   104
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   105
    ^ (self basicNew) receiver:recNode selector:selectorString args:(Array with:argNode1 with:argNode2) lineno:0
570
e55ab798d077 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   106
e55ab798d077 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   107
    "Modified: 28.6.1997 / 15:16:01 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   108
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   109
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   110
receiver:recNode selector:selectorString arg:argNode
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   111
    ^ self receiver:recNode selector:selectorString arg:argNode fold:nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   112
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   113
7ad01559b262 Initial revision
claus
parents:
diff changeset
   114
receiver:recNode selector:selectorString arg:argNode fold:folding
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   115
    |result recVal argVal selector globalName canFold|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   116
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   117
   "
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   118
     The constant folding code can usually not optimize much
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   119
     - this may change when some kind of constant/macro declaration is added to smalltalk,
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   120
     so that constant classVars can be inlined.
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   121
    "
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   122
    folding notNil ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   123
        selector := selectorString asSymbolIfInterned.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   124
        selector notNil ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   125
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   126
            "/
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   127
            "/ do constant folding ...
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   128
            "/
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   129
            canFold := false.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   130
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   131
            (recNode isGlobal and:[argNode isConstant]) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   132
                globalName := recNode name.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   133
                recVal := recNode evaluate.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   134
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   135
                (globalName = 'SmallInteger') ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   136
                    ( #( bitMaskFor: ) includes:selector)
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   137
                    ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   138
                        canFold := true
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   139
                    ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   140
                ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   141
            ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   142
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   143
            (recNode isConstant and:[argNode isConstant]) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   144
                "check if we can do it ..."
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   145
                recVal := recNode evaluate.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   146
                "
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   147
                 we could do much more here - but then, we need a dependency from
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   148
                 the folded selectors method to the method we generate code for ...
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   149
                 limit optimizations to those that will never change
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   150
                 (or - if you change them - you will crash so bad ...)
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   151
                "
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   152
                argVal := argNode evaluate.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   153
                (recVal respondsToArithmetic and:[argVal respondsToArithmetic]) ifTrue:[
2197
c92fee01c220 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2102
diff changeset
   154
                    ( #( + - * / // \\ min: max: quo: raisedTo:) includes:selector) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   155
                        (#( / // \\ ) includes:selector) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   156
                            argVal = 0 ifTrue:[
1533
bff4a03d6d48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   157
                                ^ ParseErrorNode errorString:'division by zero in constant expression'
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   158
                            ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   159
                        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   160
                        canFold := true
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   161
                    ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   162
                    ( #( @ ) includes:selector) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   163
                        canFold := (folding == #full)
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   164
                    ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   165
                ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   166
                (recVal isInteger and:[argVal isInteger]) ifTrue:[
1017
c923ff9f397e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 993
diff changeset
   167
                    ( #( bitShift: bitOr: bitAnd: ) includes:selector) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   168
                        canFold := true
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   169
                    ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   170
                ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   171
                (recVal isMemberOf:String) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   172
                    (argVal isInteger and:[selector == #at:]) ifTrue:[
993
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
   173
                        canFold := folding isSymbol
902eec8d132b oops - folding argument is not always a symbol.
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
   174
                                   and:[(folding >= #level2) or:[folding == #full]].
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   175
                    ].
1093
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   176
                    selector == #',' ifTrue:[
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   177
                        (argVal isMemberOf:String) ifTrue:[
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   178
                            canFold := folding isSymbol
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   179
                                       and:[(folding >= #level2) or:[folding == #full]].
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   180
                        ].
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   181
                        (argVal isMemberOf:Character) ifTrue:[
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   182
                            canFold := folding isSymbol
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   183
                                       and:[(folding >= #level2) or:[folding == #full]].
41e224d479b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1080
diff changeset
   184
                        ].
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   185
                    ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   186
                ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   187
            ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   188
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   189
            canFold ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   190
                (recVal respondsTo:selector) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   191
                    SignalSet anySignal handle:[:ex |
1533
bff4a03d6d48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   192
                        ^ ParseErrorNode errorString:'error in constant expression (' , ex description , ')'
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   193
                    ] do:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   194
                        result := recVal perform:selector with:argVal.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   195
                    ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   196
                    ^ ConstantNode type:(ConstantNode typeOfConstant:result) value:result
2617
160ca364f3d3 More fixes for start/end position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2610
diff changeset
   197
                                   from: recNode startPosition to: argNode endPosition
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   198
                ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   199
            ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   200
        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   201
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   202
        "/
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   203
        "/ #perform with a constant selector
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   204
        "/
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   205
        (selector == #perform: 
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   206
        and:[argNode isConstant]) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   207
            argVal := argNode evaluate.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   208
            argVal isSymbol ifTrue:[
2620
25babff22da4 start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2617
diff changeset
   209
                ^ (UnaryNode receiver:recNode selector:argVal fold:folding)
25babff22da4 start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2617
diff changeset
   210
                    startPosition: recNode startPosition endPosition: argNode endPosition.
25babff22da4 start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2617
diff changeset
   211
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   212
            ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   213
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   214
    ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   215
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   216
    ^ (self basicNew) receiver:recNode selector:selectorString args:(Array with:argNode) lineno:0
576
5cb4af0eea67 also inline and:/or: ...
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   217
2617
160ca364f3d3 More fixes for start/end position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2610
diff changeset
   218
    "Modified: / 16-11-1999 / 21:50:33 / cg"
2620
25babff22da4 start/end position fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2617
diff changeset
   219
    "Modified: / 01-08-2011 / 12:31:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   220
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   221
7ad01559b262 Initial revision
claus
parents:
diff changeset
   222
receiver:recNode selector:selectorString args:anArray
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   223
    ^ self receiver:recNode selector:selectorString args:anArray fold:nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   224
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   225
7ad01559b262 Initial revision
claus
parents:
diff changeset
   226
receiver:recNode selector:selectorString args:argArray fold:folding
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   227
    |numArgs arg1 arg1Val|
117
claus
parents: 111
diff changeset
   228
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   229
    folding notNil ifTrue:[
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   230
        numArgs := argArray size.
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   231
        numArgs > 0 ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   232
            arg1 := (argArray at:1).
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   233
            (numArgs == 1) ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   234
                ^ self receiver:recNode selector:selectorString arg:arg1 fold:folding 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   235
            ].
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   236
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   237
            "/
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   238
            "/ #perform:... with a constant selector
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   239
            "/
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   240
            numArgs <= 6 ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   241
                (#(nil
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   242
                   #'perform:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   243
                   #'perform:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   244
                   #'perform:with:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   245
                   #'perform:with:with:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   246
                   #'perform:with:with:with:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   247
                   #'perform:with:with:with:with:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   248
                ) at:numArgs) = selectorString 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   249
                ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   250
                    arg1 isConstant ifTrue:[    
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   251
                        arg1Val := arg1 evaluate.
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   252
                        arg1Val isSymbol ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   253
                            ^ MessageNode 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   254
                                    receiver:recNode 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   255
                                    selector:arg1Val
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   256
                                    args:(argArray copyFrom:2)
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   257
                                    fold:folding
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   258
                        ]
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   259
                    ]
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   260
                ]
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   261
            ].
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   262
        ].
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   263
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   264
        (numArgs == 2) ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   265
            ^ self receiver:recNode selector:selectorString arg1:arg1 arg2:(argArray at:2) fold:folding 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   266
        ].
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   267
        numArgs > Method maxNumberOfArguments ifTrue:[
1533
bff4a03d6d48 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1529
diff changeset
   268
            ^ ParseErrorNode errorString:'too many arguments for current VM implementation'.
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   269
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   270
    ].
117
claus
parents: 111
diff changeset
   271
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   272
    ^ (self basicNew) receiver:recNode selector:selectorString args:argArray lineno:0
117
claus
parents: 111
diff changeset
   273
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   274
    "Modified: / 3.9.1995 / 16:41:39 / claus"
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   275
    "Modified: / 15.5.1998 / 15:32:05 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   276
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   277
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   278
!MessageNode methodsFor:'accessing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   279
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   280
arg1
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   281
    ^ argArray at:1
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   282
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   283
1639
65686abde429 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1629
diff changeset
   284
arg2
65686abde429 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1629
diff changeset
   285
    ^ argArray at:2
65686abde429 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1629
diff changeset
   286
!
65686abde429 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1629
diff changeset
   287
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   288
args
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   289
    ^ argArray
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   290
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   291
543
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   292
arguments
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   293
    ^ argArray ? #()
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   294
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   295
    "Created: 19.6.1997 / 17:31:14 / cg"
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   296
    "Modified: 19.6.1997 / 17:32:25 / cg"
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   297
!
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   298
2496
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   299
endCharPosition
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   300
    ^ endCharPosition
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   301
!
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   302
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   303
endCharPosition:something
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   304
    endCharPosition := something.
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   305
!
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   306
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   307
endLineNr
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   308
    ^ endLineNr
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   309
!
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   310
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   311
endLineNr:something
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   312
    endLineNr := something.
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   313
!
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   314
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   315
lineNumber
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   316
     ^ lineNr
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   317
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   318
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   319
lineNumber:num
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   320
     lineNr := num
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   321
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   322
2496
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   323
lines
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   324
    ^ lines
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   325
!
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   326
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   327
lines:something
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   328
    lines := something.
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   329
!
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
   330
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   331
receiver
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   332
    ^ receiver
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   333
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   334
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   335
receiver:r selector:s args:a lineno:l
2601
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
   336
3290
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   337
    receiver notNil ifTrue:[ receiver parent: nil].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   338
    receiver := r.
3290
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   339
    receiver notNil ifTrue:[
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   340
        receiver parent notNil ifTrue:[self breakPoint:#cg].
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   341
        receiver parent: self
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   342
    ].
1500
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   343
2610
398820190422 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2601
diff changeset
   344
    startPosition := receiver startPosition.
398820190422 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2601
diff changeset
   345
1500
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   346
"/ create the symbol only, if the symbol is already known in the system.
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   347
"/ otherwise a lot of partial symbols will be created by the SyntaxHighlighter
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   348
"/ during typing
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   349
"/    selector := s asSymbol.
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   350
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   351
    selector := s asSymbolIfInterned ? s.
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   352
3336
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
   353
    argArray notNil ifTrue:[argArray do:[:each| each parent:nil]].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   354
    argArray := a.
2865
cc62390767a2 changed: #receiver:selector:args:lineno:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2849
diff changeset
   355
    "JV@2012-04-20: I hate this #Error being returned. We should not
cc62390767a2 changed: #receiver:selector:args:lineno:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2849
diff changeset
   356
     be lazy to create a new class - ErrorNode. Results in a mess!!"
cc62390767a2 changed: #receiver:selector:args:lineno:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2849
diff changeset
   357
    argArray ~~ #Error ifTrue:[
2869
819a9e78f728 changed: #receiver:selector:args:lineno:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2865
diff changeset
   358
        argArray notEmptyOrNil ifTrue:[
3336
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
   359
            argArray do:[:each| each parent:self].
2869
819a9e78f728 changed: #receiver:selector:args:lineno:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2865
diff changeset
   360
            endPosition := argArray last endPosition
3336
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
   361
        ].
2610
398820190422 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2601
diff changeset
   362
    ].
398820190422 More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2601
diff changeset
   363
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   364
    lineNr := l.
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   365
    self checkInlinability.
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   366
2601
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
   367
    "Modified: / 02-07-1997 / 17:01:24 / cg"
2869
819a9e78f728 changed: #receiver:selector:args:lineno:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2865
diff changeset
   368
    "Modified: / 08-05-2012 / 17:07:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   369
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   370
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   371
selector
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   372
    ^ selector
595
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   373
!
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   374
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
   375
selector:s
1500
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   376
"/ create the symbol only, if the symbol is already known in the system.
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   377
"/ otherwise a lot of partial symbols will be created by the SyntaxHighlighter
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   378
"/ during typing
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   379
"/    selector := s asSymbol.
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   380
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   381
    selector := s asSymbolIfInterned ? s.
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
   382
"/    selector := s asSymbol.
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
   383
!
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
   384
3290
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   385
selectorPartPositions
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   386
    ^ selectorPartPositions
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   387
!
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   388
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   389
selectorPartPositions:something
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   390
    selectorPartPositions := something.
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   391
!
ed93979b62ac class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3278
diff changeset
   392
595
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   393
selectorPosition
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   394
    "return the value of the instance variable 'selectorPosition' (automatically generated)"
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   395
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   396
    ^ selectorPosition
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   397
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   398
    "Created: 5.8.1997 / 02:49:27 / cg"
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   399
!
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   400
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   401
selectorPosition:something
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   402
    "set the value of the instance variable 'selectorPosition' (automatically generated)"
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   403
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   404
    selectorPosition := something.
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   405
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   406
    "Created: 5.8.1997 / 02:49:27 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   407
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   408
7ad01559b262 Initial revision
claus
parents:
diff changeset
   409
!MessageNode methodsFor:'checks'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   410
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   411
checkCondition
3310
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   412
    "check ifTrue/ifFalse for plausibility.
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   413
     TODO: rewite to use lint/lint rules and apply them before accepting"
2489
da5775ff9f1f comment
Michael Beyl <mb@exept.de>
parents: 2429
diff changeset
   414
2102
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   415
    |args lastArg receiverSelector or1 or2|
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   416
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   417
    receiver isBlock ifTrue:[
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   418
        (Block canUnderstand:selector) ifFalse:[
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   419
            ^ 'blocks usually do not respond to ' , selector , ' messages'
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   420
        ].
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   421
    ].
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   422
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   423
    "/ (rr keyw:ra = a) ifTrue:[ ...]
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   424
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   425
    receiver isMessage ifTrue:[
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   426
        (receiver numArgs > 0) ifTrue:[
3330
6abed184183c class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3317
diff changeset
   427
            receiverSelector := receiver selector.
2102
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   428
            (receiverSelector isKeyword) ifTrue:[
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   429
                (args := receiver arguments) notEmptyOrNil ifTrue:[
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   430
                    (lastArg := args last) isMessage ifTrue:[
1989
e6a763ac2587 oops - parenthesized was written with typo
Claus Gittinger <cg@exept.de>
parents: 1809
diff changeset
   431
                        lastArg parenthesized ifFalse:[
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   432
                            (#( #'=' #'~=' #'==' #'~~' '>' '<' '>=' '<=') 
1629
8f69fe5b0fea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1628
diff changeset
   433
                            includes:(lastArg selector asSymbol)) ifTrue:[
1628
9641d61e717f precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1627
diff changeset
   434
                                ^ 'possible precedence error in condition (missing parenthesis ?)'
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   435
                            ]
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   436
                        ]
2102
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   437
                    ].
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   438
                ].
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   439
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   440
                (selector == #ifFalse: or:[ selector == #ifFalse:ifTrue: ]) ifTrue:[
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   441
                    receiverSelector == #or: ifTrue:[
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   442
                        or1 := receiver receiver.    
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   443
                        or2 := receiver arg1.
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   444
                        (or1 isMessage and:[or1 selector = '~~']) ifTrue:[
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   445
                            (or2 isBlock 
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   446
                            and:[ or2 isSingleExpressionBlock
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   447
                            and:[ or2 statements expression isMessage 
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   448
                            and:[ or2 statements expression selector = '~~']]]) ifTrue:[
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   449
                                ^ 'please use "((...==...) and:[...==...]) ifTrue:" here\\(are you obfuscating by purpose ?)'
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   450
                            ].
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   451
                        ].
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   452
                    ].
0d60bf6818d7 obfuscated code detection
Claus Gittinger <cg@exept.de>
parents: 2096
diff changeset
   453
                ].
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   454
            ]
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   455
        ].
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   456
    ].
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   457
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   458
    ^ nil
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   459
!
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   460
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   461
checkGlobalFromNameSpaceConflictFor:aNode
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   462
    "check if aNode is a local-nameSpace's variable,
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   463
     which hides a global from Smalltalk with the same name.
3310
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   464
     This is especially bad for Error handle: do:... 
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   465
     TODO: rewite to use lint/lint rules and apply them before accepting"
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   466
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   467
    |fullName shortName|
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   468
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   469
    aNode isGlobalVariable ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   470
        fullName := aNode name.
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   471
        shortName := Class nameWithoutPrefix:fullName.
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   472
        shortName ~= fullName ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   473
            (Smalltalk includesKey:shortName) ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   474
                ^ 'Possible name conflict (local ',shortName,' vs. Smalltalk::',shortName,')'
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   475
            ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   476
        ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   477
    ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   478
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   479
    ^ nil.
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   480
!
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   481
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   482
checkIdentityCompare
3310
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   483
    "check #== applied to Floats, Strings or Fractions
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   484
     TODO: rewite to use lint/lint rules and apply them before accepting"
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   485
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   486
    |rec arg1 arg1Value operand|
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   487
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   488
    ((selector == #==) or:[selector == #~~]) ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   489
        (argArray size > 0) ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   490
            arg1 := argArray at:1
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   491
        ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   492
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   493
        "
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   494
         it once took me almost an hour, to find a '==' which
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   495
         should have been an '=' (you cannot compare floats with ==)
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   496
         (well, I looked at the '==' at least 50 times -
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   497
          - but didn't think about it ...).
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   498
         that's reason enough to add this check here.
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   499
         I will add more as heuristic knowledge increases ...
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   500
         (send me comments on common programming errors...)
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   501
        "
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   502
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   503
        receiver isConstant ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   504
            rec := receiver evaluate.
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   505
            ((rec isMemberOf:String) or:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   506
             (rec isMemberOf:Float) or:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   507
             (rec isMemberOf:Fraction)]]) ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   508
                operand := rec
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   509
            ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   510
        ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   511
        arg1 isConstant ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   512
            arg1Value := arg1 evaluate.
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   513
            ((arg1Value isMemberOf:String) or:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   514
             (arg1Value isMemberOf:Float) or:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   515
             (arg1Value isMemberOf:Fraction)]]) ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   516
                operand := arg1Value
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   517
            ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   518
        ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   519
        operand notNil ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   520
            (selector == #==) ifTrue:[
2849
fa7f159cbbb0 changed: #checkIdentityCompare
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   521
                ^ 'identity compare is unsafe here (will usually return false here. Consider changing to "=")'
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   522
            ].
2849
fa7f159cbbb0 changed: #checkIdentityCompare
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   523
            ^ 'identity compare is unsafe here (will usually return true here. Consider changing to "~=")'
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   524
        ]
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   525
    ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   526
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   527
    ^ nil
2849
fa7f159cbbb0 changed: #checkIdentityCompare
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   528
fa7f159cbbb0 changed: #checkIdentityCompare
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   529
    "Modified: / 08-03-2012 / 01:07:33 / cg"
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   530
!
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   531
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   532
checkInlinability
3310
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   533
    "early check for possible inlinability.
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   534
     TODO: rewite to use lint/lint rules and apply them before accepting"
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   535
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   536
    |numArgs arg1 arg2 arg3|
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   537
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   538
    (numArgs := argArray size) >= 1 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   539
        arg1 := argArray at:1.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   540
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   541
    numArgs == 0 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   542
        (selector == #whileTrue 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   543
        or:[selector == #whileFalse]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   544
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   545
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   546
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   547
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   548
        (selector == #value) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   549
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   550
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   551
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   552
        ].
1425
4f698bf5ff76 inline [...] loop
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
   553
        ((selector == #repeat) or:[selector == #loop]) ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   554
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   555
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   556
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   557
        ].
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   558
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   559
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   560
    numArgs == 1 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   561
        (selector == #or: 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   562
        or:[selector == #and:]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   563
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   564
                arg1 possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   565
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   566
        ].
576
5cb4af0eea67 also inline and:/or: ...
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   567
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   568
        (selector == #ifTrue: 
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   569
        or:[selector == #ifFalse:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   570
        or:[selector == #ifNil:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   571
        or:[selector == #ifNotNil:]]]) ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   572
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   573
                arg1 possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   574
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   575
        ].
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   576
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   577
        (selector == #whileTrue: 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   578
        or:[selector == #whileFalse:]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   579
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   580
                arg1 possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   581
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   582
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   583
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   584
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   585
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   586
        selector == #timesRepeat: ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   587
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   588
                arg1 possiblyInlined:true withSelector:selector.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   589
            ]
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   590
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   591
        ^ self
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   592
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   593
    numArgs >= 2 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   594
        arg2 := argArray at:2.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   595
    ].    
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   596
    numArgs == 2 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   597
        (selector == #ifTrue:ifFalse:
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   598
        or:[selector == #ifFalse:ifTrue:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   599
        or:[selector == #ifNil:ifNotNil:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   600
        or:[selector == #ifNotNil:ifNil:]]]) ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   601
            (arg1 isBlock 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   602
            and:[arg2 isBlock]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   603
                arg1 possiblyInlined:true.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   604
                arg2 possiblyInlined:true.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   605
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   606
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   607
        selector == #to:do: ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   608
            arg2 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   609
                arg2 possiblyInlined:true withSelector:selector.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   610
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   611
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   612
        ^ self
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   613
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   614
    numArgs >= 3 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   615
        arg3 := argArray at:3.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   616
    ].    
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   617
    numArgs == 3 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   618
        selector == #to:by:do: ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   619
            arg3 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   620
                arg3 possiblyInlined:true withSelector:selector.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   621
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   622
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   623
        ^ self
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   624
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   625
    ^ self
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   626
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   627
    "Created: / 2.7.1997 / 17:01:10 / cg"
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   628
    "Modified: / 2.4.1998 / 19:08:54 / cg"
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   629
!
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   630
2096
b993f62fab49 alreadyWarned selectors
Claus Gittinger <cg@exept.de>
parents: 2028
diff changeset
   631
plausibilityCheckIn:aParser
3310
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   632
    "some useful checks applied when accepting in a browser.
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   633
     TODO: rewite to use lint/lint rules and apply them before accepting"
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   634
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   635
    |arg1 msg|
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   636
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   637
    (argArray size > 0) ifTrue:[
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   638
        arg1 := argArray at:1
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   639
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   640
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   641
    "
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   642
     check #== applied to Floats, Strings or Fractions
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   643
    "
7ad01559b262 Initial revision
claus
parents:
diff changeset
   644
    ((selector == #==) or:[selector == #~~]) ifTrue:[
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   645
        (msg := self checkIdentityCompare) notNil ifTrue:[^ msg].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   646
    ].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   647
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   648
    "
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   649
     [...] ifTrue:...
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   650
     an error often occuring when you are a beginner ...
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   651
    "
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   652
    ((selector == #ifTrue:) or:[selector == #ifFalse:]) ifTrue:[
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   653
        (msg := self checkCondition) notNil ifTrue:[^ msg].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   654
    ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   655
    ((selector == #ifTrue:ifFalse:) or:[selector == #ifFalse:ifTrue:]) ifTrue:[
1626
6addd73f7d47 precedence check for if-condition
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   656
        (msg := self checkCondition) notNil ifTrue:[^ msg].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   657
    ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   658
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   659
    "
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   660
     (...) whileTrue:[
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   661
    "
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   662
    ((selector == #whileTrue:) or:[selector == #whileFalse:]) ifTrue:[
2028
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   663
        (receiver isBlock not and:[ receiver parenthesized ]) ifTrue:[
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   664
            "/ only warn, if code was originally parenthized
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   665
            ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block or respond reasonable to #value'
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   666
        ].
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   667
        arg1 isBlock ifFalse:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
   668
            ^ 'will fail at runtime, if argument to ' , selector , ' does not evaluate to a block or respond reasonable to #value'
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   669
        ].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   670
    ].
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   671
2028
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   672
    "
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   673
     [...] ensure:[...]
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   674
    "
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   675
    ((selector == #ensure:) or:[(selector == #ifCurtailed:)]) ifTrue:[
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   676
        (receiver isBlock not and:[ receiver parenthesized ]) ifTrue:[
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   677
            "/ only warn, if code was originally parenthized
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   678
            ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block or respond reasonable to #value'
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   679
        ].
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   680
        (arg1 isBlock not and:[ arg1 parenthesized ]) ifTrue:[
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   681
            ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block or respond reasonable to #value'
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   682
        ].
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   683
        (arg1 isBlock and:[arg1 isEmptyBlock]) ifTrue:[
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   684
            ^ 'useless ensure (empty block)'
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   685
        ].
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   686
    ].
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   687
905
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   688
    argArray size > 0 ifTrue:[
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   689
        "/ check for a beginners error (using super as arg)
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   690
        "/ as in (something ? super) foo
3310
f22eebdb8868 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3290
diff changeset
   691
        "/ let him know, that this will not be a "super foo"
905
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   692
        argArray do:[:arg | arg isSuper ifTrue:[
1192
b13a83abf72f warning message
Claus Gittinger <cg@exept.de>
parents: 1154
diff changeset
   693
                                ^ 'super special semantic only with receiver of message sends'
905
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   694
                            ]
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   695
                    ].
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   696
    ].
1154
8c8787349aaf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   697
2208
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   698
    (selector = #'handle:do:' 
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   699
    or:[ selector = #'handle:from:do:'
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   700
    or:[ selector = #'ignoreIn:'
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   701
    or:[ selector = #'catch:' ]]]) ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   702
        (msg := self checkGlobalFromNameSpaceConflictFor:receiver) notNil ifTrue:[^ msg].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   703
    ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   704
    (selector = #'on:do:'
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   705
    or:[ selector = #'on:do:ensure:'
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   706
    or:[ selector = #'on:do:on:do:' ]]) ifTrue:[
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   707
        (msg := self checkGlobalFromNameSpaceConflictFor:arg1) notNil ifTrue:[^ msg].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   708
    ].
334c127f8586 possible name clash check (Error handle:do:) with Error class
Claus Gittinger <cg@exept.de>
parents: 2197
diff changeset
   709
1154
8c8787349aaf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   710
"/    receiver isBlock ifTrue:[
8c8787349aaf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   711
"/        ([] respondsTo:selector) ifFalse:[
8c8787349aaf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   712
"/            ^ 'blocks do not respond to ' , selector , '; Missing ''.'' between statements ?'
8c8787349aaf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   713
"/        ].
8c8787349aaf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   714
"/    ].
8c8787349aaf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1134
diff changeset
   715
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   716
    ^ nil
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   717
2028
a9b5ec797153 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1994
diff changeset
   718
    "Modified: / 28-03-2007 / 14:14:28 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   719
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   720
7ad01559b262 Initial revision
claus
parents:
diff changeset
   721
!MessageNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   722
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   723
codeOn:aStream inBlock:b for:aCompiler
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   724
    self codeOn:aStream inBlock:b valueNeeded:true for:aCompiler
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   725
!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   726
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   727
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
2345
d3c1bbb5cddc comment/format in: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
   728
    "most work is in checking for inlinable code here."
d3c1bbb5cddc comment/format in: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
   729
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   730
    |recType nargs isBuiltIn litIndex cls clsLitIndex code isSpecial
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   731
     specialCode stackTop arg1 arg2 arg3 isSuper realReceiver 
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   732
     noSendDrop alreadyDropped
1994
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   733
     useSelfSend usedSelector|
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   734
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   735
    selector := selector asSymbol.
1994
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   736
    usedSelector := aCompiler nameSpaceSelectorFor:selector.
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   737
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   738
    "/ must be added for browsers-search to work on optimized nodes
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   739
    usedSelector ~~ selector ifTrue:[ aCompiler addLiteral:selector ].
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   740
    litIndex := aCompiler addLiteral:usedSelector.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   741
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   742
    noSendDrop := aCompiler class newCodeSet == true.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   743
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   744
    realReceiver := self realReceiver.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   745
    isSuper := realReceiver isSuper.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   746
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   747
    argArray isNil ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   748
        nargs := 0
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   749
    ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   750
        nargs := argArray size.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   751
        nargs > 0 ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   752
            arg1 := argArray at:1.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   753
            nargs > 1 ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   754
                arg2 := argArray at:2.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   755
                nargs > 2 ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   756
                    arg3 := argArray at:3.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   757
                ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   758
            ]    
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   759
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   760
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   761
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   762
    recType := receiver type.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   763
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   764
    (nargs == 0) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   765
        (recType == #ThisContext) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   766
            valueNeeded ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   767
                "for now, only do it in methods"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   768
                b isNil ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   769
                    (selector == #restart) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   770
                        aStream nextPut:#jump; nextPut:1.      "jump to start"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   771
                        ^ self
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   772
                    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   773
                ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   774
                (selector == #return) ifTrue:[  "^ nil"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   775
                    aStream nextPut:#retNil.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   776
                    ^ self
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   777
                ].
2562
be17095cbb21 comment/format in: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2542
diff changeset
   778
            ].
be17095cbb21 comment/format in: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2542
diff changeset
   779
            "/ aCompiler rememberContextReturnablePragma
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   780
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   781
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   782
        (receiver isBlock 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   783
        and:[receiver numArgs == 0
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   784
        and:[receiver isInlinable]]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   785
            selector == #value ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   786
                receiver codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   787
                ^ self
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   788
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   789
            ((selector == #whileTrue) or:[selector == #whileFalse]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   790
                ^ self codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   791
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   792
            ((selector == #repeat) or:[selector == #loop]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   793
                valueNeeded ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   794
                    ^ self codeRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   795
                ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   796
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   797
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   798
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   799
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   800
    (nargs == 1) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   801
        (recType == #ThisContext) ifTrue:[
2343
e3c3dad6a800 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   802
            (selector == #return:) ifTrue:[
e3c3dad6a800 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   803
                arg1 codeOn:aStream inBlock:b for:aCompiler.  "^ value"
e3c3dad6a800 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   804
                aStream nextPut:#retTop.
e3c3dad6a800 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   805
                valueNeeded ifTrue:[
e3c3dad6a800 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   806
                    "/ although we know, that it is useless, we generate a push-nil
2344
4cfbc5060382 comment/format in: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2343
diff changeset
   807
                    "/ to make any stack-checkers happy (caller will generate a pop).
2343
e3c3dad6a800 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   808
                    aStream nextPut:#pushNil.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   809
                ].
2343
e3c3dad6a800 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2331
diff changeset
   810
                ^ self.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   811
             ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   812
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   813
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   814
        ((selector == #ifNil:) or:[selector == #ifNotNil:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   815
            receiver isBlock ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   816
                (arg1 isBlock not
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   817
                or:[arg1 numArgs == 0]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   818
                    ^ self codeIfNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   819
                ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   820
                (arg1 isConstant or:[arg1 isVariable]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   821
                    ^ self codeIfNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   822
                ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   823
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   824
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   825
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   826
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   827
        (arg1 isBlock 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   828
        and:[arg1 isInlinable
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   829
        and:[arg1 numArgs == 0]]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   830
            ((selector == #ifTrue:) or:[selector == #ifFalse:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   831
                receiver isBlock ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   832
                    ^ self codeIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   833
                ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   834
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   835
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   836
            (selector == #or:) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   837
                ^ self codeOrOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   838
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   839
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   840
            (selector == #and:) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   841
                ^ self codeAndOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   842
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   843
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   844
            (selector == #timesRepeat:) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   845
                "/ now, always inline #timesRepeat:;
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   846
                "/ the receiver must understand #> and #-
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
   847
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   848
               ^ self codeTimesRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   849
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   850
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   851
            ((selector == #whileTrue:) or:[selector == #whileFalse:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   852
                (receiver isBlock 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   853
                and:[receiver isInlinable
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   854
                and:[receiver numArgs == 0]]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   855
                    ^ self codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   856
                ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   857
            ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   858
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   859
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   860
        ((selector == #ifTrue:) or:[selector == #ifFalse:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   861
            (arg1 isConstant or:[arg1 isVariable]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   862
                ^ self codeIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   863
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   864
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   865
1994
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   866
        usedSelector == #? ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   867
            "/ only do short-circuit optimization, if arg is not a message;
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   868
            "/ (could have side-effects)
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   869
            "/
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   870
            arg1 isMessage ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   871
                ^ self codeQuestOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   872
            ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   873
        ].
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   874
        (selector == #caseOf:) ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   875
            (self codeCaseOfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler) ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   876
                ^ self
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   877
            ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   878
        ].
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   879
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   880
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   881
    (nargs == 2) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   882
        receiver isBlock ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   883
            (arg1 isBlock 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   884
            and:[arg1 isInlinable
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   885
            and:[arg1 numArgs == 0
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   886
            and:[arg2 isBlock 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   887
            and:[arg2 isInlinable
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   888
            and:[arg2 numArgs == 0]]]]]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   889
                ((selector == #ifTrue:ifFalse:) or:[selector == #ifFalse:ifTrue:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   890
                    ^ self codeIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   891
                ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   892
                ((selector == #ifNil:ifNotNil:) or:[selector == #ifNotNil:ifNil:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   893
                    ^ self codeIfNilNotNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   894
                ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   895
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   896
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   897
            ((arg1 isConstant or:[arg1 isVariable])
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   898
            and:[arg2 isConstant or:[arg2 isVariable]]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   899
                ((selector == #ifTrue:ifFalse:) or:[selector == #ifFalse:ifTrue:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   900
                    ^ self codeIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   901
                ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   902
                ((selector == #ifNil:ifNotNil:) or:[selector == #ifNotNil:ifNil:]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   903
                    ^ self codeIfNilNotNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   904
                ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   905
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   906
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   907
        selector == #to:do: ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   908
            (arg2 isBlock 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   909
            and:[arg2 isInlinable 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   910
            and:[arg2 numArgs == 1]]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   911
                ^ self codeToDoOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   912
            ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   913
        ].
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   914
        (selector == #'caseOf:otherwise:') ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   915
            (self codeCaseOfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler) ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   916
                ^ self
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   917
            ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
   918
        ].
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   919
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   920
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   921
    (nargs == 3) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   922
        selector == #to:by:do: ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   923
            "/ step must be a constant (need to know how to compare)
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   924
            (arg2 isConstant 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   925
            and:[arg2 type == #Integer
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   926
            and:[arg3 isBlock 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   927
            and:[arg3 isInlinable 
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   928
            and:[arg3 numArgs == 1]]]]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   929
                ^ self codeToByDoOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   930
            ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   931
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   932
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   933
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   934
    isBuiltIn := isSpecial := false.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   935
    isSuper ifFalse:[
1994
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   936
        isBuiltIn := aCompiler isBuiltInSelector:usedSelector forReceiver:receiver.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   937
        isBuiltIn ifFalse:[
1994
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   938
            specialCode := aCompiler specialSendCodeFor:usedSelector.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   939
            isSpecial := specialCode notNil.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   940
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   941
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   942
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   943
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   944
    "can we use a send-bytecode ?"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   945
    (isBuiltIn or:[isSpecial]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   946
        receiver codeOn:aStream inBlock:b for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   947
        (nargs > 0) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   948
            arg1 codeOn:aStream inBlock:b for:aCompiler.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   949
            (nargs > 1) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   950
                arg2 codeOn:aStream inBlock:b for:aCompiler
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   951
            ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   952
        ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
   953
        lineNr >= 255 ifTrue:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
   954
            self codeLineNumber: lineNr on: aStream for:aCompiler.  
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
   955
        ].
1994
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   956
        aStream nextPut:usedSelector.
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
   957
        (aCompiler hasLineNumber:usedSelector) ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   958
            aStream nextPut:lineNr.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   959
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   960
        isSpecial ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   961
            aStream nextPut:specialCode
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   962
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   963
        valueNeeded ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   964
            aStream nextPut:#drop
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   965
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   966
        ^ self
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   967
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   968
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   969
    ((nargs == 0) and:[selector == #yourself]) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   970
        "yourself is often added to get the receiver -
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   971
         we get it without the yourself-message"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   972
2429
89d05ce26891 changed: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2399
diff changeset
   973
        (valueNeeded or:[receiver isMessage]) ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   974
            receiver codeOn:aStream inBlock:b for:aCompiler
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   975
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   976
        ^ self
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   977
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   978
2345
d3c1bbb5cddc comment/format in: #codeOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2344
diff changeset
   979
    "not inlinable - generate a send"
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
   980
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   981
    stackTop := nil.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   982
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   983
    useSelfSend := isSuper not and:[ recType == #Self and:[ litIndex <= 16rFFFF ] ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   984
    useSelfSend ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   985
        receiver codeOn:aStream inBlock:b for:aCompiler.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   986
        receiver isConstant ifTrue:[ 
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   987
            stackTop := receiver
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   988
        ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   989
    ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   990
    argArray notNil ifTrue:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   991
        argArray do:[:arg |
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   992
            (stackTop notNil and:[arg canReuseAsArg:stackTop]) ifTrue:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   993
                aStream nextPut:#dup.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   994
                "/ 'reuse:' print. stackTop print. ' in ' print. aCompiler selector printNL.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   995
            ] ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   996
                arg codeOn:aStream inBlock:b for:aCompiler.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   997
                stackTop := arg.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   998
            ]
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
   999
        ]
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1000
    ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1001
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1002
    isSuper ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1003
        cls := aCompiler targetClass.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1004
        realReceiver isHere ifTrue:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1005
            "/ same code as supersend, but targetClass starts search
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1006
        ] ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1007
            "/ targetClasses superclass starts search
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1008
            cls := cls superclass.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1009
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1010
        clsLitIndex := aCompiler addLiteral:cls.
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1011
        self emitSuperSendLiteralIndex:litIndex classLiteralIndex:clsLitIndex numArgs:nargs line:lineNr on:aStream for:aCompiler.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1012
        valueNeeded ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1013
            aStream nextPut:#drop
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1014
        ].
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1015
        ^ self.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1016
    ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1017
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1018
    valueNeeded ifTrue:[ noSendDrop := true ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1019
    alreadyDropped := false.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1020
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1021
    (litIndex <= 255) ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1022
        (nargs <= 3) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1023
            |codes|
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1024
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1025
            noSendDrop ifTrue:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1026
                useSelfSend ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1027
                    codes := #(sendSelf0 sendSelf1 sendSelf2 sendSelf3)
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1028
                ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1029
                    codes := #(send0 send1 send2 send3)
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1030
                ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1031
            ] ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1032
                useSelfSend ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1033
                    codes := #(sendSelfDrop0 sendSelfDrop1 sendSelfDrop2 sendSelfDrop3)
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1034
                ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1035
                    codes := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3)
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1036
                ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1037
                alreadyDropped := true.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1038
            ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1039
            lineNr >= 255 ifTrue:[
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1040
                self codeLineNumber: lineNr on: aStream for: aCompiler.
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1041
            ].
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1042
            aStream nextPut:(codes at:(nargs + 1)); nextPut:lineNr; nextPut:litIndex.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1043
            valueNeeded ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1044
                alreadyDropped ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1045
                    aStream nextPut:#drop
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1046
                ].
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1047
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1048
            ^ self
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1049
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1050
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1051
        useSelfSend ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1052
            code := #sendSelf
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1053
        ] ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1054
            noSendDrop ifTrue:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1055
                code := #send
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1056
            ] ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1057
                code := #sendDrop.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1058
                alreadyDropped := true.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1059
            ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1060
        ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1061
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1062
        lineNr >= 255 ifTrue:[
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1063
            self codeLineNumber: lineNr on: aStream for: aCompiler.
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1064
        ].           
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1065
        aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1066
        valueNeeded ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1067
            alreadyDropped ifFalse:[
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1068
                aStream nextPut:#drop
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1069
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1070
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1071
        ^ self
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1072
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1073
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1074
    "needs 16bit literal index"
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1075
    (litIndex <= 16rFFFF) ifTrue:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1076
        useSelfSend ifTrue:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1077
            aStream nextPut:#sendSelfL; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs.
1801
9fd56369b7f1 more long ops
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
  1078
        ] ifFalse:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1079
            self emitSendLiteralIndex:litIndex numArgs:nargs line:lineNr on:aStream for:aCompiler.
1801
9fd56369b7f1 more long ops
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
  1080
        ].
9fd56369b7f1 more long ops
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
  1081
    ] ifFalse:[
9fd56369b7f1 more long ops
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
  1082
        "needs 32bit literal index"
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1083
        self emitSendLiteralIndex:litIndex numArgs:nargs line:lineNr on:aStream for:aCompiler.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1084
    ].
1801
9fd56369b7f1 more long ops
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
  1085
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1086
    valueNeeded ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1087
        aStream nextPut:#drop
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1088
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1089
1994
4094e1eb3399 preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents: 1989
diff changeset
  1090
    "Modified: / 03-09-1995 / 12:55:42 / claus"
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1091
    "Modified: / 25-05-2012 / 11:29:47 / cg"
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1092
    "Modified: / 12-04-2013 / 22:42:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1093
! !
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1094
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1095
!MessageNode methodsFor:'enumerating'!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1096
3336
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1097
allNodesDo:aBlock
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1098
    "evaluate aBlock for each node in this node and subnodes"
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1099
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1100
    aBlock value:self.
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1101
    receiver allNodesDo:aBlock.
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1102
    argArray notNil ifTrue:[
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1103
        argArray do:[:arg | arg allNodesDo:aBlock].
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1104
    ]
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1105
!
1b4396f06cbf class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3330
diff changeset
  1106
3278
73ef6a07d279 class: ParseNode
Claus Gittinger <cg@exept.de>
parents: 3274
diff changeset
  1107
messageSelectorsDo:aBlock
73ef6a07d279 class: ParseNode
Claus Gittinger <cg@exept.de>
parents: 3274
diff changeset
  1108
    "evaluate aBlock for each message-selector here and in subnodes"
73ef6a07d279 class: ParseNode
Claus Gittinger <cg@exept.de>
parents: 3274
diff changeset
  1109
73ef6a07d279 class: ParseNode
Claus Gittinger <cg@exept.de>
parents: 3274
diff changeset
  1110
    aBlock value:selector.
73ef6a07d279 class: ParseNode
Claus Gittinger <cg@exept.de>
parents: 3274
diff changeset
  1111
    receiver messageSelectorsDo:aBlock.
3274
18fa73f6a23b renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents: 3266
diff changeset
  1112
    argArray notNil ifTrue:[
3278
73ef6a07d279 class: ParseNode
Claus Gittinger <cg@exept.de>
parents: 3274
diff changeset
  1113
        argArray do:[:arg | arg messageSelectorsDo:aBlock].
3274
18fa73f6a23b renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents: 3266
diff changeset
  1114
    ]
18fa73f6a23b renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents: 3266
diff changeset
  1115
!
18fa73f6a23b renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents: 3266
diff changeset
  1116
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1117
messagesDo:aBlock
3313
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1118
    "evaluate aBlock for each message-node here and in subnodes"
3274
18fa73f6a23b renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents: 3266
diff changeset
  1119
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1120
    aBlock value:self.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1121
    receiver messagesDo:aBlock.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1122
    argArray notNil ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1123
        argArray do:[:arg | arg messagesDo:aBlock].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1124
    ]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1125
!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1126
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1127
nodeDo:anEnumerator
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1128
    "helper for parse tree walking"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1129
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1130
    |args|
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1131
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1132
    args := argArray ? #().
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1133
    ^ anEnumerator doMessage:self receiver:receiver selector:selector arguments:args
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1134
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1135
    "Created: 19.6.1997 / 16:46:39 / cg"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1136
    "Modified: 19.6.1997 / 17:08:28 / cg"
3313
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1137
!
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1138
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1139
variableNodesDo:aBlock
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1140
    "evaluate aBlock for each variable-node here and in subnodes"
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1141
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1142
    receiver variableNodesDo:aBlock.
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1143
    argArray notNil ifTrue:[
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1144
        argArray do:[:arg | arg variableNodesDo:aBlock].
860a2a61cbde enumerators
Claus Gittinger <cg@exept.de>
parents: 3310
diff changeset
  1145
    ]
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1146
! !
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1147
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1148
!MessageNode methodsFor:'evaluation'!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1149
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1150
evaluateForCascadeIn:anEnvironment
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1151
    ^ self evaluateIn:anEnvironment forCascade:true
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1152
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1153
    "Modified: / 20-04-2005 / 12:12:01 / cg"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1154
!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1155
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1156
evaluateIn:anEnvironment
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1157
    ^ self evaluateIn:anEnvironment forCascade:false
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1158
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1159
    "Modified: / 20-04-2005 / 12:11:55 / cg"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1160
!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1161
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1162
evaluateIn:anEnvironment forCascade:forCascade
2329
50473c5384bb changed: #evaluateIn:forCascade:
Claus Gittinger <cg@exept.de>
parents: 2321
diff changeset
  1163
    |retVal defClass r a1 a2 a3 nargs argValueArray class sel|
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1164
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1165
    sel := self evaluationSelector.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1166
    receiver isSuper ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1167
        r := receiver value.
2329
50473c5384bb changed: #evaluateIn:forCascade:
Claus Gittinger <cg@exept.de>
parents: 2321
diff changeset
  1168
50473c5384bb changed: #evaluateIn:forCascade:
Claus Gittinger <cg@exept.de>
parents: 2321
diff changeset
  1169
        defClass := receiver definingClass.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1170
        receiver isHere ifTrue:[
2329
50473c5384bb changed: #evaluateIn:forCascade:
Claus Gittinger <cg@exept.de>
parents: 2321
diff changeset
  1171
            class := defClass.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1172
        ] ifFalse:[
2329
50473c5384bb changed: #evaluateIn:forCascade:
Claus Gittinger <cg@exept.de>
parents: 2321
diff changeset
  1173
            class := defClass superclass.
1691
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1174
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1175
        argArray notNil ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1176
            argValueArray := argArray collect:[:arg | arg evaluateIn:anEnvironment].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1177
        ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1178
            argValueArray := #()
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1179
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1180
        retVal := r perform:sel inClass:class withArguments:argValueArray.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1181
    ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1182
        r := receiver evaluateIn:anEnvironment.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1183
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1184
        argArray isNil ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1185
            retVal := r perform:sel
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1186
        ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1187
            nargs := argArray size.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1188
            (nargs == 0) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1189
                retVal := r perform:sel
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1190
            ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1191
                a1 := (argArray at:1) evaluateIn:anEnvironment.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1192
                (nargs == 1) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1193
                    retVal := r perform:sel with:a1
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1194
                ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1195
                    a2 := (argArray at:2) evaluateIn:anEnvironment.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1196
                    (nargs == 2) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1197
                        retVal := r perform:sel with:a1 with:a2
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1198
                    ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1199
                        a3 := (argArray at:3) evaluateIn:anEnvironment.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1200
                        (nargs == 3) ifTrue:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1201
                            retVal := r perform:sel with:a1 with:a2 with:a3
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1202
                        ] ifFalse:[
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1203
                            argValueArray := Array new:nargs.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1204
                            argValueArray at:1 put:a1.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1205
                            argValueArray at:2 put:a2.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1206
                            argValueArray at:3 put:a3.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1207
                            4 to:nargs do:[:idx | argValueArray at:idx put:((argArray at:idx) evaluateIn:anEnvironment)].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1208
                            retVal := r perform:sel withArguments:argValueArray.
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1209
                        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1210
                    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1211
                ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1212
            ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1213
        ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1214
    ].
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1215
    ^ forCascade ifTrue:[r] ifFalse:[retVal]
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1216
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1217
    "Created: / 20-04-2005 / 12:11:39 / cg"
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1218
!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1219
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1220
evaluationSelector
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1221
    ^ selector asSymbol
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1222
! !
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1223
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1224
!MessageNode methodsFor:'optimized code generation'!
ab6d550484d7 category
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  1225
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1226
codeAndIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1227
    "generate code for (x and:[y]) ifxxx:[ ... ] ifyyy:[ ... ]"
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1228
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1229
    |theByteCode optByteCode receiver1 receiver2 theArg theArg2 pos1 pos2 pos3 code here jmp
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1230
     block1 block2 andBlock optByteCode2|
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1231
1464
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  1232
    aCompiler addLiteral:#and:.
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  1233
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1234
    theByteCode := #falseJump.
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1235
    receiver1 := receiver receiver.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1236
    theArg := nil.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1237
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1238
    optByteCode := self optimizedConditionFor:receiver1 with:theByteCode for:aCompiler.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1239
    optByteCode notNil ifTrue:[
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1240
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1241
            theArg := receiver1 arg1
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1242
        ].
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1243
        receiver1 := receiver1 receiver.
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1244
        theByteCode := optByteCode
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1245
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1246
    "/ code the left-of the and-part
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1247
    receiver1 codeOn:aStream inBlock:b for:aCompiler.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1248
    theArg notNil ifTrue:[
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1249
        theArg codeOn:aStream inBlock:b for:aCompiler
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1250
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1251
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1252
    pos1 := aStream position + 1.   "/ remember branch target of left-fail branch
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1253
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1254
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1255
    "/ code the right of the and-part
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1256
    (selector == #ifTrue:ifFalse:) ifTrue:[
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1257
        jmp := #falseJump
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1258
    ] ifFalse:[
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1259
        jmp := #trueJump
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1260
    ].
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1261
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1262
    andBlock := receiver arg1.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1263
    theArg2 := nil.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1264
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1265
    "/ code the left-of the and-part
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1266
    (andBlock statements isNil or:[andBlock statements nextStatement isNil]) ifTrue:[
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1267
        "/ simple - one statement
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1268
        receiver2 := andBlock statements expression.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1269
        optByteCode2 := self optimizedConditionFor:receiver2 with:jmp for:aCompiler.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1270
    ].
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1271
    optByteCode2 notNil ifTrue:[
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1272
        ((optByteCode2 == #eqJump) or:[optByteCode2 == #notEqJump]) ifTrue:[
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1273
            theArg2 := receiver2 arg1
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1274
        ].
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1275
        receiver2 := receiver2 receiver.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1276
        receiver2 codeOn:aStream inBlock:b for:aCompiler.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1277
        theArg2 notNil ifTrue:[
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1278
            theArg2 codeOn:aStream inBlock:b for:aCompiler
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1279
        ].
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1280
        jmp := optByteCode2
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1281
    ] ifFalse:[
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1282
        andBlock codeInlineOn:aStream inBlock:b for:aCompiler.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1283
    ].
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1284
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1285
    aStream nextPut:jmp.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1286
    pos2 := aStream position + 1.   "/ remember branch target of right-fail branch 
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1287
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1288
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1289
    code := aStream contents.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1290
    (selector == #ifFalse:ifTrue:) ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1291
        code at:pos1 put:(aStream position + 1)
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1292
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1293
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1294
    "/ code the if-block
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1295
    block1 := argArray at: 1.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1296
    self codeBlockEvaluation:block1 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1297
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1298
    aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1299
    pos3 := aStream position + 1.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1300
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1301
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1302
    here := aStream position + 1.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1303
    (selector == #ifTrue:ifFalse:) ifTrue:[
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  1304
        code at:pos1 put:here
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1305
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1306
    code at:pos2 put:here.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1307
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1308
    "/ code the else-block
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1309
    block2 := argArray at: 2.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1310
    self codeBlockEvaluation:block2 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1311
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1312
    code at:pos3 put:(aStream position + 1)
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1313
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1314
    "Created: 6.9.1996 / 12:56:23 / cg"
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1315
!
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1316
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1317
codeAndIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1318
    "generate code for (x and:[y]) ifxxx:[ ... ]"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1319
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1320
    |theByteCode optByteCode andBlock theArg pos1 pos2 pos3 code here jmp
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1321
     receiver1 receiver2 optByteCode2 theArg2 block|
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1322
1464
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  1323
    aCompiler addLiteral:#and:.
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  1324
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1325
    theByteCode := #falseJump.
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1326
    receiver1 := receiver receiver.
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1327
    theArg := nil.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1328
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  1329
    optByteCode := self optimizedConditionFor:receiver1 with:theByteCode for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1330
    optByteCode notNil ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1331
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1332
            theArg := receiver1 arg1
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1333
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1334
        receiver1 := receiver1 receiver.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1335
        theByteCode := optByteCode
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1336
    ].
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1337
    "/ code the left-of the and-part
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1338
    receiver1 codeOn:aStream inBlock:b for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1339
    theArg notNil ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1340
        theArg codeOn:aStream inBlock:b for:aCompiler
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1341
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1342
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1343
    pos1 := aStream position + 1.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1344
    aStream nextPut:0.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1345
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1346
    andBlock := receiver arg1. "/ the and:-block
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1347
    (selector == #ifTrue:) ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1348
        jmp := #falseJump
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1349
    ] ifFalse:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1350
        jmp := #trueJump
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1351
    ].
2941
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1352
    optByteCode2 := nil.
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1353
346983db9f8f changed:
Claus Gittinger <cg@exept.de>
parents: 2925
diff changeset
  1354
    (andBlock statements isNil or:[andBlock statements nextStatement isNil]) ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1355
        "/ simple - one statement
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1356
        receiver2 := andBlock statements expression.
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  1357
        optByteCode2 := self optimizedConditionFor:receiver2 with:jmp for:aCompiler.
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1358
    ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1359
    optByteCode2 notNil ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1360
        ((optByteCode2 == #eqJump) or:[optByteCode2 == #notEqJump]) ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1361
            theArg2 := receiver2 arg1
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1362
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1363
        receiver2 := receiver2 receiver.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1364
        receiver2 codeOn:aStream inBlock:b for:aCompiler.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1365
        theArg2 notNil ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1366
            theArg2 codeOn:aStream inBlock:b for:aCompiler
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1367
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1368
        jmp := optByteCode2.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1369
    ] ifFalse:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1370
        andBlock codeInlineOn:aStream inBlock:b for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1371
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1372
    aStream nextPut:jmp.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1373
    pos2 := aStream position + 1.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1374
    aStream nextPut:0.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1375
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1376
    code := aStream contents.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1377
    (selector == #ifFalse:) ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1378
        code at:pos1 put:(aStream position + 1)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1379
    ].
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1380
    block := argArray at: 1.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1381
    self codeBlockEvaluation:block on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1382
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1383
    valueNeeded ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1384
        aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1385
        pos3 := aStream position + 1.
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1386
        aStream nextPut:0.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1387
        here := aStream position + 1.
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1388
        (selector == #ifTrue:) ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1389
            code at:pos1 put:here
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1390
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1391
        code at:pos2 put:here.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1392
        aStream nextPut:#pushNil.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1393
        code at:pos3 put:(aStream position + 1)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1394
    ] ifFalse:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1395
        here := aStream position + 1.
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1396
        (selector == #ifTrue:) ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1397
            code at:pos1 put:here
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1398
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
  1399
        code at:pos2 put:here
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1400
    ]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1401
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1402
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1403
codeAndOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1404
    "generate code for (x and:[y])"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1405
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1406
    |jumpTarget1 rightExpr|
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1407
1464
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  1408
    aCompiler addLiteral:#and:.
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  1409
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1410
    (receiver isConstant and:[receiver value == true ]) ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1411
        "/ happens when code is "commented" i.e. true and:[ ... ]
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1412
        
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1413
    ] ifFalse:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1414
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1415
        receiver codeOn:aStream inBlock:b for:aCompiler.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1416
        valueNeeded ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1417
            aStream nextPut:#dup.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1418
        ].
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1419
        aStream nextPut:#falseJump.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1420
        jumpTarget1 := aStream position + 1.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1421
        aStream nextPut:0.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1422
        valueNeeded ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1423
            aStream nextPut:#drop.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1424
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1425
    ].
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1426
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1427
    rightExpr := argArray at:1.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1428
    rightExpr codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
163
9a7dfd547e69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  1429
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1430
    jumpTarget1 notNil ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1431
        (aStream contents) at:jumpTarget1 put:(aStream position + 1)
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  1432
    ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1433
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1434
    "Created: 17.6.1996 / 15:46:42 / cg"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1435
    "Modified: 17.6.1996 / 15:47:44 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1436
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1437
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1438
codeBlockEvaluation:aBlock on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1439
    "gen code to evaluate a block"
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1440
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1441
    (aBlock isBlock and:[aBlock isInlinable]) ifTrue:[
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1442
        aBlock codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1443
    ] ifFalse:[
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1444
        aBlock codeOn:aStream inBlock:b for:aCompiler.
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1445
        aBlock isConstant ifFalse:[
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1446
            self codeValueSendOn:aStream for:aCompiler.
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1447
        ].
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1448
        valueNeeded ifFalse:[
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1449
            aStream nextPut:#drop
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1450
        ].
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1451
    ].
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1452
!
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1453
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1454
codeCaseOfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1455
    "expr
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1456
        caseOf: {
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1457
            [val1] -> [ caseStats1 ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1458
            [val2] -> [ caseStats2 ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1459
            ...
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1460
            [valN] -> [ caseStatsN ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1461
        }
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1462
        otherwise: [
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1463
            otherStats
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1464
        ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1465
     also handles caseOf, without otherwise: arg.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1466
     Compiled as a nested if-statement.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1467
    "
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1468
2893
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1469
    |caseArg otherwiseArg checkAndCollectCases checkAndCollectCases2 caseValueExpressions caseBlocks elseBlock ifMessage|
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1470
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1471
    checkAndCollectCases := 
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1472
        [:expr :atEnd |
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1473
            |numCasesAllocated caseNr caseValueExpression caseBlock|
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1474
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1475
            expr receiver isMessage ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1476
            expr selector = #'at:put:' ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1477
            "check if at: arg is an integer (the case-nr)"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1478
            expr arg1 isConstant ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1479
            (caseNr := expr arg1 value) isInteger ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1480
            "check if put: arg is []->[] (the case-spec)"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1481
            expr arg2 isMessage ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1482
            expr arg2 selector == #'->' ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1483
            expr arg2 receiver isBlock ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1484
            (caseBlock := expr arg2 arg1) isBlock ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1485
            "the case-value-block must consist of a single expression"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1486
            expr arg2 receiver isSingleExpressionBlock ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1487
            (caseValueExpression := expr arg2 receiver simpleSendBlockExpression) notNil ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1488
            caseValueExpressions isEmptyOrNil ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1489
                caseValueExpressions := OrderedCollection withSize:caseNr.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1490
                caseBlocks := OrderedCollection withSize:caseNr.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1491
            ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1492
            caseValueExpressions at:caseNr put:caseValueExpression.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1493
            caseBlocks at:caseNr put:caseBlock.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1494
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1495
            atEnd ifFalse: [
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1496
                expr receiver isCascade ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1497
                    "at the left, there must be another cascade"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1498
                    checkAndCollectCases value:expr receiver value:false.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1499
                ] ifFalse:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1500
                    "at the left, there must be an (Array new:N) at:1 put:([]->[]) expression"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1501
                    checkAndCollectCases value:expr receiver value:true.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1502
                    expr receiver selector = #'at:put:' ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1503
                    expr receiver receiver isMessage ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1504
                    expr receiver receiver selector = #'new:' ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1505
                    expr receiver receiver receiver isGlobal ifFalse:[ ^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1506
                    expr receiver receiver receiver name = 'Array' ifFalse:[^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1507
                    expr receiver receiver arg1 isConstant ifFalse:[^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1508
                    (numCasesAllocated := expr receiver receiver arg1 value) isInteger ifFalse:[^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1509
                    numCasesAllocated = caseBlocks size ifFalse:[^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1510
                ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1511
            ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1512
        ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1513
2893
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1514
    checkAndCollectCases2 :=    "/ for with:with: cases
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1515
        [:expr |
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1516
            |caseNr caseValueExpression caseBlock|
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1517
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1518
            expr args do:[:eachCaseArg |
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1519
                "check if put: eachCaseArg is []->[] (the case-spec)"
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1520
                eachCaseArg isMessage ifFalse:[ ^ false].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1521
                eachCaseArg selector == #'->' ifFalse:[ ^ false].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1522
                eachCaseArg receiver isBlock ifFalse:[ ^ false].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1523
                (caseBlock := eachCaseArg arg1) isBlock ifFalse:[ ^ false].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1524
                "the case-value-block must consist of a single expression"
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1525
                eachCaseArg receiver isSingleExpressionBlock ifFalse:[ ^ false].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1526
                (caseValueExpression := eachCaseArg receiver simpleSendBlockExpression) notNil ifFalse:[ ^ false].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1527
                caseValueExpressions isEmptyOrNil ifTrue:[
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1528
                    caseValueExpressions := OrderedCollection new.
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1529
                    caseBlocks := OrderedCollection new.
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1530
                ].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1531
                caseValueExpressions add:caseValueExpression.
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1532
                caseBlocks add:caseBlock.
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1533
            ].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1534
        ].
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1535
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1536
    receiver isMessage ifTrue:[ ^ false].   "for now: I cannot introduce temporaries"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1537
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1538
    caseArg := argArray at:1.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1539
    "caseArg has already been transformed from a {...}- to
2893
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1540
     an Array-creating cascade expression or an Array-with:... expression"
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1541
    caseArg isCascade ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1542
        caseArg receiver isMessage ifFalse:[^ false].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1543
        checkAndCollectCases value:(caseArg receiver) value:false.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1544
    ] ifFalse:[
2893
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1545
        (caseArg isMessage
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1546
            and:[ (caseArg receiver isGlobalNamed:'Array')
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1547
            and:[ 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1548
                #( 'with:'
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1549
                   'with:with:' 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1550
                   'with:with:with:' 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1551
                   'with:with:with:with:' 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1552
                   'with:with:with:with:with:' 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1553
                   'with:with:with:with:with:with:' 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1554
                   'with:with:with:with:with:with:with:' 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1555
                   'with:with:with:with:with:with:with:with:' 
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1556
                    ) includes:caseArg selector ]
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1557
        ]) ifTrue:[
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1558
            checkAndCollectCases2 value:caseArg.
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1559
        ] ifFalse:[
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1560
            "whenever an explicit Array-expression is used here, add support below"
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1561
            ^ false
0fe6659c742e changed: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  1562
        ].
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1563
    ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1564
    argArray size > 1 ifTrue:[
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1565
        otherwiseArg := argArray at:2.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1566
        otherwiseArg isBlock ifFalse:[^ false]
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1567
    ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1568
    "compile as a nested if"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1569
3356
3c0e828c3f36 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3336
diff changeset
  1570
    elseBlock := otherwiseArg ? (ConstantNode value:nil).
2870
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1571
    caseValueExpressions with:caseBlocks reverseDo:[:eachCaseValueExpression :eachCaseBlock |
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1572
        |cond|
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1573
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1574
        cond := MessageNode receiver:receiver selector:#'=' arg:eachCaseValueExpression.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1575
        ifMessage := MessageNode
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1576
                        receiver:cond
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1577
                        selector:#'ifTrue:ifFalse:'
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1578
                        arg1:eachCaseBlock
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1579
                        arg2:elseBlock.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1580
        elseBlock := BlockNode withExpression:ifMessage in:b.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1581
    ].
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1582
    ifMessage codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1583
    ^ true
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1584
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1585
    "Created: / 25-05-2012 / 11:28:27 / cg"
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1586
!
75f1f73b3bf9 added: #codeCaseOfOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  1587
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1588
codeForCascadeOn:aStream inBlock:b for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1589
    "like codeOn, but always leave the receiver instead of the result"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1590
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1591
    |nargs isBuiltIn code litIndex cls clsLitIndex isSuper realReceiver noSendDrop|
1048
6eaeba225e67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1592
1500
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
  1593
    selector := selector asSymbol.
1048
6eaeba225e67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  1594
    noSendDrop := aCompiler class newCodeSet == true.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1595
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1596
    realReceiver := self realReceiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1597
    isSuper := realReceiver isSuper.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1598
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1599
    argArray isNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1600
        nargs := 0
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1601
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1602
        nargs := argArray size
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1603
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1604
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1605
    isBuiltIn := isSuper not and:[ aCompiler isBuiltInSelector:selector forReceiver:receiver ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1606
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1607
    litIndex := aCompiler addLiteral:selector.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1608
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1609
    receiver codeOn:aStream inBlock:b for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1610
    aStream nextPut:#dup.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1611
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1612
    "can we use a send-bytecode ?"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1613
    isBuiltIn ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1614
        (nargs > 0) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1615
            (argArray at:1) codeOn:aStream inBlock:b for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1616
            (nargs > 1) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1617
                (argArray at:2) codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1618
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1619
        ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1620
        lineNr >= 255 ifTrue:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1621
            self codeLineNumber: lineNr on: aStream for:aCompiler.  
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1622
        ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1623
        aStream nextPut:selector.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1624
        (aCompiler hasLineNumber:selector) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1625
            aStream nextPut:lineNr.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1626
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1627
        aStream nextPut:#drop.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1628
        ^ self
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1629
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1630
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1631
    "no - generate a send"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1632
    argArray notNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1633
        argArray do:[:arg |
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1634
            arg codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1635
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1636
    ].
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
  1637
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1638
    isSuper ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1639
        cls := aCompiler targetClass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1640
        realReceiver isHere ifTrue:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1641
            "/ same code as supersend, but targetClass starts search
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1642
        ] ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1643
            "/ targetClasses superclass starts search
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1644
            cls := cls superclass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1645
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1646
        clsLitIndex := aCompiler addLiteral:cls.
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1647
        self emitSuperSendLiteralIndex:litIndex classLiteralIndex:clsLitIndex numArgs:nargs line:lineNr on:aStream for:aCompiler.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1648
        aStream nextPut:#drop.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1649
        ^ self
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
  1650
    ].
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
  1651
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1652
    noSendDrop ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1653
        litIndex <= 255 ifTrue:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1654
            (nargs <= 3) ifTrue:[
1046
8e5818442eb9 newCode (for rel5)
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  1655
                code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1656
                lineNr >= 255 ifTrue:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1657
                    self codeLineNumber: lineNr on: aStream for:aCompiler.  
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1658
                ].
1046
8e5818442eb9 newCode (for rel5)
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  1659
                aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1660
                ^ self
1046
8e5818442eb9 newCode (for rel5)
Claus Gittinger <cg@exept.de>
parents: 1045
diff changeset
  1661
            ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1662
            lineNr >= 255 ifTrue:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1663
                self codeLineNumber: lineNr on: aStream for:aCompiler.  
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1664
            ].
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1665
            aStream nextPut:#sendDrop; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1666
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1667
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1668
    ].
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1669
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  1670
    self emitSendLiteralIndex:litIndex numArgs:nargs line:lineNr on:aStream for:aCompiler.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  1671
    aStream nextPut:#drop.
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
  1672
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1673
    "Modified: / 04-07-1999 / 19:06:53 / cg"
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  1674
    "Modified: / 13-04-2013 / 10:49:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1675
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1676
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1677
codeForSideEffectOn:aStream inBlock:b for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1678
    self codeOn:aStream inBlock:b valueNeeded:false for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1679
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1680
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1681
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1682
    |arg1 rightExpr pos1|
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1683
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1684
    (selector == #and:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1685
    or:[selector == #or:]) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1686
        arg1 := argArray at:1.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1687
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1688
        "/ for now:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1689
        "/ only do it for non-blocks, since
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1690
        "/ the JIT compiler is smart enough to
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1691
        "/ specially optimize the resulting code
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1692
        "/ (and not smart enough to optimized the
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1693
        "/  other - actually more efficient - code)
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1694
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1695
        (arg1 isBlock not 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1696
"/        or:[arg1 isInlinable]
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1697
        ) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1698
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1699
            "/ encode #and: as:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1700
            "/
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1701
            "/      eLeft
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1702
            "/      jmp_false       LBL
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1703
            "/      eRight
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1704
            "/      retTop
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1705
            "/  LBL:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1706
            "/      retFalse
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1707
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1708
            "/ encode #or: as:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1709
            "/
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1710
            "/      eLeft
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1711
            "/      jmp_true       LBL
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1712
            "/      eRight
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1713
            "/      retTop
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1714
            "/  LBL:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1715
            "/      retTrue
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1716
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1717
            receiver codeOn:aStream inBlock:b for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1718
            selector == #and: ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1719
                aStream nextPut:#falseJump.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1720
            ] ifFalse:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1721
                aStream nextPut:#trueJump.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1722
            ].
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1723
            pos1 := aStream position + 1.
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1724
            aStream nextPut:0.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1725
        
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1726
            rightExpr := argArray at:1.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1727
            rightExpr isBlock ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1728
                rightExpr codeInlineOn:aStream inBlock:b valueNeeded:true for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1729
            ] ifFalse:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1730
                rightExpr codeOn:aStream inBlock:b for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1731
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1732
            aStream nextPut:#retTop.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1733
        
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1734
            (aStream contents) at:pos1 put:(aStream position + 1).
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1735
            selector == #and: ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1736
                aStream nextPut:#retFalse.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1737
            ] ifFalse:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1738
                aStream nextPut:#retTrue
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1739
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1740
            ^ self.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1741
        ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1742
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1743
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1744
    super
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1745
        codeForSimpleReturnOn:aStream 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1746
        inBlock:b 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1747
        lineNumber:lineNrOrNil 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1748
        for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1749
!
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
  1750
104
claus
parents: 103
diff changeset
  1751
codeIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1752
    "generate code for x ifxxx:[ ... ] yyy:[ ...]"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1753
334
cd7491b7ad33 dont code a jump after if-part if it ends in a return.
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1754
    |pos pos2 theReceiver theArg theByteCode optByteCode subsel code needLineNr
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1755
     needJump block1 block2|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1756
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1757
    theReceiver := receiver.
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  1758
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1759
    theReceiver isConstant ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1760
        (self tryFoldedIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1761
            ^ self
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1762
        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1763
    ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1764
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  1765
    (theReceiver isMessage) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1766
        subsel := theReceiver selector.
2399
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1767
        ((subsel == #and:) and:[theReceiver arg1 isBlock and:[theReceiver arg1 isInlinable]]) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1768
            self codeAndIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1769
            ^ self
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1770
        ].
2399
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1771
        ((subsel == #or:) and:[theReceiver arg1 isBlock and:[theReceiver arg1 isInlinable]]) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1772
            self codeOrIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1773
            ^ self
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1774
        ]
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  1775
    ].
2399
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1776
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1777
    (selector == #ifTrue:ifFalse:) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1778
        theByteCode := #falseJump
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1779
    ] ifFalse:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1780
        theByteCode := #trueJump
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1781
    ].
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  1782
    optByteCode := self optimizedConditionFor:theReceiver with:theByteCode for:aCompiler.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1783
    optByteCode notNil ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1784
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1785
            theArg := theReceiver arg1
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1786
        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1787
        theReceiver := theReceiver receiver.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1788
        theByteCode := optByteCode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1789
    ].
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1790
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1791
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1792
    needLineNr := true.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1793
    theArg isNil ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1794
        theReceiver isMessage ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1795
            (aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1796
                theReceiver lineNumber == lineNr ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1797
                    needLineNr := false
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1798
                ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1799
            ]
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1800
        ]
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1801
    ] ifFalse:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1802
        theArg codeOn:aStream inBlock:b for:aCompiler
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1803
    ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1804
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1805
    needLineNr ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1806
        (lineNr between:1 and:255) ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1807
            aStream nextPut:#lineno; nextPut:lineNr.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1808
        ]
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1809
    ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1810
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1811
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1812
    pos := aStream position + 1.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1813
    aStream nextPut:0.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1814
    block1 := argArray at:1.
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1815
    self codeBlockEvaluation:block1 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1816
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1817
    needJump := true.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1818
    (block1 isBlock and:[block1 endsWithReturn]) ifTrue:[
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1819
        needJump := false
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1820
    ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1821
    needJump ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1822
        aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1823
        pos2 := aStream position + 1.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1824
        aStream nextPut:0.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1825
    ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1826
    code := aStream contents.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1827
    code at:pos put:(aStream position + 1).
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1828
    block2 := (argArray at:2).
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1829
    self codeBlockEvaluation:block2 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1830
    needJump ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1831
        code at:pos2 put:(aStream position + 1)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1832
    ]
166
9f6c57a3bce1 no line number bytecode in if-else if not needed
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
  1833
2399
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1834
    "
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1835
     |a|
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1836
     (a size = 0 and:a isNil) ifTrue: [self halt.] ifFalse:[]
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1837
    "
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1838
57ba9eb8c502 changed: #codeIfElseOn:inBlock:valueNeeded:for:
Claus Gittinger <cg@exept.de>
parents: 2384
diff changeset
  1839
    "Modified: / 21-05-2010 / 15:39:15 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1840
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1841
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1842
codeIfNilNotNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1034
d4f1640f1aad better code for #ifNil:ifNotNil:, if args are non-block consts
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1843
    "generate code for x ifNil:[ ... ] ifNotNil:[...]
d4f1640f1aad better code for #ifNil:ifNotNil:, if args are non-block consts
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1844
     or: x ifNil:const1 ifNotNil:const2"
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1845
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  1846
    |pos pos2 theReceiver theArg theByteCode code
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1847
     needLineNr block1 block2|
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1848
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1849
    theReceiver := receiver.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1850
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1851
    (selector == #ifNil:ifNotNil:) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1852
        theByteCode := #notNilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1853
    ] ifFalse:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1854
        theByteCode := #nilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1855
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1856
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1857
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1858
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1859
    needLineNr := true.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1860
    theArg isNil ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1861
        theReceiver isMessage ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1862
            (aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1863
                theReceiver lineNumber == lineNr ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1864
                    needLineNr := false
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1865
                ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1866
            ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1867
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1868
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1869
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1870
    needLineNr ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1871
        (lineNr between:1 and:255) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1872
            aStream nextPut:#lineno; nextPut:lineNr.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1873
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1874
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1875
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1876
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1877
    pos := aStream position + 1.
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1878
    aStream nextPut:0.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1879
    block1 := argArray at: 1.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1880
    self codeBlockEvaluation:block1 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1881
    aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1882
    pos2 := aStream position + 1.
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1883
    aStream nextPut:0.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1884
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1885
    code := aStream contents.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1886
    code at:pos put:(aStream position + 1).
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1887
    block2 := argArray at: 2.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1888
    self codeBlockEvaluation:block2 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1889
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1890
    code := aStream contents.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1891
    code at:pos2 put:(aStream position + 1)
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1892
1034
d4f1640f1aad better code for #ifNil:ifNotNil:, if args are non-block consts
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1893
    "Modified: / 11.2.2000 / 12:50:36 / cg"
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1894
!
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1895
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1896
codeIfNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1897
    "generate code for x ifNil:[ ... ]"
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1898
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1899
    |pos theReceiver theByteCode code needLineNr|
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1900
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1901
    theReceiver := receiver.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1902
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1903
    (selector == #ifNil:) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1904
        theByteCode := #notNilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1905
    ] ifFalse:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1906
        theByteCode := #nilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1907
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1908
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1909
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1910
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1911
    needLineNr := true.
899
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1912
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1913
    theReceiver isMessage ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1914
        (aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1915
            theReceiver lineNumber == lineNr ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1916
                needLineNr := false
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1917
            ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1918
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1919
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1920
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1921
    needLineNr ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1922
        (lineNr between:1 and:255) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1923
            aStream nextPut:#lineno; nextPut:lineNr.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1924
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1925
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1926
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1927
    valueNeeded ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1928
        aStream nextPut:#dup.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1929
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1930
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1931
    pos := aStream position + 1.
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1932
    aStream nextPut:0.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1933
    valueNeeded ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1934
        aStream nextPut:#drop.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1935
    ].
899
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1936
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  1937
    self codeBlockEvaluation:(argArray at: 1) on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1938
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1939
    code := aStream contents.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  1940
    code at:pos put:(aStream position + 1)
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1941
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1942
    "Modified: / 28.10.1997 / 18:33:42 / cg"
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1943
!
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1944
104
claus
parents: 103
diff changeset
  1945
codeIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1946
    "generate code for x ifxxx:[ ... ]"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1947
103
claus
parents: 102
diff changeset
  1948
    |pos pos2 theReceiver theArg theByteCode optByteCode subsel code
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  1949
     needLineNr block|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1950
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1951
    theReceiver := receiver.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1952
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1953
    theReceiver isConstant ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1954
        (self tryFoldedIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1955
            ^ self
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1956
        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1957
    ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1958
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  1959
    (theReceiver isMessage) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1960
        subsel := theReceiver selector.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1961
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1962
        (subsel == #and:) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1963
            theReceiver arg1 isBlock ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1964
                self codeAndIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1965
                ^ self
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1966
            ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1967
        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1968
        (subsel == #or:) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1969
            theReceiver arg1 isBlock ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1970
                self codeOrIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1971
                ^ self
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1972
            ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1973
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1974
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1975
    (selector == #ifTrue:) ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1976
        theByteCode := #falseJump
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1977
    ] ifFalse:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1978
        theByteCode := #trueJump
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1979
    ].
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  1980
    optByteCode := self optimizedConditionFor:theReceiver with:theByteCode for:aCompiler.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1981
    optByteCode notNil ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1982
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1983
            theArg := theReceiver arg1
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1984
        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1985
        theReceiver := theReceiver receiver.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1986
        theByteCode := optByteCode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1987
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1988
104
claus
parents: 103
diff changeset
  1989
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1990
    theArg notNil ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1991
        theArg codeOn:aStream inBlock:b for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1992
    ].
53
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
  1993
103
claus
parents: 102
diff changeset
  1994
    needLineNr := true.
claus
parents: 102
diff changeset
  1995
    theArg isNil ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1996
        theReceiver isMessage ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1997
            (aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1998
                theReceiver lineNumber == lineNr ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  1999
                    needLineNr := false
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2000
                ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2001
            ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2002
        ]
103
claus
parents: 102
diff changeset
  2003
    ].
claus
parents: 102
diff changeset
  2004
claus
parents: 102
diff changeset
  2005
    needLineNr ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2006
        (lineNr between:1 and:255) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2007
            aStream nextPut:#lineno; nextPut:lineNr.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2008
        ]
53
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
  2009
    ].
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
  2010
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2011
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2012
    pos := aStream position + 1.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2013
    aStream nextPut:0.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2014
    block := (argArray at:1).
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2015
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2016
    self codeBlockEvaluation:block on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  2017
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  2018
    code := aStream contents.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2019
    valueNeeded ifTrue:[
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2020
        aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2021
        pos2 := aStream position + 1.
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2022
        aStream nextPut:0.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2023
        code at:pos put:(aStream position + 1).
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  2024
        aStream nextPut:#pushNil.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2025
        code at:pos2 put:(aStream position + 1)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2026
    ] ifFalse:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2027
        code at:pos put:(aStream position + 1)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2028
    ]
308
fe3b95e6d9c0 oops - dont try to inline: (expr or:expr2) ifXXX
Claus Gittinger <cg@exept.de>
parents: 289
diff changeset
  2029
627
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  2030
    "Modified: / 28.10.1997 / 18:33:42 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2031
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2032
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2033
codeOrIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2034
    "generate code for (x or:[y]) ifxxx:[ ... ] ifyyy:[ ... ]"
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2035
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2036
    |theByteCode optByteCode theReceiver theArg pos1 pos2 pos3 code here jmp
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2037
     block1 block2 optJmp blockExpr|
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2038
1464
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2039
    aCompiler addLiteral:#or:.
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2040
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2041
    theByteCode := #trueJump.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2042
    theReceiver := receiver receiver.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2043
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2044
    optByteCode := self optimizedConditionFor:theReceiver with:theByteCode for:aCompiler.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2045
    optByteCode notNil ifTrue:[
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2046
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2047
            theArg := theReceiver arg1
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2048
        ].
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2049
        theReceiver := theReceiver receiver.
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2050
        theByteCode := optByteCode
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2051
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2052
    "/ code the left-of the or-part
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2053
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2054
    theArg notNil ifTrue:[
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2055
        theArg codeOn:aStream inBlock:b for:aCompiler
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2056
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2057
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2058
    pos1 := aStream position + 1.   "/ remember branch target of left-ok branch
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2059
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2060
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2061
    "/ code the right of the or-part
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2062
    (selector == #ifTrue:ifFalse:) ifTrue:[
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2063
        jmp := #falseJump
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2064
    ] ifFalse:[
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2065
        jmp := #trueJump
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2066
    ].
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2067
    theReceiver := receiver arg1.
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2068
    theArg := nil.
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2069
    optJmp := nil.
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2070
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2071
    (theReceiver isBlock
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2072
    and:[theReceiver statements notNil
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2073
    and:[theReceiver statements nextStatement isNil]]) ifTrue:[
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2074
        blockExpr := theReceiver statements expression.
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2075
        optJmp := self optimizedConditionFor:blockExpr with:jmp for:aCompiler.
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2076
        optJmp notNil ifTrue:[
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2077
            ((optJmp == #eqJump) or:[optJmp == #notEqJump]) ifTrue:[
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2078
                theArg := blockExpr arg1
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2079
            ].
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2080
            theReceiver := blockExpr receiver.
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2081
            jmp := optJmp
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2082
        ].
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2083
    ].
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2084
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2085
    optJmp notNil ifTrue:[
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2086
        theReceiver codeOn:aStream inBlock:b for:aCompiler.
1058
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  2087
        theArg notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  2088
            theArg codeOn:aStream inBlock:b for:aCompiler
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
  2089
        ]
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2090
    ] ifFalse:[
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2091
        theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2092
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2093
    aStream nextPut:jmp.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2094
    pos2 := aStream position + 1.   "/ remember branch target of right-fail branch 
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2095
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2096
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2097
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2098
    code := aStream contents.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2099
    (selector == #ifTrue:ifFalse:) ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2100
        code at:pos1 put:(aStream position + 1)
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2101
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2102
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2103
    "/ code the if-block
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2104
    block1 := argArray at: 1.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2105
    self codeBlockEvaluation:block1 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2106
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2107
    aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2108
    pos3 := aStream position + 1.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2109
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2110
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2111
    here := aStream position + 1.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2112
    (selector == #ifFalse:ifTrue:) ifTrue:[
1057
97ef980e2a46 better code for
Claus Gittinger <cg@exept.de>
parents: 1048
diff changeset
  2113
        code at:pos1 put:here
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2114
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2115
    code at:pos2 put:here.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2116
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2117
    "/ code the else-block
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2118
    block2 := argArray at: 2.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2119
    self codeBlockEvaluation:block2 on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2120
    code at:pos3 put:(aStream position + 1)
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2121
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2122
    "Created: 6.9.1996 / 13:08:52 / cg"
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2123
!
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  2124
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2125
codeOrIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2126
    "generate code for (x or:[y]) ifxxx:[ ... ]"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2127
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2128
    |theByteCode optByteCode theReceiver theArg pos1 pos2 pos3 code here jmp
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2129
     block|
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2130
1464
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2131
    aCompiler addLiteral:#or:.
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2132
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2133
    theByteCode := #trueJump.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2134
    theReceiver := receiver receiver.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2135
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2136
    optByteCode := self optimizedConditionFor:theReceiver with:theByteCode for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2137
    optByteCode notNil ifTrue:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2138
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2139
            theArg := theReceiver arg1
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2140
        ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2141
        theReceiver := theReceiver receiver.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2142
        theByteCode := optByteCode
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2143
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2144
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2145
    theArg notNil ifTrue:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2146
        theArg codeOn:aStream inBlock:b for:aCompiler
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2147
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2148
    aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2149
    pos1 := aStream position + 1.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2150
    aStream nextPut:0.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2151
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2152
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2153
    theReceiver := receiver arg1.
434
c48a356d8a34 oops - optimizable or: ... ifTrue/ifFalse generated
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
  2154
    theArg := nil.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2155
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2156
"new:"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2157
    (selector == #ifTrue:) ifTrue:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2158
        theByteCode := #falseJump
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2159
    ] ifFalse:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2160
        theByteCode := #trueJump
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2161
    ].
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2162
    optByteCode := self optimizedConditionFor:theReceiver with:theByteCode for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2163
    optByteCode notNil ifTrue:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2164
        theReceiver isBlock ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2165
            theReceiver := theReceiver statements expression
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2166
        ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2167
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2168
            theArg := theReceiver arg1
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2169
        ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2170
        theReceiver := theReceiver receiver.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2171
        theByteCode := optByteCode.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2172
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2173
        theReceiver codeOn:aStream inBlock:b for:aCompiler.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2174
        theArg notNil ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2175
            theArg codeOn:aStream inBlock:b for:aCompiler
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2176
        ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2177
        aStream nextPut:theByteCode.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2178
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2179
    ] ifFalse:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2180
"org"
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2181
        theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2182
        (selector == #ifTrue:) ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2183
            jmp := #falseJump
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2184
        ] ifFalse:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2185
            jmp := #trueJump
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2186
        ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2187
        aStream nextPut:jmp
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2188
    ].
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2189
    pos2 := aStream position + 1.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2190
    aStream nextPut:0.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2191
    (selector == #ifTrue:) ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2192
        (aStream contents) at:pos1 put:(aStream position + 1)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2193
    ].
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2194
    block := argArray at: 1.
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2195
    self codeBlockEvaluation:block on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2196
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2197
    code := aStream contents.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2198
    valueNeeded ifTrue:[
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2199
        aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2200
        pos3 := aStream position + 1.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2201
        aStream nextPut:0.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2202
        here := aStream position + 1.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2203
        (selector == #ifFalse:) ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2204
            code at:pos1 put:here
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2205
        ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2206
        code at:pos2 put:here.
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2207
        aStream nextPut:#pushNil.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2208
        code at:pos3 put:(aStream position + 1)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2209
    ] ifFalse:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2210
        here := aStream position + 1.
1059
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2211
        (selector == #ifFalse:) ifTrue:[
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2212
            code at:pos1 put:here
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2213
        ].
7ce5819138e8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1058
diff changeset
  2214
        code at:pos2 put:here
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2215
    ]
434
c48a356d8a34 oops - optimizable or: ... ifTrue/ifFalse generated
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
  2216
c48a356d8a34 oops - optimizable or: ... ifTrue/ifFalse generated
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
  2217
    "Modified: 9.11.1996 / 19:52:26 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2218
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2219
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2220
codeOrOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2221
    "generate code for (x or:[y])"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2222
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2223
    |jumpTarget1 rightExpr|
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2224
1464
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2225
    aCompiler addLiteral:#or:.
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2226
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2227
    (receiver isConstant and:[receiver value == false ]) ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2228
        "/ happens when code is "commented" i.e. false or:[ ... ]
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2229
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2230
    ] ifFalse:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2231
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2232
        receiver codeOn:aStream inBlock:b for:aCompiler.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2233
        valueNeeded ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2234
            aStream nextPut:#dup.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2235
        ].
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2236
        aStream nextPut:#trueJump.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2237
        jumpTarget1 := aStream position + 1.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2238
        aStream nextPut:0.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2239
        valueNeeded ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2240
            aStream nextPut:#drop.
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2241
        ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2242
    ].
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2243
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2244
    rightExpr := argArray at:1.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2245
    rightExpr codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2246
3317
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2247
    jumpTarget1 notNil ifTrue:[
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2248
        (aStream contents) at:jumpTarget1 put:(aStream position + 1)
55c8ae8f88e6 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  2249
    ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2250
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2251
    "Created: 17.6.1996 / 15:40:22 / cg"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2252
    "Modified: 17.6.1996 / 15:47:22 / cg"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2253
!
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2254
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2255
codeQuestOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
627
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  2256
    "generate code for x ? y. 
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  2257
     However, this is only done for non-send args."
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2258
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2259
    |pos code|
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2260
1464
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2261
    aCompiler addLiteral:#'?'.
fa19f86d1ef4 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1463
diff changeset
  2262
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2263
    receiver codeOn:aStream inBlock:b for:aCompiler.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2264
    aStream nextPut:#dup.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2265
    aStream nextPut:#notNilJump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2266
    pos := aStream position + 1.
437
994414f5126a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 436
diff changeset
  2267
    aStream nextPut:0.
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2268
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2269
    aStream nextPut:#drop.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2270
    (argArray at: 1) codeOn:aStream inBlock:b for:aCompiler.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2271
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2272
    code := aStream contents.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2273
    code at:pos put:(aStream position + 1).
909
4917ac8408fb oops - inlined ? for-effect left value on top of stack
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2274
4917ac8408fb oops - inlined ? for-effect left value on top of stack
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2275
    valueNeeded ifFalse:[
4917ac8408fb oops - inlined ? for-effect left value on top of stack
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2276
        aStream nextPut:#drop.
4917ac8408fb oops - inlined ? for-effect left value on top of stack
Claus Gittinger <cg@exept.de>
parents: 908
diff changeset
  2277
    ].
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2278
627
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  2279
    "Created: / 10.11.1996 / 18:28:57 / cg"
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  2280
    "Modified: / 28.10.1997 / 18:16:20 / cg"
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2281
!
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  2282
602
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2283
codeRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1425
4f698bf5ff76 inline [...] loop
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
  2284
    "generate code for 
4f698bf5ff76 inline [...] loop
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
  2285
        [ ... ] repeat
4f698bf5ff76 inline [...] loop
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
  2286
     and:
4f698bf5ff76 inline [...] loop
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
  2287
        [ ... ] loop
4f698bf5ff76 inline [...] loop
Claus Gittinger <cg@exept.de>
parents: 1422
diff changeset
  2288
    "
602
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2289
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2290
    |pos|
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2291
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2292
    pos := aStream position + 1.
602
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2293
    receiver codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2294
    aStream nextPut:#jump; nextPut:pos.
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2295
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2296
    "Created: 29.8.1997 / 08:14:58 / cg"
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2297
!
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  2298
104
claus
parents: 103
diff changeset
  2299
codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2300
    "like code on, but assumes that receiver has already been
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2301
     coded onto stack - needed for cascade"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2302
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2303
    |nargs isBuiltIn code litIndex cls clsLitIndex isSuper realReceiver 
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2304
     noSendDrop alreadyDropped|
1045
ee448a958d19 migration support
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  2305
1500
3c4cb012b24b Lazy conversion of selector strings to symbols.
Stefan Vogel <sv@exept.de>
parents: 1480
diff changeset
  2306
    selector := selector asSymbol.
1048
6eaeba225e67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1046
diff changeset
  2307
    noSendDrop := aCompiler class newCodeSet == true.
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2308
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2309
    realReceiver := self realReceiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2310
    isSuper := realReceiver isSuper.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2311
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2312
    argArray isNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2313
        nargs := 0
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2314
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2315
        nargs := argArray size
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2316
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2317
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2318
    litIndex := aCompiler addLiteral:selector.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2319
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2320
    isBuiltIn := isSuper not and:[ aCompiler isBuiltInSelector:selector forReceiver:receiver ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2321
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2322
    "can we use a send-bytecode ?"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2323
    isBuiltIn ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2324
        (nargs > 0) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2325
            (argArray at:1) codeOn:aStream inBlock:b for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2326
            (nargs > 1) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2327
                (argArray at:2) codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2328
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2329
        ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2330
        lineNr >= 255 ifTrue:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  2331
            self codeLineNumber: lineNr on: aStream for:aCompiler.  
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2332
        ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2333
        aStream nextPut:selector.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2334
        (aCompiler hasLineNumber:selector) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2335
            aStream nextPut:lineNr.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2336
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2337
        valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2338
            aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2339
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2340
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2341
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2342
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2343
    argArray notNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2344
        argArray do:[:arg |
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2345
            arg codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2346
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2347
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2348
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2349
    isSuper ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2350
        cls := aCompiler targetClass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2351
        realReceiver isHere ifTrue:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2352
            "/ same code as supersend, but targetClass starts search
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2353
        ] ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2354
            "/ targetClasses superclass starts search
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2355
            cls := cls superclass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2356
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2357
        clsLitIndex := aCompiler addLiteral:cls.
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  2358
        self emitSuperSendLiteralIndex:litIndex classLiteralIndex:clsLitIndex numArgs:nargs line:lineNr on:aStream for:aCompiler.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2359
        valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2360
            aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2361
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2362
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2363
    ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2364
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2365
    (nargs == 0) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2366
        (selector == #yourself) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2367
            "yourself is often added to get the receiver -
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2368
             we get it without the yourself-message"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2369
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2370
            valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2371
                aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2372
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2373
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2374
        ].
49
02660b790c3e *** empty log message ***
claus
parents: 48
diff changeset
  2375
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2376
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2377
    alreadyDropped := false.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2378
    valueNeeded ifTrue:[ noSendDrop := true ].
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2379
117
claus
parents: 111
diff changeset
  2380
    litIndex <= 255 ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2381
        (nargs <= 3) ifTrue:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2382
            noSendDrop ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2383
                code := #(send0 send1 send2 send3) at:(nargs+1).
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2384
            ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2385
                code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2386
                alreadyDropped := true.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2387
            ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2388
            lineNr >= 255 ifTrue:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  2389
                self codeLineNumber: lineNr on: aStream for:aCompiler.  
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2390
            ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2391
            aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2392
            valueNeeded ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2393
                alreadyDropped ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2394
                    aStream nextPut:#drop
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2395
                ].
1045
ee448a958d19 migration support
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  2396
            ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2397
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2398
        ].
106
claus
parents: 104
diff changeset
  2399
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2400
        noSendDrop ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2401
            code := #send
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2402
        ] ifFalse:[
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2403
            code := #sendDrop.
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2404
            alreadyDropped := true.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2405
        ].
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2406
        lineNr >= 255 ifTrue:[
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  2407
            self codeLineNumber: lineNr on: aStream for:aCompiler.  
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2408
        ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2409
        aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2410
        valueNeeded ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2411
            alreadyDropped ifFalse:[
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2412
                aStream nextPut:#drop
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2413
            ].
1045
ee448a958d19 migration support
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  2414
        ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2415
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2416
    ].
49
02660b790c3e *** empty log message ***
claus
parents: 48
diff changeset
  2417
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  2418
    self emitSendLiteralIndex:litIndex numArgs:nargs line:lineNr on:aStream for:aCompiler.
1809
007cb2a08623 some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents: 1801
diff changeset
  2419
    valueNeeded ifFalse:[
1045
ee448a958d19 migration support
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  2420
        aStream nextPut:#drop
ee448a958d19 migration support
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
  2421
    ].
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
  2422
3108
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2423
    "Modified: / 16-07-1998 / 20:26:52 / cg"
805f9d928eda Emit LINE16 bytecode insn just before a SEND bytecode is emmited when
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3017
diff changeset
  2424
    "Modified: / 13-04-2013 / 10:46:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2425
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2426
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2427
codeTimesRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2428
    "generate code for n timesRepeat:[ ... ]"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2429
908
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2430
    |pos1 pos2 lateEval loopCount|
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  2431
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  2432
    lateEval := false.
528
0a35ed44989f oops - timesRepeat dupped one too many
Claus Gittinger <cg@exept.de>
parents: 437
diff changeset
  2433
908
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2434
    receiver isConstant ifTrue:[
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2435
        loopCount := receiver evaluate.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2436
        (loopCount isMemberOf:SmallInteger) ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2437
            loopCount := nil.
908
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2438
        ] ifTrue:[
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2439
            loopCount <= 0 ifTrue:[
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2440
                "/ thats it - all we need is the receiver on the stack
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2441
                valueNeeded ifTrue:[
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2442
                    receiver codeOn:aStream inBlock:b for:aCompiler.
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2443
                ].
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2444
                ^ self
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2445
            ]
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2446
        ].
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2447
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2448
908
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2449
    receiver codeOn:aStream inBlock:b for:aCompiler.
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2450
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  2451
    valueNeeded ifTrue:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2452
        "/ easily reconstructable - no need to keep on stack
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2453
        loopCount notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2454
            lateEval := true.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2455
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2456
        lateEval ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2457
            aStream nextPut:#dup
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2458
        ].
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  2459
    ].
96
claus
parents: 95
diff changeset
  2460
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2461
    loopCount isNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2462
        aStream nextPut:#pushgt0; nextPut:lineNr; nextPut:#falseJump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2463
        pos2 := aStream position + 1.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2464
        aStream nextPut:0.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2465
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2466
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2467
    pos1 := aStream position + 1.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2468
    (argArray at:1) codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2469
    aStream nextPut:#minus1; nextPut:lineNr.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2470
    aStream nextPut:#pushgt0; nextPut:lineNr.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2471
    aStream nextPut:#trueJump; nextPut:pos1.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2472
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2473
    pos2 notNil ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2474
        (aStream contents) at:pos2 put:(aStream position + 1).
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2475
    ].
528
0a35ed44989f oops - timesRepeat dupped one too many
Claus Gittinger <cg@exept.de>
parents: 437
diff changeset
  2476
    aStream nextPut:#drop.  "/ drop run variable
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2477
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  2478
    lateEval ifTrue:[
908
294e131f2f6d oops - 0 timesRepeat (with constant receiver) did it once
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2479
        receiver codeOn:aStream inBlock:b for:aCompiler.
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  2480
    ]
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  2481
528
0a35ed44989f oops - timesRepeat dupped one too many
Claus Gittinger <cg@exept.de>
parents: 437
diff changeset
  2482
    "Modified: 27.5.1997 / 14:28:49 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2483
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2484
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2485
codeToByDoOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2486
    "generate code for a to:b by:c do:[:arg | ... ]"
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2487
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2488
    |pos pos2 start stop step lateEval theBlock loopVarIndex
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2489
     stepVal stopVarIndex|
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2490
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2491
    "/ NOTICE: could compile it as a timesRepeat-like loop, if
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2492
    "/ the loop-counter is not accessed within the loop-block.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2493
    "/ This generates somewhat (15%) faster code, but makes
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2494
    "/ debugging somewhat difficult (no loop-value seen in debugger).
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2495
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2496
    start := receiver.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2497
    stop := (argArray at:1).
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2498
    step := (argArray at:2).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2499
1397
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
  2500
"/    stop isConstant ifFalse:[self error:'should not happen' mayProceed:true].
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
  2501
"/    (stop evaluate isMemberOf:SmallInteger) ifFalse:[self error:'should not happen' mayProceed:true].
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
  2502
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
  2503
    step isConstant ifFalse:[self error:'should not happen' mayProceed:true].
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2504
    stepVal := step evaluate.
1397
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
  2505
    (stepVal isMemberOf:SmallInteger) ifFalse:[
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
  2506
        self error:'should not happen' mayProceed:true
969f505b6111 #errorSignal -> #description
Stefan Vogel <sv@exept.de>
parents: 1389
diff changeset
  2507
    ].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2508
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2509
    start codeOn:aStream inBlock:b for:aCompiler.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2510
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2511
    lateEval := false.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2512
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2513
    valueNeeded ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2514
        "/ easily reconstructable - no need to keep on stack
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2515
        start isConstant ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2516
            (start evaluate isMemberOf:SmallInteger) ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2517
                lateEval := true.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2518
            ]
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2519
        ].
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2520
        lateEval ifFalse:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2521
            aStream nextPut:#dup
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2522
        ].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2523
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2524
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2525
    "/ if stop is not constant, and not an argVar,
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2526
    "/  evaluate it into a temp slot ...
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2527
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2528
    (stop isConstant and:[stop type == #Integer]) ifFalse:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2529
        "/ a method/blockArg is constant as well ...
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2530
        (stop isVariable and:[stop isArgument]) ifFalse:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2531
            stop codeOn:aStream inBlock:b for:aCompiler.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2532
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2533
            b isNil ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2534
                stopVarIndex := aCompiler addTempVar.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2535
                aStream nextPut:#storeMethodVar; nextPut:stopVarIndex.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2536
            ] ifFalse:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2537
                stopVarIndex := b addTempVar.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2538
                aStream nextPut:#storeBlockVar; nextPut:stopVarIndex.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2539
            ].
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2540
        ]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2541
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2542
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2543
    pos := aStream position + 1.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2544
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2545
    aStream nextPut:#dup.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2546
    stopVarIndex notNil ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2547
        b isNil ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2548
            aStream nextPut:#pushMethodVar; nextPut:stopVarIndex.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2549
        ] ifFalse:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2550
            aStream nextPut:#pushBlockVar; nextPut:stopVarIndex.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2551
        ]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2552
    ] ifFalse:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2553
        stop codeOn:aStream inBlock:b for:aCompiler.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2554
    ].
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2555
    stepVal >= 0 ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2556
        aStream nextPut:#>.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2557
    ] ifFalse:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2558
        aStream nextPut:#<.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2559
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2560
    (aCompiler hasLineNumber:selector) ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2561
        aStream nextPut:lineNr.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2562
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2563
    aStream nextPut:#trueJump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2564
    pos2 := aStream position + 1.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2565
    aStream nextPut:0.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2566
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2567
    theBlock := argArray at:3.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2568
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2569
    "/ need a temporary in the outer context for
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2570
    "/ the loop ...
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2571
    b isNil ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2572
        loopVarIndex := aCompiler addTempVar.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2573
        aStream nextPut:#dup.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2574
        aStream nextPut:#storeMethodVar; nextPut:loopVarIndex.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2575
    ] ifFalse:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2576
        loopVarIndex := b addTempVar.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2577
        aStream nextPut:#dup.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2578
        aStream nextPut:#storeBlockVar; nextPut:loopVarIndex.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2579
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2580
    theBlock indexOfFirstTemp:loopVarIndex.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2581
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2582
    theBlock codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2583
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2584
    "/ increment/decrement counter & jump back.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2585
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2586
    stepVal == 1 ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2587
        aStream nextPut:#plus1; nextPut:lineNr.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2588
    ] ifFalse:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2589
        stepVal == -1 ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2590
            aStream nextPut:#minus1; nextPut:lineNr.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2591
        ] ifFalse:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2592
            step codeOn:aStream inBlock:b for:aCompiler.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2593
            aStream nextPut:#+.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2594
            (aCompiler hasLineNumber:#+) ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2595
                aStream nextPut:lineNr.
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2596
            ].
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2597
        ]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2598
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2599
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2600
    aStream nextPut:#jump; nextPut:pos.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2601
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2602
    (aStream contents) at:pos2 put:(aStream position + 1).
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2603
    aStream nextPut:#drop.  "/ drop run variable
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2604
    lateEval ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2605
        start codeOn:aStream inBlock:b for:aCompiler.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2606
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2607
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2608
    "/ no need to nil-out loop-tempVar to help GC
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2609
    "/ (its integer, anyway).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2610
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2611
    b isNil ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2612
        aCompiler removeTempVar
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2613
    ] ifFalse:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2614
        b removeTempVar
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2615
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2616
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2617
    stopVarIndex notNil ifTrue:[
1281
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2618
        b isNil ifTrue:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2619
            aCompiler removeTempVar
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2620
        ] ifFalse:[
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2621
            b removeTempVar
e70c494950b2 ansi error: to:by:do: with 0 increment.
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
  2622
        ]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2623
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2624
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2625
    "Created: 27.6.1997 / 12:48:18 / cg"
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2626
    "Modified: 27.6.1997 / 13:43:06 / cg"
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2627
!
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2628
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2629
codeToDoOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2630
    "generate code for n to:n do:[:unusedArg | ... ]"
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2631
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2632
    |pos pos2 start stop lateEval theBlock loopVarIndex
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2633
     stopVarIndex|
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2634
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2635
    "/ NOTICE: could compile it as a timesRepeat, if
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2636
    "/ the loop-counter is not accessed within the loop-block.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2637
    "/ This generates somewhat (15%) faster code, but makes
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2638
    "/ debugging somewhat difficult (no loop-value seen in debugger).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2639
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2640
    start := receiver.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2641
    stop := (argArray at:1).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2642
"/    stop isConstant ifFalse:[self halt:'should not happen'].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2643
"/    (stop evaluate isMemberOf:SmallInteger) ifFalse:[self halt:'should not happen'].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2644
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2645
    start codeOn:aStream inBlock:b for:aCompiler.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2646
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2647
    lateEval := false.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2648
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2649
    valueNeeded ifTrue:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2650
        "/ easily reconstructable - no need to keep on stack
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2651
        start isConstant ifTrue:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2652
            (start evaluate isMemberOf:SmallInteger) ifTrue:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2653
                lateEval := true.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2654
            ]
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2655
        ].
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2656
        lateEval ifFalse:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2657
            aStream nextPut:#dup
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2658
        ].
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2659
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2660
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2661
    "/ if stop is not constant, and not an argVar,
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2662
    "/  evaluate it into a temp slot ...
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2663
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2664
    (stop isConstant and:[stop type == #Integer]) ifFalse:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2665
        "/ a method/blockArg is constant as well ...
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2666
        (stop isVariable and:[stop isArgument]) ifFalse:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2667
            stop codeOn:aStream inBlock:b for:aCompiler.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2668
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2669
            b isNil ifTrue:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2670
                stopVarIndex := aCompiler addTempVar.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2671
                aStream nextPut:#storeMethodVar; nextPut:stopVarIndex.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2672
            ] ifFalse:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2673
                stopVarIndex := b addTempVar.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2674
                aStream nextPut:#storeBlockVar; nextPut:stopVarIndex.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2675
            ].
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2676
        ]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2677
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2678
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2679
    pos := aStream position + 1.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2680
624
e71abe9654e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  2681
    aStream nextPut:#lineno; nextPut:lineNr.
e71abe9654e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  2682
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2683
    aStream nextPut:#dup.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2684
    stopVarIndex notNil ifTrue:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2685
        b isNil ifTrue:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2686
            aStream nextPut:#pushMethodVar; nextPut:stopVarIndex.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2687
        ] ifFalse:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2688
            aStream nextPut:#pushBlockVar; nextPut:stopVarIndex.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2689
        ]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2690
    ] ifFalse:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2691
        stop codeOn:aStream inBlock:b for:aCompiler.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2692
    ].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2693
    aStream nextPut:#>.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2694
    (aCompiler hasLineNumber:selector) ifTrue:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2695
        aStream nextPut:lineNr.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2696
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2697
    aStream nextPut:#trueJump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2698
    pos2 := aStream position + 1.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2699
    aStream nextPut:0.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2700
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2701
    theBlock := argArray at:2.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2702
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2703
    "/ need a temporary in the outer context for
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2704
    "/ the loop ...
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2705
    b isNil ifTrue:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2706
        loopVarIndex := aCompiler addTempVar.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2707
        aStream nextPut:#dup.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2708
        aStream nextPut:#storeMethodVar; nextPut:loopVarIndex.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2709
    ] ifFalse:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2710
        loopVarIndex := b addTempVar.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2711
        aStream nextPut:#dup.
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2712
        aStream nextPut:#storeBlockVar; nextPut:loopVarIndex.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2713
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2714
    theBlock indexOfFirstTemp:loopVarIndex.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2715
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2716
    theBlock codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2717
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2718
    "/ increment counter & jump back.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2719
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2720
    aStream nextPut:#plus1; nextPut:lineNr; nextPut:#jump; nextPut:pos.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2721
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2722
    (aStream contents) at:pos2 put:(aStream position + 1).
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2723
    aStream nextPut:#drop.  "/ drop run variable
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2724
    lateEval ifTrue:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2725
        start codeOn:aStream inBlock:b for:aCompiler.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2726
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2727
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2728
    "/ no need to nil-out loop-tempVar to help GC
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2729
    "/ (its integer, anyway).
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2730
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2731
    b isNil ifTrue:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2732
        aCompiler removeTempVar
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2733
    ] ifFalse:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2734
        b removeTempVar
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2735
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2736
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2737
    stopVarIndex notNil ifTrue:[
1371
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2738
        b isNil ifTrue:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2739
            aCompiler removeTempVar
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2740
        ] ifFalse:[
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2741
            b removeTempVar
de4c37ac12fc code rewritten to be independent of stream zero-base
Claus Gittinger <cg@exept.de>
parents: 1281
diff changeset
  2742
        ]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2743
    ].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2744
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2745
    "Created: 26.6.1997 / 10:58:47 / cg"
624
e71abe9654e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  2746
    "Modified: 19.10.1997 / 01:31:40 / cg"
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2747
!
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2748
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2749
codeValueSendOn:aStream for:aCompiler
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2750
    "/ send #value to the top of the stack ...
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2751
    aStream nextPut:#value.
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2752
    (aCompiler hasLineNumber:#value) ifTrue:[
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2753
        aStream nextPut:lineNr.
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2754
    ]
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2755
!
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  2756
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2757
codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2758
    "generate code for
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2759
        [...] whileXXX:[ ... ] 
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2760
     and also 
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2761
        [...] whileXXX
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2762
    "
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2763
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2764
    |pos pos2 theReceiver theArg theByteCode optByteCode needLineNr blockExpr
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2765
     hasLoopBlock fastReceiver condStats constCondition|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2766
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2767
    hasLoopBlock := true.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2768
    (selector == #whileTrue:) ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2769
        theByteCode := #falseJump.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2770
    ] ifFalse:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2771
        (selector == #whileFalse:) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2772
            theByteCode := #trueJump
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2773
        ] ifFalse:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2774
            hasLoopBlock := false.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2775
            (selector == #whileTrue) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2776
                theByteCode := #trueJump
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2777
            ] ifFalse:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2778
                theByteCode := #falseJump
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2779
            ].
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2780
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2781
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2782
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2783
    theReceiver := receiver.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2784
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2785
    (receiver isBlock
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2786
    and:[(condStats := receiver statements) notNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2787
    and:[condStats nextStatement isNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2788
    and:[condStats expression notNil]]])
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2789
    ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2790
        fastReceiver := receiver statements expression.
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2791
        optByteCode := self optimizedConditionFor:fastReceiver with:theByteCode for:aCompiler.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2792
    ] ifFalse:[
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2793
        optByteCode := self optimizedConditionFor:theReceiver with:theByteCode for:aCompiler.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2794
    ].
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2795
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2796
    optByteCode notNil ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2797
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2798
            theArg := receiver statements expression arg1
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2799
        ].
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2800
        theReceiver := receiver statements expression receiver.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2801
        theByteCode := optByteCode
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2802
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2803
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2804
"/ OLD:
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2805
"/    valueNeeded ifTrue:[aStream nextPut:#pushNil].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2806
"/
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2807
    needLineNr := true.
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2808
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2809
    pos := aStream position + 1.
386
2f66de89a89b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
  2810
389
8aa5f9f08139 care for lineNumber in while-loop
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
  2811
"/    aCompiler lineNumberInfo == #full ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2812
        self codeLineNumber:lineNr on:aStream for:aCompiler.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2813
        needLineNr := false.
389
8aa5f9f08139 care for lineNumber in while-loop
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
  2814
"/    ].
386
2f66de89a89b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
  2815
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2816
    optByteCode notNil ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2817
        theReceiver codeOn:aStream inBlock:b for:aCompiler.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2818
        theArg notNil ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2819
            theArg codeOn:aStream inBlock:b for:aCompiler
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2820
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2821
    ] ifFalse:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2822
        (fastReceiver notNil 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2823
        and:[fastReceiver isConstant]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2824
            constCondition := fastReceiver evaluate.
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2825
            theByteCode == #trueJump ifTrue:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2826
                constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2827
                    theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2828
                ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2829
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2830
                        theByteCode := #never
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2831
                    ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2832
                ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2833
            ] ifFalse:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2834
                theByteCode == #falseJump ifTrue:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2835
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2836
                        theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2837
                    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2838
                        constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2839
                            theByteCode := #never
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2840
                        ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2841
                    ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2842
                ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2843
            ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2844
        ].
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2845
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2846
        (theByteCode ~~ #jump and:[theByteCode ~~ #never]) ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2847
            theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2848
        ].
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2849
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2850
        "/
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2851
        "/ cannot enable code below 
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2852
        "/ (tiny loops would not be debuggable with next, since lineNo remains the same)
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2853
        "/ think about it ...
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2854
        "/
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2855
        blockExpr := theReceiver simpleSendBlockExpression.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2856
        blockExpr notNil ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2857
            blockExpr isMessage ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2858
                (aCompiler hasLineNumber:(blockExpr selector)) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2859
                    blockExpr lineNumber == lineNr ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2860
                        needLineNr := false
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2861
                    ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2862
                ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2863
            ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2864
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2865
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2866
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2867
    needLineNr ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2868
        self codeLineNumber:lineNr on:aStream for:aCompiler.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2869
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2870
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2871
    hasLoopBlock ifFalse:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2872
        "/ simple [...] whileXXX
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2873
        theByteCode ~~ #never ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2874
            aStream nextPut:theByteCode; nextPut:pos.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2875
        ].
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2876
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2877
        valueNeeded ifTrue:[aStream nextPut:#pushNil].
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2878
        ^ self
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2879
    ].
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2880
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2881
    "/ [...] whileXXX:[...]
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2882
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2883
    theByteCode ~~ #never ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2884
        aStream nextPut:theByteCode.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2885
        pos2 := aStream position + 1.
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2886
        aStream nextPut:0.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2887
    ].
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2888
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2889
    (argArray at:1) codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2890
    aStream nextPut:#jump; nextPut:pos.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2891
    theByteCode ~~ #never ifTrue:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2892
        (aStream contents) at:pos2 put:(aStream position + 1).
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2893
    ].
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2894
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2895
    valueNeeded ifTrue:[aStream nextPut:#pushNil].
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2896
389
8aa5f9f08139 care for lineNumber in while-loop
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
  2897
    "Modified: 22.10.1996 / 21:34:37 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2898
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2899
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2900
new_codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2901
    "generate code for
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2902
        [...] whileXXX:[ ... ] 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2903
     and also 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2904
        [...] whileXXX
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2905
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2906
     This generates the check at the end and should generate better
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2907
     code (only 1 conditional-branch at the end instead of 2 branches).
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2908
     However, for now, it is disabled, since the JIT has special provisions
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2909
     to detect loops and actually generates better machine code for the
910
eb4849c04fff comment
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
  2910
     old bytecode sequence ... (sigh)
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2911
    "
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2912
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2913
    |pos pos0 theReceiver theArg theByteCode optByteCode needLineNr blockExpr
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2914
     hasLoopBlock fastReceiver condStats constCondition|
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2915
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2916
    hasLoopBlock := true.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2917
    (selector == #whileTrue:) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2918
        theByteCode := #trueJump.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2919
    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2920
        (selector == #whileFalse:) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2921
            theByteCode := #falseJump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2922
        ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2923
            hasLoopBlock := false.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2924
            (selector == #whileTrue) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2925
                theByteCode := #trueJump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2926
            ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2927
                theByteCode := #falseJump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2928
            ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2929
        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2930
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2931
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2932
    theReceiver := receiver.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2933
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2934
    (receiver isBlock
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2935
    and:[(condStats := receiver statements) notNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2936
    and:[condStats nextStatement isNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2937
    and:[(fastReceiver := condStats expression) notNil]]])
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2938
    ifTrue:[
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2939
        optByteCode := self optimizedConditionFor:fastReceiver with:theByteCode for:aCompiler.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2940
    ] ifFalse:[
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  2941
        optByteCode := self optimizedConditionFor:theReceiver with:theByteCode for:aCompiler.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2942
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2943
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2944
    optByteCode notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2945
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2946
            theArg := receiver statements expression arg1
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2947
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2948
        theReceiver := receiver statements expression receiver.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2949
        theByteCode := optByteCode
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2950
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2951
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2952
    needLineNr := true.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2953
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2954
    hasLoopBlock ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2955
        (argArray at:1) isEmptyBlock ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2956
            aStream nextPut:#jump.
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2957
            pos0 := aStream position + 1.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2958
            aStream nextPut:0.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2959
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2960
            pos := aStream position + 1.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2961
            (argArray at:1) codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2962
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2963
            (aStream contents) at:pos0 put:(aStream position + 1).
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2964
        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2965
    ] ifFalse:[
3266
96ed152db6df class: MessageNode
Stefan Vogel <sv@exept.de>
parents: 3164
diff changeset
  2966
        pos := aStream position + 1.
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2967
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2968
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2969
    optByteCode isNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2970
        blockExpr := theReceiver simpleSendBlockExpression.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2971
        blockExpr notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2972
            blockExpr isMessage ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2973
                (aCompiler hasLineNumber:(blockExpr selector)) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2974
                    blockExpr lineNumber == lineNr ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2975
                        needLineNr := false
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2976
                    ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2977
                ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2978
            ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2979
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2980
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2981
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2982
    needLineNr ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2983
        self codeLineNumber:lineNr on:aStream for:aCompiler.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2984
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2985
    needLineNr := false.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2986
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2987
    optByteCode notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2988
        theReceiver codeOn:aStream inBlock:b for:aCompiler.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2989
        theArg notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2990
            theArg codeOn:aStream inBlock:b for:aCompiler
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2991
        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2992
    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2993
        (fastReceiver notNil 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2994
        and:[fastReceiver isConstant]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2995
            constCondition := fastReceiver evaluate.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2996
            theByteCode == #trueJump ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2997
                constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2998
                    theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2999
                ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3000
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3001
                        theByteCode := #never
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3002
                    ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3003
                ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3004
            ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3005
                theByteCode == #falseJump ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3006
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3007
                        theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3008
                    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3009
                        constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3010
                            theByteCode := #never
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3011
                        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3012
                    ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3013
                ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3014
            ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3015
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3016
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3017
        (theByteCode ~~ #jump and:[theByteCode ~~ #never]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3018
            theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3019
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3020
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3021
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3022
    hasLoopBlock ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3023
        "/ simple [...] whileXXX
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3024
        theByteCode ~~ #never ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3025
            aStream nextPut:theByteCode; nextPut:pos.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3026
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3027
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3028
        valueNeeded ifTrue:[aStream nextPut:#pushNil].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3029
        ^ self
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3030
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3031
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3032
    "/ [...] whileXXX:[...]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3033
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3034
    theByteCode ~~ #never ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3035
        aStream nextPut:theByteCode.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3036
        aStream nextPut:pos.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3037
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3038
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3039
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3040
    valueNeeded ifTrue:[aStream nextPut:#pushNil].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3041
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3042
    "Modified: 22.10.1996 / 21:34:37 / cg"
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3043
!
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  3044
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3045
optimizedConditionFor:aReceiver with:aByteCode for:aCompiler
186
05a99f1bd747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
  3046
    |rec sel stats|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  3047
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3048
    rec := aReceiver.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3049
    (rec isBlock) ifTrue:[
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3050
        (stats := rec statements) notNil ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3051
            stats nextStatement isNil ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3052
                rec := rec statements expression
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3053
            ]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3054
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3055
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3056
    (rec isUnaryMessage) ifTrue:[
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3057
        sel := rec selector.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3058
        (sel == #isNil) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3059
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3060
            "/ isNil trueJmp  -> nilJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3061
            "/ isNil falseJmp -> notNilJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3062
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3063
            aCompiler addLiteral:#isNil.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3064
            (aByteCode == #trueJump) ifTrue:[^ #nilJump].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3065
            (aByteCode == #falseJump) ifTrue:[^ #notNilJump]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3066
        ].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3067
        (sel == #notNil) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3068
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3069
            "/ notNil trueJmp  -> notNilJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3070
            "/ notNil falseJmp -> nilJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3071
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3072
            aCompiler addLiteral:#notNil.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3073
            (aByteCode == #trueJump) ifTrue:[^ #notNilJump].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3074
            (aByteCode == #falseJump) ifTrue:[^ #nilJump]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3075
        ].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3076
        (sel == #not) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3077
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3078
            "/ not trueJmp  -> falseJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3079
            "/ not falseJmp -> trueJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3080
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3081
            aCompiler addLiteral:#not.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3082
            (aByteCode == #trueJump) ifTrue:[^ #falseJump].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3083
            (aByteCode == #falseJump) ifTrue:[^ #trueJump]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3084
        ].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3085
        ^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  3086
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3087
    (rec isBinaryMessage) ifTrue:[
1463
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3088
        sel := rec selector.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3089
        rec arg1 isConstant ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3090
            (rec arg1 value == 0) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3091
                "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3092
                "/ ==0 trueJmp  -> zeroJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3093
                "/ ==0 falseJmp -> notZeroJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3094
                "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3095
                (sel == #==) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3096
                    aCompiler addLiteral:#==.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3097
                    (aByteCode == #trueJump) ifTrue:[^ #zeroJump].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3098
                    (aByteCode == #falseJump) ifTrue:[^ #notZeroJump]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3099
                ].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3100
                "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3101
                "/ ~~0 trueJmp  -> notZeroJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3102
                "/ ~~0 falseJmp -> zeroJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3103
                "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3104
                (sel == #~~) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3105
                    aCompiler addLiteral:#~~.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3106
                    (aByteCode == #falseJump) ifTrue:[^ #zeroJump].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3107
                    (aByteCode == #trueJump) ifTrue:[^ #notZeroJump]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3108
                ].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3109
                ^ nil
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3110
            ]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3111
        ].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3112
        (sel == #==) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3113
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3114
            "/ == trueJmp  -> eqJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3115
            "/ == falseJmp -> notEqJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3116
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3117
            aCompiler addLiteral:#==.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3118
            (aByteCode == #trueJump) ifTrue:[^ #eqJump].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3119
            (aByteCode == #falseJump) ifTrue:[^ #notEqJump]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3120
        ].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3121
        (sel == #~~) ifTrue:[
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3122
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3123
            "/ ~~ trueJmp  -> notEqJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3124
            "/ ~~ falseJmp -> eqJump
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3125
            "/
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3126
            aCompiler addLiteral:#~~.
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3127
            (aByteCode == #falseJump) ifTrue:[^ #eqJump].
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3128
            (aByteCode == #trueJump) ifTrue:[^ #notEqJump]
14c0b5d19e13 make sure, all literals are present in the methods literal-table.
Claus Gittinger <cg@exept.de>
parents: 1435
diff changeset
  3129
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3130
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3131
    ^ nil
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3132
!
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3133
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3134
tryFoldedIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3135
    |rVal branch|
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3136
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3137
    receiver isConstant ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3138
        rVal := receiver evaluate.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3139
        rVal == true ifTrue:[
1248
ba526cbb348a fixed optimization of: <true|false> ifTrue/false: non-block
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  3140
            (selector == #ifFalse:) ifTrue:[
1422
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3141
                valueNeeded ifTrue:[
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3142
                    "/ true ifFalse:[] - evaluates to nil.
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3143
                    aStream nextPut:#pushNil
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3144
                ].
1248
ba526cbb348a fixed optimization of: <true|false> ifTrue/false: non-block
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  3145
                ^ true.
ba526cbb348a fixed optimization of: <true|false> ifTrue/false: non-block
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  3146
            ].
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3147
            ((selector == #ifTrue:) or:[selector == #ifTrue:ifFalse:]) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3148
                branch := (argArray at: 1).
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3149
            ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3150
            (selector == #ifFalse:ifTrue:) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3151
                branch := (argArray at: 2).
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3152
            ].
1248
ba526cbb348a fixed optimization of: <true|false> ifTrue/false: non-block
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  3153
        ].
ba526cbb348a fixed optimization of: <true|false> ifTrue/false: non-block
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  3154
        rVal == false ifTrue:[
ba526cbb348a fixed optimization of: <true|false> ifTrue/false: non-block
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  3155
            (selector == #ifTrue:) ifTrue:[
1422
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3156
                valueNeeded ifTrue:[
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3157
                    "/ false ifTrue:[] - evaluates to nil.
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3158
                    aStream nextPut:#pushNil
cdee45eb0303 oops - wrong code was generatedd for inlined
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
  3159
                ].
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3160
                ^ true.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3161
            ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3162
            ((selector == #ifFalse:) or:[selector == #ifFalse:ifTrue:]) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3163
                branch := (argArray at: 1).
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3164
            ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3165
            (selector == #ifTrue:ifFalse:) ifTrue:[
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3166
                branch := (argArray at: 2).
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3167
            ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3168
        ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3169
        branch notNil ifTrue:[
1435
be9680c6145c factored out some common code (block-code and value-sending)
Claus Gittinger <cg@exept.de>
parents: 1425
diff changeset
  3170
            self codeBlockEvaluation:branch on:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
992
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3171
            ^ true.
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3172
        ]
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3173
    ].
7e8ef3583a43 do not emit conditionalBranch, if receiver of
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
  3174
    ^ false
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3175
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3176
1080
bd3f19f6009a category change
Claus Gittinger <cg@exept.de>
parents: 1059
diff changeset
  3177
!MessageNode methodsFor:'printing & storing'!
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3178
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3179
printOn:aStream indent:i 
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3180
    |selectorParts|
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3181
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3182
    (#( whileTrue: whileFalse: ) includes:selector) ifTrue:[
888
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  3183
        receiver isBlock ifTrue:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  3184
            ^ self printWhileOn:aStream indent:i
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  3185
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3186
    ].
3330
6abed184183c class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3317
diff changeset
  3187
    selectorParts := selector keywords.
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3188
    receiver printOn:aStream indent:i parenthized:(receiver precedence <= self precedence).
1791
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3189
    argArray notNil ifTrue:[
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3190
        argArray with:selectorParts
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3191
            do:[:arg :selPart | 
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3192
                aStream
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3193
                    cr;
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3194
                    spaces:i + 4;
2542
251e766c3530 changed: #printOn:indent:
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
  3195
                    nextPutAll:selPart.
251e766c3530 changed: #printOn:indent:
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
  3196
                arg printOn:aStream 
251e766c3530 changed: #printOn:indent:
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
  3197
                    indent:i + 4 
251e766c3530 changed: #printOn:indent:
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
  3198
                    parenthized:(arg precedence <= self precedence).
1791
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3199
            ]
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3200
    ].
cd786d318d6f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  3201
2542
251e766c3530 changed: #printOn:indent:
Claus Gittinger <cg@exept.de>
parents: 2521
diff changeset
  3202
    "Modified: / 06-07-2011 / 09:44:55 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3203
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3204
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3205
printWhileOn:aStream indent:i
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3206
    "special handling of whileTrue/whileFalse"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3207
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3208
    |arg|
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3209
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3210
    aStream nextPutAll:'['.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3211
    receiver statements printOn:aStream indent:i.
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3212
    aStream nextPutAll:'] ',selector,' '.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3213
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3214
    arg := argArray at:1.
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3215
    arg printOn:aStream indent:i parenthized:(arg precedence <= self precedence).
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3216
! !
106
claus
parents: 104
diff changeset
  3217
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3218
!MessageNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3219
1565
9388e72e2dff Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents: 1533
diff changeset
  3220
argumentCount
9388e72e2dff Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents: 1533
diff changeset
  3221
    "VisualAge/ANSI compatibility - same as numArgs"
9388e72e2dff Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents: 1533
diff changeset
  3222
9388e72e2dff Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents: 1533
diff changeset
  3223
    ^ argArray size
9388e72e2dff Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents: 1533
diff changeset
  3224
!
9388e72e2dff Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents: 1533
diff changeset
  3225
395
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3226
collectBlocksInto:aCollection
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3227
    receiver collectBlocksInto:aCollection.
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3228
    argArray size > 0 ifTrue:[
1727
58820b0c1e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
  3229
        argArray do:[:arg |
58820b0c1e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
  3230
            arg collectBlocksInto:aCollection.
58820b0c1e7a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1724
diff changeset
  3231
        ]
395
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3232
    ].
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3233
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3234
    "Created: 23.10.1996 / 15:44:49 / cg"
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3235
    "Modified: 23.10.1996 / 16:03:46 / cg"
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3236
!
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  3237
2384
3854f86e767a added: #containsReturn
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  3238
containsReturn
3854f86e767a added: #containsReturn
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  3239
    receiver containsReturn ifTrue:[^ true].
3854f86e767a added: #containsReturn
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  3240
    ^ self arguments contains:[:arg | arg containsReturn]
3854f86e767a added: #containsReturn
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  3241
!
3854f86e767a added: #containsReturn
Claus Gittinger <cg@exept.de>
parents: 2345
diff changeset
  3242
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3243
isCascade
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3244
    ^ false
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3245
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3246
    "Created: / 16.7.1998 / 20:03:42 / cg"
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3247
!
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3248
1384
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  3249
numArgs
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  3250
    ^ argArray size
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  3251
!
0db9682870d9 evaluate -> evaluateIn:
Claus Gittinger <cg@exept.de>
parents: 1382
diff changeset
  3252
1588
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3253
precedence
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3254
    ^ 10
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3255
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3256
    "Created: / 20-04-2005 / 14:10:59 / cg"
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3257
!
4c3183dfaa5f printing
Claus Gittinger <cg@exept.de>
parents: 1587
diff changeset
  3258
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3259
realReceiver
746
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  3260
    receiver isCascade ifTrue:[
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  3261
        ^ receiver realReceiver
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3262
    ].
746
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  3263
    self isCascade ifTrue:[
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  3264
        ^ receiver receiver
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3265
    ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  3266
746
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  3267
    ^ receiver
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  3268
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  3269
    "Modified: / 17.7.1998 / 02:09:05 / cg"
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3270
!
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3271
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3272
withConstantValueDo:aBlock
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3273
    "return true, if this evaluates to a constant value
3016
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3274
     and evaluate aBlock with it. Used for constant folding"
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3275
3017
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3276
    |recVal argValues allArgsConstant fold cond2 condVal2|
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3277
2273
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3278
    (receiver isGlobal and:[receiver name = 'Smalltalk']) ifTrue:[
3017
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3279
        "/ (Smalltalk respondsTo:#isSmalltalkX) -> true
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3280
        (selector == #respondsTo:) ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3281
            argArray size == 1 ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3282
                argArray first isConstant ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3283
                    argArray first value == #isSmalltalkX ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3284
                        "/ true here !!
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3285
                        aBlock value:true.
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3286
                        ^ true
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3287
                    ].
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3288
                ].
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3289
            ].
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3290
        ].
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3291
        "/ (Smalltalk isSmalltalkX) -> true
2273
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3292
        (selector == #isSmalltalkX) ifTrue:[
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3293
            "/ true here !!
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3294
            aBlock value:true.
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3295
            ^ true
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3296
        ].
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3297
    ].
d952d08cf43c changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2270
diff changeset
  3298
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3299
    (receiver withConstantValueDo:[:val | recVal := val]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3300
        argValues := Array new:argArray size.
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3301
        allArgsConstant := true.
2270
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  3302
        argArray notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  3303
            argArray doWithIndex:[:arg :index |
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  3304
                allArgsConstant := allArgsConstant
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3305
                                and:[ arg withConstantValueDo:[:val | argValues at:index put:val] ]
2270
Claus Gittinger <cg@exept.de>
parents: 2268
diff changeset
  3306
            ].
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3307
        ].
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3308
        allArgsConstant ifTrue:[
3016
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3309
            fold := true.
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3310
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3311
            "/ only a few messages are checked:
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3312
            recVal isNumber ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3313
                (#(positive negative abs negated + - * == = ~= ~~) includes:selector) ifFalse:[
3016
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3314
                    recVal isInteger ifTrue:[
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3315
                        (#(<< bitShift: bitAnd: bitOr:) includes:selector) ifFalse:[
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3316
                            ^ false
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3317
                        ].
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3318
                    ] ifFalse:[
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3319
                        ^ false
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3320
                    ]
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3321
                ].
2331
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3322
            ] ifFalse:[
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3323
                recVal isBoolean ifTrue:[
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3324
                    (#(not && || ) includes:selector) ifFalse:[
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3325
                        ^ false
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3326
                    ].
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3327
                ] ifFalse:[
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3328
                    recVal isString ifTrue:[
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3329
                        (#(size) includes:selector) ifFalse:[
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3330
                            ^ false
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3331
                        ].
2925
9ab2302a632d changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
  3332
                    ] ifFalse:[
9ab2302a632d changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
  3333
                        recVal isArray ifTrue:[
9ab2302a632d changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
  3334
                            (#(size) includes:selector) ifFalse:[
9ab2302a632d changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
  3335
                                ^ false
9ab2302a632d changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
  3336
                            ].
3016
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3337
                        ] ifFalse:[
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3338
                            ^ false
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3339
                        ]
2331
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3340
                    ].
471a6febf163 changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2329
diff changeset
  3341
                ]
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3342
            ].
3016
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3343
        
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3344
            aBlock value:(recVal perform:selector withArguments:argValues).
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3345
            ^ true
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3346
        ].
3017
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3347
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3348
        "/ detects: ((Smalltalk respondsTo:#isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3349
        selector == #and: ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3350
            recVal == false ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3351
                "/ false here !!
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3352
                aBlock value:recVal.
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3353
                ^ true "/ constant
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3354
            ].
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3355
            recVal == true ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3356
                argArray first isBlockNode ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3357
                    argArray first isSingleExpressionBlock ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3358
                        cond2 := argArray first simpleSendBlockExpression.
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3359
                        cond2 notNil ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3360
                            (cond2 withConstantValueDo:[:val | condVal2 := val]) ifTrue:[
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3361
                                aBlock value:condVal2.
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3362
                                ^ true "/ constant
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3363
                            ]
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3364
                        ]
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3365
                    ]                                          
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3366
                ]
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3367
            ].
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3368
        ].
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3369
    ].
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3370
    ^ false
2925
9ab2302a632d changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
  3371
9ab2302a632d changed: #withConstantValueDo:
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
  3372
    "Modified: / 12-09-2012 / 12:27:52 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  3373
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  3374
2321
3eb00a4f2c8a category change
Claus Gittinger <cg@exept.de>
parents: 2273
diff changeset
  3375
!MessageNode methodsFor:'testing'!
3eb00a4f2c8a category change
Claus Gittinger <cg@exept.de>
parents: 2273
diff changeset
  3376
3eb00a4f2c8a category change
Claus Gittinger <cg@exept.de>
parents: 2273
diff changeset
  3377
isMessage
3eb00a4f2c8a category change
Claus Gittinger <cg@exept.de>
parents: 2273
diff changeset
  3378
    ^ true
3eb00a4f2c8a category change
Claus Gittinger <cg@exept.de>
parents: 2273
diff changeset
  3379
! !
3eb00a4f2c8a category change
Claus Gittinger <cg@exept.de>
parents: 2273
diff changeset
  3380
2601
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3381
!MessageNode methodsFor:'visiting'!
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3382
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3383
acceptVisitor:aVisitor 
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3384
    "Double dispatch back to the visitor, passing my type encoded in
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3385
     the selector (visitor pattern)"
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3386
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3387
    "stub code automatically generated - please change if required"
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3388
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3389
    ^ aVisitor visitMessageNode:self
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3390
! !
0bee48798eac - added acceptVisior:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2562
diff changeset
  3391
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  3392
!MessageNode class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  3393
3017
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3394
version
3356
3c0e828c3f36 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3336
diff changeset
  3395
    ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.207 2014-02-12 23:47:06 cg Exp $'
3017
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3396
!
c891786676f3 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3016
diff changeset
  3397
2496
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
  3398
version_CVS
3356
3c0e828c3f36 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 3336
diff changeset
  3399
    ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.207 2014-02-12 23:47:06 cg Exp $'
2268
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3400
!
Claus Gittinger <cg@exept.de>
parents: 2208
diff changeset
  3401
2496
4d67e1d9423b Jan's changes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2489
diff changeset
  3402
version_SVN
3164
f11d0862c65e Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents: 3108
diff changeset
  3403
    ^ '$ Id $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  3404
! !
3016
382e4e75d795 class: MessageNode
Claus Gittinger <cg@exept.de>
parents: 2941
diff changeset
  3405