gen_structlog.go 3.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.

package vm

import (
	"encoding/json"

	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/common/hexutil"
	"github.com/ethereum/go-ethereum/common/math"
11
	"github.com/holiman/uint256"
12 13
)

14 15
var _ = (*structLogMarshaling)(nil)

16
// MarshalJSON marshals as JSON.
17 18
func (s StructLog) MarshalJSON() ([]byte, error) {
	type StructLog struct {
19 20 21 22 23 24
		Pc            uint64                      `json:"pc"`
		Op            OpCode                      `json:"op"`
		Gas           math.HexOrDecimal64         `json:"gas"`
		GasCost       math.HexOrDecimal64         `json:"gasCost"`
		Memory        hexutil.Bytes               `json:"memory"`
		MemorySize    int                         `json:"memSize"`
25
		Stack         []uint256.Int               `json:"stack"`
26
		ReturnData    hexutil.Bytes               `json:"returnData"`
27 28 29 30 31 32
		Storage       map[common.Hash]common.Hash `json:"-"`
		Depth         int                         `json:"depth"`
		RefundCounter uint64                      `json:"refund"`
		Err           error                       `json:"-"`
		OpName        string                      `json:"opName"`
		ErrorString   string                      `json:"error"`
33 34 35 36 37 38 39
	}
	var enc StructLog
	enc.Pc = s.Pc
	enc.Op = s.Op
	enc.Gas = math.HexOrDecimal64(s.Gas)
	enc.GasCost = math.HexOrDecimal64(s.GasCost)
	enc.Memory = s.Memory
40
	enc.MemorySize = s.MemorySize
41
	enc.Stack = s.Stack
42
	enc.ReturnData = s.ReturnData
43 44
	enc.Storage = s.Storage
	enc.Depth = s.Depth
45
	enc.RefundCounter = s.RefundCounter
46 47
	enc.Err = s.Err
	enc.OpName = s.OpName()
48
	enc.ErrorString = s.ErrorString()
49 50 51
	return json.Marshal(&enc)
}

52
// UnmarshalJSON unmarshals from JSON.
53 54
func (s *StructLog) UnmarshalJSON(input []byte) error {
	type StructLog struct {
55 56 57 58 59 60
		Pc            *uint64                     `json:"pc"`
		Op            *OpCode                     `json:"op"`
		Gas           *math.HexOrDecimal64        `json:"gas"`
		GasCost       *math.HexOrDecimal64        `json:"gasCost"`
		Memory        *hexutil.Bytes              `json:"memory"`
		MemorySize    *int                        `json:"memSize"`
61
		Stack         []uint256.Int               `json:"stack"`
62
		ReturnData    *hexutil.Bytes              `json:"returnData"`
63 64 65 66
		Storage       map[common.Hash]common.Hash `json:"-"`
		Depth         *int                        `json:"depth"`
		RefundCounter *uint64                     `json:"refund"`
		Err           error                       `json:"-"`
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
	}
	var dec StructLog
	if err := json.Unmarshal(input, &dec); err != nil {
		return err
	}
	if dec.Pc != nil {
		s.Pc = *dec.Pc
	}
	if dec.Op != nil {
		s.Op = *dec.Op
	}
	if dec.Gas != nil {
		s.Gas = uint64(*dec.Gas)
	}
	if dec.GasCost != nil {
		s.GasCost = uint64(*dec.GasCost)
	}
	if dec.Memory != nil {
85
		s.Memory = *dec.Memory
86
	}
87 88 89
	if dec.MemorySize != nil {
		s.MemorySize = *dec.MemorySize
	}
90
	if dec.Stack != nil {
91
		s.Stack = dec.Stack
92
	}
93
	if dec.ReturnData != nil {
94
		s.ReturnData = *dec.ReturnData
95
	}
96 97 98 99 100 101
	if dec.Storage != nil {
		s.Storage = dec.Storage
	}
	if dec.Depth != nil {
		s.Depth = *dec.Depth
	}
102 103 104
	if dec.RefundCounter != nil {
		s.RefundCounter = *dec.RefundCounter
	}
105
	if dec.Err != nil {
106
		s.Err = dec.Err
107 108 109
	}
	return nil
}