gen_structlog.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. Stack []*math.HexOrDecimal256 `json:"stack"`
  18. Storage map[common.Hash]common.Hash `json:"-"`
  19. Depth int `json:"depth"`
  20. Err error `json:"error"`
  21. OpName string `json:"opName"`
  22. MemorySize int `json:"memSize"`
  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. if s.Stack != nil {
  31. enc.Stack = make([]*math.HexOrDecimal256, len(s.Stack))
  32. for k, v := range s.Stack {
  33. enc.Stack[k] = (*math.HexOrDecimal256)(v)
  34. }
  35. }
  36. enc.Storage = s.Storage
  37. enc.Depth = s.Depth
  38. enc.Err = s.Err
  39. enc.OpName = s.OpName()
  40. enc.MemorySize = s.MemorySize()
  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. Stack []*math.HexOrDecimal256 `json:"stack"`
  51. Storage map[common.Hash]common.Hash `json:"-"`
  52. Depth *int `json:"depth"`
  53. Err *error `json:"error"`
  54. }
  55. var dec StructLog
  56. if err := json.Unmarshal(input, &dec); err != nil {
  57. return err
  58. }
  59. if dec.Pc != nil {
  60. s.Pc = *dec.Pc
  61. }
  62. if dec.Op != nil {
  63. s.Op = *dec.Op
  64. }
  65. if dec.Gas != nil {
  66. s.Gas = uint64(*dec.Gas)
  67. }
  68. if dec.GasCost != nil {
  69. s.GasCost = uint64(*dec.GasCost)
  70. }
  71. if dec.Memory != nil {
  72. s.Memory = dec.Memory
  73. }
  74. if dec.Stack != nil {
  75. s.Stack = make([]*big.Int, len(dec.Stack))
  76. for k, v := range dec.Stack {
  77. s.Stack[k] = (*big.Int)(v)
  78. }
  79. }
  80. if dec.Storage != nil {
  81. s.Storage = dec.Storage
  82. }
  83. if dec.Depth != nil {
  84. s.Depth = *dec.Depth
  85. }
  86. if dec.Err != nil {
  87. s.Err = *dec.Err
  88. }
  89. return nil
  90. }