fix(web): correct childWithDescendant() functionality
This fix allows for more granular address control when marshalling nodes
across WASM. This is necessary for node methods which accept another
node as a parameter (i.e., `childWithDescendant()`)
(cherry picked from commit 21390af2dd)
This commit is contained in:
parent
62cc419262
commit
20a5d46b50
4 changed files with 30 additions and 10 deletions
|
|
@ -34,8 +34,8 @@ export function unmarshalCaptures(
|
|||
*
|
||||
* Marshals a {@link Node} to the transfer buffer.
|
||||
*/
|
||||
export function marshalNode(node: Node) {
|
||||
let address = TRANSFER_BUFFER;
|
||||
export function marshalNode(node: Node, index = 0) {
|
||||
let address = TRANSFER_BUFFER + index * SIZE_OF_NODE;
|
||||
C.setValue(address, node.id, 'i32');
|
||||
address += SIZE_OF_INT;
|
||||
C.setValue(address, node.startIndex, 'i32');
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ export class Node {
|
|||
*/
|
||||
childWithDescendant(descendant: Node): Node | null {
|
||||
marshalNode(this);
|
||||
marshalNode(descendant);
|
||||
marshalNode(descendant, 1);
|
||||
C._ts_node_child_with_descendant_wasm(this.tree[0]);
|
||||
return unmarshalNode(this.tree);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue