From 0d1393dd3de17f2d5e982853582e322eb4f41a14 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Tue, 1 Mar 2016 17:16:03 -0600 Subject: Names section --- BinaryEncoding.md | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index a34e63c..b021753 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
bit `0` : a name is present
bit `1` : the function is an import
bit `2` : the function has local variables
bit `3` : the function is an export | +| flags | `uint8` | always | flags indicating attributes of a function
bit `1` : the function is an import
bit `2` : the function has local variables
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,42 @@ 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 | +### Function Names section + +ID: `function_names` + +| Field | Type | Description | +| ----- | ----- | ----- | +| names | `utf8-C-string*` | sequence of null-terminated utf8-encoded strings | + +The number of names is determined by the number of declared functions. The +sequence of names assigns a name to each function index. + +This section is optional and does not contribute to the semenatics of execution. +A validation error in this section is not reported and is treated as the section +being 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 in the [text format](TextFormat.md). + +### Local Names section + +ID: `local_names` + +| Field | Type | Description | +| ----- | ----- | ----- | +| names | `utf8-C-string*` | sequence of null-terminated utf8-encoded strings | + +The number of names is determined by the sum of all functions' number of locals. +The sequence of names is defined to be the concatentation of the sequence of +local names (ordered by local index) for each function (ordered by function index). +This sequence assigns a name to every local index in every function. + +This section is optional and does not contribute to the semenatics of execution. +A validation error in this section is not reported and is treated as the section +being 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 locals in the [text format](TextFormat.md). + ### End section ID: `end` -- cgit v1.2.3