@@ -191,7 +191,8 @@ Except when specified otherwise, all values are encoded in
191
191
### Additional Encoding Types
192
192
193
193
0 . [ Array] ( #array )
194
- 0 . [ String] ( #string )
194
+ 0 . [ Byte Sequence] ( #byte-sequence )
195
+ 0 . [ Identifier] ( #identifier )
195
196
196
197
#### Array
197
198
@@ -200,12 +201,20 @@ followed by a sequence of that many elements of that type.
200
201
201
202
> Array elements needn't all be the same size in some representations.
202
203
203
- #### String
204
+ #### Byte Sequence
204
205
205
- A * string * is an [ array] of bytes.
206
+ A * byte sequence * is an [ array] of bytes.
206
207
207
- > Strings in this context may contain arbitrary bytes and aren't required to be
208
- valid UTF-8 or any other format, and aren't required to be NUL-terminated.
208
+ > Byte sequences may contain arbitrary bytes and aren't required to be
209
+ [ valid UTF-8] or any other format.
210
+
211
+ #### Identifier
212
+
213
+ An * identifier* is a [ byte sequence] which is [ valid UTF-8] .
214
+
215
+ > Identifiers may contain NUL characters, aren't required to be NUL-terminated,
216
+ aren't required to be normalized, and aren't required to be marked with a BOM
217
+ (though they aren't prohibited from containing a BOM).
209
218
210
219
### Value Types
211
220
@@ -358,8 +367,8 @@ initializers.
358
367
359
368
Modules contain a version [ varuint32] .
360
369
361
- Modules also contain a sequence of sections. Each section has a [ string ] * name *
362
- and associated data.
370
+ Modules also contain a sequence of sections. Each section has an [ identifier ]
371
+ * name * and associated data.
363
372
364
373
** Validation:**
365
374
- The version index is required to be equal to ` 0xc ` .
@@ -435,8 +444,8 @@ An *import* consists of:
435
444
436
445
| Field Name | Type | Description |
437
446
| --------------- | -------------------- | ---------------------------------------- |
438
- | ` module_name ` | [ string ] | the name of the module to import from |
439
- | ` export_name ` | [ string ] | the name of the export in that module |
447
+ | ` module_name ` | [ identifier ] | the name of the module to import from |
448
+ | ` export_name ` | [ identifier ] | the name of the export in that module |
440
449
| ` kind ` | [ external kind] | the kind of import |
441
450
442
451
If ` kind ` is ` Function ` , the following fields are appended.
@@ -566,7 +575,7 @@ An *export* consists of:
566
575
567
576
| Field Name | Type | Description |
568
577
| --------------- | ------------------ | --------------------------------------- |
569
- | ` name ` | [ string ] | field name |
578
+ | ` name ` | [ identifier ] | field name |
570
579
| ` kind ` | [ external kind] | the kind of export |
571
580
| ` index ` | [ varuint32] | an index into an [ index space] |
572
581
@@ -677,7 +686,7 @@ A *data initializer* consists of:
677
686
| --------------- | -------------------------------- | --------------------------------------------------- |
678
687
| ` index ` | [ varuint32] | a [ linear memory index] ( #linear-memory-index-space ) |
679
688
| ` offset ` | [ instantiation-time initializer] | the index of the byte in memory to start at |
680
- | ` data ` | [ string ] | data to initialize the contents of linear memory |
689
+ | ` data ` | [ byte sequence ] | data to initialize the contents of linear memory |
681
690
682
691
It describes data to be loaded into the linear memory identified by the index in
683
692
the [ linear-memory index space] during
@@ -702,8 +711,8 @@ the [linear-memory index space] during
702
711
The Names Section consists of an [ array] of function name descriptors, which
703
712
each describe names for the function with the corresponding index in the
704
713
[ function index space] and which consist of:
705
- - the function name, a [ string ] .
706
- - the names of the locals in the function, an [ array] of [ strings ] .
714
+ - the function name, an [ identifier ] .
715
+ - the names of the locals in the function, an [ array] of [ identifiers ] .
707
716
708
717
The Names Section doesn't change execution semantics and malformed constructs,
709
718
such as out-of-bounds indices, in this section cause the section to be ignored,
@@ -718,11 +727,6 @@ human-readable format in a browser or other development environment, the names
718
727
in this section are to be used as the names of functions and locals in the
719
728
[ text format] .
720
729
721
- TODO: Should the names in this section be required to be valid UTF-8 strings?
722
- This section isn't used during normal validation or execution, so it's off the
723
- "hot path" and is only used during debugging, to present strings to humans, so
724
- it might make sense.
725
-
726
730
### Module Index Spaces
727
731
728
732
Module Index Spaces are abstract mappings from indices, starting from zero, to
@@ -2664,8 +2668,9 @@ being the value of the linear-memory space's initial size field is created,
2664
2668
added to the instance, and initialized to all zeros. For a linear-memory import,
2665
2669
storage for the array is already allocated.
2666
2670
2667
- The contents of the [ Data Section] are loaded into the byte array. Each [ string]
2668
- is loaded into linear memory starting at its associated start offset value.
2671
+ The contents of the [ Data Section] are loaded into the byte array. Each
2672
+ [ byte sequence] is loaded into linear memory starting at its associated start
2673
+ offset value.
2669
2674
2670
2675
** Trap:** Dynamic Resource Exhaustion, if dynamic resources are insufficient to
2671
2676
support creation of the array.
@@ -2863,11 +2868,14 @@ TODO: Figure out what to say about the text format.
2863
2868
[ boolean ] : #booleans
2864
2869
[ byte ] : #bytes
2865
2870
[ bytes ] : #bytes
2871
+ [ byte sequence ] : #byte-sequence
2866
2872
[ call-stack resources ] : #call-stack-resources
2867
2873
[ effective address ] : #effective-address
2868
2874
[ external kind] : #external-kinds)
2869
2875
[ false ] : #booleans
2870
2876
[ Floor and Ceiling Functions ] : https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
2877
+ [ identifier ] : #identifier
2878
+ [ identifiers ] : #identifier
2871
2879
[ index space ] : #module-index-spaces
2872
2880
[ instantiation-time initializer ] : #instantiation-time-initializers
2873
2881
[ KiB ] : https://en.wikipedia.org/wiki/Kibibyte
@@ -2888,8 +2896,6 @@ TODO: Figure out what to say about the text format.
2888
2896
[ shifted ] : https://en.wikipedia.org/wiki/Logical_shift
2889
2897
[ sign-extended ] : https://en.wikipedia.org/wiki/Sign_extension
2890
2898
[ signature kind ] : #signature-kinds
2891
- [ string ] : #string
2892
- [ strings ] : #string
2893
2899
[ table ] : #tables
2894
2900
[ table element type ] : #table-element-type
2895
2901
[ text format ] : #text-format
@@ -2904,6 +2910,7 @@ TODO: Figure out what to say about the text format.
2904
2910
[ two's complement sum ] : https://en.wikipedia.org/wiki/Two%27s_complement#Addition
2905
2911
[ value type ] : #value-types
2906
2912
[ uint32 ] : #primitive-type-encodings
2913
+ [ valid UTF-8 ] : https://encoding.spec.whatwg.org/#utf-8-decode-without-bom-or-fail
2907
2914
[ varuint1 ] : #primitive-type-encodings
2908
2915
[ varuint7 ] : #primitive-type-encodings
2909
2916
[ varuint32 ] : #primitive-type-encodings
0 commit comments