gen_structlog.go 2.7 KB

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