diff options
| author | Luke Wagner <mail@lukewagner.name> | 2016-03-07 10:01:24 -0600 |
|---|---|---|
| committer | Luke Wagner <mail@lukewagner.name> | 2016-03-07 10:01:24 -0600 |
| commit | d7bde57191ed15a97e9b357b2c16fa908f25e680 (patch) | |
| tree | d3601669615c9466b572e22af0f3d2d14cc10a0e /BinaryEncoding.md | |
| parent | 30fdfe890aa6ad904238c16f0ee77d9d36877f6b (diff) | |
| parent | c08726cc0f25a0988277b3e1d7a0765fdf24f527 (diff) | |
| download | nanowasm-design-d7bde57191ed15a97e9b357b2c16fa908f25e680.tar.gz | |
Merge pull request #580 from WebAssembly/name-section
Names section
Diffstat (limited to 'BinaryEncoding.md')
| -rw-r--r-- | BinaryEncoding.md | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 71da872..09e65f5 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -165,9 +165,8 @@ must contain a function body. Imported and exported functions must have a name. | Field | Type | Present? | Description | | ----- | ----- | ----- | ----- | -| flags | `uint8` | always | flags indicating attributes of a function <br>bit `0` : a name is present<br>bit `1` : the function is an import<br>bit `2` : the function has local variables<br>bit `3` : the function is an export | +| flags | `uint8` | always | flags indicating attributes of a function <br>bit `1` : the function is an import<br>bit `2` : the function has local variables<br>bit `3` : the function is an export | | signature | `uint16` | always | index into the Signature section | -| name | `uint32` | `flags[0] == 1` | name of the function as an offset within the module | | body size | `uint16` | `flags[0] == 0` | size of function body to follow, in bytes | | body | `bytes` | `flags[0] == 0` | function body | @@ -234,6 +233,45 @@ This section must be preceded by a [Functions](#functions-section) section. | count | `varuint32` | count of entries to follow | | entries | `uint16*` | repeated indexes into the function table | +### Names section + +ID: `names` + +This section may occur 0 or 1 times and does not change execution semantics. A +validation error in this section does not cause validation for the whole module +to fail and is instead treated as if the section was absent. The expectation is +that, when a binary WebAssembly module is viewed in a browser or other +development environment, the names in this section will be used as the names of +functions and locals in the [text format](TextFormat.md). + +| Field | Type | Description | +| ----- | ----- | ----- | +| count | `varuint32` | count of entries to follow | +| entries | `function_names*` | sequence of names | + +The sequence of `function_name` assigns names to the corresponding +function index. The count may be greater or less than the actual number of +functions. + +#### Function names + +| Field | Type | Description | +| ----- | ----- | ----- | +| fun_name_len | `varuint32` | string length, in bytes | +| fun_name_str | `bytes` | valid utf8 encoding | +| local_count | `varuint32` | count of local names to follow | +| local_names | `local_name*` | sequence of local names | + +The sequence of `local_name` assigns names to the corresponding local index. The +count may be greater or less than the actual number of locals. + +#### Local name + +| Field | Type | Description | +| ----- | ----- | ----- | +| local_name_len | `varuint32` | string length, in bytes | +| local_name_str | `bytes` | valid utf8 encoding | + ### End section ID: `end` |
