gen_structlog.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. Storage map[common.Hash]common.Hash `json:"-"`
  22. Depth int `json:"depth"`
  23. RefundCounter uint64 `json:"refund"`
  24. Err error `json:"-"`
  25. OpName string `json:"opName"`
  26. ErrorString string `json:"error"`
  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.RefundCounter = s.RefundCounter
  44. enc.Err = s.Err
  45. enc.OpName = s.OpName()
  46. enc.ErrorString = s.ErrorString()
  47. return json.Marshal(&enc)
  48. }
  49. // UnmarshalJSON unmarshals from JSON.
  50. func (s *StructLog) UnmarshalJSON(input []byte) error {
  51. type StructLog struct {
  52. Pc *uint64 `json:"pc"`
  53. Op *OpCode `json:"op"`
  54. Gas *math.HexOrDecimal64 `json:"gas"`
  55. GasCost *math.HexOrDecimal64 `json:"gasCost"`
  56. Memory *hexutil.Bytes `json:"memory"`
  57. MemorySize *int `json:"memSize"`
  58. Stack []*math.HexOrDecimal256 `json:"stack"`
  59. Storage map[common.Hash]common.Hash `json:"-"`
  60. Depth *int `json:"depth"`
  61. RefundCounter *uint64 `json:"refund"`
  62. Err error `json:"-"`
  63. }
  64. var dec StructLog
  65. if err := json.Unmarshal(input, &dec); err != nil {
  66. return err
  67. }
  68. if dec.Pc != nil {
  69. s.Pc = *dec.Pc
  70. }
  71. if dec.Op != nil {
  72. s.Op = *dec.Op
  73. }
  74. if dec.Gas != nil {
  75. s.Gas = uint64(*dec.Gas)
  76. }
  77. if dec.GasCost != nil {
  78. s.GasCost = uint64(*dec.GasCost)
  79. }
  80. if dec.Memory != nil {
  81. s.Memory = *dec.Memory
  82. }
  83. if dec.MemorySize != nil {
  84. s.MemorySize = *dec.MemorySize
  85. }
  86. if dec.Stack != nil {
  87. s.Stack = make([]*big.Int, len(dec.Stack))
  88. for k, v := range dec.Stack {
  89. s.Stack[k] = (*big.Int)(v)
  90. }
  91. }
  92. if dec.Storage != nil {
  93. s.Storage = dec.Storage
  94. }
  95. if dec.Depth != nil {
  96. s.Depth = *dec.Depth
  97. }
  98. if dec.RefundCounter != nil {
  99. s.RefundCounter = *dec.RefundCounter
  100. }
  101. if dec.Err != nil {
  102. s.Err = dec.Err
  103. }
  104. return nil
  105. }