gen_structlog.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. func (s StructLog) MarshalJSON() ([]byte, error) {
  12. type StructLog struct {
  13. Pc uint64 `json:"pc"`
  14. Op OpCode `json:"op"`
  15. Gas math.HexOrDecimal64 `json:"gas"`
  16. GasCost math.HexOrDecimal64 `json:"gasCost"`
  17. Memory hexutil.Bytes `json:"memory"`
  18. MemorySize int `json:"memSize"`
  19. Stack []*math.HexOrDecimal256 `json:"stack"`
  20. Storage map[common.Hash]common.Hash `json:"-"`
  21. Depth int `json:"depth"`
  22. Err error `json:"-"`
  23. OpName string `json:"opName"`
  24. ErrorString string `json:"error"`
  25. }
  26. var enc StructLog
  27. enc.Pc = s.Pc
  28. enc.Op = s.Op
  29. enc.Gas = math.HexOrDecimal64(s.Gas)
  30. enc.GasCost = math.HexOrDecimal64(s.GasCost)
  31. enc.Memory = s.Memory
  32. enc.MemorySize = s.MemorySize
  33. if s.Stack != nil {
  34. enc.Stack = make([]*math.HexOrDecimal256, len(s.Stack))
  35. for k, v := range s.Stack {
  36. enc.Stack[k] = (*math.HexOrDecimal256)(v)
  37. }
  38. }
  39. enc.Storage = s.Storage
  40. enc.Depth = s.Depth
  41. enc.Err = s.Err
  42. enc.OpName = s.OpName()
  43. enc.ErrorString = s.ErrorString()
  44. return json.Marshal(&enc)
  45. }
  46. func (s *StructLog) UnmarshalJSON(input []byte) error {
  47. type StructLog struct {
  48. Pc *uint64 `json:"pc"`
  49. Op *OpCode `json:"op"`
  50. Gas *math.HexOrDecimal64 `json:"gas"`
  51. GasCost *math.HexOrDecimal64 `json:"gasCost"`
  52. Memory *hexutil.Bytes `json:"memory"`
  53. MemorySize *int `json:"memSize"`
  54. Stack []*math.HexOrDecimal256 `json:"stack"`
  55. Storage map[common.Hash]common.Hash `json:"-"`
  56. Depth *int `json:"depth"`
  57. Err error `json:"-"`
  58. }
  59. var dec StructLog
  60. if err := json.Unmarshal(input, &dec); err != nil {
  61. return err
  62. }
  63. if dec.Pc != nil {
  64. s.Pc = *dec.Pc
  65. }
  66. if dec.Op != nil {
  67. s.Op = *dec.Op
  68. }
  69. if dec.Gas != nil {
  70. s.Gas = uint64(*dec.Gas)
  71. }
  72. if dec.GasCost != nil {
  73. s.GasCost = uint64(*dec.GasCost)
  74. }
  75. if dec.Memory != nil {
  76. s.Memory = *dec.Memory
  77. }
  78. if dec.MemorySize != nil {
  79. s.MemorySize = *dec.MemorySize
  80. }
  81. if dec.Stack != nil {
  82. s.Stack = make([]*big.Int, len(dec.Stack))
  83. for k, v := range dec.Stack {
  84. s.Stack[k] = (*big.Int)(v)
  85. }
  86. }
  87. if dec.Storage != nil {
  88. s.Storage = dec.Storage
  89. }
  90. if dec.Depth != nil {
  91. s.Depth = *dec.Depth
  92. }
  93. if dec.Err != nil {
  94. s.Err = dec.Err
  95. }
  96. return nil
  97. }