From 37b115db1a80fc930bdd7ded565b951ebc3b175d Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Tue, 17 Jan 2017 12:26:31 -0800 Subject: Identity&order in values returned by some APIs (#957) * Identity&order in values returned by some APIs Clarified that Module.imports, exports, and customSections return new Arrays. Clarified order in imports/exports * ordering of imports/exports match custom sections verbiage * Simpler sentences --- JS.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'JS.md') diff --git a/JS.md b/JS.md index 243dfe9..a7a71fd 100644 --- a/JS.md +++ b/JS.md @@ -199,7 +199,7 @@ Array exports(moduleObject) If `moduleObject` is not a `WebAssembly.Module`, a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) is thrown. -This function returns an `Array` produced by mapping each +This function returns a new `Array` every time it is called. Each such `Array` is produced by mapping each [`Ast.export`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/ast.ml#L152) `e` of [moduleObject.[[Module]].exports](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/ast.ml#L187) to the Object `{ name: String(e.name), kind: e.ekind }` where `e.name` is [decoded as UTF8](Web.md#names) @@ -207,6 +207,8 @@ and `e.ekind` is mapped to one of the String values `"function"`, `"table"`, `"m Note: other fields like `signature` may be added in the future. +The returned `Array` is populated in the same order exports appear in the WebAssembly binary's exports table. + ### `WebAssembly.Module.imports` The `imports` function has the signature: @@ -218,7 +220,7 @@ Array imports(moduleObject) If `moduleObject` is not a `WebAssembly.Module`, a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror) is thrown. -This function returns an `Array` produced by mapping each +This function returns a new `Array` every time it is called. Each such `Array` is produced by mapping each [`Ast.import`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/ast.ml#L167) `i` of [moduleObject.[[Module]].imports](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/ast.ml#L203) to the Object `{ module: String(i.module_name), name: String(i.item_name), kind: i.ikind }` where @@ -227,6 +229,8 @@ to the Object `{ module: String(i.module_name), name: String(i.item_name), kind: Note: other fields like `signature` may be added in the future. +The returned `Array` is populated in the same order imports appear in the WebAssembly binary's imports table. + ### `WebAssembly.Module.customSections` The `customSections` function has the signature: @@ -240,14 +244,13 @@ is thrown. Let `sectionNameString` be the result of [`ToString`](https://tc39.github.io/ecma262/#sec-tostring)(`sectionName`). -This function returns an `Array` produced by mapping each +This function returns a new `Array` every time it is called. Each such `Array` is produced by mapping each [custom section](BinaryEncoding.md#high-level-structure) (i.e., section with `id` 0) whose `name` field ([decoded as UTF-8](Web.md#names)) is equal to `sectionNameString` to an `ArrayBuffer` containing a copy of the section's -`payload_data`. (Note: `payload_data` does not include `name` or `name_len`.) +`payload_data`. (Note: `payload_data` does not include `name` or `name_len`.). -The `Array` is populated in the same order as that in which custom sections -appeared in the WebAssembly binary. +The `Array` is populated in the same order custom sections appear in the WebAssembly binary. ### Structured Clone of a `WebAssembly.Module` -- cgit v1.2.3