github.com/etherite/go-etherite@v0.0.0-20171015192807-5f4dd87b2f6e/core/vm/gen_structlog.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package vm 4 5 import ( 6 "encoding/json" 7 "math/big" 8 9 "github.com/etherite/go-etherite/common" 10 "github.com/etherite/go-etherite/common/hexutil" 11 "github.com/etherite/go-etherite/common/math" 12 ) 13 14 func (s StructLog) MarshalJSON() ([]byte, error) { 15 type StructLog struct { 16 Pc uint64 `json:"pc"` 17 Op OpCode `json:"op"` 18 Gas math.HexOrDecimal64 `json:"gas"` 19 GasCost math.HexOrDecimal64 `json:"gasCost"` 20 Memory hexutil.Bytes `json:"memory"` 21 MemorySize int `json:"memSize"` 22 Stack []*math.HexOrDecimal256 `json:"stack"` 23 Storage map[common.Hash]common.Hash `json:"-"` 24 Depth int `json:"depth"` 25 Err error `json:"error"` 26 OpName string `json:"opName"` 27 } 28 var enc StructLog 29 enc.Pc = s.Pc 30 enc.Op = s.Op 31 enc.Gas = math.HexOrDecimal64(s.Gas) 32 enc.GasCost = math.HexOrDecimal64(s.GasCost) 33 enc.Memory = s.Memory 34 enc.MemorySize = s.MemorySize 35 if s.Stack != nil { 36 enc.Stack = make([]*math.HexOrDecimal256, len(s.Stack)) 37 for k, v := range s.Stack { 38 enc.Stack[k] = (*math.HexOrDecimal256)(v) 39 } 40 } 41 enc.Storage = s.Storage 42 enc.Depth = s.Depth 43 enc.Err = s.Err 44 enc.OpName = s.OpName() 45 return json.Marshal(&enc) 46 } 47 48 func (s *StructLog) UnmarshalJSON(input []byte) error { 49 type StructLog struct { 50 Pc *uint64 `json:"pc"` 51 Op *OpCode `json:"op"` 52 Gas *math.HexOrDecimal64 `json:"gas"` 53 GasCost *math.HexOrDecimal64 `json:"gasCost"` 54 Memory hexutil.Bytes `json:"memory"` 55 MemorySize *int `json:"memSize"` 56 Stack []*math.HexOrDecimal256 `json:"stack"` 57 Storage map[common.Hash]common.Hash `json:"-"` 58 Depth *int `json:"depth"` 59 Err *error `json:"error"` 60 } 61 var dec StructLog 62 if err := json.Unmarshal(input, &dec); err != nil { 63 return err 64 } 65 if dec.Pc != nil { 66 s.Pc = *dec.Pc 67 } 68 if dec.Op != nil { 69 s.Op = *dec.Op 70 } 71 if dec.Gas != nil { 72 s.Gas = uint64(*dec.Gas) 73 } 74 if dec.GasCost != nil { 75 s.GasCost = uint64(*dec.GasCost) 76 } 77 if dec.Memory != nil { 78 s.Memory = dec.Memory 79 } 80 if dec.MemorySize != nil { 81 s.MemorySize = *dec.MemorySize 82 } 83 if dec.Stack != nil { 84 s.Stack = make([]*big.Int, len(dec.Stack)) 85 for k, v := range dec.Stack { 86 s.Stack[k] = (*big.Int)(v) 87 } 88 } 89 if dec.Storage != nil { 90 s.Storage = dec.Storage 91 } 92 if dec.Depth != nil { 93 s.Depth = *dec.Depth 94 } 95 if dec.Err != nil { 96 s.Err = *dec.Err 97 } 98 return nil 99 }