Skip to content

Commit

Permalink
Prettify section names (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
rossberg authored and Luke Wagner committed Apr 28, 2016
1 parent 90c9301 commit 67c25af
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions BinaryEncoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,42 +94,42 @@ Each section is optional and may appear at most once.
Known sections (from this list) may not appear out of order.
The content of each section is encoded in its `payload_str`.

* [Signatures](#signatures-section) section
* [Import Table](#import-table-section) section
* [Function Signatures](#function-signatures-section) section
* [Indirect Function Table](#indirect-function-table-section) section
* [Type](#type-section) section
* [Import](#import-section) section
* [Function](#function-section) section
* [Table](#table-section) section
* [Memory](#memory-section) section
* [Export Table](#export-table-section) section
* [Start Function](#start-function-section) section
* [Function Bodies](#function-bodies-section) section
* [Data Segments](#data-segments-section) section
* [Names](#names-section) section
* [Export](#export-section) section
* [Start](#start-section) section
* [Code](#code-section) section
* [Data](#data-section) section
* [Name](#name-section) section

The end of the last present section must coincide with the last byte of the
module. The shortest valid module is 8 bytes (`magic number`, `version`,
followed by zero sections).

### Signatures section
### Type section

ID: `signatures`
ID: `type`

The signatures section declares all function signatures that will be used in the module.
The type section declares all function signatures that will be used in the module.

| Field | Type | Description |
| ----- | ----- | ----- |
| count | `varuint32` | count of signature entries to follow |
| entries | `signature_entry*` | repeated signature entries as described below |
| entries | `type_entry*` | repeated type entries as described below |

#### Signature entry
#### Type entry
| Field | Type | Description |
| ----- | ----- | ----- |
| param_count | `varuint32` | the number of parameters to the function |
| return_type | `value_type?` | the return type of the function, with `0` indicating no return type |
| param_types | `value_type*` | the parameter types of the function |

### Import Table section
### Import section

ID: `import_table`
ID: `import`

The import section declares all imports that will be used in the module.

Expand All @@ -147,29 +147,29 @@ The import section declares all imports that will be used in the module.
| function_len | `varuint32` | function string length |
| function_str | `bytes` | function string of `function_len` bytes |

### Function Signatures section
### Function section

ID: `function_signatures`
ID: `function`

The Function Signatures section declares the signatures of all functions in the
module.
The function section _declares_ the signatures of all functions in the
module (their definitions appear in the [code section](#code-section)).

| Field | Type | Description |
| ----- | ----- | ----- |
| count | `varuint32` | count of signature indices to follow |
| signatures | `varuint32*` | sequence of indices into the Signature section |
| types | `varuint32*` | sequence of indices into the type section |

### Indirect Function Table section
### Table section

ID: `function_table`
ID: `table`

The indirect function table section defines the module's
The table section defines the module's
[indirect function table](AstSemantics.md#calls).

| Field | Type | Description |
| ----- | ----- | ----- |
| count | `varuint32` | count of entries to follow |
| entries | `varuint32*` | repeated indexes into the function table |
| entries | `varuint32*` | repeated indexes into the function section |

### Memory section

Expand All @@ -184,11 +184,11 @@ associated with the module.
| maximum | `varuint32` | maximum memory size in 64KiB pages |
| exported | `uint8` | `1` if the memory is visible outside the module |

### Export Table section
### Export section

ID: `export_table`
ID: `export`

The export table section declares all exports from the module.
The export section declares all exports from the module.

| Field | Type | Description |
| ----- | ----- | ----- |
Expand All @@ -202,34 +202,35 @@ The export table section declares all exports from the module.
| function_len | `varuint32` | function string length |
| function_str | `bytes` | function string of `function_len` bytes |

### Start Function section
### Start section

ID: `start_function`
ID: `start`

The start function section declares the [start function](Modules.md#module-start-function).
The start section declares the [start function](Modules.md#module-start-function).

| Field | Type | Description |
| ----- | ----- | ----- |
| index | `varuint32` | start function index |

### Function Bodies section
### Code section

ID: `function_bodies`
ID: `code`

The Function Bodies section assigns a body to every function in the module.
The count of function signatures and function bodies must be the same and the `i`th
signature corresponds to the `i`th function body.
The code section assigns a body to every function in the module.
The count of function declared in the [function section](#function-section)
and function bodies defined in this section must be the same and the `i`th
declaration corresponds to the `i`th function body.

| Field | Type | Description |
| ----- | ----- | ----- | ----- |
| count | `varuint32` | count of function bodies to follow |
| bodies | `function_body*` | sequence of [Function Bodies](#function-bodies) |

### Data Segments section
### Data section

ID: `data_segments`
ID: `data`

The data segments section declares the initialized data that should be loaded
The data section declares the initialized data that should be loaded
into the linear memory.

| Field | Type | Description |
Expand All @@ -245,9 +246,9 @@ a `data_segment` is:
| size | `varuint32` | size of `data` (in bytes) |
| data | `bytes` | sequence of `size` bytes |

### Names section
### Name section

ID: `names`
ID: `name`

The names section does not change execution semantics and a validation error in
this section does not cause validation for the whole module to fail and is
Expand All @@ -261,7 +262,7 @@ and locals in the [text format](TextFormat.md).
| count | `varuint32` | count of entries to follow |
| entries | `function_names*` | sequence of names |

The sequence of `function_name` assigns names to the corresponding
The sequence of `function_names` assigns names to the corresponding
function index. The count may be greater or less than the actual number of
functions.

Expand Down

0 comments on commit 67c25af

Please sign in to comment.