neo-go/pkg/vm/output.go
Anthony De Meulemeester 69c3e645b6
VM improvements, tests + bugfixes (#61)
* changed vm commands to match more of the standard

* fixed Uint16 jmp bug in VM

* moved test to vm + fixed numnotequal bug

* fixed broken tests

* moved compiler tests to vm tests

* added basic for support + inc and dec stmts

* bumped version
2018-04-02 17:04:42 +02:00

25 lines
485 B
Go

package vm
import "encoding/json"
// StackOutput holds information about the stack, used for pretty printing
// the stack.
type stackItem struct {
Value interface{} `json:"value"`
Type string `json:"type"`
}
func buildStackOutput(s *Stack) string {
items := make([]stackItem, s.Len())
i := 0
s.Iter(func(e *Element) {
items[i] = stackItem{
Value: e.value,
Type: e.value.String(),
}
i++
})
b, _ := json.MarshalIndent(items, "", " ")
return string(b)
}