Implement Wasm binding for Tree.getChangedRanges()
This commit is contained in:
parent
7de4985a27
commit
0d70b485c0
4 changed files with 94 additions and 5 deletions
|
|
@ -175,6 +175,26 @@ class Tree {
|
|||
walk() {
|
||||
return this.rootNode.walk();
|
||||
}
|
||||
|
||||
getChangedRanges(other) {
|
||||
if (other.constructor !== Tree) {
|
||||
throw new TypeError('Argument must be a Tree');
|
||||
}
|
||||
|
||||
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
||||
const count = getValue(TRANSFER_BUFFER, 'i32');
|
||||
const buffer = getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');
|
||||
const result = new Array(count);
|
||||
if (count > 0) {
|
||||
let address = buffer;
|
||||
for (let i = 0; i < count; i++) {
|
||||
result[i] = unmarshalRange(address);
|
||||
address += SIZE_OF_RANGE;
|
||||
}
|
||||
C._free(buffer);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class Node {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue