Skip to content

Commit 736c903

Browse files
authored
Fix markup of algorithms (#1045)
1 parent 16265e1 commit 736c903

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

JS.md

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -319,49 +319,49 @@ For each [`import`](https://github.com/WebAssembly/spec/blob/master/interpreter/
319319
1. If `Type(o)` is not Object, throw a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror).
320320
1. Let `v` be the value of performing [`Get`](http://tc39.github.io/ecma262/#sec-get-o-p)(`o`, [`i.item_name`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/ast.ml#L171))
321321
1. If `i` is a function import:
322-
1. If [`IsCallable(v)`](https://tc39.github.io/ecma262/#sec-iscallable) is `false`,
323-
throw a `WebAssembly.LinkError`.
324-
1. If `v` is an [Exported Function Exotic Object](#exported-function-exotic-objects):
325-
1. (The signature of `v.[[Closure]]` is checked against the import's declared
326-
[`func_type`](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#func_type)
327-
by `Eval.init` below.)
328-
1. Let `closure` be `v.[[Closure]]`.
329-
1. Otherwise:
330-
1. Let `closure` be a new [host function](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L9)
331-
of the given signature:
322+
1. If [`IsCallable(v)`](https://tc39.github.io/ecma262/#sec-iscallable) is `false`,
323+
throw a `WebAssembly.LinkError`.
324+
1. If `v` is an [Exported Function Exotic Object](#exported-function-exotic-objects):
325+
1. (The signature of `v.[[Closure]]` is checked against the import's declared
326+
[`func_type`](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#func_type)
327+
by `Eval.init` below.)
328+
1. Let `closure` be `v.[[Closure]]`.
329+
1. Otherwise:
330+
1. Let `closure` be a new [host function](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L9)
331+
of the given signature:
332332
1. If the signature contains an `i64` (as argument or result), the host
333333
function immediately throws a [`TypeError`](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror)
334334
when called.
335335
1. Otherwise, the host function calls `v` with an `undefined` receiver
336336
and WebAssembly arguments coerced to JavaScript arguments
337337
via [`ToJSValue`](#tojsvalue). The result is returned by coercing
338338
via [`ToWebAssemblyValue`](#towebassemblyvalue).
339-
1. Append `v` to `funcs`.
340-
1. Append `closure` to `imports`.
339+
1. Append `v` to `funcs`.
340+
1. Append `closure` to `imports`.
341341
1. If `i` is a global import:
342-
1. [Assert](https://tc39.github.io/ecma262/#assert): the global is immutable
343-
by MVP validation constraint.
344-
1. If the `global_type` of `i` is `i64` or `Type(v)` is not Number, throw a `WebAssembly.LinkError`.
345-
1. Append [`ToWebAssemblyValue`](#towebassemblyvalue)`(v)` to `imports`.
342+
1. [Assert](https://tc39.github.io/ecma262/#assert): the global is immutable
343+
by MVP validation constraint.
344+
1. If the `global_type` of `i` is `i64` or `Type(v)` is not Number, throw a `WebAssembly.LinkError`.
345+
1. Append [`ToWebAssemblyValue`](#towebassemblyvalue)`(v)` to `imports`.
346346
1. If `i` is a memory import:
347-
1. If `v` is not a [`WebAssembly.Memory` object](#webassemblymemory-objects),
347+
1. If `v` is not a [`WebAssembly.Memory` object](#webassemblymemory-objects),
348348
throw a `WebAssembly.LinkError`.
349-
1. (The imported `Memory`'s `length` and `maximum` properties are checked against the import's declared
349+
1. (The imported `Memory`'s `length` and `maximum` properties are checked against the import's declared
350350
[`memory_type`](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#memory_type)
351351
by `Eval.init` below.)
352-
1. Append `v` to `memories`.
353-
1. Append `v.[[Memory]]` to `imports`.
352+
1. Append `v` to `memories`.
353+
1. Append `v.[[Memory]]` to `imports`.
354354
1. Otherwise (`i` is a table import):
355-
1. If `v` is not a [`WebAssembly.Table` object](#webassemblytable-objects),
356-
throw a `WebAssembly.LinkError`.
357-
1. (The imported `Table`'s `length`, `maximum` and `element` properties are checked against the import's declared
355+
1. If `v` is not a [`WebAssembly.Table` object](#webassemblytable-objects),
356+
throw a `WebAssembly.LinkError`.
357+
1. (The imported `Table`'s `length`, `maximum` and `element` properties are checked against the import's declared
358358
[`table_type`](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#table_type)
359359
by `Eval.init` below.)
360-
1. Append `v` to `tables`.
361-
1. Append `v.[[Table]]` to `imports`.
362-
1. For each index `i` of `v.[[Table]]`:
363-
1. Let `e` be the `i`the element of `v.[[Table]]`.
364-
1. If `e` is a [`closure`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L7) `c`:
360+
1. Append `v` to `tables`.
361+
1. Append `v.[[Table]]` to `imports`.
362+
1. For each index `i` of `v.[[Table]]`:
363+
1. Let `e` be the `i`the element of `v.[[Table]]`.
364+
1. If `e` is a [`closure`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L7) `c`:
365365
1. Append the `i`th element of `v.[[Values]]` to `funcs`.
366366

367367
Let `instance` be the result of creating a new
@@ -390,50 +390,50 @@ Among other things, this function performs the following observable steps:
390390
The following steps are performed _before_ the `start` function executes:
391391

392392
1. For each table 't' in [`instance.tables`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L17):
393-
1. If there is no element in `tables` whose `table.[[Table]]` is `t`:
394-
1. Let `table` be a new `WebAssembly.Table` object with [[Table]] set to `t` and [[Values]] set to a new list of the same length all whose entries are `null`.
395-
1. Append `table` to `tables`.
396-
1. Otherwise:
397-
1. Let `table` be the element in `tables` whose `table.[[Table]]` is `t`
398-
1. (Note: At most one `WebAssembly.Table` object is created for any table, so the above `table` is unique, even if there are multiple occurrances in the list. Moreover, if the item was an import, the original object will be found.)
399-
1. For each index `i` of `t`:
400-
1. Let `c` be the `i`th element of `t`
401-
1. If `c` is a [`closure`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L7) `c`:
402-
1. If there is an [Exported Function Exotic Object](#exported-function-exotic-objects) in `funcs` whose `[[Closure]]` equals `c`:
403-
1. Let `func` be that function object.
404-
1. (Note: At most one wrapper is created for any closure, so `func` is uniquely determined. Moreover, if the item was an import that is already an [Exported Function Exotic Object](#exported-function-exotic-objects), then the original function object will be found. For imports that are regular JS functions, a new wrapper will be created.)
405-
1. Otherwise:
406-
1. Let `func` be an [Exported Function Exotic Object](#exported-function-exotic-objects) created from `c`.
407-
1. Append `func` to `funcs`.
408-
1. Set the `i`th element of `table.[[Values]]` to `func`.
393+
1. If there is no element in `tables` whose `table.[[Table]]` is `t`:
394+
1. Let `table` be a new `WebAssembly.Table` object with [[Table]] set to `t` and [[Values]] set to a new list of the same length all whose entries are `null`.
395+
1. Append `table` to `tables`.
396+
1. Otherwise:
397+
1. Let `table` be the element in `tables` whose `table.[[Table]]` is `t`
398+
1. (Note: At most one `WebAssembly.Table` object is created for any table, so the above `table` is unique, even if there are multiple occurrances in the list. Moreover, if the item was an import, the original object will be found.)
399+
1. For each index `i` of `t`:
400+
1. Let `c` be the `i`th element of `t`
401+
1. If `c` is a [`closure`](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L7) `c`:
402+
1. If there is an [Exported Function Exotic Object](#exported-function-exotic-objects) in `funcs` whose `[[Closure]]` equals `c`:
403+
1. Let `func` be that function object.
404+
1. (Note: At most one wrapper is created for any closure, so `func` is uniquely determined. Moreover, if the item was an import that is already an [Exported Function Exotic Object](#exported-function-exotic-objects), then the original function object will be found. For imports that are regular JS functions, a new wrapper will be created.)
405+
1. Otherwise:
406+
1. Let `func` be an [Exported Function Exotic Object](#exported-function-exotic-objects) created from `c`.
407+
1. Append `func` to `funcs`.
408+
1. Set the `i`th element of `table.[[Values]]` to `func`.
409409

410410
(Note: The table and element function objects created by the above steps are only observable for tables that are either imported or exported.)
411411

412412
Let `exports` be a list of (string, JS value) pairs that is mapped from
413413
each [external](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L24) value `e` in `instance.exports` as follows:
414414

415415
1. If `e` is a [closure](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L12) `c`:
416-
1. If there is an [Exported Function Exotic Object](#exported-function-exotic-objects) `func` in `funcs` whose `func.[[Closure]]` equals `c`, then return `func`.
417-
1. (Note: At most one wrapper is created for any closure, so `func` is unique, even if there are multiple occurrances in the list. Moreover, if the item was an import that is already an [Exported Function Exotic Object](#exported-function-exotic-objects), then the original function object will be found. For imports that are regular JS functions, a new wrapper will be created.)
418-
1. Otherwise:
419-
1. Let `func` be an [Exported Function Exotic Object](#exported-function-exotic-objects) created from `c`.
420-
1. Append `func` to `funcs`.
421-
1. Return `func`.
416+
1. If there is an [Exported Function Exotic Object](#exported-function-exotic-objects) `func` in `funcs` whose `func.[[Closure]]` equals `c`, then return `func`.
417+
1. (Note: At most one wrapper is created for any closure, so `func` is unique, even if there are multiple occurrances in the list. Moreover, if the item was an import that is already an [Exported Function Exotic Object](#exported-function-exotic-objects), then the original function object will be found. For imports that are regular JS functions, a new wrapper will be created.)
418+
1. Otherwise:
419+
1. Let `func` be an [Exported Function Exotic Object](#exported-function-exotic-objects) created from `c`.
420+
1. Append `func` to `funcs`.
421+
1. Return `func`.
422422
1. If `e` is a [global](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L15) `v`:
423-
1. [Assert](https://tc39.github.io/ecma262/#assert): the global is immutable
424-
by MVP validation constraint.
425-
1. If `v` is an `i64`, throw a `WebAssembly.LinkError`.
426-
1. Return [`ToJSValue`](#tojsvalue)`(v)`.
423+
1. [Assert](https://tc39.github.io/ecma262/#assert): the global is immutable
424+
by MVP validation constraint.
425+
1. If `v` is an `i64`, throw a `WebAssembly.LinkError`.
426+
1. Return [`ToJSValue`](#tojsvalue)`(v)`.
427427
1. If `e` is a [memory](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L14) `m`:
428-
1. If there is an element `memory` in `memories` whose `memory.[[Memory]]` is `m`, then return `memory`.
429-
1. (Note: At most one `WebAssembly.Memory` object is created for any memory, so the above `memory` is unique, even if there are multiple occurrances in the list. Moreover, if the item was an import, the original object will be found.)
430-
1. Otherwise:
431-
1. Let `memory` be a new `WebAssembly.Memory` object created via [`CreateMemoryObject`](#creatememoryobject) from `m`.
432-
1. Append `memory` to `memories`.
433-
1. Return `memory`.
428+
1. If there is an element `memory` in `memories` whose `memory.[[Memory]]` is `m`, then return `memory`.
429+
1. (Note: At most one `WebAssembly.Memory` object is created for any memory, so the above `memory` is unique, even if there are multiple occurrances in the list. Moreover, if the item was an import, the original object will be found.)
430+
1. Otherwise:
431+
1. Let `memory` be a new `WebAssembly.Memory` object created via [`CreateMemoryObject`](#creatememoryobject) from `m`.
432+
1. Append `memory` to `memories`.
433+
1. Return `memory`.
434434
1. Otherwise `e` must be a [table](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L13) `t`:
435-
1. Assert: There is an element `table` in `tables` whose `table.[[Table]]` is `t`.
436-
1. Return that `table`.
435+
1. Assert: There is an element `table` in `tables` whose `table.[[Table]]` is `t`.
436+
1. Return that `table`.
437437

438438
Note: For the purpose of the above algorithm, two [closure](https://github.com/WebAssembly/spec/blob/master/interpreter/spec/instance.ml#L7) values are considered equal if and only if:
439439

0 commit comments

Comments
 (0)