Skip to content

Commit

Permalink
Rename function to reverse from reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdrag00nv2 committed Jul 11, 2023
1 parent efb1b4a commit efc9ece
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions runtime/interpreter/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -2412,14 +2412,14 @@ func (v *ArrayValue) GetMember(interpreter *Interpreter, locationRange LocationR
},
)

case sema.ArrayTypeReversedFunctionName:
case sema.ArrayTypeReverseFunctionName:
return NewHostFunctionValue(
interpreter,
sema.ArrayReversedFunctionType(
sema.ArrayReverseFunctionType(
v.SemaType(interpreter).ElementType(false),
),
func(invocation Invocation) Value {
return v.Reversed(
return v.Reverse(
invocation.Interpreter,
invocation.LocationRange,
)
Expand Down Expand Up @@ -2884,7 +2884,7 @@ func (v *ArrayValue) Slice(
)
}

func (v *ArrayValue) Reversed(
func (v *ArrayValue) Reverse(
interpreter *Interpreter,
locationRange LocationRange,
) Value {
Expand Down
13 changes: 7 additions & 6 deletions runtime/sema/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -1788,10 +1788,11 @@ It does not modify the original array.
If either of the parameters are out of the bounds of the array, or the indices are invalid (` + "`from > upTo`" + `), then the function will fail.
`

const ArrayTypeReversedFunctionName = "reversed"
const ArrayTypeReverseFunctionName = "reverse"

const arrayTypeReversedFunctionDocString = `
const arrayTypeReverseFunctionDocString = `
Returns a new array with contents in the reversed order.
Available if the array element type is not resource-kinded.
`

func getArrayMembers(arrayType ArrayType) map[string]MemberResolver {
Expand Down Expand Up @@ -1887,7 +1888,7 @@ func getArrayMembers(arrayType ArrayType) map[string]MemberResolver {
)
},
},
ArrayTypeReversedFunctionName: {
ArrayTypeReverseFunctionName: {
Kind: common.DeclarationKindFunction,
Resolve: func(memoryGauge common.MemoryGauge, identifier string, targetRange ast.Range, report func(error)) *Member {
elementType := arrayType.ElementType(false)
Expand All @@ -1907,8 +1908,8 @@ func getArrayMembers(arrayType ArrayType) map[string]MemberResolver {
memoryGauge,
arrayType,
identifier,
ArrayReversedFunctionType(elementType),
arrayTypeReversedFunctionDocString,
ArrayReverseFunctionType(elementType),
arrayTypeReverseFunctionDocString,
)
},
},
Expand Down Expand Up @@ -2224,7 +2225,7 @@ func ArraySliceFunctionType(elementType Type) *FunctionType {
}
}

func ArrayReversedFunctionType(elementType Type) *FunctionType {
func ArrayReverseFunctionType(elementType Type) *FunctionType {
return &FunctionType{
Parameters: []Parameter{},
ReturnTypeAnnotation: NewTypeAnnotation(&VariableSizedType{
Expand Down

0 comments on commit efc9ece

Please sign in to comment.