@grain/stdlib 0.6.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +123 -77
- package/bigint.md +30 -30
- package/buffer.gr +20 -53
- package/buffer.md +47 -47
- package/bytes.gr +111 -35
- package/bytes.md +111 -32
- package/char.gr +201 -99
- package/char.md +361 -34
- package/exception.gr +11 -11
- package/exception.md +26 -1
- package/float32.gr +327 -3
- package/float32.md +606 -19
- package/float64.gr +320 -3
- package/float64.md +606 -19
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +102 -14
- package/int16.md +23 -23
- package/int32.gr +25 -4
- package/int32.md +65 -30
- package/int64.gr +26 -1
- package/int64.md +65 -30
- package/int8.md +23 -23
- package/json.gr +366 -51
- package/json.md +418 -2
- package/list.gr +328 -31
- package/list.md +492 -69
- package/map.gr +20 -12
- package/map.md +44 -38
- package/marshal.gr +41 -40
- package/marshal.md +2 -2
- package/number.gr +159 -30
- package/number.md +215 -38
- package/option.md +21 -21
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +103 -12
- package/pervasives.gr +2 -2
- package/pervasives.md +37 -37
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +19 -19
- package/queue.gr +183 -29
- package/queue.md +296 -40
- package/random.md +6 -6
- package/range.gr +4 -4
- package/range.md +6 -6
- package/rational.md +16 -16
- package/regex.gr +52 -51
- package/regex.md +11 -11
- package/result.md +16 -16
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +8 -8
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +1 -1
- package/runtime/dataStructures.md +33 -33
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +1 -1
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +4 -4
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +79 -73
- package/runtime/string.gr +37 -105
- package/runtime/string.md +3 -9
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +13 -13
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +138 -138
- package/set.gr +18 -11
- package/set.md +42 -36
- package/stack.gr +171 -2
- package/stack.md +297 -15
- package/string.gr +352 -557
- package/string.md +77 -34
- package/uint16.md +22 -22
- package/uint32.gr +25 -4
- package/uint32.md +63 -28
- package/uint64.gr +25 -5
- package/uint64.md +63 -28
- package/uint8.md +22 -22
- package/uri.gr +57 -53
- package/uri.md +11 -12
- package/wasi/file.gr +67 -59
- package/wasi/file.md +39 -39
- package/wasi/process.md +5 -5
- package/wasi/random.md +3 -3
- package/wasi/time.md +4 -4
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/wasi/file.md
CHANGED
|
@@ -509,7 +509,7 @@ Functions and constants included in the File module.
|
|
|
509
509
|
### File.**stdin**
|
|
510
510
|
|
|
511
511
|
```grain
|
|
512
|
-
stdin
|
|
512
|
+
stdin: FileDescriptor
|
|
513
513
|
```
|
|
514
514
|
|
|
515
515
|
The `FileDescriptor` for `stdin`.
|
|
@@ -517,7 +517,7 @@ The `FileDescriptor` for `stdin`.
|
|
|
517
517
|
### File.**stdout**
|
|
518
518
|
|
|
519
519
|
```grain
|
|
520
|
-
stdout
|
|
520
|
+
stdout: FileDescriptor
|
|
521
521
|
```
|
|
522
522
|
|
|
523
523
|
The `FileDescriptor` for `stdout`.
|
|
@@ -525,7 +525,7 @@ The `FileDescriptor` for `stdout`.
|
|
|
525
525
|
### File.**stderr**
|
|
526
526
|
|
|
527
527
|
```grain
|
|
528
|
-
stderr
|
|
528
|
+
stderr: FileDescriptor
|
|
529
529
|
```
|
|
530
530
|
|
|
531
531
|
The `FileDescriptor` for `stderr`.
|
|
@@ -533,7 +533,7 @@ The `FileDescriptor` for `stderr`.
|
|
|
533
533
|
### File.**pathOpen**
|
|
534
534
|
|
|
535
535
|
```grain
|
|
536
|
-
pathOpen
|
|
536
|
+
pathOpen:
|
|
537
537
|
(dirFd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
|
|
538
538
|
openFlags: List<OpenFlag>, rights: List<Rights>,
|
|
539
539
|
rightsInheriting: List<Rights>, flags: List<FdFlag>) =>
|
|
@@ -563,7 +563,7 @@ Returns:
|
|
|
563
563
|
### File.**fdRead**
|
|
564
564
|
|
|
565
565
|
```grain
|
|
566
|
-
fdRead
|
|
566
|
+
fdRead:
|
|
567
567
|
(fd: FileDescriptor, size: Number) => Result<(Bytes, Number), Exception>
|
|
568
568
|
```
|
|
569
569
|
|
|
@@ -585,7 +585,7 @@ Returns:
|
|
|
585
585
|
### File.**fdPread**
|
|
586
586
|
|
|
587
587
|
```grain
|
|
588
|
-
fdPread
|
|
588
|
+
fdPread:
|
|
589
589
|
(fd: FileDescriptor, offset: Int64, size: Number) =>
|
|
590
590
|
Result<(Bytes, Number), Exception>
|
|
591
591
|
```
|
|
@@ -614,7 +614,7 @@ No other changes yet.
|
|
|
614
614
|
</details>
|
|
615
615
|
|
|
616
616
|
```grain
|
|
617
|
-
fdPrestatGet
|
|
617
|
+
fdPrestatGet: (fd: FileDescriptor) => Result<Prestat, Exception>
|
|
618
618
|
```
|
|
619
619
|
|
|
620
620
|
Get information about a preopened directory.
|
|
@@ -634,7 +634,7 @@ Returns:
|
|
|
634
634
|
### File.**fdWrite**
|
|
635
635
|
|
|
636
636
|
```grain
|
|
637
|
-
fdWrite
|
|
637
|
+
fdWrite: (fd: FileDescriptor, data: Bytes) => Result<Number, Exception>
|
|
638
638
|
```
|
|
639
639
|
|
|
640
640
|
Write to a file descriptor.
|
|
@@ -655,7 +655,7 @@ Returns:
|
|
|
655
655
|
### File.**fdPwrite**
|
|
656
656
|
|
|
657
657
|
```grain
|
|
658
|
-
fdPwrite
|
|
658
|
+
fdPwrite:
|
|
659
659
|
(fd: FileDescriptor, data: Bytes, offset: Int64) =>
|
|
660
660
|
Result<Number, Exception>
|
|
661
661
|
```
|
|
@@ -679,7 +679,7 @@ Returns:
|
|
|
679
679
|
### File.**fdAllocate**
|
|
680
680
|
|
|
681
681
|
```grain
|
|
682
|
-
fdAllocate
|
|
682
|
+
fdAllocate:
|
|
683
683
|
(fd: FileDescriptor, offset: Int64, size: Int64) => Result<Void, Exception>
|
|
684
684
|
```
|
|
685
685
|
|
|
@@ -702,7 +702,7 @@ Returns:
|
|
|
702
702
|
### File.**fdClose**
|
|
703
703
|
|
|
704
704
|
```grain
|
|
705
|
-
fdClose
|
|
705
|
+
fdClose: (fd: FileDescriptor) => Result<Void, Exception>
|
|
706
706
|
```
|
|
707
707
|
|
|
708
708
|
Close a file descriptor.
|
|
@@ -722,7 +722,7 @@ Returns:
|
|
|
722
722
|
### File.**fdDatasync**
|
|
723
723
|
|
|
724
724
|
```grain
|
|
725
|
-
fdDatasync
|
|
725
|
+
fdDatasync: (fd: FileDescriptor) => Result<Void, Exception>
|
|
726
726
|
```
|
|
727
727
|
|
|
728
728
|
Synchronize the data of a file to disk.
|
|
@@ -742,7 +742,7 @@ Returns:
|
|
|
742
742
|
### File.**fdSync**
|
|
743
743
|
|
|
744
744
|
```grain
|
|
745
|
-
fdSync
|
|
745
|
+
fdSync: (fd: FileDescriptor) => Result<Void, Exception>
|
|
746
746
|
```
|
|
747
747
|
|
|
748
748
|
Synchronize the data and metadata of a file to disk.
|
|
@@ -762,7 +762,7 @@ Returns:
|
|
|
762
762
|
### File.**fdStats**
|
|
763
763
|
|
|
764
764
|
```grain
|
|
765
|
-
fdStats
|
|
765
|
+
fdStats: (fd: FileDescriptor) => Result<Stats, Exception>
|
|
766
766
|
```
|
|
767
767
|
|
|
768
768
|
Retrieve information about a file descriptor.
|
|
@@ -782,7 +782,7 @@ Returns:
|
|
|
782
782
|
### File.**fdSetFlags**
|
|
783
783
|
|
|
784
784
|
```grain
|
|
785
|
-
fdSetFlags
|
|
785
|
+
fdSetFlags:
|
|
786
786
|
(fd: FileDescriptor, flags: List<FdFlag>) => Result<Void, Exception>
|
|
787
787
|
```
|
|
788
788
|
|
|
@@ -804,7 +804,7 @@ Returns:
|
|
|
804
804
|
### File.**fdSetRights**
|
|
805
805
|
|
|
806
806
|
```grain
|
|
807
|
-
fdSetRights
|
|
807
|
+
fdSetRights:
|
|
808
808
|
(fd: FileDescriptor, rights: List<Rights>, rightsInheriting: List<Rights>) =>
|
|
809
809
|
Result<Void, Exception>
|
|
810
810
|
```
|
|
@@ -828,7 +828,7 @@ Returns:
|
|
|
828
828
|
### File.**fdFilestats**
|
|
829
829
|
|
|
830
830
|
```grain
|
|
831
|
-
fdFilestats
|
|
831
|
+
fdFilestats: (fd: FileDescriptor) => Result<Filestats, Exception>
|
|
832
832
|
```
|
|
833
833
|
|
|
834
834
|
Retrieve information about a file.
|
|
@@ -848,7 +848,7 @@ Returns:
|
|
|
848
848
|
### File.**fdSetSize**
|
|
849
849
|
|
|
850
850
|
```grain
|
|
851
|
-
fdSetSize
|
|
851
|
+
fdSetSize: (fd: FileDescriptor, size: Int64) => Result<Void, Exception>
|
|
852
852
|
```
|
|
853
853
|
|
|
854
854
|
Set (truncate) the size of a file.
|
|
@@ -869,7 +869,7 @@ Returns:
|
|
|
869
869
|
### File.**fdSetAccessTime**
|
|
870
870
|
|
|
871
871
|
```grain
|
|
872
|
-
fdSetAccessTime
|
|
872
|
+
fdSetAccessTime:
|
|
873
873
|
(fd: FileDescriptor, timestamp: Int64) => Result<Void, Exception>
|
|
874
874
|
```
|
|
875
875
|
|
|
@@ -891,7 +891,7 @@ Returns:
|
|
|
891
891
|
### File.**fdSetAccessTimeNow**
|
|
892
892
|
|
|
893
893
|
```grain
|
|
894
|
-
fdSetAccessTimeNow
|
|
894
|
+
fdSetAccessTimeNow: (fd: FileDescriptor) => Result<Void, Exception>
|
|
895
895
|
```
|
|
896
896
|
|
|
897
897
|
Set the access (created) time of a file to the current time.
|
|
@@ -911,7 +911,7 @@ Returns:
|
|
|
911
911
|
### File.**fdSetModifiedTime**
|
|
912
912
|
|
|
913
913
|
```grain
|
|
914
|
-
fdSetModifiedTime
|
|
914
|
+
fdSetModifiedTime:
|
|
915
915
|
(fd: FileDescriptor, timestamp: Int64) => Result<Void, Exception>
|
|
916
916
|
```
|
|
917
917
|
|
|
@@ -933,7 +933,7 @@ Returns:
|
|
|
933
933
|
### File.**fdSetModifiedTimeNow**
|
|
934
934
|
|
|
935
935
|
```grain
|
|
936
|
-
fdSetModifiedTimeNow
|
|
936
|
+
fdSetModifiedTimeNow: (fd: FileDescriptor) => Result<Void, Exception>
|
|
937
937
|
```
|
|
938
938
|
|
|
939
939
|
Set the modified time of a file to the current time.
|
|
@@ -953,7 +953,7 @@ Returns:
|
|
|
953
953
|
### File.**fdReaddir**
|
|
954
954
|
|
|
955
955
|
```grain
|
|
956
|
-
fdReaddir
|
|
956
|
+
fdReaddir: (fd: FileDescriptor) => Result<Array<DirectoryEntry>, Exception>
|
|
957
957
|
```
|
|
958
958
|
|
|
959
959
|
Read the entires of a directory.
|
|
@@ -973,7 +973,7 @@ Returns:
|
|
|
973
973
|
### File.**fdRenumber**
|
|
974
974
|
|
|
975
975
|
```grain
|
|
976
|
-
fdRenumber
|
|
976
|
+
fdRenumber:
|
|
977
977
|
(fromFd: FileDescriptor, toFd: FileDescriptor) => Result<Void, Exception>
|
|
978
978
|
```
|
|
979
979
|
|
|
@@ -995,7 +995,7 @@ Returns:
|
|
|
995
995
|
### File.**fdSeek**
|
|
996
996
|
|
|
997
997
|
```grain
|
|
998
|
-
fdSeek
|
|
998
|
+
fdSeek:
|
|
999
999
|
(fd: FileDescriptor, offset: Int64, whence: Whence) =>
|
|
1000
1000
|
Result<Int64, Exception>
|
|
1001
1001
|
```
|
|
@@ -1019,7 +1019,7 @@ Returns:
|
|
|
1019
1019
|
### File.**fdTell**
|
|
1020
1020
|
|
|
1021
1021
|
```grain
|
|
1022
|
-
fdTell
|
|
1022
|
+
fdTell: (fd: FileDescriptor) => Result<Int64, Exception>
|
|
1023
1023
|
```
|
|
1024
1024
|
|
|
1025
1025
|
Read a file descriptor's offset.
|
|
@@ -1039,7 +1039,7 @@ Returns:
|
|
|
1039
1039
|
### File.**pathCreateDirectory**
|
|
1040
1040
|
|
|
1041
1041
|
```grain
|
|
1042
|
-
pathCreateDirectory
|
|
1042
|
+
pathCreateDirectory:
|
|
1043
1043
|
(fd: FileDescriptor, path: String) => Result<Void, Exception>
|
|
1044
1044
|
```
|
|
1045
1045
|
|
|
@@ -1061,7 +1061,7 @@ Returns:
|
|
|
1061
1061
|
### File.**pathFilestats**
|
|
1062
1062
|
|
|
1063
1063
|
```grain
|
|
1064
|
-
pathFilestats
|
|
1064
|
+
pathFilestats:
|
|
1065
1065
|
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
|
|
1066
1066
|
Result<Filestats, Exception>
|
|
1067
1067
|
```
|
|
@@ -1085,7 +1085,7 @@ Returns:
|
|
|
1085
1085
|
### File.**pathSetAccessTime**
|
|
1086
1086
|
|
|
1087
1087
|
```grain
|
|
1088
|
-
pathSetAccessTime
|
|
1088
|
+
pathSetAccessTime:
|
|
1089
1089
|
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
|
|
1090
1090
|
timestamp: Int64) => Result<Void, Exception>
|
|
1091
1091
|
```
|
|
@@ -1110,7 +1110,7 @@ Returns:
|
|
|
1110
1110
|
### File.**pathSetAccessTimeNow**
|
|
1111
1111
|
|
|
1112
1112
|
```grain
|
|
1113
|
-
pathSetAccessTimeNow
|
|
1113
|
+
pathSetAccessTimeNow:
|
|
1114
1114
|
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
|
|
1115
1115
|
Result<Void, Exception>
|
|
1116
1116
|
```
|
|
@@ -1134,7 +1134,7 @@ Returns:
|
|
|
1134
1134
|
### File.**pathSetModifiedTime**
|
|
1135
1135
|
|
|
1136
1136
|
```grain
|
|
1137
|
-
pathSetModifiedTime
|
|
1137
|
+
pathSetModifiedTime:
|
|
1138
1138
|
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
|
|
1139
1139
|
timestamp: Int64) => Result<Void, Exception>
|
|
1140
1140
|
```
|
|
@@ -1159,7 +1159,7 @@ Returns:
|
|
|
1159
1159
|
### File.**pathSetModifiedTimeNow**
|
|
1160
1160
|
|
|
1161
1161
|
```grain
|
|
1162
|
-
pathSetModifiedTimeNow
|
|
1162
|
+
pathSetModifiedTimeNow:
|
|
1163
1163
|
(fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
|
|
1164
1164
|
Result<Void, Exception>
|
|
1165
1165
|
```
|
|
@@ -1183,7 +1183,7 @@ Returns:
|
|
|
1183
1183
|
### File.**pathLink**
|
|
1184
1184
|
|
|
1185
1185
|
```grain
|
|
1186
|
-
pathLink
|
|
1186
|
+
pathLink:
|
|
1187
1187
|
(sourceFd: FileDescriptor, dirFlags: List<LookupFlag>, sourcePath:
|
|
1188
1188
|
String, targetFd: FileDescriptor, targetPath: String) =>
|
|
1189
1189
|
Result<Void, Exception>
|
|
@@ -1210,7 +1210,7 @@ Returns:
|
|
|
1210
1210
|
### File.**pathSymlink**
|
|
1211
1211
|
|
|
1212
1212
|
```grain
|
|
1213
|
-
pathSymlink
|
|
1213
|
+
pathSymlink:
|
|
1214
1214
|
(fd: FileDescriptor, sourcePath: String, targetPath: String) =>
|
|
1215
1215
|
Result<Void, Exception>
|
|
1216
1216
|
```
|
|
@@ -1234,7 +1234,7 @@ Returns:
|
|
|
1234
1234
|
### File.**pathUnlink**
|
|
1235
1235
|
|
|
1236
1236
|
```grain
|
|
1237
|
-
pathUnlink
|
|
1237
|
+
pathUnlink: (fd: FileDescriptor, path: String) => Result<Void, Exception>
|
|
1238
1238
|
```
|
|
1239
1239
|
|
|
1240
1240
|
Unlink a file.
|
|
@@ -1255,7 +1255,7 @@ Returns:
|
|
|
1255
1255
|
### File.**pathReadlink**
|
|
1256
1256
|
|
|
1257
1257
|
```grain
|
|
1258
|
-
pathReadlink
|
|
1258
|
+
pathReadlink:
|
|
1259
1259
|
(fd: FileDescriptor, path: String, size: Number) =>
|
|
1260
1260
|
Result<(String, Number), Exception>
|
|
1261
1261
|
```
|
|
@@ -1279,7 +1279,7 @@ Returns:
|
|
|
1279
1279
|
### File.**pathRemoveDirectory**
|
|
1280
1280
|
|
|
1281
1281
|
```grain
|
|
1282
|
-
pathRemoveDirectory
|
|
1282
|
+
pathRemoveDirectory:
|
|
1283
1283
|
(fd: FileDescriptor, path: String) => Result<Void, Exception>
|
|
1284
1284
|
```
|
|
1285
1285
|
|
|
@@ -1301,7 +1301,7 @@ Returns:
|
|
|
1301
1301
|
### File.**pathRename**
|
|
1302
1302
|
|
|
1303
1303
|
```grain
|
|
1304
|
-
pathRename
|
|
1304
|
+
pathRename:
|
|
1305
1305
|
(sourceFd: FileDescriptor, sourcePath: String, targetFd: FileDescriptor,
|
|
1306
1306
|
targetPath: String) => Result<Void, Exception>
|
|
1307
1307
|
```
|
|
@@ -1331,7 +1331,7 @@ No other changes yet.
|
|
|
1331
1331
|
</details>
|
|
1332
1332
|
|
|
1333
1333
|
```grain
|
|
1334
|
-
open
|
|
1334
|
+
open:
|
|
1335
1335
|
(path: String, openFlags: List<OpenFlag>, rights: List<Rights>,
|
|
1336
1336
|
rightsInheriting: List<Rights>, flags: List<FdFlag>) =>
|
|
1337
1337
|
Result<FileDescriptor, Exception>
|
package/wasi/process.md
CHANGED
|
@@ -218,7 +218,7 @@ Functions and constants included in the Process module.
|
|
|
218
218
|
### Process.**argv**
|
|
219
219
|
|
|
220
220
|
```grain
|
|
221
|
-
argv
|
|
221
|
+
argv: () => Result<Array<String>, Exception>
|
|
222
222
|
```
|
|
223
223
|
|
|
224
224
|
Access command line arguments.
|
|
@@ -232,7 +232,7 @@ Returns:
|
|
|
232
232
|
### Process.**env**
|
|
233
233
|
|
|
234
234
|
```grain
|
|
235
|
-
env
|
|
235
|
+
env: () => Result<Array<String>, Exception>
|
|
236
236
|
```
|
|
237
237
|
|
|
238
238
|
Access environment variables.
|
|
@@ -246,7 +246,7 @@ Returns:
|
|
|
246
246
|
### Process.**exit**
|
|
247
247
|
|
|
248
248
|
```grain
|
|
249
|
-
exit
|
|
249
|
+
exit: (code: Number) => Result<Void, Exception>
|
|
250
250
|
```
|
|
251
251
|
|
|
252
252
|
Terminate the process normally.
|
|
@@ -266,7 +266,7 @@ Returns:
|
|
|
266
266
|
### Process.**sigRaise**
|
|
267
267
|
|
|
268
268
|
```grain
|
|
269
|
-
sigRaise
|
|
269
|
+
sigRaise: (signal: Signal) => Result<Void, Exception>
|
|
270
270
|
```
|
|
271
271
|
|
|
272
272
|
Send a signal to the process of the calling thread.
|
|
@@ -286,7 +286,7 @@ Returns:
|
|
|
286
286
|
### Process.**schedYield**
|
|
287
287
|
|
|
288
288
|
```grain
|
|
289
|
-
schedYield
|
|
289
|
+
schedYield: () => Result<Void, Exception>
|
|
290
290
|
```
|
|
291
291
|
|
|
292
292
|
Yield execution to the calling thread.
|
package/wasi/random.md
CHANGED
|
@@ -27,7 +27,7 @@ Functions and constants included in the Random module.
|
|
|
27
27
|
</details>
|
|
28
28
|
|
|
29
29
|
```grain
|
|
30
|
-
randomUint32
|
|
30
|
+
randomUint32: () => Result<Uint32, Exception>
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
Produce a random 32-bit integer. This function can be slow, so it's best to seed a generator if lots of random data is needed.
|
|
@@ -53,7 +53,7 @@ Returns:
|
|
|
53
53
|
</details>
|
|
54
54
|
|
|
55
55
|
```grain
|
|
56
|
-
randomUint64
|
|
56
|
+
randomUint64: () => Result<Uint64, Exception>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
Produce a random 64-bit integer. This function can be slow, so it's best to seed a generator if lots of random data is needed.
|
|
@@ -67,7 +67,7 @@ Returns:
|
|
|
67
67
|
### Random.**random**
|
|
68
68
|
|
|
69
69
|
```grain
|
|
70
|
-
random
|
|
70
|
+
random: () => Result<Number, Exception>
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
Produce a random number. This function can be slow, so it's best to seed a generator if lots of random data is needed.
|
package/wasi/time.md
CHANGED
|
@@ -15,7 +15,7 @@ Functions and constants included in the Time module.
|
|
|
15
15
|
### Time.**realTime**
|
|
16
16
|
|
|
17
17
|
```grain
|
|
18
|
-
realTime
|
|
18
|
+
realTime: () => Result<Int64, Exception>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Get the current time, in nanoseconds.
|
|
@@ -30,7 +30,7 @@ Returns:
|
|
|
30
30
|
### Time.**monotonicTime**
|
|
31
31
|
|
|
32
32
|
```grain
|
|
33
|
-
monotonicTime
|
|
33
|
+
monotonicTime: () => Result<Int64, Exception>
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
Get the time of the system's high-resolution clock, in nanoseconds.
|
|
@@ -47,7 +47,7 @@ Returns:
|
|
|
47
47
|
### Time.**processCpuTime**
|
|
48
48
|
|
|
49
49
|
```grain
|
|
50
|
-
processCpuTime
|
|
50
|
+
processCpuTime: () => Result<Int64, Exception>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
Get the number of nanoseconds elapsed since the process began.
|
|
@@ -61,7 +61,7 @@ Returns:
|
|
|
61
61
|
### Time.**threadCpuTime**
|
|
62
62
|
|
|
63
63
|
```grain
|
|
64
|
-
threadCpuTime
|
|
64
|
+
threadCpuTime: () => Result<Int64, Exception>
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Get the number of nanoseconds elapsed since the thread began.
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
@noPervasives
|
|
2
|
-
module Printing
|
|
3
|
-
|
|
4
|
-
// Printing utilities for runtime code (primarily for debugging)
|
|
5
|
-
from "runtime/unsafe/wasmi32" include WasmI32
|
|
6
|
-
from "runtime/unsafe/memory" include Memory
|
|
7
|
-
from "runtime/numberUtils" include NumberUtils
|
|
8
|
-
|
|
9
|
-
foreign wasm fd_write:
|
|
10
|
-
(WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "wasi_snapshot_preview1"
|
|
11
|
-
|
|
12
|
-
@unsafe
|
|
13
|
-
provide let numberToString = (n: WasmI64) => {
|
|
14
|
-
NumberUtils.itoa64(n, 10n)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@unsafe
|
|
18
|
-
provide let printNumber = (n: WasmI64) => {
|
|
19
|
-
// like print(), but `s` should be a Grain string
|
|
20
|
-
use WasmI32.{ (+) }
|
|
21
|
-
let s = numberToString(n)
|
|
22
|
-
let ptr = WasmI32.fromGrain(s)
|
|
23
|
-
// iov: [<ptr to string> <nbytes of string> <ptr to newline> <nbytes of newline>] (32 bytes)
|
|
24
|
-
// buf: <iov> <written> <newline char>
|
|
25
|
-
// fd_write(STDOUT (1), iov, len(iov), written)
|
|
26
|
-
let buf = Memory.malloc(37n)
|
|
27
|
-
let iov = buf
|
|
28
|
-
let written = buf + 32n
|
|
29
|
-
let lf = buf + 36n
|
|
30
|
-
WasmI32.store(iov, ptr + 8n, 0n)
|
|
31
|
-
WasmI32.store(iov, WasmI32.load(ptr, 4n), 4n)
|
|
32
|
-
WasmI32.store8(lf, 10n, 0n)
|
|
33
|
-
WasmI32.store(iov, lf, 8n)
|
|
34
|
-
WasmI32.store(iov, 1n, 12n)
|
|
35
|
-
fd_write(1n, iov, 2n, written)
|
|
36
|
-
Memory.free(buf)
|
|
37
|
-
void
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@unsafe
|
|
41
|
-
provide let printString = (s: String) => {
|
|
42
|
-
// like print(), but `s` should be a Grain string
|
|
43
|
-
use WasmI32.{ (+) }
|
|
44
|
-
let ptr = WasmI32.fromGrain(s)
|
|
45
|
-
// iov: [<ptr to string> <nbytes of string> <ptr to newline> <nbytes of newline>] (32 bytes)
|
|
46
|
-
// buf: <iov> <written> <newline char>
|
|
47
|
-
// fd_write(STDOUT (1), iov, len(iov), written)
|
|
48
|
-
let buf = Memory.malloc(37n)
|
|
49
|
-
let iov = buf
|
|
50
|
-
let written = buf + 32n
|
|
51
|
-
let lf = buf + 36n
|
|
52
|
-
WasmI32.store(iov, ptr + 8n, 0n)
|
|
53
|
-
WasmI32.store(iov, WasmI32.load(ptr, 4n), 4n)
|
|
54
|
-
WasmI32.store8(lf, 10n, 0n)
|
|
55
|
-
WasmI32.store(iov, lf, 8n)
|
|
56
|
-
WasmI32.store(iov, 1n, 12n)
|
|
57
|
-
fd_write(1n, iov, 2n, written)
|
|
58
|
-
Memory.free(buf)
|
|
59
|
-
void
|
|
60
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Printing
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## Values
|
|
6
|
-
|
|
7
|
-
Functions and constants included in the Printing module.
|
|
8
|
-
|
|
9
|
-
### Printing.**numberToString**
|
|
10
|
-
|
|
11
|
-
```grain
|
|
12
|
-
numberToString : (n: WasmI64) => String
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Printing.**printNumber**
|
|
16
|
-
|
|
17
|
-
```grain
|
|
18
|
-
printNumber : (n: WasmI64) => Void
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Printing.**printString**
|
|
22
|
-
|
|
23
|
-
```grain
|
|
24
|
-
printString : (s: String) => Void
|
|
25
|
-
```
|
|
26
|
-
|