Skip to content

Commit

Permalink
decouple core of Int value implementation from interpreter into value…
Browse files Browse the repository at this point in the history
…s package
  • Loading branch information
turbolent committed Feb 13, 2025
1 parent e060afa commit a8ca1c1
Show file tree
Hide file tree
Showing 6 changed files with 570 additions and 187 deletions.
17 changes: 0 additions & 17 deletions interpreter/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,6 @@ func (VoidValue) Encode(e *atree.Encoder) error {
return e.CBOR.EncodeRawBytes(cborVoidValue)
}

// Encode encodes the value as
//
// cbor.Tag{
// Number: CBORTagIntValue,
// Content: *big.Int(v.BigInt),
// }
func (v IntValue) Encode(e *atree.Encoder) error {
err := e.CBOR.EncodeRawBytes([]byte{
// tag number
0xd8, values.CBORTagIntValue,
})
if err != nil {
return err
}
return e.CBOR.EncodeBigInt(v.BigInt)
}

// Encode encodes Int8Value as
//
// cbor.Tag{
Expand Down
3 changes: 3 additions & 0 deletions interpreter/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ func ConvertStoredValue(gauge common.MemoryGauge, value atree.Value) (Value, err
case values.BoolValue:
return BoolValue(value), nil

case values.IntValue:
return IntValue{IntValue: value}, nil

case Value:
return value, nil

Expand Down
Loading

0 comments on commit a8ca1c1

Please sign in to comment.