Skip to content

Commit a8ca1c1

Browse files
committed
decouple core of Int value implementation from interpreter into values package
1 parent e060afa commit a8ca1c1

File tree

6 files changed

+570
-187
lines changed

6 files changed

+570
-187
lines changed

interpreter/encode.go

-17
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,6 @@ func (VoidValue) Encode(e *atree.Encoder) error {
140140
return e.CBOR.EncodeRawBytes(cborVoidValue)
141141
}
142142

143-
// Encode encodes the value as
144-
//
145-
// cbor.Tag{
146-
// Number: CBORTagIntValue,
147-
// Content: *big.Int(v.BigInt),
148-
// }
149-
func (v IntValue) Encode(e *atree.Encoder) error {
150-
err := e.CBOR.EncodeRawBytes([]byte{
151-
// tag number
152-
0xd8, values.CBORTagIntValue,
153-
})
154-
if err != nil {
155-
return err
156-
}
157-
return e.CBOR.EncodeBigInt(v.BigInt)
158-
}
159-
160143
// Encode encodes Int8Value as
161144
//
162145
// cbor.Tag{

interpreter/storage.go

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ func ConvertStoredValue(gauge common.MemoryGauge, value atree.Value) (Value, err
9898
case values.BoolValue:
9999
return BoolValue(value), nil
100100

101+
case values.IntValue:
102+
return IntValue{IntValue: value}, nil
103+
101104
case Value:
102105
return value, nil
103106

0 commit comments

Comments
 (0)