Yeah, ok, but the problem is in the debugger because when you debug the syntax-error version, it points to 5=4 instead of pointing to #ifTrue:.
Actually, the Debugger is working fine; the problem is that the Compiler in-lines code for some selectors like #ifTrue:, but doesn't set the pc value for the code in the encoder's sourceMap. This is probably because in the in-line code there isn't one unique pc value that would correspond to the message send bytecode it replaces.
For the #ifTrue: case you point out, I was able to get the debugger to select the correct range with the following changes to MethodNode messages. All this code does is set the default PC value of 0 before calling the MacroEmitter, instead of after, in case the MacroEmitter itself decides to set the PC. In the MacroEmitter for #emitIf... I simply set the pc after the conditional branch bytecode was emitted:
'From Squeak 1.31 of Feb 4, 1998 on 29 March 1998 at 11:00:48 pm'!
!MessageNode methodsFor: 'code generation' stamp: 'tao 3/29/98 22:49'! emitForEffect: stack on: strm
special > 0 ifTrue: [pc _ 0. self perform: (MacroEmitters at: special) with: stack with: strm with: false] ifFalse: [super emitForEffect: stack on: strm]! !
!MessageNode methodsFor: 'code generation' stamp: 'tao 3/29/98 22:50'! emitForValue: stack on: strm
special > 0 ifTrue: [pc _ 0. self perform: (MacroEmitters at: special) with: stack with: strm with: true] ifFalse: [receiver ~~ nil ifTrue: [receiver emitForValue: stack on: strm]. arguments do: [:argument | argument emitForValue: stack on: strm]. selector emit: stack args: arguments size on: strm super: receiver == NodeSuper. pc _ strm position]! !
!MessageNode methodsFor: 'code generation' stamp: 'tao 3/29/98 22:53'! emitIf: stack on: strm value: forValue | thenExpr thenSize elseExpr elseSize | thenSize _ sizes at: 1. elseSize _ sizes at: 2. (forValue not and: [(elseSize*thenSize) > 0]) ifTrue: "Two-armed IFs forEffect share a single pop" [^ super emitForEffect: stack on: strm]. thenExpr _ arguments at: 1. elseExpr _ arguments at: 2. receiver emitForValue: stack on: strm. forValue ifTrue: "Code all forValue as two-armed" [self emitBranchOn: false dist: thenSize pop: stack on: strm. pc _ strm position. thenExpr emitForEvaluatedValue: stack on: strm. stack pop: 1. "then and else alternate; they don't accumulate" thenExpr returns not ifTrue: "Elide jump over else after a return" [self emitJump: elseSize on: strm]. elseExpr emitForEvaluatedValue: stack on: strm] ifFalse: "One arm is empty here (two-arms code forValue)" [thenSize > 0 ifTrue: [self emitBranchOn: false dist: thenSize pop: stack on: strm. pc _ strm position. thenExpr emitForEvaluatedEffect: stack on: strm] ifFalse: [self emitBranchOn: true dist: elseSize pop: stack on: strm. pc _ strm position. elseExpr emitForEvaluatedEffect: stack on: strm]]! !
-- tim
squeak-dev@lists.squeakfoundation.org