Add separate conversion stage to DAP info
Clarification and motivation
IMO the logic related to DAP handlers is pretty hacky.
- In the handler for scopes we create the current variables, and in the handler for variables we read them. So we rely on that the client (VSCode) will call us in particular order. There is a similar thing using
_dsSource
variable in state. - Eventually we have to look forward and pick instruction of the next snapshot, if available, which is inconvenient (see handler for stack trace request).
Having a state like in the first point is very sad, especially in Haskell.
The solution that I see here: add a processing stage where we convert InterpretSnapshot
to another history that would be more suitable for DAP. Our attempt to put this processing to one of the existing stages (to snapshots collection or to DAP handlers) resulted in those stages getting complicated as can be witnessed now.
There will be no need for handlers to have state, everything will already be available on the tape. Such DAP-like snapshots will additionally contain:
- Next instruction
- Variables
- Scopes
Also, such extraction of a processing stage would separate the InterpretSnapshot
-> DAP conversion logic from language server logic, and LIGO debugger would need to implement only the former without worrying about the latter.
So I propose to add some datatype DAPSnapshot
that would carry everything necessary for DAP handlers. It should likely operate with DAP-specific types where possible (e.g. DAP.StackFrame
instead of our Morley-specific StackFrame
). But don't include language-server-specific things like seqNo
there.
And have should have stages:
-
[InterpretSnapshot] -> [DAPSnapshot]
conversion function. - Handlers that would work with this
DAPSnapshot
, they should have no other state except forTape DAPSnapshot
and things like breakpoints. They should not do anything smart, rather only convert betweenDAPSnapshot
and responses in the demanded format.
Maybe even more stages, if that turns out to be convenient.
The current NavigableSnapshot
typeclass and most methods of HasSpecificMessages
typeclass hopefully won't be necessary anymore. Everything specific to particular debugger will go to [InterpretSnapshot] -> [DAPSnapshot]
conversion function.
Acceptance criteria
- The specified separation into stages is implemented.
- LIGO debugger is checked on that it can be migrated on the new code without severe issues.