Add array.reverse(array) and strings.reverse(string) built-in functions. (#4161)

The function `array.reverse` takes an array as an argument, and returns an array with a reversed order of elements.
The function `strings.reverse` takes a string as an argument, and returns a string with a reversed order of unicode code points.
WASM support is included for both built-ins.

Fixes #3736

Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
This commit is contained in:
Kristian Svalland
2021-12-27 12:47:39 +01:00
committed by GitHub
parent 328ffcd40a
commit 6f81c4a620
13 changed files with 280 additions and 0 deletions
+34
View File
@@ -123,6 +123,26 @@
"type": "function"
}
},
{
"name": "array.reverse",
"decl": {
"args": [
{
"dynamic": {
"type": "any"
},
"type": "array"
}
],
"result": {
"dynamic": {
"type": "any"
},
"type": "array"
},
"type": "function"
}
},
{
"name": "array.slice",
"decl": {
@@ -2979,6 +2999,20 @@
"type": "function"
}
},
{
"name": "strings.reverse",
"decl": {
"args": [
{
"type": "string"
}
],
"result": {
"type": "string"
},
"type": "function"
}
},
{
"name": "substring",
"decl": {