forked from TrueCloudLab/neoneo-go
vm: fix istack marshaling, fix #2799
This commit is contained in:
parent
90582faacd
commit
aef01bf663
2 changed files with 20 additions and 1 deletions
|
@ -72,6 +72,13 @@ type Context struct {
|
||||||
retCount int
|
retCount int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type contextAux struct {
|
||||||
|
Script string
|
||||||
|
IP int
|
||||||
|
NextIP int
|
||||||
|
Caller string
|
||||||
|
}
|
||||||
|
|
||||||
// ContextUnloadCallback is a callback method used on context unloading from istack.
|
// ContextUnloadCallback is a callback method used on context unloading from istack.
|
||||||
type ContextUnloadCallback func(ctx *Context, commit bool) error
|
type ContextUnloadCallback func(ctx *Context, commit bool) error
|
||||||
|
|
||||||
|
@ -357,3 +364,14 @@ func (c *Context) HasTryBlock() bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON implements the JSON marshalling interface.
|
||||||
|
func (c *Context) MarshalJSON() ([]byte, error) {
|
||||||
|
var aux = contextAux{
|
||||||
|
Script: c.ScriptHash().StringLE(),
|
||||||
|
IP: c.ip,
|
||||||
|
NextIP: c.nextip,
|
||||||
|
Caller: c.sc.callingScriptHash.StringLE(),
|
||||||
|
}
|
||||||
|
return json.Marshal(aux)
|
||||||
|
}
|
||||||
|
|
|
@ -382,7 +382,8 @@ func (v *VM) PopResult() interface{} {
|
||||||
|
|
||||||
// DumpIStack returns json formatted representation of the invocation stack.
|
// DumpIStack returns json formatted representation of the invocation stack.
|
||||||
func (v *VM) DumpIStack() string {
|
func (v *VM) DumpIStack() string {
|
||||||
return dumpStack(&v.istack)
|
b, _ := json.MarshalIndent(v.istack.ToArray(), "", " ")
|
||||||
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DumpEStack returns json formatted representation of the execution stack.
|
// DumpEStack returns json formatted representation of the execution stack.
|
||||||
|
|
Loading…
Reference in a new issue