Skip to content

Commit

Permalink
swap arguments of New(Unmetered?)HostFunctionValue to put the functio…
Browse files Browse the repository at this point in the history
…n type before the function block
  • Loading branch information
Naomi Liu committed Feb 10, 2023
1 parent b64a089 commit e9f3ce6
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 176 deletions.
4 changes: 2 additions & 2 deletions runtime/interpreter/deployedcontract.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func newPublicTypesFunctionValue(inter *Interpreter, addressValue AddressValue,
var publicTypes *ArrayValue

address := addressValue.ToAddress()
return NewHostFunctionValue(inter, func(inv Invocation) Value {
return NewHostFunctionValue(inter, sema.DeployedContractTypePublicTypesFunctionType, func(inv Invocation) Value {
if publicTypes == nil {
innerInter := inv.Interpreter
contractLocation := common.NewAddressLocation(innerInter, address, name.Str)
Expand Down Expand Up @@ -97,5 +97,5 @@ func newPublicTypesFunctionValue(inter *Interpreter, addressValue AddressValue,
}

return publicTypes
}, sema.DeployedContractTypePublicTypesFunctionType)
})
}
6 changes: 3 additions & 3 deletions runtime/interpreter/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ func (f *HostFunctionValue) MeteredString(memoryGauge common.MemoryGauge, _ Seen
}

func NewUnmeteredHostFunctionValue(
function HostFunction,
funcType *sema.FunctionType,
function HostFunction,
) *HostFunctionValue {
// Host functions can be passed by value,
// so for the interpreter value transfer check to work,
Expand All @@ -209,13 +209,13 @@ func NewUnmeteredHostFunctionValue(

func NewHostFunctionValue(
gauge common.MemoryGauge,
function HostFunction,
funcType *sema.FunctionType,
function HostFunction,
) *HostFunctionValue {

common.UseMemory(gauge, common.HostFunctionValueMemoryUsage)

return NewUnmeteredHostFunctionValue(function, funcType)
return NewUnmeteredHostFunctionValue(funcType, function)
}

var _ Value = &HostFunctionValue{}
Expand Down
4 changes: 2 additions & 2 deletions runtime/interpreter/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func TestFunctionStaticType(t *testing.T) {

hostFunctionValue := NewHostFunctionValue(
inter,
hostFunction,
hostFunctionType,
hostFunction,
)

staticType := hostFunctionValue.StaticType(inter)
Expand All @@ -73,8 +73,8 @@ func TestFunctionStaticType(t *testing.T) {

hostFunctionValue := NewHostFunctionValue(
inter,
hostFunction,
hostFunctionType,
hostFunction,
)

compositeValue := NewCompositeValue(
Expand Down
Loading

0 comments on commit e9f3ce6

Please sign in to comment.