MessageNode.st
author Claus Gittinger <cg@exept.de>
Mon, 12 Jul 1999 17:21:52 +0200
changeset 905 9d5500bffa74
parent 902 4ceee83e5e07
child 908 294e131f2f6d
permissions -rw-r--r--
*** empty log message ***
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
47
f861ad42703e *** empty log message ***
claus
parents: 39
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
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    12
7ad01559b262 Initial revision
claus
parents:
diff changeset
    13
ParseNode subclass:#MessageNode
595
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
    14
	instanceVariableNames:'receiver selector argArray lineNr selectorPosition'
166
9f6c57a3bce1 no line number bytecode in if-else if not needed
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
    15
	classVariableNames:''
9f6c57a3bce1 no line number bytecode in if-else if not needed
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
    16
	poolDictionaries:''
9f6c57a3bce1 no line number bytecode in if-else if not needed
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
    17
	category:'System-Compiler-Support'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    18
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    19
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
    20
!MessageNode class methodsFor:'documentation'!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    21
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    22
copyright
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    23
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
47
f861ad42703e *** empty log message ***
claus
parents: 39
diff changeset
    25
	      All Rights Reserved
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    26
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    27
 This software is furnished under a license and may be used
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    28
 only in accordance with the terms of that license and with the
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    30
 be provided or otherwise made available to, or used by, any
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    31
 other person.  No title to or ownership of the software is
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    32
 hereby transferred.
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    33
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    34
!
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    35
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    36
documentation
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    37
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    38
    node for parse-trees, representing message sends
261
0372e948ca2d commentary
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
    39
    This is a helper class for the compiler.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    40
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 261
diff changeset
    41
    [author:]
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    42
	Claus Gittinger
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    43
"
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    44
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    45
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
    46
!MessageNode class methodsFor:'instance creation'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    47
7ad01559b262 Initial revision
claus
parents:
diff changeset
    48
receiver:recNode selector:selectorString 
7ad01559b262 Initial revision
claus
parents:
diff changeset
    49
    ^ (self basicNew) receiver:recNode selector:selectorString args:nil lineno:0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    50
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    51
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    52
receiver:recNode selector:selectorString arg1:argNode1 arg2:argNode2 fold:folding
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    53
    |result recVal argVal selector|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    54
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    55
    "
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    56
     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
    57
     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
    58
     enhancing the compiler ....
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    59
     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
    60
     allowing constant arrays of complex objects.
140
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
     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
    63
    "
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
    64
    folding notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    65
	"/
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    66
	"/ do constant folding ...
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    67
	"/
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    68
	(recNode isConstant and:[argNode1 isConstant]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    69
	    "check if we can do it ..."
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    70
	    selector := selectorString asSymbolIfInterned.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    71
	    selector notNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    72
		recVal := recNode evaluate.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    73
		(recVal respondsTo:selector) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    74
		    "
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    75
		     we could do much more here - but then, we need a dependency from
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    76
		     the folded selectors method to the method we generate code for ...
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    77
		     limit optimizations to those that will never change
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    78
		     (or - if you change them - you will crash so bad ...)
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    79
		    "
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    80
		    argVal := argNode1 evaluate.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    81
		    ((recVal isMemberOf:Array) and:[argVal isMemberOf:Array]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    82
			folding == #full ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    83
			    (selector == #with:collect:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    84
				(argNode2 isBlock) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    85
				    SignalSet anySignal handle:[:ex |
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    86
					^ 'error in constant expression (' , ex errorString , ')'
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    87
				    ] do:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    88
					result := recVal perform:selector with:argVal with:(argNode2 evaluate).
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    89
				    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    90
				    ^ ConstantNode type:(ConstantNode typeOfConstant:result) value:result
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    91
				]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    92
			    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    93
			]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    94
		    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    95
		]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    96
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
    97
	]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    98
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
    99
    ^ (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
   100
e55ab798d077 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   101
    "Modified: 28.6.1997 / 15:16:01 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   102
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   103
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   104
receiver:recNode selector:selectorString arg:argNode
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   105
    ^ self receiver:recNode selector:selectorString arg:argNode fold:nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   106
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   107
7ad01559b262 Initial revision
claus
parents:
diff changeset
   108
receiver:recNode selector:selectorString arg:argNode fold:folding
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   109
    |result recVal argVal selector globalName canFold|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   110
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   111
   "
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   112
     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
   113
     - 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
   114
     so that constant classVars can be inlined.
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   115
    "
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   116
    folding notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   117
	selector := selectorString asSymbolIfInterned.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   118
	selector notNil ifTrue:[
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   119
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   120
	    "/
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   121
	    "/ do constant folding ...
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   122
	    "/
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   123
	    canFold := false.
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   124
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   125
	    (recNode isGlobal and:[argNode isConstant]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   126
		globalName := recNode name.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   127
		recVal := recNode evaluate.
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   128
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   129
		(globalName = 'SmallInteger') ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   130
		    ( #( bitMaskFor: ) includes:selector)
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   131
		    ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   132
			canFold := true
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   133
		    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   134
		].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   135
		(globalName = 'Float') ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   136
		    ( #( pi unity zero ) includes:selector)
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   137
		    ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   138
			(recVal respondsTo:selector) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   139
			    canFold := true
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   140
			]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   141
		    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   142
		]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   143
	    ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   144
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   145
	    (recNode isConstant and:[argNode isConstant]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   146
		"check if we can do it ..."
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   147
		recVal := recNode evaluate.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   148
		"
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   149
		 we could do much more here - but then, we need a dependency from
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   150
		 the folded selectors method to the method we generate code for ...
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   151
		 limit optimizations to those that will never change
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   152
		 (or - if you change them - you will crash so bad ...)
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   153
		"
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   154
		argVal := argNode evaluate.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   155
		(recVal respondsToArithmetic and:[argVal respondsToArithmetic]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   156
		    ( #( + - * / // \\ min: max: quo:) includes:selector) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   157
			(#( / // \\ ) includes:selector) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   158
			    argVal = 0 ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   159
				^ 'division by zero in constant expression'
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   160
			    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   161
			].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   162
			canFold := true
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   163
		    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   164
		    ( #( @ ) includes:selector) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   165
			canFold := (folding == #full)
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   166
		    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   167
		].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   168
		(recVal isInteger and:[argVal isInteger]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   169
		    ( #( bitShift: bitOr: ) includes:selector) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   170
			canFold := true
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   171
		    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   172
		].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   173
		(recVal isMemberOf:String) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   174
		    (argVal isInteger and:[selector == #at:]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   175
			canFold := (folding >= #level2) or:[folding == #full].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   176
		    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   177
		    ((argVal isMemberOf:String) and:[selector == #',']) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   178
			canFold := (folding >= #level2) or:[folding == #full].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   179
		    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   180
		].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   181
	    ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   182
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   183
	    canFold ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   184
		(recVal respondsTo:selector) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   185
		    SignalSet anySignal handle:[:ex |
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   186
			^ 'error in constant expression (' , ex errorString , ')'
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   187
		    ] do:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   188
			result := recVal perform:selector with:argVal.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   189
		    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   190
		    ^ ConstantNode type:(ConstantNode typeOfConstant:result) value:result
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   191
		]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   192
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   193
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   194
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   195
	"/
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   196
	"/ #perform with a constant selector
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   197
	"/
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   198
	(selector == #perform: 
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   199
	and:[argNode isConstant]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   200
	    argVal := argNode evaluate.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   201
	    argVal isSymbol ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   202
		^ UnaryNode receiver:recNode selector:argVal fold:folding
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   203
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   204
	].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   205
    ].
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   206
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   207
    ^ (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
   208
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   209
    "Modified: / 15.1.1998 / 15:04:27 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   210
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   211
7ad01559b262 Initial revision
claus
parents:
diff changeset
   212
receiver:recNode selector:selectorString args:anArray
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   213
    ^ self receiver:recNode selector:selectorString args:anArray fold:nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   214
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   215
7ad01559b262 Initial revision
claus
parents:
diff changeset
   216
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
   217
    |numArgs arg1 arg1Val|
117
claus
parents: 111
diff changeset
   218
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 204
diff changeset
   219
    folding notNil ifTrue:[
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   220
        numArgs := argArray size.
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   221
        numArgs > 0 ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   222
            arg1 := (argArray at:1).
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   223
            (numArgs == 1) ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   224
                ^ 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
   225
            ].
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   226
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   227
            "/
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   228
            "/ #perform:... with a constant selector
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   229
            "/
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   230
            numArgs <= 6 ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   231
                (#(nil
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   232
                   #'perform:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   233
                   #'perform:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   234
                   #'perform:with:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   235
                   #'perform:with:with:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   236
                   #'perform:with:with:with:with:with:'
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   237
                   #'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
   238
                ) at:numArgs) = selectorString 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   239
                ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   240
                    arg1 isConstant ifTrue:[    
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   241
                        arg1Val := arg1 evaluate.
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   242
                        arg1Val isSymbol ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   243
                            ^ MessageNode 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   244
                                    receiver:recNode 
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   245
                                    selector:arg1Val
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   246
                                    args:(argArray copyFrom:2)
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   247
                                    fold:folding
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   248
                        ]
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   249
                    ]
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   250
                ]
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   251
            ].
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   252
        ].
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   253
715
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   254
        (numArgs == 2) ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   255
            ^ 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
   256
        ].
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   257
        numArgs > Method maxNumberOfArguments ifTrue:[
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   258
            ^ 'too many arguments for current VM implementation'.
408ac886ffc1 allow 0-args in #receiver:selector:args:fold:
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   259
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   260
    ].
117
claus
parents: 111
diff changeset
   261
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   262
    ^ (self basicNew) receiver:recNode selector:selectorString args:argArray lineno:0
117
claus
parents: 111
diff changeset
   263
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   264
    "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
   265
    "Modified: / 15.5.1998 / 15:32:05 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   266
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   267
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   268
!MessageNode methodsFor:'accessing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   269
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   270
arg1
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   271
    ^ argArray at:1
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   272
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   273
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   274
args
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   275
    ^ argArray
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   276
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   277
543
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   278
arguments
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   279
    ^ argArray ? #()
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   280
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   281
    "Created: 19.6.1997 / 17:31:14 / cg"
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   282
    "Modified: 19.6.1997 / 17:32:25 / cg"
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   283
!
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   284
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   285
lineNumber
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   286
     ^ lineNr
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   287
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   288
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   289
lineNumber:num
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   290
     lineNr := num
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   291
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   292
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   293
receiver
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   294
    ^ receiver
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   295
!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   296
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   297
receiver:r selector:s args:a lineno:l
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   298
    receiver := r.
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   299
    selector := s asSymbolIfInterned ? s.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   300
    argArray := a.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   301
    lineNr := l.
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   302
    self checkInlinability.
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   303
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   304
    "Modified: 2.7.1997 / 17:01:24 / cg"
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   305
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   306
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   307
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
   308
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   309
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   310
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   311
selector
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   312
    ^ selector
595
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   313
!
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   314
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   315
selectorPosition
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   316
    "return the value of the instance variable 'selectorPosition' (automatically generated)"
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   317
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   318
    ^ selectorPosition
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   319
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   320
    "Created: 5.8.1997 / 02:49:27 / cg"
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   321
!
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   322
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   323
selectorPosition:something
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   324
    "set the value of the instance variable 'selectorPosition' (automatically generated)"
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   325
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   326
    selectorPosition := something.
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   327
a90e8d8bf417 remember position of selector
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
   328
    "Created: 5.8.1997 / 02:49:27 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   329
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   330
7ad01559b262 Initial revision
claus
parents:
diff changeset
   331
!MessageNode methodsFor:'checks'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   332
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   333
checkInlinability
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   334
    "early check for possible inlinability"
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   335
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   336
    |numArgs arg1 arg2 arg3|
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   337
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   338
    (numArgs := argArray size) >= 1 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   339
        arg1 := argArray at:1.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   340
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   341
    numArgs == 0 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   342
        (selector == #whileTrue 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   343
        or:[selector == #whileFalse]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   344
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   345
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   346
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   347
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   348
        (selector == #value) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   349
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   350
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   351
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   352
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   353
        (selector == #repeat) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   354
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   355
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   356
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   357
        ].
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   358
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   359
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   360
    numArgs == 1 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   361
        (selector == #or: 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   362
        or:[selector == #and:]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   363
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   364
                arg1 possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   365
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   366
        ].
576
5cb4af0eea67 also inline and:/or: ...
Claus Gittinger <cg@exept.de>
parents: 574
diff changeset
   367
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   368
        (selector == #ifTrue: 
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   369
        or:[selector == #ifFalse:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   370
        or:[selector == #ifNil:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   371
        or:[selector == #ifNotNil:]]]) ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   372
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   373
                arg1 possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   374
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   375
        ].
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   376
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   377
        (selector == #whileTrue: 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   378
        or:[selector == #whileFalse:]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   379
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   380
                arg1 possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   381
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   382
            receiver isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   383
                receiver possiblyInlined:true
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   384
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   385
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   386
        selector == #timesRepeat: ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   387
            arg1 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   388
                arg1 possiblyInlined:true withSelector:selector.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   389
            ]
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   390
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   391
        ^ self
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   392
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   393
    numArgs >= 2 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   394
        arg2 := argArray at:2.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   395
    ].    
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   396
    numArgs == 2 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   397
        (selector == #ifTrue:ifFalse:
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   398
        or:[selector == #ifFalse:ifTrue:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   399
        or:[selector == #ifNil:ifNotNil:
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   400
        or:[selector == #ifNotNil:ifNil:]]]) ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   401
            (arg1 isBlock 
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   402
            and:[arg2 isBlock]) ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   403
                arg1 possiblyInlined:true.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   404
                arg2 possiblyInlined:true.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   405
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   406
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   407
        selector == #to:do: ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   408
            arg2 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   409
                arg2 possiblyInlined:true withSelector:selector.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   410
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   411
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   412
        ^ self
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   413
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   414
    numArgs >= 3 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   415
        arg3 := argArray at:3.
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   416
    ].    
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   417
    numArgs == 3 ifTrue:[
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   418
        selector == #to:by:do: ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   419
            arg3 isBlock ifTrue:[
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   420
                arg3 possiblyInlined:true withSelector:selector.
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   421
            ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   422
        ].
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   423
        ^ self
574
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   424
    ].
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   425
    ^ self
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   426
676
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   427
    "Created: / 2.7.1997 / 17:01:10 / cg"
69d1fe23a2b4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 639
diff changeset
   428
    "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
   429
!
993d1182782b fixed inlining of blocks where subBlocks
Claus Gittinger <cg@exept.de>
parents: 570
diff changeset
   430
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   431
plausibilityCheck
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   432
    |rec arg1 arg1Value operand|
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   433
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   434
    (argArray size > 0) ifTrue:[
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   435
        arg1 := argArray at:1
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   436
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   437
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   438
    "
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   439
     it once took me almost an hour, to find a '==' which
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   440
     should have been an '=' (you cannot compare floats with ==)
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   441
     (well, I looked at the '==' at least 50 times -
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   442
      - but didn't think about it ...).
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   443
     thats reason enough to add this check here.
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   444
     I will add more as heuristic knowledge increases ...
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   445
     (send me comments on common programming errors ...)
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   446
    "
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   447
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   448
    "
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   449
     check #== applied to Floats, Strings or Fractions
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   450
    "
7ad01559b262 Initial revision
claus
parents:
diff changeset
   451
    ((selector == #==) or:[selector == #~~]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   452
        receiver isConstant ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   453
            rec := receiver evaluate.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   454
            ((rec isMemberOf:String) or:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   455
             (rec isMemberOf:Float) or:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   456
             (rec isMemberOf:Fraction)]]) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   457
                operand := rec
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   458
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   459
        ].
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   460
        arg1 isConstant ifTrue:[
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   461
            arg1Value := arg1 evaluate.
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   462
            ((arg1Value isMemberOf:String) or:[
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   463
             (arg1Value isMemberOf:Float) or:[
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   464
             (arg1Value isMemberOf:Fraction)]]) ifTrue:[
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   465
                operand := arg1Value
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   466
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   467
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   468
        operand notNil ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   469
            (selector == #==) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   470
                ^ 'identity compare is unsafe here'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   471
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   472
            ^ 'identity compare will usually return true here'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   473
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   474
    ].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   475
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   476
    "
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   477
     [...] ifTrue:...
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   478
     an error often occuring when you are a beginner ...
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   479
    "
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   480
    ((selector == #ifTrue:) or:[selector == #ifFalse:]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   481
        receiver isBlock ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   482
            (Block canUnderstand:selector) ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   483
                ^ 'blocks usually do not respond to ' , selector , ' messages'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   484
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   485
        ].
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   486
        arg1 isBlock ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   487
            ^ 'will fail at runtime, if argument to ' , selector , ' does not evaluate to a block'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   488
        ]
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   489
    ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   490
    ((selector == #ifTrue:ifFalse:) or:[selector == #ifFalse:ifTrue:]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   491
        receiver isBlock ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   492
            (Block canUnderstand:selector) ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   493
                ^ 'blocks usually do not respond to ' , selector , ' messages'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   494
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   495
        ].
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   496
        arg1 isBlock ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   497
            ^ 'will fail at runtime, if 1st. argument to ' , selector , ' does not evaluate to a block'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   498
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   499
        (argArray at:2) isBlock ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   500
            ^ 'will fail at runtime, if 2nd. argument to ' , selector , ' does not evaluate to a block'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   501
        ]
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   502
    ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   503
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   504
    "
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   505
     (...) whileTrue:[
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   506
    "
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   507
    ((selector == #whileTrue:) or:[selector == #whileFalse:]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   508
        receiver isBlock ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   509
            "
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   510
             only warn, if code was originally parenthized
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   511
            "
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   512
            receiver parenthized ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   513
                ^ 'will fail at runtime, if receiver of ' , selector , ' does not evaluate to a block'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   514
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   515
        ].
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   516
        arg1 isBlock ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   517
            ^ 'will fail at runtime, if argument to ' , selector , ' does not evaluate to a block'
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   518
        ].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 0
diff changeset
   519
    ].
902
4ceee83e5e07 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 899
diff changeset
   520
905
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   521
    argArray size > 0 ifTrue:[
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   522
        "/ check for a beginners error (using super as arg)
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   523
        "/ as in (something ? super) foo
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   524
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   525
        argArray do:[:arg | arg isSuper ifTrue:[
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   526
                                ^ 'super special semantic only with message sends'
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   527
                            ]
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   528
                    ].
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
   529
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   530
    ^ nil
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   531
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   532
    "Modified: / 16.7.1998 / 20:29:53 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   533
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   534
7ad01559b262 Initial revision
claus
parents:
diff changeset
   535
!MessageNode methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   536
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   537
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
   538
    "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
   539
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   540
    |theByteCode optByteCode theReceiver theArg pos1 pos2 pos3 code here jmp|
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   541
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   542
    theByteCode := #falseJump.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   543
    theReceiver := receiver receiver.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   544
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   545
    optByteCode := self optimizedConditionFor:theReceiver
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   546
					 with:theByteCode.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   547
    optByteCode notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   548
	((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   549
	    theArg := theReceiver arg1
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   550
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   551
	theReceiver := theReceiver receiver.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   552
	theByteCode := optByteCode
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   553
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   554
    "/ code the left-of the and-part
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   555
    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
   556
    theArg notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   557
	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
   558
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   559
    aStream nextPut:theByteCode.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   560
    pos1 := aStream position.   "/ remember branch target of left-fail branch
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   561
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   562
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   563
    "/ 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
   564
    theReceiver := receiver arg1.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   565
    theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   566
    (selector == #ifTrue:ifFalse:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   567
	jmp := #falseJump
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   568
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   569
	jmp := #trueJump
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   570
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   571
    aStream nextPut:jmp.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   572
    pos2 := aStream position.   "/ remember branch target of right-fail branch 
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   573
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   574
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   575
    code := aStream contents.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   576
    (selector == #ifFalse:ifTrue:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   577
	code at:pos1 put:(aStream position)
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   578
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   579
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   580
    "/ code the if-block
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   581
    (argArray at: 1) codeInlineOn: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
   582
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   583
    aStream nextPut:#jump.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   584
    pos3 := aStream position.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   585
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   586
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   587
    here := aStream position.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   588
    (selector == #ifTrue:ifFalse:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   589
	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
   590
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   591
    code at:pos2 put:here.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   592
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   593
    "/ code the else-block
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   594
    (argArray at: 2) codeInlineOn: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
   595
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   596
    code at:pos3 put:(aStream position)
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   597
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   598
    "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
   599
!
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
   600
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   601
codeAndIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   602
    "generate code for (x and:[y]) ifxxx:[ ... ]"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   603
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   604
    |theByteCode optByteCode andBlock theArg pos1 pos2 pos3 code here jmp
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   605
     receiver1 receiver2 optByteCode2 theArg2|
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   606
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   607
    theByteCode := #falseJump.
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   608
    receiver1 := receiver receiver.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   609
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   610
    optByteCode := self optimizedConditionFor:receiver1
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   611
                                         with:theByteCode.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   612
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   613
    optByteCode notNil ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   614
        ((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
   615
            theArg := receiver1 arg1
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   616
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   617
        receiver1 := receiver1 receiver.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   618
        theByteCode := optByteCode
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   619
    ].
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   620
    receiver1 codeOn:aStream inBlock:b for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   621
    theArg notNil ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   622
        theArg codeOn:aStream inBlock:b for:aCompiler
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   623
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   624
    aStream nextPut:theByteCode.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   625
    pos1 := aStream position.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   626
    aStream nextPut:0.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   627
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   628
    andBlock := receiver arg1. "/ the and:-block
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   629
    (selector == #ifTrue:) ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   630
        jmp := #falseJump
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   631
    ] ifFalse:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   632
        jmp := #trueJump
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   633
    ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   634
    andBlock statements nextStatement isNil ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   635
        "/ simple - one statement
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   636
        receiver2 := andBlock statements expression.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   637
        optByteCode2 := self optimizedConditionFor:receiver2
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   638
                                              with:jmp.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   639
    ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   640
    optByteCode2 notNil ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   641
        ((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
   642
            theArg2 := receiver2 arg1
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   643
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   644
        receiver2 := receiver2 receiver.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   645
        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
   646
        theArg2 notNil ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   647
            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
   648
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   649
        jmp := optByteCode2.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   650
    ] ifFalse:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   651
        andBlock codeInlineOn:aStream inBlock:b for:aCompiler.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   652
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   653
    aStream nextPut:jmp.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   654
    pos2 := aStream position.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   655
    aStream nextPut:0.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   656
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   657
    code := aStream contents.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   658
    (selector == #ifFalse:) ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   659
        code at:pos1 put:(aStream position)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   660
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   661
    (argArray at: 1) codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   662
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   663
    valueNeeded ifTrue:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   664
        aStream nextPut:#jump.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   665
        pos3 := aStream position.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   666
        aStream nextPut:0.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   667
        here := aStream position.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   668
        (selector == #ifTrue:) ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   669
            code at:pos1 put:here
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   670
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   671
        code at:pos2 put:here.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   672
        aStream nextPut:#pushNil.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   673
        code at:pos3 put:(aStream position)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   674
    ] ifFalse:[
812
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   675
        here := aStream position.
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   676
        (selector == #ifTrue:) ifTrue:[
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   677
            code at:pos1 put:here
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   678
        ].
367d2e8eb499 slightly better code for optimizable and:[...] block in if.
Claus Gittinger <cg@exept.de>
parents: 746
diff changeset
   679
        code at:pos2 put:here
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   680
    ]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   681
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   682
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   683
codeAndOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   684
    "generate code for (x and:[y])"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   685
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   686
    |pos1 rightExpr|
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   687
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   688
    receiver codeOn:aStream inBlock:b for:aCompiler.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   689
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   690
	aStream nextPut:#dup.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   691
    ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   692
    aStream nextPut:#falseJump.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   693
    pos1 := aStream position.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   694
    aStream nextPut:0.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   695
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   696
	aStream nextPut:#drop.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   697
    ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   698
    rightExpr := argArray at:1.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   699
    rightExpr codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
163
9a7dfd547e69 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
   700
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   701
    (aStream contents) at:pos1 put:(aStream position)
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   702
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   703
    "Created: 17.6.1996 / 15:46:42 / cg"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   704
    "Modified: 17.6.1996 / 15:47:44 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   705
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   706
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   707
codeForCascadeOn:aStream inBlock:b for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   708
    "like codeOn, but always leave the receiver instead of the result"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   709
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   710
    |nargs isBuiltIn code codeL litIndex cls clsLitIndex isSuper realReceiver|
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   711
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   712
    realReceiver := self realReceiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   713
    isSuper := realReceiver isSuper.
886
454c57fbf1c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
   714
    selector := selector asSymbol.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   715
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   716
    argArray isNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   717
        nargs := 0
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   718
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   719
        nargs := argArray size
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   720
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   721
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   722
    isBuiltIn := false.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   723
    isSuper ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   724
        (nargs == 0) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   725
            isBuiltIn := aCompiler isBuiltInUnarySelector:selector forReceiver:receiver
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   726
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   727
        (nargs == 1) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   728
            isBuiltIn := aCompiler isBuiltIn1ArgSelector:selector forReceiver:receiver
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   729
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   730
        (nargs == 2) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   731
            isBuiltIn := aCompiler isBuiltIn2ArgSelector:selector forReceiver:receiver
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   732
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   733
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   734
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   735
    receiver codeOn:aStream inBlock:b for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   736
    aStream nextPut:#dup.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   737
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   738
    "can we use a send-bytecode ?"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   739
    isBuiltIn ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   740
        (nargs > 0) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   741
            (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
   742
            (nargs > 1) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   743
                (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
   744
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   745
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   746
        aStream nextPut:selector.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   747
        (aCompiler hasLineNumber:selector) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   748
            aStream nextPut:lineNr.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   749
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   750
        aStream nextPut:#drop.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   751
        ^ self
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   752
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   753
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   754
    "no - generate a send"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   755
    argArray notNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   756
        argArray do:[:arg |
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   757
            arg codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   758
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   759
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   760
    litIndex := aCompiler addLiteral:selector.
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   761
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   762
    isSuper ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   763
        cls := aCompiler targetClass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   764
        realReceiver isHere ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   765
            code := #hereSend.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   766
            codeL := #hereSendL.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   767
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   768
            code := #superSend.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   769
            codeL := #superSendL.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   770
            cls := cls superclass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   771
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   772
        clsLitIndex := aCompiler addLiteral:cls.
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   773
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   774
        (litIndex <= 255 and:[clsLitIndex <= 255]) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   775
            aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:clsLitIndex; nextPut:#drop.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   776
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   777
        ].
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   778
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   779
        "need 16bit litIndex"
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   780
        aStream nextPut:codeL; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:clsLitIndex; nextPut:0; nextPut:#drop.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   781
        ^ self
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   782
    ].
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   783
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   784
    litIndex <= 255 ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   785
        (nargs <= 3) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   786
            code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   787
            aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   788
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   789
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   790
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   791
        aStream nextPut:#sendDrop; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
   792
        ^ self
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   793
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   794
    "need 16bit litIndex"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   795
    aStream nextPut:#sendDropL; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
   796
886
454c57fbf1c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
   797
    "Modified: / 4.7.1999 / 19:06:53 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   798
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   799
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   800
codeForSideEffectOn:aStream inBlock:b for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
   801
    self codeOn:aStream inBlock:b valueNeeded:false for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   802
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   803
843
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   804
codeForSimpleReturnOn:aStream inBlock:b lineNumber:lineNrOrNil for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   805
    |arg1 rightExpr pos1|
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   806
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   807
    (selector == #and:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   808
    or:[selector == #or:]) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   809
        arg1 := argArray at:1.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   810
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   811
        "/ for now:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   812
        "/ only do it for non-blocks, since
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   813
        "/ the JIT compiler is smart enough to
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   814
        "/ specially optimize the resulting code
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   815
        "/ (and not smart enough to optimized the
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   816
        "/  other - actually more efficient - code)
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   817
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   818
        (arg1 isBlock not 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   819
"/        or:[arg1 isInlinable]
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   820
        ) ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   821
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   822
            "/ encode #and: as:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   823
            "/
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   824
            "/      eLeft
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   825
            "/      jmp_false       LBL
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   826
            "/      eRight
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   827
            "/      retTop
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   828
            "/  LBL:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   829
            "/      retFalse
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   830
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   831
            "/ encode #or: as:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   832
            "/
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   833
            "/      eLeft
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   834
            "/      jmp_true       LBL
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   835
            "/      eRight
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   836
            "/      retTop
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   837
            "/  LBL:
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   838
            "/      retTrue
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   839
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   840
            receiver codeOn:aStream inBlock:b for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   841
            selector == #and: ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   842
                aStream nextPut:#falseJump.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   843
            ] ifFalse:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   844
                aStream nextPut:#trueJump.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   845
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   846
            pos1 := aStream position.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   847
            aStream nextPut:0.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   848
        
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   849
            rightExpr := argArray at:1.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   850
            rightExpr isBlock ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   851
                rightExpr codeInlineOn:aStream inBlock:b valueNeeded:true for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   852
            ] ifFalse:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   853
                rightExpr codeOn:aStream inBlock:b for:aCompiler.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   854
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   855
            aStream nextPut:#retTop.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   856
        
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   857
            (aStream contents) at:pos1 put:(aStream position).
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   858
            selector == #and: ifTrue:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   859
                aStream nextPut:#retFalse.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   860
            ] ifFalse:[
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   861
                aStream nextPut:#retTrue
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   862
            ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   863
            ^ self.
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   864
        ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   865
    ].
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   866
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   867
    super
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   868
        codeForSimpleReturnOn:aStream 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   869
        inBlock:b 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   870
        lineNumber:lineNrOrNil 
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   871
        for:aCompiler
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   872
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   873
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   874
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   875
!
522c116f86d9 boolean-return expression rewrite
Claus Gittinger <cg@exept.de>
parents: 817
diff changeset
   876
104
claus
parents: 103
diff changeset
   877
codeIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   878
    "generate code for x ifxxx:[ ... ] yyy:[ ...]"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   879
334
cd7491b7ad33 dont code a jump after if-part if it ends in a return.
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   880
    |pos pos2 theReceiver theArg theByteCode optByteCode subsel code needLineNr
cd7491b7ad33 dont code a jump after if-part if it ends in a return.
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
   881
     needJump block1|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   882
7ad01559b262 Initial revision
claus
parents:
diff changeset
   883
    theReceiver := receiver.
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
   884
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
   885
    (theReceiver isMessage) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   886
	subsel := theReceiver selector.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   887
	(subsel == #and:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   888
	    self codeAndIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   889
	    ^ self
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   890
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   891
	(subsel == #or:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   892
	    self codeOrIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   893
	    ^ self
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   894
	]
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
   895
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   896
    (selector == #ifTrue:ifFalse:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   897
	theByteCode := #falseJump
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   898
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   899
	(selector == #ifFalse:ifTrue:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   900
	    theByteCode := #trueJump
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   901
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   902
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   903
    optByteCode := self optimizedConditionFor:theReceiver
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   904
					 with:theByteCode.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   905
    optByteCode notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   906
	((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   907
	    theArg := theReceiver arg1
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   908
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   909
	theReceiver := theReceiver receiver.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   910
	theByteCode := optByteCode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   911
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   912
    theByteCode notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   913
	theReceiver codeOn:aStream inBlock:b for:aCompiler.
53
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
   914
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   915
	needLineNr := true.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   916
	theArg isNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   917
	    theReceiver isMessage ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   918
		(aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   919
		    theReceiver lineNumber == lineNr ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   920
			needLineNr := false
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   921
		    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   922
		]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   923
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   924
	] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   925
	    theArg codeOn:aStream inBlock:b for:aCompiler
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   926
	].
53
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
   927
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   928
	needLineNr ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   929
	    (lineNr between:1 and:255) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   930
		aStream nextPut:#lineno; nextPut:lineNr.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   931
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   932
	].
166
9f6c57a3bce1 no line number bytecode in if-else if not needed
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   933
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   934
	aStream nextPut:theByteCode.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   935
	pos := aStream position.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   936
	aStream nextPut:0.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   937
	block1 := argArray at:1.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   938
	block1 codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   939
	needJump := true.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   940
	(block1 isBlock and:[block1 endsWithReturn]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   941
	    needJump := false
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   942
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   943
	needJump ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   944
	    aStream nextPut:#jump.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   945
	    pos2 := aStream position.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   946
	    aStream nextPut:0.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   947
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   948
	code := aStream contents.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   949
	code at:pos put:(aStream position).
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   950
	(argArray at:2) codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   951
	needJump ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   952
	    code at:pos2 put:(aStream position)
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
   953
	]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   954
    ]
166
9f6c57a3bce1 no line number bytecode in if-else if not needed
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   955
434
c48a356d8a34 oops - optimizable or: ... ifTrue/ifFalse generated
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
   956
    "Modified: 9.11.1996 / 19:53:52 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   957
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   958
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   959
codeIfNilNotNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   960
    "generate code for x ifNil:[ ... ] ifNotNil:[...]"
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   961
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   962
    |pos pos2 theReceiver theArg theByteCode optByteCode subsel code
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   963
     needLineNr|
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   964
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   965
    theReceiver := receiver.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   966
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   967
    (selector == #ifNil:ifNotNil:) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   968
        theByteCode := #notNilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   969
    ] ifFalse:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   970
        theByteCode := #nilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   971
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   972
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   973
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   974
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   975
    needLineNr := true.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   976
    theArg isNil ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   977
        theReceiver isMessage ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   978
            (aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   979
                theReceiver lineNumber == lineNr ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   980
                    needLineNr := false
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   981
                ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   982
            ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   983
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   984
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   985
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   986
    needLineNr ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   987
        (lineNr between:1 and:255) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   988
            aStream nextPut:#lineno; nextPut:lineNr.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   989
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   990
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   991
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   992
    aStream nextPut:theByteCode.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   993
    pos := aStream position.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   994
    aStream nextPut:0.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   995
    (argArray at: 1) codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   996
    aStream nextPut:#jump.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   997
    pos2 := aStream position.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   998
    aStream nextPut:0.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
   999
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1000
    code := aStream contents.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1001
    code at:pos put:(aStream position).
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1002
    (argArray at: 2) codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1003
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1004
    code := aStream contents.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1005
    code at:pos2 put:(aStream position)
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1006
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1007
    "Modified: / 28.10.1997 / 18:33:42 / cg"
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1008
!
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1009
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1010
codeIfNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1011
    "generate code for x ifNil:[ ... ]"
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1012
899
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1013
    |pos pos2 theReceiver arg theByteCode optByteCode subsel code
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1014
     needLineNr|
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1015
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1016
    theReceiver := receiver.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1017
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1018
    (selector == #ifNil:) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1019
        theByteCode := #notNilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1020
    ] ifFalse:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1021
        theByteCode := #nilJump
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1022
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1023
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1024
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1025
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1026
    needLineNr := true.
899
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1027
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1028
    theReceiver isMessage ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1029
        (aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1030
            theReceiver lineNumber == lineNr ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1031
                needLineNr := false
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1032
            ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1033
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1034
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1035
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1036
    needLineNr ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1037
        (lineNr between:1 and:255) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1038
            aStream nextPut:#lineno; nextPut:lineNr.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1039
        ]
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1040
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1041
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1042
    valueNeeded ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1043
        aStream nextPut:#dup.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1044
    ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1045
    aStream nextPut:theByteCode.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1046
    pos := aStream position.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1047
    aStream nextPut:0.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1048
    valueNeeded ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1049
        aStream nextPut:#drop.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1050
    ].
899
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1051
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1052
    ((arg := argArray at: 1) isBlock
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1053
    and:[arg isInlinable]) ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1054
        arg codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1055
    ] ifFalse:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1056
        arg codeOn:aStream inBlock:b for:aCompiler.
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1057
        aStream nextPut:#value.
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1058
        (aCompiler hasLineNumber:#value) ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1059
            aStream nextPut:lineNr.
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1060
        ].
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1061
    ].
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1062
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1063
    code := aStream contents.
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1064
    code at:pos put:(aStream position)
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1065
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1066
    "Modified: / 28.10.1997 / 18:33:42 / cg"
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1067
!
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1068
104
claus
parents: 103
diff changeset
  1069
codeIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1070
    "generate code for x ifxxx:[ ... ]"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1071
103
claus
parents: 102
diff changeset
  1072
    |pos pos2 theReceiver theArg theByteCode optByteCode subsel code
claus
parents: 102
diff changeset
  1073
     needLineNr|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1074
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1075
    theReceiver := receiver.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1076
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  1077
    (theReceiver isMessage) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1078
	subsel := theReceiver selector.
308
fe3b95e6d9c0 oops - dont try to inline: (expr or:expr2) ifXXX
Claus Gittinger <cg@exept.de>
parents: 289
diff changeset
  1079
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1080
	(subsel == #and:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1081
	    theReceiver arg1 isBlock ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1082
		self codeAndIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1083
		^ self
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1084
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1085
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1086
	(subsel == #or:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1087
	    theReceiver arg1 isBlock ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1088
		self codeOrIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1089
		^ self
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1090
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1091
	].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1092
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1093
    (selector == #ifTrue:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1094
	theByteCode := #falseJump
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1095
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1096
	theByteCode := #trueJump
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1097
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1098
    optByteCode := self optimizedConditionFor:theReceiver
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1099
					 with:theByteCode.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1100
    optByteCode notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1101
	((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1102
	    theArg := theReceiver arg1
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1103
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1104
	theReceiver := theReceiver receiver.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1105
	theByteCode := optByteCode
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1106
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1107
104
claus
parents: 103
diff changeset
  1108
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1109
    theArg notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1110
	theArg codeOn:aStream inBlock:b for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1111
    ].
53
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
  1112
103
claus
parents: 102
diff changeset
  1113
    needLineNr := true.
claus
parents: 102
diff changeset
  1114
    theArg isNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1115
	theReceiver isMessage ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1116
	    (aCompiler hasLineNumber:(theReceiver selector)) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1117
		theReceiver lineNumber == lineNr ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1118
		    needLineNr := false
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1119
		]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1120
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1121
	]
103
claus
parents: 102
diff changeset
  1122
    ].
claus
parents: 102
diff changeset
  1123
claus
parents: 102
diff changeset
  1124
    needLineNr ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1125
	(lineNr between:1 and:255) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1126
	    aStream nextPut:#lineno; nextPut:lineNr.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1127
	]
53
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
  1128
    ].
c5dd7abf8431 *** empty log message ***
claus
parents: 52
diff changeset
  1129
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1130
    aStream nextPut:theByteCode.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1131
    pos := aStream position.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1132
    aStream nextPut:0.
104
claus
parents: 103
diff changeset
  1133
    (argArray at: 1) codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
76
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  1134
55d64cb1ffea *** empty log message ***
claus
parents: 75
diff changeset
  1135
    code := aStream contents.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1136
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1137
	aStream nextPut:#jump.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1138
	pos2 := aStream position.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1139
	aStream nextPut:0.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1140
	code at:pos put:(aStream position).
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1141
	aStream nextPut:#pushNil.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1142
	code at:pos2 put:(aStream position)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1143
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1144
	code at:pos put:(aStream position)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1145
    ]
308
fe3b95e6d9c0 oops - dont try to inline: (expr or:expr2) ifXXX
Claus Gittinger <cg@exept.de>
parents: 289
diff changeset
  1146
627
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  1147
    "Modified: / 28.10.1997 / 18:33:42 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1148
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1149
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1150
codeOn:aStream inBlock:b for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1151
    self codeOn:aStream inBlock:b valueNeeded:true for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1152
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1153
104
claus
parents: 103
diff changeset
  1154
codeOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
245
8a78aa886351 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1155
    |recType nargs isBuiltIn litIndex cls clsLitIndex code isSpecial
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1156
     specialCode stackTop arg1 arg2 arg3 isSuper realReceiver|
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1157
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1158
    realReceiver := self realReceiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1159
    isSuper := realReceiver isSuper.
867
7d20544c2c63 oops - late selector as symbol
Claus Gittinger <cg@exept.de>
parents: 861
diff changeset
  1160
    selector := selector asSymbol.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1161
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1162
    argArray isNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1163
        nargs := 0
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1164
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1165
        nargs := argArray size.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1166
        nargs > 0 ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1167
            arg1 := argArray at:1.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1168
            nargs > 1 ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1169
                arg2 := argArray at:2.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1170
                nargs > 2 ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1171
                    arg3 := argArray at:3.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1172
                ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1173
            ]    
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1174
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1175
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1176
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 189
diff changeset
  1177
    isBuiltIn := isSpecial := false.
117
claus
parents: 111
diff changeset
  1178
    recType := receiver type.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1179
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1180
    (nargs == 0) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1181
        (recType == #ThisContext) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1182
            valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1183
                "for now, only do it in methods"
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1184
                b isNil ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1185
                    (selector == #restart) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1186
                        aStream nextPut:#jump; nextPut:1.      "jump to start"
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1187
                        ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1188
                    ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1189
                ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1190
                (selector == #return) ifTrue:[  "^ nil"
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1191
                    aStream nextPut:#retNil.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1192
                    ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1193
                ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1194
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1195
        ].
52
d80ec10c3321 *** empty log message ***
claus
parents: 49
diff changeset
  1196
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1197
        (receiver isBlock 
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1198
        and:[receiver numArgs == 0
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1199
        and:[receiver isInlinable]]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1200
            selector == #value ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1201
                receiver codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1202
                ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1203
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1204
            ((selector == #whileTrue) or:[selector == #whileFalse]) ifTrue:[
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1205
                ^ self codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1206
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1207
            (selector == #repeat) ifTrue:[
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1208
                valueNeeded ifFalse:[
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1209
                    ^ self codeRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1210
                ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1211
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1212
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1213
        isSuper ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1214
            isBuiltIn := aCompiler isBuiltInUnarySelector:selector forReceiver:receiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1215
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1216
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1217
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1218
    (nargs == 1) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1219
        (recType == #ThisContext) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1220
            valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1221
                (selector == #return:) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1222
                    arg1 codeOn:aStream inBlock:b for:aCompiler.  "^ value"
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1223
                    aStream nextPut:#retTop.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1224
                    ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1225
                ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1226
             ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1227
        ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
  1228
899
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1229
        ((selector == #ifNil:) or:[selector == #ifNotNil:]) ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1230
            receiver isBlock ifFalse:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1231
                (arg1 isBlock not
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1232
                or:[arg1 numArgs == 0]) ifTrue:[
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1233
                    ^ self codeIfNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1234
                ]
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1235
            ].
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1236
        ].
fb678b9e18a7 also inline ifNot:/ifNotNil: for non-block arg.
Claus Gittinger <cg@exept.de>
parents: 898
diff changeset
  1237
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1238
        (arg1 isBlock 
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1239
        and:[arg1 isInlinable
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1240
        and:[arg1 numArgs == 0]]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1241
            ((selector == #ifTrue:) or:[selector == #ifFalse:]) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1242
                receiver isBlock ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1243
                    ^ self codeIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1244
                ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1245
            ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1246
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1247
            (selector == #or:) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1248
                ^ self codeOrOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1249
            ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1250
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1251
            (selector == #and:) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1252
                ^ self codeAndOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1253
            ].
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1254
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1255
            (selector == #timesRepeat:) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1256
                "/ now, always inline #timesRepeat:;
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1257
                "/ the receiver must understand #> and #-
564
ffac5191213f always inline #timesRepeat: (as #> 0 ... - 1)
Claus Gittinger <cg@exept.de>
parents: 561
diff changeset
  1258
                
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1259
               ^ self codeTimesRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1260
            ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1261
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1262
            ((selector == #whileTrue:) or:[selector == #whileFalse:]) ifTrue:[
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1263
                (receiver isBlock 
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1264
                and:[receiver isInlinable
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1265
                and:[receiver numArgs == 0]]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1266
                    ^ self codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1267
                ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1268
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1269
        ].
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1270
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1271
        selector == #? ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1272
            "/ only do short-circuit optimization, if arg is not a message;
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1273
            "/ (could have side-effects)
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1274
            "/
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1275
            arg1 isMessage ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1276
                ^ self codeQuestOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1277
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1278
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1279
        isSuper ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1280
            isBuiltIn := aCompiler isBuiltIn1ArgSelector:selector forReceiver:receiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1281
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1282
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1283
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1284
    (nargs == 2) ifTrue:[
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1285
        receiver isBlock ifFalse:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1286
            (arg1 isBlock 
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1287
            and:[arg1 isInlinable
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1288
            and:[arg1 numArgs == 0
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1289
            and:[arg2 isBlock 
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1290
            and:[arg2 isInlinable
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1291
            and:[arg2 numArgs == 0]]]]]) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1292
                ((selector == #ifTrue:ifFalse:) or:[selector == #ifFalse:ifTrue:]) ifTrue:[
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1293
                    ^ self codeIfElseOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
898
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1294
                ].
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1295
                ((selector == #ifNil:ifNotNil:) or:[selector == #ifNotNil:ifNil:]) ifTrue:[
8db540a5fda8 inline code for
Claus Gittinger <cg@exept.de>
parents: 888
diff changeset
  1296
                    ^ self codeIfNilNotNilOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1297
                ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1298
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1299
        ].
536
9fe0b3be6672 better code for <int> to: <int> do:[unusedArg | ...]
Claus Gittinger <cg@exept.de>
parents: 531
diff changeset
  1300
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1301
        selector == #to:do: ifTrue:[
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1302
            (arg2 isBlock 
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1303
            and:[arg2 isInlinable 
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1304
            and:[arg2 numArgs == 1]]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1305
                ^ self codeToDoOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1306
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1307
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1308
        isSuper ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1309
            isBuiltIn := aCompiler isBuiltIn2ArgSelector:selector forReceiver:receiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1310
        ]
531
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1311
    ].
1d037c37e5a2 code cleanup
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
  1312
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1313
    (nargs == 3) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1314
        selector == #to:by:do: ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1315
            "/ step must be a constant (need to know how to compare)
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1316
            (arg2 isConstant 
851
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1317
            and:[arg2 type == #Integer
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1318
            and:[arg3 isBlock 
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1319
            and:[arg3 isInlinable 
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1320
            and:[arg3 numArgs == 1]]]]) ifTrue:[
4afe809029f6 oops - care for block-num-args being correct when
Claus Gittinger <cg@exept.de>
parents: 843
diff changeset
  1321
                ^ self codeToByDoOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1322
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1323
        ].
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1324
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1325
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1326
    isSuper ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1327
        isBuiltIn ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1328
            specialCode := aCompiler specialSendCodeFor:selector.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1329
            isSpecial := specialCode notNil.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1330
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1331
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1332
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1333
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1334
    "can we use a send-bytecode ?"
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 189
diff changeset
  1335
    (isBuiltIn or:[isSpecial]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1336
        receiver codeOn:aStream inBlock:b for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1337
        (nargs > 0) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1338
            arg1 codeOn:aStream inBlock:b for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1339
            (nargs > 1) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1340
                arg2 codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1341
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1342
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1343
        aStream nextPut:selector.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1344
        (aCompiler hasLineNumber:selector) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1345
            aStream nextPut:lineNr.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1346
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1347
        isSpecial ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1348
            aStream nextPut:specialCode
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1349
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1350
        valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1351
            aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1352
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1353
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1354
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1355
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1356
    ((nargs == 0) and:[selector == #yourself]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1357
        "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
  1358
         we get it without the yourself-message"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1359
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1360
        valueNeeded ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1361
            receiver codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1362
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1363
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1364
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1365
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1366
    "no - generate a send"
117
claus
parents: 111
diff changeset
  1367
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1368
    isSuper ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1369
        cls := aCompiler targetClass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1370
        realReceiver isHere ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1371
            code := #hereSend.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1372
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1373
            code := #superSend.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1374
            cls := cls superclass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1375
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1376
        clsLitIndex := aCompiler addLiteral:cls.
117
claus
parents: 111
diff changeset
  1377
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1378
        clsLitIndex := 0.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1379
    ].
106
claus
parents: 104
diff changeset
  1380
117
claus
parents: 111
diff changeset
  1381
    litIndex := aCompiler addLiteral:selector.
claus
parents: 111
diff changeset
  1382
    (litIndex <= 255 and:[clsLitIndex <= 255]) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1383
        stackTop := nil.
117
claus
parents: 111
diff changeset
  1384
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1385
        (recType ~~ #Self) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1386
            receiver codeOn:aStream inBlock:b for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1387
            receiver isConstant ifTrue:[ 
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1388
                stackTop := receiver
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1389
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1390
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1391
        argArray notNil ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1392
            argArray do:[:arg |
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1393
                (stackTop notNil 
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1394
                and:[arg canReuseAsArg:stackTop]) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1395
                    aStream nextPut:#dup.
245
8a78aa886351 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1396
"/ 'reuse:' print. stackTop print. ' in ' print. aCompiler selector printNL.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1397
                ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1398
                    arg codeOn:aStream inBlock:b for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1399
                    stackTop := arg.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1400
                ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1401
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1402
        ].
106
claus
parents: 104
diff changeset
  1403
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1404
        isSuper ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1405
            aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:clsLitIndex.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1406
            valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1407
                aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1408
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1409
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1410
        ].
245
8a78aa886351 use dup if possible when pushing args
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
  1411
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1412
        (nargs <= 3) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1413
            |codes|
106
claus
parents: 104
diff changeset
  1414
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1415
            valueNeeded ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1416
                (recType == #Self) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1417
                    codes := #(sendSelf0 sendSelf1 sendSelf2 sendSelf3)
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1418
                ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1419
                    codes := #(send0 send1 send2 send3)
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1420
                ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1421
            ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1422
                (recType == #Self) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1423
                    codes := #(sendSelfDrop0 sendSelfDrop1 sendSelfDrop2 sendSelfDrop3)
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1424
                ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1425
                    codes := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3)
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1426
                ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1427
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1428
            aStream nextPut:(codes at:(nargs + 1)); nextPut:lineNr; nextPut:litIndex.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1429
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1430
        ].
106
claus
parents: 104
diff changeset
  1431
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1432
        (recType == #Self) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1433
            code := #sendSelf
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1434
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1435
            valueNeeded ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1436
                code := #send
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1437
            ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1438
                code := #sendDrop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1439
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1440
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1441
        aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1442
        valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1443
            (recType == #Self) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1444
                aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1445
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1446
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1447
        ^ self
106
claus
parents: 104
diff changeset
  1448
    ].
claus
parents: 104
diff changeset
  1449
claus
parents: 104
diff changeset
  1450
    "needs 16bit literal index"
117
claus
parents: 111
diff changeset
  1451
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1452
    isSuper ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1453
        argArray notNil ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1454
            argArray do:[:arg |
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1455
                arg codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1456
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1457
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1458
        realReceiver isHere ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1459
            code := #hereSendL
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1460
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1461
            code := #superSendL.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1462
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1463
        aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:clsLitIndex; nextPut:0.
117
claus
parents: 111
diff changeset
  1464
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1465
        recType ~~ #Self ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1466
            receiver codeOn:aStream inBlock:b for:aCompiler.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1467
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1468
        argArray notNil ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1469
            argArray do:[:arg |
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1470
                arg codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1471
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1472
        ].
117
claus
parents: 111
diff changeset
  1473
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1474
        recType == #Self ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1475
            code := #sendSelfL
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1476
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1477
            code := #sendL
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1478
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1479
        aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1480
    ].
117
claus
parents: 111
diff changeset
  1481
    valueNeeded ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1482
        aStream nextPut:#drop
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1483
    ].
117
claus
parents: 111
diff changeset
  1484
627
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  1485
    "Modified: / 3.9.1995 / 12:55:42 / claus"
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1486
    "Modified: / 16.7.1998 / 20:26:38 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1487
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1488
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1489
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
  1490
    "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
  1491
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1492
    |theByteCode optByteCode theReceiver theArg pos1 pos2 pos3 code here jmp|
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1493
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1494
    theByteCode := #trueJump.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1495
    theReceiver := receiver receiver.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1496
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1497
    optByteCode := self optimizedConditionFor:theReceiver
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1498
					 with:theByteCode.
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1499
    optByteCode notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1500
	((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1501
	    theArg := theReceiver arg1
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1502
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1503
	theReceiver := theReceiver receiver.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1504
	theByteCode := optByteCode
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1505
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1506
    "/ 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
  1507
    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
  1508
    theArg notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1509
	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
  1510
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1511
    aStream nextPut:theByteCode.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1512
    pos1 := aStream position.   "/ remember branch target of left-ok branch
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1513
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1514
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1515
    "/ 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
  1516
    theReceiver := receiver arg1.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1517
    theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1518
    (selector == #ifTrue:ifFalse:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1519
	jmp := #falseJump
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1520
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1521
	jmp := #trueJump
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1522
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1523
    aStream nextPut:jmp.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1524
    pos2 := aStream position.   "/ remember branch target of right-fail branch 
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1525
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1526
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1527
    code := aStream contents.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1528
    (selector == #ifTrue:ifFalse:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1529
	code at:pos1 put:(aStream position)
338
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1530
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1531
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1532
    "/ code the if-block
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1533
    (argArray at: 1) codeInlineOn: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
  1534
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1535
    aStream nextPut:#jump.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1536
    pos3 := aStream position.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1537
    aStream nextPut:0.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1538
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1539
    here := aStream position.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1540
    (selector == #ifFalse:ifTrue:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1541
	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
  1542
    ].
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1543
    code at:pos2 put:here.
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1544
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1545
    "/ code the else-block
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1546
    (argArray at: 2) codeInlineOn: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
  1547
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1548
    code at:pos3 put:(aStream position)
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1549
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1550
    "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
  1551
!
8ab1a2715ab1 better code for (expr and:/or:[expr2]) ifXXX:[ .. ] ifYYY:[ ... ]
Claus Gittinger <cg@exept.de>
parents: 334
diff changeset
  1552
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1553
codeOrIfOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1554
    "generate code for (x or:[y]) ifxxx:[ ... ]"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1555
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1556
    |theByteCode optByteCode theReceiver theArg pos1 pos2 pos3 code here jmp|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1557
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1558
    theByteCode := #trueJump.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1559
    theReceiver := receiver receiver.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1560
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1561
    optByteCode := self optimizedConditionFor:theReceiver with:theByteCode.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1562
    optByteCode notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1563
	((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1564
	    theArg := theReceiver arg1
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1565
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1566
	theReceiver := theReceiver receiver.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1567
	theByteCode := optByteCode
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1568
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1569
    theReceiver codeOn:aStream inBlock:b for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1570
    theArg notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1571
	theArg codeOn:aStream inBlock:b for:aCompiler
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1572
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1573
    aStream nextPut:theByteCode.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1574
    pos1 := aStream position.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1575
    aStream nextPut:0.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1576
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1577
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1578
    theReceiver := receiver arg1.
434
c48a356d8a34 oops - optimizable or: ... ifTrue/ifFalse generated
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
  1579
    theArg := nil.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1580
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1581
"new:"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1582
    (selector == #ifTrue:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1583
	theByteCode := #falseJump
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1584
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1585
	theByteCode := #trueJump
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1586
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1587
    optByteCode := self optimizedConditionFor:theReceiver with:theByteCode.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1588
    optByteCode notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1589
	theReceiver isBlock ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1590
	    theReceiver := theReceiver statements expression
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1591
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1592
	((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1593
	    theArg := theReceiver arg1
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1594
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1595
	theReceiver := theReceiver receiver.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1596
	theByteCode := optByteCode.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1597
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1598
	theReceiver codeOn:aStream inBlock:b for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1599
	theArg notNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1600
	    theArg codeOn:aStream inBlock:b for:aCompiler
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1601
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1602
	aStream nextPut:theByteCode.
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
    ] ifFalse:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1605
"org"
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1606
	theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1607
	(selector == #ifTrue:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1608
	    jmp := #falseJump
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1609
	] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1610
	    jmp := #trueJump
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1611
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1612
	aStream nextPut:jmp
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1613
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1614
    pos2 := aStream position.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1615
    aStream nextPut:0.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1616
    (selector == #ifTrue:) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1617
	(aStream contents) at:pos1 put:(aStream position)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1618
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1619
    (argArray at: 1) codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1620
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1621
    code := aStream contents.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1622
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1623
	aStream nextPut:#jump.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1624
	pos3 := aStream position.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1625
	aStream nextPut:0.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1626
	here := aStream position.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1627
	(selector == #ifFalse:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1628
	    code at:pos1 put:here
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1629
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1630
	code at:pos2 put:here.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1631
	aStream nextPut:#pushNil.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1632
	code at:pos3 put:(aStream position)
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1633
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1634
	here := aStream position.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1635
	(selector == #ifFalse:) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1636
	    code at:pos1 put:here
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1637
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1638
	code at:pos2 put:here
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1639
    ]
434
c48a356d8a34 oops - optimizable or: ... ifTrue/ifFalse generated
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
  1640
c48a356d8a34 oops - optimizable or: ... ifTrue/ifFalse generated
Claus Gittinger <cg@exept.de>
parents: 429
diff changeset
  1641
    "Modified: 9.11.1996 / 19:52:26 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1642
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1643
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1644
codeOrOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1645
    "generate code for (x or:[y])"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1646
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1647
    |pos1 rightExpr|
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1648
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1649
    receiver codeOn:aStream inBlock:b for:aCompiler.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1650
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1651
	aStream nextPut:#dup.
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1652
    ].
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1653
    aStream nextPut:#trueJump.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1654
    pos1 := aStream position.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1655
    aStream nextPut:0.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1656
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1657
	aStream nextPut:#drop.
289
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1658
    ].
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1659
    rightExpr := argArray at:1.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1660
    rightExpr codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler.
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1661
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1662
    (aStream contents) at:pos1 put:(aStream position)
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1663
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1664
    "Created: 17.6.1996 / 15:40:22 / cg"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1665
    "Modified: 17.6.1996 / 15:47:22 / cg"
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1666
!
7134d1233ba6 better code for and: / or:
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1667
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1668
codeQuestOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
627
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  1669
    "generate code for x ? y. 
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  1670
     However, this is only done for non-send args."
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1671
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1672
    |pos code|
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1673
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1674
    receiver codeOn:aStream inBlock:b for:aCompiler.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1675
    aStream nextPut:#dup.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1676
    aStream nextPut:#notNilJump.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1677
    pos := aStream position.
437
994414f5126a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 436
diff changeset
  1678
    aStream nextPut:0.
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1679
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1680
    aStream nextPut:#drop.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1681
    (argArray at: 1) codeOn:aStream inBlock:b for:aCompiler.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1682
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1683
    code := aStream contents.
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1684
    code at:pos put:(aStream position)
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1685
627
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  1686
    "Created: / 10.11.1996 / 18:28:57 / cg"
b29a02258247 comments
Claus Gittinger <cg@exept.de>
parents: 624
diff changeset
  1687
    "Modified: / 28.10.1997 / 18:16:20 / cg"
436
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1688
!
b34370bb0a74 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 434
diff changeset
  1689
602
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1690
codeRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1691
    "generate code for [ ... ] repeat"
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1692
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1693
    |pos|
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1694
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1695
    pos := aStream position.
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1696
    receiver codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1697
    aStream nextPut:#jump; nextPut:pos.
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1698
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1699
    "Created: 29.8.1997 / 08:14:58 / cg"
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1700
!
1be5dd333adc inline #repeat
Claus Gittinger <cg@exept.de>
parents: 595
diff changeset
  1701
104
claus
parents: 103
diff changeset
  1702
codeSendOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1703
    "like code on, but assumes that receiver has already been
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1704
     coded onto stack - needed for cascade"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1705
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1706
    |nargs isBuiltIn code codeL litIndex cls clsLitIndex isSuper realReceiver|
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1707
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  1708
    selector := selector asSymbol.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  1709
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1710
    realReceiver := self realReceiver.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1711
    isSuper := realReceiver isSuper.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1712
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1713
    argArray isNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1714
        nargs := 0
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1715
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1716
        nargs := argArray size
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1717
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1718
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1719
    isBuiltIn := false.
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1720
    isSuper ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1721
        (nargs == 0) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1722
            isBuiltIn := aCompiler isBuiltInUnarySelector:selector forReceiver:receiver
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1723
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1724
        (nargs == 1) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1725
            isBuiltIn := aCompiler isBuiltIn1ArgSelector:selector forReceiver:receiver
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1726
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1727
        (nargs == 2) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1728
            isBuiltIn := aCompiler isBuiltIn2ArgSelector:selector forReceiver:receiver
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1729
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1730
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1731
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1732
    "can we use a send-bytecode ?"
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1733
    isBuiltIn ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1734
        (nargs > 0) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1735
            (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
  1736
            (nargs > 1) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1737
                (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
  1738
            ]
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1739
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1740
        aStream nextPut:selector.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1741
        (aCompiler hasLineNumber:selector) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1742
            aStream nextPut:lineNr.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1743
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1744
        valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1745
            aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1746
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1747
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1748
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1749
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1750
    argArray notNil ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1751
        argArray do:[:arg |
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1752
            arg codeOn:aStream inBlock:b for:aCompiler
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1753
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1754
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1755
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1756
    isSuper ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1757
        cls := aCompiler targetClass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1758
        realReceiver isHere ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1759
            code := #hereSend.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1760
            codeL := #hereSendL
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1761
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1762
            code := #superSend.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1763
            codeL := #superSend.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1764
            cls := cls superclass.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1765
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1766
        clsLitIndex := aCompiler addLiteral:cls.
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
  1767
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1768
        litIndex := aCompiler addLiteral:selector.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1769
        (litIndex <= 255 and:[clsLitIndex <= 255]) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1770
            aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs; nextPut:clsLitIndex.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1771
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1772
            aStream nextPut:codeL; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs; nextPut:clsLitIndex; nextPut:0.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1773
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1774
        valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1775
            aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1776
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1777
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1778
    ].
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1779
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1780
    (nargs == 0) ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1781
        (selector == #yourself) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1782
            "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
  1783
             we get it without the yourself-message"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1784
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1785
            valueNeeded ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1786
                aStream nextPut:#drop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1787
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1788
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1789
        ].
49
02660b790c3e *** empty log message ***
claus
parents: 48
diff changeset
  1790
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1791
117
claus
parents: 111
diff changeset
  1792
    litIndex := aCompiler addLiteral:selector.
claus
parents: 111
diff changeset
  1793
    litIndex <= 255 ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1794
        (nargs <= 3) ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1795
            valueNeeded ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1796
                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
  1797
            ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1798
                code := #(sendDrop0 sendDrop1 sendDrop2 sendDrop3) at:(nargs+1).
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1799
            ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1800
            aStream nextPut:code; nextPut:lineNr; nextPut:litIndex.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1801
            ^ self
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1802
        ].
106
claus
parents: 104
diff changeset
  1803
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1804
        valueNeeded ifTrue:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1805
            code := #send
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1806
        ] ifFalse:[
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1807
            code := #sendDrop
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1808
        ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1809
        aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:nargs.
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1810
        ^ self
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1811
    ].
49
02660b790c3e *** empty log message ***
claus
parents: 48
diff changeset
  1812
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1813
    valueNeeded ifTrue:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1814
        code := #sendL
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1815
    ] ifFalse:[
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1816
        code := #sendDropL
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1817
    ].
117
claus
parents: 111
diff changeset
  1818
    aStream nextPut:code; nextPut:lineNr; nextPut:litIndex; nextPut:0; nextPut:nargs
189
673580572edd fixed cascades involving super sends (i.e. super foo; bar)
Claus Gittinger <cg@exept.de>
parents: 186
diff changeset
  1819
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  1820
    "Modified: / 16.7.1998 / 20:26:52 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1821
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1822
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1823
codeTimesRepeatOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1824
    "generate code for n timesRepeat:[ ... ]"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1825
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1826
    |pos1 pos2 theReceiver lateEval loopCount|
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1827
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1828
    theReceiver := receiver.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1829
    theReceiver 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
  1830
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  1831
    lateEval := false.
528
0a35ed44989f oops - timesRepeat dupped one too many
Claus Gittinger <cg@exept.de>
parents: 437
diff changeset
  1832
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1833
    theReceiver isConstant ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1834
        loopCount := theReceiver evaluate.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1835
        (loopCount isMemberOf:SmallInteger) ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1836
            loopCount := nil.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1837
        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1838
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1839
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  1840
    valueNeeded ifTrue:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1841
        "/ easily reconstructable - no need to keep on stack
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1842
        loopCount notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1843
            lateEval := true.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1844
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1845
        lateEval ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1846
            aStream nextPut:#dup
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1847
        ].
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  1848
    ].
96
claus
parents: 95
diff changeset
  1849
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1850
    loopCount isNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1851
        aStream nextPut:#pushgt0; nextPut:lineNr; nextPut:#falseJump.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1852
        pos2 := aStream position.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1853
        aStream nextPut:0.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1854
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1855
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1856
    pos1 := aStream position.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1857
    (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
  1858
    aStream nextPut:#minus1; nextPut:lineNr.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1859
    aStream nextPut:#pushgt0; nextPut:lineNr.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1860
    aStream nextPut:#trueJump; nextPut:pos1.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1861
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1862
    pos2 notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1863
        (aStream contents) at:pos2 put:(aStream position).
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1864
    ].
528
0a35ed44989f oops - timesRepeat dupped one too many
Claus Gittinger <cg@exept.de>
parents: 437
diff changeset
  1865
    aStream nextPut:#drop.  "/ drop run variable
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1866
349
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  1867
    lateEval ifTrue:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  1868
        theReceiver 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
  1869
    ]
7632e597a3df no need to keep receiver on stack for
Claus Gittinger <cg@exept.de>
parents: 338
diff changeset
  1870
528
0a35ed44989f oops - timesRepeat dupped one too many
Claus Gittinger <cg@exept.de>
parents: 437
diff changeset
  1871
    "Modified: 27.5.1997 / 14:28:49 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1872
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  1873
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1874
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
  1875
    "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
  1876
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1877
    |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
  1878
     stepVal stopVarIndex|
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1879
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1880
    "/ 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
  1881
    "/ 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
  1882
    "/ 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
  1883
    "/ 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
  1884
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1885
    start := receiver.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1886
    stop := (argArray at:1).
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1887
    step := (argArray at:2).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1888
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1889
"/    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
  1890
"/    (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
  1891
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1892
    step 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
  1893
    stepVal := step evaluate.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1894
    (stepVal isMemberOf:SmallInteger) ifFalse:[self halt:'should not happen'].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1895
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1896
    start codeOn:aStream inBlock:b for:aCompiler.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1897
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1898
    lateEval := false.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1899
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1900
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1901
	"/ easily reconstructable - no need to keep on stack
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1902
	start isConstant ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1903
	    (start evaluate isMemberOf:SmallInteger) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1904
		lateEval := true.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1905
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1906
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1907
	lateEval ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1908
	    aStream nextPut:#dup
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1909
	].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1910
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1911
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1912
    "/ 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
  1913
    "/  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
  1914
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1915
    (stop isConstant and:[stop type == #Integer]) ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1916
	"/ a method/blockArg is constant as well ...
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1917
	(stop isVariable and:[stop isArgument]) ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1918
	    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
  1919
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1920
	    b isNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1921
		stopVarIndex := aCompiler addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1922
		aStream nextPut:#storeMethodVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1923
	    ] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1924
		stopVarIndex := b addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1925
		aStream nextPut:#storeBlockVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1926
	    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1927
	]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1928
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1929
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1930
    pos := aStream position.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1931
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1932
    aStream nextPut:#dup.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1933
    stopVarIndex notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1934
	b isNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1935
	    aStream nextPut:#pushMethodVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1936
	] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1937
	    aStream nextPut:#pushBlockVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1938
	]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1939
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1940
	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
  1941
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1942
    stepVal > 0 ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1943
	aStream nextPut:#>.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1944
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1945
	aStream nextPut:#<.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1946
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1947
    (aCompiler hasLineNumber:selector) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1948
	aStream nextPut:lineNr.
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1949
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1950
    aStream nextPut:#trueJump.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1951
    pos2 := aStream position.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1952
    aStream nextPut:0.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1953
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1954
    theBlock := argArray at:3.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1955
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1956
    "/ 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
  1957
    "/ the loop ...
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1958
    b isNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1959
	loopVarIndex := aCompiler addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1960
	aStream nextPut:#dup.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1961
	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
  1962
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1963
	loopVarIndex := b addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1964
	aStream nextPut:#dup.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1965
	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
  1966
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1967
    theBlock indexOfFirstTemp:loopVarIndex.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1968
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1969
    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
  1970
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1971
    "/ increment/decrement counter & jump back.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1972
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1973
    stepVal == 1 ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1974
	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
  1975
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1976
	stepVal == -1 ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1977
	    aStream nextPut:#minus1; nextPut:lineNr.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1978
	] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1979
	    step codeOn:aStream inBlock:b for:aCompiler.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1980
	    aStream nextPut:#+.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1981
	    (aCompiler hasLineNumber:#+) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1982
		aStream nextPut:lineNr.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1983
	    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1984
	]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1985
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1986
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1987
    aStream nextPut:#jump; nextPut:pos.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1988
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1989
    (aStream contents) at:pos2 put:(aStream position).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1990
    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
  1991
    lateEval ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1992
	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
  1993
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1994
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1995
    "/ 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
  1996
    "/ (its integer, anyway).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1997
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  1998
    b isNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  1999
	aCompiler removeTempVar
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2000
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2001
	b removeTempVar
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2002
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2003
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2004
    stopVarIndex notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2005
	b isNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2006
	    aCompiler removeTempVar
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2007
	] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2008
	    b removeTempVar
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2009
	]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2010
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2011
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2012
    "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
  2013
    "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
  2014
!
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2015
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2016
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
  2017
    "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
  2018
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2019
    |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
  2020
     stopVarIndex|
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2021
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2022
    "/ 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
  2023
    "/ 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
  2024
    "/ 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
  2025
    "/ 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
  2026
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2027
    start := receiver.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2028
    stop := (argArray at:1).
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2029
"/    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
  2030
"/    (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
  2031
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2032
    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
  2033
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2034
    lateEval := false.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2035
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2036
    valueNeeded ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2037
	"/ easily reconstructable - no need to keep on stack
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2038
	start isConstant ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2039
	    (start evaluate isMemberOf:SmallInteger) ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2040
		lateEval := true.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2041
	    ]
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2042
	].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2043
	lateEval ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2044
	    aStream nextPut:#dup
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2045
	].
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2046
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2047
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2048
    "/ 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
  2049
    "/  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
  2050
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2051
    (stop isConstant and:[stop type == #Integer]) ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2052
	"/ a method/blockArg is constant as well ...
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2053
	(stop isVariable and:[stop isArgument]) ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2054
	    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
  2055
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2056
	    b isNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2057
		stopVarIndex := aCompiler addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2058
		aStream nextPut:#storeMethodVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2059
	    ] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2060
		stopVarIndex := b addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2061
		aStream nextPut:#storeBlockVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2062
	    ].
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2063
	]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2064
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2065
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2066
    pos := aStream position.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2067
624
e71abe9654e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  2068
    aStream nextPut:#lineno; nextPut:lineNr.
e71abe9654e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  2069
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2070
    aStream nextPut:#dup.
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2071
    stopVarIndex notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2072
	b isNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2073
	    aStream nextPut:#pushMethodVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2074
	] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2075
	    aStream nextPut:#pushBlockVar; nextPut:stopVarIndex.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2076
	]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2077
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2078
	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
  2079
    ].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2080
    aStream nextPut:#>.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2081
    (aCompiler hasLineNumber:selector) ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2082
	aStream nextPut:lineNr.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2083
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2084
    aStream nextPut:#trueJump.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2085
    pos2 := aStream position.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2086
    aStream nextPut:0.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2087
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2088
    theBlock := argArray at:2.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2089
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2090
    "/ 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
  2091
    "/ the loop ...
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2092
    b isNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2093
	loopVarIndex := aCompiler addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2094
	aStream nextPut:#dup.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2095
	aStream nextPut:#storeMethodVar; nextPut:loopVarIndex.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2096
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2097
	loopVarIndex := b addTempVar.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2098
	aStream nextPut:#dup.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2099
	aStream nextPut:#storeBlockVar; nextPut:loopVarIndex.
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2100
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2101
    theBlock indexOfFirstTemp:loopVarIndex.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2102
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2103
    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
  2104
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2105
    "/ increment counter & jump back.
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2106
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2107
    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
  2108
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2109
    (aStream contents) at:pos2 put:(aStream position).
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2110
    aStream nextPut:#drop.  "/ drop run variable
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2111
    lateEval ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2112
	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
  2113
    ].
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2114
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2115
    "/ 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
  2116
    "/ (its integer, anyway).
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2117
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2118
    b isNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2119
	aCompiler removeTempVar
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2120
    ] ifFalse:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2121
	b removeTempVar
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2122
    ].
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2123
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2124
    stopVarIndex notNil ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2125
	b isNil ifTrue:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2126
	    aCompiler removeTempVar
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2127
	] ifFalse:[
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2128
	    b removeTempVar
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2129
	]
565
00673e9d6edc more inlining of #to:do: and #to:by:do:
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
  2130
    ].
561
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2131
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2132
    "Created: 26.6.1997 / 10:58:47 / cg"
624
e71abe9654e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 602
diff changeset
  2133
    "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
  2134
!
19279079cc9a inline toDo blocks withs constant start/stop
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  2135
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2136
codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2137
    "generate code for
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2138
        [...] whileXXX:[ ... ] 
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2139
     and also 
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2140
        [...] whileXXX
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2141
    "
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2142
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2143
    |pos pos2 theReceiver theArg theByteCode optByteCode needLineNr blockExpr
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2144
     hasLoopBlock fastReceiver condStats constCondition|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2145
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2146
    hasLoopBlock := true.
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2147
    (selector == #whileTrue:) ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2148
        theByteCode := #falseJump.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2149
    ] ifFalse:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2150
        (selector == #whileFalse:) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2151
            theByteCode := #trueJump
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2152
        ] ifFalse:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2153
            hasLoopBlock := false.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2154
            (selector == #whileTrue) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2155
                theByteCode := #trueJump
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2156
            ] ifFalse:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2157
                theByteCode := #falseJump
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2158
            ].
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2159
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2160
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2161
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2162
    theReceiver := receiver.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2163
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2164
    (receiver isBlock
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2165
    and:[(condStats := receiver statements) notNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2166
    and:[condStats nextStatement isNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2167
    and:[condStats expression notNil]]])
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2168
    ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2169
        fastReceiver := receiver statements expression.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2170
        optByteCode := self optimizedConditionFor:fastReceiver with:theByteCode.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2171
    ] ifFalse:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2172
        optByteCode := self optimizedConditionFor:theReceiver with:theByteCode.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2173
    ].
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2174
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2175
    optByteCode notNil ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2176
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2177
            theArg := receiver statements expression arg1
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2178
        ].
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2179
        theReceiver := receiver statements expression receiver.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2180
        theByteCode := optByteCode
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2181
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2182
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2183
"/ OLD:
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2184
"/    valueNeeded ifTrue:[aStream nextPut:#pushNil].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2185
"/
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2186
    needLineNr := true.
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2187
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2188
    pos := aStream position.
386
2f66de89a89b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
  2189
389
8aa5f9f08139 care for lineNumber in while-loop
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
  2190
"/    aCompiler lineNumberInfo == #full ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2191
        self codeLineNumber:lineNr on:aStream for:aCompiler.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2192
        needLineNr := false.
389
8aa5f9f08139 care for lineNumber in while-loop
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
  2193
"/    ].
386
2f66de89a89b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 371
diff changeset
  2194
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2195
    optByteCode notNil ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2196
        theReceiver codeOn:aStream inBlock:b for:aCompiler.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2197
        theArg notNil ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2198
            theArg codeOn:aStream inBlock:b for:aCompiler
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2199
        ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2200
    ] ifFalse:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2201
        (fastReceiver notNil 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2202
        and:[fastReceiver isConstant]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2203
            constCondition := fastReceiver evaluate.
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2204
            theByteCode == #trueJump ifTrue:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2205
                constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2206
                    theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2207
                ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2208
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2209
                        theByteCode := #never
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2210
                    ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2211
                ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2212
            ] ifFalse:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2213
                theByteCode == #falseJump ifTrue:[
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2214
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2215
                        theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2216
                    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2217
                        constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2218
                            theByteCode := #never
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2219
                        ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2220
                    ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2221
                ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2222
            ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2223
        ].
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2224
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2225
        (theByteCode ~~ #jump and:[theByteCode ~~ #never]) ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2226
            theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2227
        ].
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2228
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2229
        "/
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2230
        "/ cannot enable code below 
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2231
        "/ (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
  2232
        "/ think about it ...
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2233
        "/
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2234
        blockExpr := theReceiver simpleSendBlockExpression.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2235
        blockExpr notNil ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2236
            blockExpr isMessage ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2237
                (aCompiler hasLineNumber:(blockExpr selector)) ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2238
                    blockExpr lineNumber == lineNr ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2239
                        needLineNr := false
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2240
                    ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2241
                ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2242
            ]
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2243
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2244
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2245
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2246
    needLineNr ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2247
        ParseNode codeLineNumber:lineNr on:aStream for:aCompiler.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2248
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2249
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2250
    hasLoopBlock ifFalse:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2251
        "/ simple [...] whileXXX
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2252
        theByteCode ~~ #never ifTrue:[
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2253
            aStream nextPut:theByteCode; nextPut:pos.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2254
        ].
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2255
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2256
        valueNeeded ifTrue:[aStream nextPut:#pushNil].
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2257
        ^ self
200
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2258
    ].
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2259
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2260
    "/ [...] whileXXX:[...]
b2f77bd77070 inline code for [...] whileXXX
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2261
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2262
    theByteCode ~~ #never ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2263
        aStream nextPut:theByteCode.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2264
        pos2 := aStream position.
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2265
        aStream nextPut:0.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2266
    ].
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2267
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2268
    (argArray at:1) codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2269
    aStream nextPut:#jump; nextPut:pos.
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2270
    theByteCode ~~ #never ifTrue:[
817
8de90dbed4bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 812
diff changeset
  2271
        (aStream contents) at:pos2 put:(aStream position).
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2272
    ].
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2273
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2274
    valueNeeded ifTrue:[aStream nextPut:#pushNil].
167
d3dbd739c65a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 166
diff changeset
  2275
389
8aa5f9f08139 care for lineNumber in while-loop
Claus Gittinger <cg@exept.de>
parents: 386
diff changeset
  2276
    "Modified: 22.10.1996 / 21:34:37 / cg"
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2277
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2278
856
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2279
new_codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2280
    "generate code for
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2281
        [...] whileXXX:[ ... ] 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2282
     and also 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2283
        [...] whileXXX
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2284
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2285
     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
  2286
     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
  2287
     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
  2288
     to detect loops and actually generates better machine code for the
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2289
     old bytecode sequence ... (sign)
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2290
    "
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2291
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2292
    |pos pos0 theReceiver theArg theByteCode optByteCode needLineNr blockExpr
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2293
     hasLoopBlock fastReceiver condStats constCondition|
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2294
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2295
    hasLoopBlock := true.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2296
    (selector == #whileTrue:) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2297
        theByteCode := #trueJump.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2298
    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2299
        (selector == #whileFalse:) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2300
            theByteCode := #falseJump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2301
        ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2302
            hasLoopBlock := false.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2303
            (selector == #whileTrue) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2304
                theByteCode := #trueJump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2305
            ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2306
                theByteCode := #falseJump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2307
            ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2308
        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2309
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2310
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2311
    theReceiver := receiver.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2312
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2313
    (receiver isBlock
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2314
    and:[(condStats := receiver statements) notNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2315
    and:[condStats nextStatement isNil
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2316
    and:[(fastReceiver := condStats expression) notNil]]])
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2317
    ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2318
        optByteCode := self optimizedConditionFor:fastReceiver with:theByteCode.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2319
    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2320
        optByteCode := self optimizedConditionFor:theReceiver with:theByteCode.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2321
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2322
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2323
    optByteCode notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2324
        ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2325
            theArg := receiver statements expression arg1
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2326
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2327
        theReceiver := receiver statements expression receiver.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2328
        theByteCode := optByteCode
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2329
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2330
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2331
    needLineNr := true.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2332
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2333
    hasLoopBlock ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2334
        (argArray at:1) isEmptyBlock ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2335
            aStream nextPut:#jump.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2336
            pos0 := aStream position.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2337
            aStream nextPut:0.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2338
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2339
            pos := aStream position.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2340
            (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
  2341
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2342
            (aStream contents) at:pos0 put:(aStream position).
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2343
        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2344
    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2345
        pos := aStream position.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2346
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2347
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2348
    optByteCode isNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2349
        blockExpr := theReceiver simpleSendBlockExpression.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2350
        blockExpr notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2351
            blockExpr isMessage ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2352
                (aCompiler hasLineNumber:(blockExpr selector)) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2353
                    blockExpr lineNumber == lineNr ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2354
                        needLineNr := false
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2355
                    ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2356
                ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2357
            ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2358
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2359
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2360
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2361
    needLineNr ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2362
        self codeLineNumber:lineNr on:aStream for:aCompiler.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2363
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2364
    needLineNr := false.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2365
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2366
    optByteCode notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2367
        theReceiver codeOn:aStream inBlock:b for:aCompiler.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2368
        theArg notNil ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2369
            theArg codeOn:aStream inBlock:b for:aCompiler
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2370
        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2371
    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2372
        (fastReceiver notNil 
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2373
        and:[fastReceiver isConstant]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2374
            constCondition := fastReceiver evaluate.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2375
            theByteCode == #trueJump ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2376
                constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2377
                    theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2378
                ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2379
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2380
                        theByteCode := #never
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2381
                    ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2382
                ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2383
            ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2384
                theByteCode == #falseJump ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2385
                    constCondition == false ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2386
                        theByteCode := #jump
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2387
                    ] ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2388
                        constCondition == true ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2389
                            theByteCode := #never
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2390
                        ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2391
                    ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2392
                ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2393
            ]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2394
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2395
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2396
        (theByteCode ~~ #jump and:[theByteCode ~~ #never]) ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2397
            theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2398
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2399
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2400
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2401
    hasLoopBlock ifFalse:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2402
        "/ simple [...] whileXXX
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2403
        theByteCode ~~ #never ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2404
            aStream nextPut:theByteCode; nextPut:pos.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2405
        ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2406
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2407
        valueNeeded ifTrue:[aStream nextPut:#pushNil].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2408
        ^ self
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2409
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2410
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2411
    "/ [...] whileXXX:[...]
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2412
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2413
    theByteCode ~~ #never ifTrue:[
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2414
        aStream nextPut:theByteCode.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2415
        aStream nextPut:pos.
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2416
    ].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2417
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2418
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2419
    valueNeeded ifTrue:[aStream nextPut:#pushNil].
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2420
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2421
    "Modified: 22.10.1996 / 21:34:37 / cg"
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2422
!
bcc52caf1192 timesRepeat: - check at loop-end
Claus Gittinger <cg@exept.de>
parents: 851
diff changeset
  2423
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2424
optimizedConditionFor:aReceiver with:aByteCode
186
05a99f1bd747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
  2425
    |rec sel stats|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2426
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2427
    rec := aReceiver.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2428
    (rec isBlock) ifTrue:[
186
05a99f1bd747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
  2429
	(stats := rec statements) notNil ifTrue:[
05a99f1bd747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
  2430
	    stats nextStatement isNil ifTrue:[
05a99f1bd747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
  2431
		rec := rec statements expression
05a99f1bd747 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 167
diff changeset
  2432
	    ]
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2433
	]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2434
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2435
    (rec isUnaryMessage) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2436
	sel := rec selector.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2437
	(sel == #isNil) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2438
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2439
	    "/ isNil trueJmp  -> nilJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2440
	    "/ isNil falseJmp -> notNilJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2441
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2442
	    (aByteCode == #trueJump) ifTrue:[^ #nilJump].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2443
	    (aByteCode == #falseJump) ifTrue:[^ #notNilJump]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2444
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2445
	(sel == #notNil) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2446
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2447
	    "/ notNil trueJmp  -> notNilJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2448
	    "/ notNil falseJmp -> nilJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2449
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2450
	    (aByteCode == #trueJump) ifTrue:[^ #notNilJump].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2451
	    (aByteCode == #falseJump) ifTrue:[^ #nilJump]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2452
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2453
	(sel == #not) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2454
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2455
	    "/ not trueJmp  -> falseJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2456
	    "/ not falseJmp -> trueJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2457
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2458
	    (aByteCode == #trueJump) ifTrue:[^ #falseJump].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2459
	    (aByteCode == #falseJump) ifTrue:[^ #trueJump]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2460
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2461
	^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2462
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2463
    (rec isBinaryMessage) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2464
	sel := rec selector.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2465
	rec arg1 isConstant ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2466
	    (rec arg1 value == 0) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2467
		"/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2468
		"/ ==0 trueJmp  -> zeroJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2469
		"/ ==0 falseJmp -> notZeroJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2470
		"/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2471
		(sel == #==) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2472
		    (aByteCode == #trueJump) ifTrue:[^ #zeroJump].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2473
		    (aByteCode == #falseJump) ifTrue:[^ #notZeroJump]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2474
		].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2475
		"/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2476
		"/ ~~0 trueJmp  -> notZeroJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2477
		"/ ~~0 falseJmp -> zeroJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2478
		"/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2479
		(sel == #~~) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2480
		    (aByteCode == #falseJump) ifTrue:[^ #zeroJump].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2481
		    (aByteCode == #trueJump) ifTrue:[^ #notZeroJump]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2482
		].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2483
		^ nil
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2484
	    ]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2485
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2486
	(sel == #==) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2487
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2488
	    "/ == trueJmp  -> eqJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2489
	    "/ == falseJmp -> notEqJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2490
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2491
	    (aByteCode == #trueJump) ifTrue:[^ #eqJump].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2492
	    (aByteCode == #falseJump) ifTrue:[^ #notEqJump]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2493
	].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2494
	(sel == #~~) ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2495
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2496
	    "/ ~~ trueJmp  -> notEqJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2497
	    "/ ~~ falseJmp -> eqJump
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2498
	    "/
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2499
	    (aByteCode == #falseJump) ifTrue:[^ #eqJump].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2500
	    (aByteCode == #trueJump) ifTrue:[^ #notEqJump]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2501
	]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2502
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2503
    ^ nil
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2504
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2505
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2506
!MessageNode methodsFor:'enumeration'!
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2507
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2508
nodeDo:anEnumerator
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2509
    "helper for parse tree walking"
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2510
543
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
  2511
    |args|
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
  2512
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
  2513
    args := argArray ? #().
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
  2514
    ^ anEnumerator doMessage:self receiver:receiver selector:selector arguments:args
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2515
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2516
    "Created: 19.6.1997 / 16:46:39 / cg"
543
de47f8969fd9 more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
  2517
    "Modified: 19.6.1997 / 17:08:28 / cg"
539
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2518
! !
69a1cd05c7d6 added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 537
diff changeset
  2519
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2520
!MessageNode methodsFor:'evaluating'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2521
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2522
evaluate
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2523
    |r nargs argValueArray class|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2524
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2525
    selector := selector asSymbol.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2526
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2527
    receiver isSuper ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2528
        r := receiver value.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2529
        receiver isHere ifTrue:[
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2530
            class := receiver definingClass.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2531
        ] ifFalse:[
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2532
            class := receiver definingClass superclass.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2533
        ].
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2534
        argArray notNil ifTrue:[
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2535
            argValueArray := argArray collect:[:arg | arg evaluate].
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2536
        ] ifFalse:[
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2537
            argValueArray := #()
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2538
        ].
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2539
        ^ r perform:selector inClass:class withArguments:argValueArray
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2540
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2541
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2542
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2543
    argArray isNil ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2544
        ^ (receiver evaluate) perform:selector
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2545
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2546
    nargs := argArray size.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2547
    (nargs == 1) ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2548
        ^ (receiver evaluate) perform:selector with:(argArray at:1) evaluate
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2549
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2550
    (nargs == 2) ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2551
        ^ (receiver evaluate) perform:selector
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2552
                                 with:(argArray at:1) evaluate
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2553
                                 with:(argArray at:2) evaluate
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2554
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2555
    (nargs == 3) ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2556
        ^ (receiver evaluate) perform:selector
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2557
                                 with:(argArray at:1) evaluate
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2558
                                 with:(argArray at:2) evaluate
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2559
                                 with:(argArray at:3) evaluate
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2560
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2561
    r := receiver evaluate.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2562
    argValueArray := argArray collect:[:arg | arg evaluate].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2563
    ^ r perform:selector withArguments:argValueArray
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2564
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2565
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2566
evaluateForCascade
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2567
    |r nargs argValueArray class|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2568
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2569
    selector := selector asSymbol.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2570
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2571
    receiver isSuper ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2572
        r := receiver value.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2573
        class := receiver definingClass.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2574
        receiver isHere ifFalse:[
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2575
            class := class superclass.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2576
        ].
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2577
        argArray notNil ifTrue:[
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2578
            argValueArray := argArray collect:[:arg | arg evaluate].
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2579
        ] ifFalse:[
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2580
            argValueArray := #()
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2581
        ].
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2582
        r perform:selector inClass:class withArguments:argValueArray.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2583
        ^ r
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2584
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2585
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2586
    r := receiver evaluate.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2587
    argArray isNil ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2588
        r perform:selector.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2589
        ^ r
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2590
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2591
    nargs := argArray size.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2592
    (nargs == 1) ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2593
        r perform:selector with:(argArray at:1) evaluate.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2594
        ^ r
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2595
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2596
    (nargs == 2) ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2597
        r perform:selector with:(argArray at:1) evaluate
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2598
                           with:(argArray at:2) evaluate.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2599
        ^ r
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2600
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2601
    (nargs == 3) ifTrue:[
861
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2602
        r perform:selector with:(argArray at:1) evaluate
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2603
                           with:(argArray at:2) evaluate
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2604
                           with:(argArray at:3) evaluate.
ccaa0ba5e7af generate selector symbols late (when compiling or evaluating)
Claus Gittinger <cg@exept.de>
parents: 856
diff changeset
  2605
        ^ r
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2606
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2607
    argValueArray := argArray collect:[:arg | arg evaluate].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2608
    r perform:selector withArguments:argValueArray.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2609
    ^ r
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2610
! !
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2611
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2612
!MessageNode methodsFor:'printing'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2613
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2614
printOn:aStream indent:i
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2615
    |needParen selectorParts index index2 arg|
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2616
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2617
    (#(whileTrue: whileFalse:) includes:selector) ifTrue:[
888
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2618
        receiver isBlock ifTrue:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2619
            ^ self printWhileOn:aStream indent:i
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2620
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2621
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2622
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2623
    index := 1.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2624
    selectorParts := OrderedCollection new.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2625
    [index == 0] whileFalse:[
888
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2626
        index2 := selector indexOf:$: startingAt:index.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2627
        index2 ~~ 0 ifTrue:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2628
            selectorParts add:(selector copyFrom:index to:index2).
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2629
            index2 := index2 + 1
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2630
        ].
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2631
        index := index2
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2632
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2633
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2634
    needParen := false.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2635
    receiver isMessage ifTrue:[
888
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2636
        receiver isUnaryMessage ifFalse:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2637
            receiver isBinaryMessage ifFalse:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2638
                needParen := true
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2639
            ].
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2640
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2641
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2642
    needParen ifTrue:[
888
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2643
        aStream nextPutAll:'('
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2644
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2645
    receiver printOn:aStream indent:i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2646
    needParen ifTrue:[
888
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2647
        aStream nextPutAll:')'
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2648
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2649
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2650
    1 to:(argArray size) do:[:argIndex |
888
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2651
        aStream cr.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2652
        aStream spaces:i+4.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2653
        (selectorParts at:argIndex) printOn:aStream.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2654
"/        aStream space.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2655
        arg := argArray at:argIndex.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2656
        needParen := false.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2657
        arg isMessage ifTrue:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2658
            arg isBinaryMessage ifFalse:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2659
                arg isUnaryMessage ifFalse:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2660
                    needParen := true
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2661
                ]
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2662
            ].
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2663
        ].
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2664
        needParen ifTrue:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2665
            aStream nextPutAll:'('
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2666
        ].
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2667
        arg printOn:aStream indent:i+4.
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2668
        needParen ifTrue:[
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2669
            aStream nextPutAll:') '
5858090fc8c3 changed #printOn: to indent
Claus Gittinger <cg@exept.de>
parents: 886
diff changeset
  2670
        ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2671
    ]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2672
!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2673
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2674
printWhileOn:aStream indent:i
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2675
    |needParen arg|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2676
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2677
    "special handling of whileTrue/whileFalse"
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2678
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2679
    aStream nextPutAll:'['.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2680
    receiver statements printOn:aStream indent:i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2681
    aStream nextPutAll:'] whileTrue: '.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2682
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2683
    arg := argArray at:1.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2684
    needParen := false.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2685
    arg isMessage ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2686
	arg isBinaryMessage ifFalse:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2687
	    arg isUnaryMessage ifFalse:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2688
		needParen := true
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2689
	    ]
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2690
	].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2691
    ].
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2692
    needParen ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2693
	aStream nextPutAll:'('
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2694
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2695
    arg printOn:aStream indent:i.
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2696
    needParen ifTrue:[
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2697
	aStream nextPutAll:') '
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2698
    ].
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2699
! !
106
claus
parents: 104
diff changeset
  2700
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2701
!MessageNode methodsFor:'queries'!
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2702
395
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2703
collectBlocksInto:aCollection
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2704
    receiver collectBlocksInto:aCollection.
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2705
    argArray size > 0 ifTrue:[
639
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2706
	argArray do:[:arg |
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2707
	    arg collectBlocksInto:aCollection.
f3dce3a697f0 inline #perform: messages with constant selector
Claus Gittinger <cg@exept.de>
parents: 627
diff changeset
  2708
	]
395
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2709
    ].
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2710
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2711
    "Created: 23.10.1996 / 15:44:49 / cg"
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2712
    "Modified: 23.10.1996 / 16:03:46 / cg"
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2713
!
16156d8711c2 added block collector
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2714
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2715
isCascade
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2716
    ^ false
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2717
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2718
    "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
  2719
!
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2720
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2721
isMessage
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2722
    ^ true
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2723
!
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2724
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2725
realReceiver
746
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  2726
    receiver isCascade ifTrue:[
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  2727
        ^ receiver realReceiver
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2728
    ].
746
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  2729
    self isCascade ifTrue:[
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  2730
        ^ receiver receiver
744
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2731
    ].
e871f9f072f8 changes for cascades to super/here semantics.
Claus Gittinger <cg@exept.de>
parents: 715
diff changeset
  2732
746
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  2733
    ^ receiver
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  2734
429cfc59b440 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 744
diff changeset
  2735
    "Modified: / 17.7.1998 / 02:09:05 / cg"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  2736
! !
140
1ef1d1395146 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 135
diff changeset
  2737
370
09c13380b03b slightly better code for "[true] whileTrue:[ ...]"
Claus Gittinger <cg@exept.de>
parents: 349
diff changeset
  2738
!MessageNode class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  2739
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  2740
version
905
9d5500bffa74 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 902
diff changeset
  2741
    ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.101 1999-07-12 15:21:52 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 140
diff changeset
  2742
! !