aboutsummaryrefslogtreecommitdiff
path: root/BinaryEncoding.md
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2017-05-11 13:14:52 -0700
committerGitHub <noreply@github.com>2017-05-11 13:14:52 -0700
commitdfc0d5173bf376e5423f7037cb0bd291df5079b9 (patch)
tree6649a81692e08f8c613a524a2e0f9d8333f14c2d /BinaryEncoding.md
parenta8d95ac349a85794c5826bc642f1fbe300b8019b (diff)
downloadnanowasm-design-dfc0d5173bf376e5423f7037cb0bd291df5079b9.tar.gz
Add a module name to the name section (#1055)
It's additional name type (with code 0) alongside function and local names.
Diffstat (limited to 'BinaryEncoding.md')
-rw-r--r--BinaryEncoding.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/BinaryEncoding.md b/BinaryEncoding.md
index fba1976..465a8df 100644
--- a/BinaryEncoding.md
+++ b/BinaryEncoding.md
@@ -449,9 +449,11 @@ be skipped over by an engine. The current list of valid `name_type` codes are:
| Name Type | Code | Description |
| --------- | ---- | ----------- |
+| [Module](#module-name) | `0` | Assigns a name to the module |
| [Function](#function-names) | `1` | Assigns names to functions |
| [Local](#local-names) | `2` | Assigns names to locals in functions |
+
When present, name subsections must appear in this order and at most once. The
end of the last subsection must coincide with the last byte of the name
section to be a well-formed name section.
@@ -498,6 +500,16 @@ where a `local_name` is encoded as:
| index | `varuint32` | the index of the function whose locals are being named |
| local_map | `name_map` | assignment of names to local indices |
+#### Module name
+
+The module name subsection assigns a name to the module itself. It simply
+consists of a single string:
+
+| Field | Type | Description |
+| ----- | ---- | ----------- |
+| name_len | `varuint32` | length of `name_str` in bytes |
+| name_str | `bytes` | UTF-8 encoding of the name |
+
# Function Bodies
Function bodies consist of a sequence of local variable declarations followed by