gen_structlog.go 3.4 KB

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