gen_structlog.go 3.6 KB

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