vm CLI: allow to dump slots
This commit is contained in:
parent
b502c5f148
commit
6da458365d
5 changed files with 166 additions and 0 deletions
|
@ -73,6 +73,24 @@ var commands = []*ishell.Cmd{
|
|||
LongHelp: "Show invocation stack contents",
|
||||
Func: handleXStack,
|
||||
},
|
||||
{
|
||||
Name: "sslot",
|
||||
Help: "Show static slot contents",
|
||||
LongHelp: "Show static slot contents",
|
||||
Func: handleSlots,
|
||||
},
|
||||
{
|
||||
Name: "lslot",
|
||||
Help: "Show local slot contents",
|
||||
LongHelp: "Show local slot contents",
|
||||
Func: handleSlots,
|
||||
},
|
||||
{
|
||||
Name: "aslot",
|
||||
Help: "Show arguments slot contents",
|
||||
LongHelp: "Show arguments slot contents",
|
||||
Func: handleSlots,
|
||||
},
|
||||
{
|
||||
Name: "loadnef",
|
||||
Help: "Load a NEF-consistent script into the VM",
|
||||
|
@ -286,6 +304,28 @@ func handleXStack(c *ishell.Context) {
|
|||
c.Println(v.Stack(c.Cmd.Name))
|
||||
}
|
||||
|
||||
func handleSlots(c *ishell.Context) {
|
||||
v := getVMFromContext(c)
|
||||
vmCtx := v.Context()
|
||||
if vmCtx == nil {
|
||||
c.Err(errors.New("no program loaded"))
|
||||
return
|
||||
}
|
||||
var rawSlot string
|
||||
switch c.Cmd.Name {
|
||||
case "sslot":
|
||||
rawSlot = vmCtx.DumpStaticSlot()
|
||||
case "lslot":
|
||||
rawSlot = vmCtx.DumpLocalSlot()
|
||||
case "aslot":
|
||||
rawSlot = vmCtx.DumpArgumentsSlot()
|
||||
default:
|
||||
c.Err(errors.New("unknown slot"))
|
||||
return
|
||||
}
|
||||
c.Println(rawSlot)
|
||||
}
|
||||
|
||||
func handleLoadNEF(c *ishell.Context) {
|
||||
v := getVMFromContext(c)
|
||||
if len(c.Args) < 2 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue