Skip to content

Commit

Permalink
Merge pull request #2621 from onflow/fxamacker/delegate-cadence-compo…
Browse files Browse the repository at this point in the history
…site-storable-to-atree

Delegate Cadence composite `Storable()` to Atree
  • Loading branch information
fxamacker authored Jul 6, 2023
2 parents 1173380 + a0ea3d5 commit 9397f7b
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions runtime/interpreter/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -2540,8 +2540,12 @@ func (v *ArrayValue) Equal(interpreter *Interpreter, locationRange LocationRange
return true
}

func (v *ArrayValue) Storable(_ atree.SlabStorage, _ atree.Address, _ uint64) (atree.Storable, error) {
return atree.StorageIDStorable(v.StorageID()), nil
func (v *ArrayValue) Storable(
storage atree.SlabStorage,
address atree.Address,
maxInlineSize uint64,
) (atree.Storable, error) {
return v.array.Storable(storage, address, maxInlineSize)
}

func (v *ArrayValue) IsReferenceTrackedResourceKindedValue() {}
Expand Down Expand Up @@ -16006,12 +16010,16 @@ func (v *CompositeValue) IsStorable() bool {
return v.Location != nil
}

func (v *CompositeValue) Storable(_ atree.SlabStorage, _ atree.Address, _ uint64) (atree.Storable, error) {
func (v *CompositeValue) Storable(
storage atree.SlabStorage,
address atree.Address,
maxInlineSize uint64,
) (atree.Storable, error) {
if !v.IsStorable() {
return NonStorable{Value: v}, nil
}

return atree.StorageIDStorable(v.StorageID()), nil
return v.dictionary.Storable(storage, address, maxInlineSize)
}

func (v *CompositeValue) NeedsStoreTo(address atree.Address) bool {
Expand Down Expand Up @@ -17517,8 +17525,12 @@ func (v *DictionaryValue) Equal(interpreter *Interpreter, locationRange Location
}
}

func (v *DictionaryValue) Storable(_ atree.SlabStorage, _ atree.Address, _ uint64) (atree.Storable, error) {
return atree.StorageIDStorable(v.StorageID()), nil
func (v *DictionaryValue) Storable(
storage atree.SlabStorage,
address atree.Address,
maxInlineSize uint64,
) (atree.Storable, error) {
return v.dictionary.Storable(storage, address, maxInlineSize)
}

func (v *DictionaryValue) IsReferenceTrackedResourceKindedValue() {}
Expand Down

0 comments on commit 9397f7b

Please sign in to comment.