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