@@ -586,24 +586,23 @@ descriptordata ::= n:name (if n = 'descriptors')
586
586
descriptorentry ::= 0x00 importentry
587
587
| 0x01 declentry
588
588
589
- importentry ::= importname:name descconfig
589
+ importentry ::= importname:name descconfig
590
590
591
- declentry ::= protoconfig descconfig
591
+ declentry ::= protoconfig descconfig
592
592
593
- protoconfig ::= v:vec(descindex) (if |v| <= 1)
593
+ protoconfig ::= v:vec(descindex) (if |v| <= 1)
594
594
595
- descconfig ::= exportnames vec(methodconfig )
595
+ descconfig ::= exportnames:vec(name) methods: vec(methodconsconfig )
596
596
597
- exportnames ::= vec( name)
597
+ methodnames ::= methodname: name exportname:name
598
598
599
- methodconfig ::= kind:methodkind
600
- methodname:name
601
- exportname:name
599
+ methodconfig ::= 0x00 methodnames => method
600
+ | 0x01 methodnames => getter
601
+ | 0x02 methodnames => setter
602
+
603
+ methodconsconfig ::= methodconfig
604
+ | 0x03 methodnames vec(methodconfig) => constructor
602
605
603
- methodkind ::= 0x00 => method
604
- | 0x01 => getter
605
- | 0x02 => setter
606
- | 0x03 => constructor
607
606
```
608
607
609
608
The descriptors custom section starts with a version number,
@@ -624,12 +623,14 @@ by including multiple descriptors sections.
624
623
Following the ` modulename ` is a sequence of ` descriptorentry ` ,
625
624
each of which describes a declared ` DescriptorOptions ` value or an imported prototype
626
625
for use in the prototype chain of subsequent declared ` DescriptorOptions ` .
627
- A declaration value can optionally specify the index of a previous entry
626
+ A declaration can optionally specify the index of a previous entry
628
627
to provide the parent in the configured prototype chain.
629
628
If the previous entry is an ` importentry ` , the ` modulename ` and ` importname `
630
629
are used to look up the prototype in the imports object.
631
630
Otherwise, if the previous entry is a ` declentry ` ,
632
631
the prototype is looked up from the declared ` DescriptorOptions ` .
632
+ If there is no configured parent,
633
+ the parent of the new prototype is ` Object.prototype ` .
633
634
634
635
Each declared descriptor has a vector of export names.
635
636
After the descriptor is created,
@@ -648,9 +649,9 @@ describing the methods that should be attached to the prototype
648
649
after instantiation.
649
650
Each configured method can be either a
650
651
normal method, a getter, a setter, or a constructor.
651
- Methods also have two associated names: the first their property name
652
- in the configured prototype and the second
653
- the name of the exported function they wrap.
652
+ Methods each have two associated names:
653
+ the first is their property name in the configured prototype
654
+ and the second is the name of the exported function they wrap.
654
655
655
656
All methods pass the receiver as the first argument:
656
657
@@ -670,9 +671,15 @@ function methodname() { return exports[exportname](...arguments); }
670
671
671
672
Furthermore, they are not installed on the configured prototype.
672
673
Instead, they are added to the ` exports ` object.
673
- The configured prototype is added as the ` prototype ` property of the generated function
674
+ The configured prototype is added as the ` prototype ` property of the generated constructor function
674
675
and the generated function is added as the ` constructor ` property of the configured prototype.
675
676
677
+ Constructor declarations also contain additional methods, getters, and setters
678
+ that will be installed as properties of the constructor itself
679
+ rather than the prototype.
680
+ Like the constructor function itself,
681
+ these "static" methods, getters, and setters do not pass their receiver as an argument.
682
+
676
683
### Instantiation
677
684
678
685
When constructing a WebAssembly instance,
0 commit comments