On Apr 17, 2013, at 10:44 PM, stephane ducasse <stephane.duca...@free.fr> wrote:
> > On Apr 17, 2013, at 10:29 PM, Camillo Bruni <camillobr...@gmail.com> wrote: > >> I really really like this :) >> >> very simple yet powerful! > > Yes this will massively simplify the debugger :) > So we will be able to get a debugger really working without needing an > magician to fix > its bugs. Yes, just the AST with Semantic Analysis information (Scope and Semantic Variables), plus bytecodelevel IR that provides the bridge to the low-level pc (bytecode mapping) data… e.g. to get the highlight in the debugger, this is now just this in DebuggerMethodMapOpal: rangeForPC: aPC contextIsActiveContext: contextIsActive "return the debug highlight for aPC" | pc | "When on the top of the stack the pc is pointing to right instruction, but deeper in the stack the pc was already advanced one bytecode, so we need to go back this one bytecode, which can consist of multiple bytes. But on IR, we record the *last* bytecode offset as the offset of the IR instruction, which means we can just go back one" pc := contextIsActive ifTrue: [aPC] ifFalse: [aPC - 1]. ^(methodNode ir instructionForPC: pc) sourceNode debugHighlightRange more helper methods will simplify this even more, e.g. we should have a method on RBMethodNode like #nodeForPC: rangeForPC: aPC contextIsActiveContext: contextIsActive "return the debug highlight for aPC" | pc | "When on the top of the stack the pc is pointing to right instruction, but deeper in the stack the pc was already advanced one bytecode, so we need to go back this one bytecode, which can consist of multiple bytes. But on IR, we record the *last* bytecode offset as the offset of the IR instruction, which means we can just go back one" pc := contextIsActive ifTrue: [aPC] ifFalse: [aPC - 1]. ^(methodNode nodeForPC: pc) debugHighlightRange And this method one then can just implement on MethodContext itself. (Caching is handled by ASTCache). Marcus