MessageNode.st
changeset 167 d3dbd739c65a
parent 166 9f6c57a3bce1
child 186 05a99f1bd747
equal deleted inserted replaced
166:9f6c57a3bce1 167:d3dbd739c65a
  1222 !
  1222 !
  1223 
  1223 
  1224 codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
  1224 codeWhileOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler
  1225     "generate code for [...] whilexxx:[ ... ]"
  1225     "generate code for [...] whilexxx:[ ... ]"
  1226 
  1226 
  1227     |pos pos2 theReceiver theArg theByteCode optByteCode|
  1227     |pos pos2 theReceiver theArg theByteCode optByteCode needLineNr blockExpr|
  1228 
  1228 
  1229     (selector == #whileTrue:) ifTrue:[
  1229     (selector == #whileTrue:) ifTrue:[
  1230 	theByteCode := #falseJump
  1230         theByteCode := #falseJump
  1231     ] ifFalse:[
  1231     ] ifFalse:[
  1232 	theByteCode := #trueJump
  1232         theByteCode := #trueJump
  1233     ].
  1233     ].
  1234 
  1234 
  1235     theReceiver := receiver.
  1235     theReceiver := receiver.
  1236     optByteCode := self optimizedConditionFor:theReceiver with:theByteCode.
  1236     optByteCode := self optimizedConditionFor:theReceiver with:theByteCode.
  1237     optByteCode notNil ifTrue:[
  1237     optByteCode notNil ifTrue:[
  1238 	((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
  1238         ((optByteCode == #eqJump) or:[optByteCode == #notEqJump]) ifTrue:[
  1239 	    theArg := receiver statements expression arg1
  1239             theArg := receiver statements expression arg1
  1240 	].
  1240         ].
  1241 	theReceiver := receiver statements expression receiver.
  1241         theReceiver := receiver statements expression receiver.
  1242 	theByteCode := optByteCode
  1242         theByteCode := optByteCode
  1243     ].
  1243     ].
  1244 
  1244 
  1245 "/ OLD:
  1245 "/ OLD:
  1246 "/    valueNeeded ifTrue:[aStream nextPut:#pushNil].
  1246 "/    valueNeeded ifTrue:[aStream nextPut:#pushNil].
  1247 "/
  1247 "/
       
  1248     needLineNr := true.
       
  1249 
  1248     pos := aStream position.
  1250     pos := aStream position.
  1249     optByteCode notNil ifTrue:[
  1251     optByteCode notNil ifTrue:[
  1250 	theReceiver codeOn:aStream inBlock:b for:aCompiler.
  1252         theReceiver codeOn:aStream inBlock:b for:aCompiler.
  1251 	theArg notNil ifTrue:[
  1253         theArg notNil ifTrue:[
  1252 	    theArg codeOn:aStream inBlock:b for:aCompiler
  1254             theArg codeOn:aStream inBlock:b for:aCompiler
  1253 	]
  1255         ]
  1254     ] ifFalse:[
  1256     ] ifFalse:[
  1255 	theReceiver codeInlineOn:aStream inBlock:b for:aCompiler
  1257         theReceiver codeInlineOn:aStream inBlock:b for:aCompiler.
  1256     ].
  1258 
  1257 
  1259         "/
  1258     (lineNr between:1 and:255) ifTrue:[
  1260         "/ cannot enable code below 
  1259 	aStream nextPut:#lineno; nextPut:lineNr.
  1261         "/ (tiny loops would not be debuggable with next, since lineNo remains the same)
       
  1262         "/ think about it ...
       
  1263         "/
       
  1264 "/        blockExpr := theReceiver simpleSendBlockReceiver.
       
  1265 "/        blockExpr notNil ifTrue:[
       
  1266 "/            blockExpr isMessage ifTrue:[
       
  1267 "/                (self class hasLineNumber:(blockExpr selector)) ifTrue:[
       
  1268 "/                    blockExpr lineNumber == lineNr ifTrue:[
       
  1269 "/                        needLineNr := false
       
  1270 "/                    ]
       
  1271 "/                ]
       
  1272 "/            ]
       
  1273 "/        ].
       
  1274     ].
       
  1275 
       
  1276     needLineNr ifTrue:[
       
  1277         (lineNr between:1 and:255) ifTrue:[
       
  1278             aStream nextPut:#lineno; nextPut:lineNr.
       
  1279         ]
  1260     ].
  1280     ].
  1261 
  1281 
  1262     aStream nextPut:theByteCode.
  1282     aStream nextPut:theByteCode.
  1263     pos2 := aStream position.
  1283     pos2 := aStream position.
  1264     aStream nextPut:0.
  1284     aStream nextPut:0.
  1271     (argArray at:1) codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
  1291     (argArray at:1) codeInlineOn:aStream inBlock:b valueNeeded:false for:aCompiler.
  1272     aStream nextPut:#jump; nextPut:pos.
  1292     aStream nextPut:#jump; nextPut:pos.
  1273     (aStream contents) at:pos2 put:(aStream position).
  1293     (aStream contents) at:pos2 put:(aStream position).
  1274 "/ NEW:
  1294 "/ NEW:
  1275     valueNeeded ifTrue:[aStream nextPut:#pushNil].
  1295     valueNeeded ifTrue:[aStream nextPut:#pushNil].
       
  1296 
       
  1297     "Modified: 13.12.1995 / 19:42:49 / cg"
  1276 !
  1298 !
  1277 
  1299 
  1278 optimizedConditionFor:aReceiver with:aByteCode
  1300 optimizedConditionFor:aReceiver with:aByteCode
  1279     |rec sel|
  1301     |rec sel|
  1280 
  1302 
  1538 ! !
  1560 ! !
  1539 
  1561 
  1540 !MessageNode class methodsFor:'documentation'!
  1562 !MessageNode class methodsFor:'documentation'!
  1541 
  1563 
  1542 version
  1564 version
  1543     ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.35 1995-12-13 17:55:49 cg Exp $'
  1565     ^ '$Header: /cvs/stx/stx/libcomp/MessageNode.st,v 1.36 1995-12-13 19:04:48 cg Exp $'
  1544 ! !
  1566 ! !