@willbooster/web-tree-sitter 19.0.2 → 19.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/debug/web-tree-sitter.cjs +534 -604
- package/debug/web-tree-sitter.cjs.map +4 -4
- package/debug/web-tree-sitter.js +534 -604
- package/debug/web-tree-sitter.js.map +4 -4
- package/debug/web-tree-sitter.wasm +0 -0
- package/debug/web-tree-sitter.wasm.map +10 -10
- package/package.json +1 -1
- package/web-tree-sitter.cjs +3 -3
- package/web-tree-sitter.cjs.map +4 -4
- package/web-tree-sitter.d.cts +8 -1
- package/web-tree-sitter.d.cts.map +1 -1
- package/web-tree-sitter.d.ts +8 -1
- package/web-tree-sitter.d.ts.map +1 -1
- package/web-tree-sitter.js +3 -3
- package/web-tree-sitter.js.map +4 -4
- package/web-tree-sitter.wasm +0 -0
- package/web-tree-sitter.wasm.map +9 -9
- package/web-tree-sitter.web.js +3 -3
- package/web-tree-sitter.web.js.map +4 -4
|
@@ -202,8 +202,8 @@ var require_web_tree_sitter = __commonJS({
|
|
|
202
202
|
if (max == 0) {
|
|
203
203
|
max += 4;
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max >> 2, "storing")] = 34821223;
|
|
206
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "storing")] = 2310721022;
|
|
207
207
|
}
|
|
208
208
|
__name(writeStackCookie, "writeStackCookie");
|
|
209
209
|
function checkStackCookie() {
|
|
@@ -212,8 +212,8 @@ var require_web_tree_sitter = __commonJS({
|
|
|
212
212
|
if (max == 0) {
|
|
213
213
|
max += 4;
|
|
214
214
|
}
|
|
215
|
-
var cookie1 =
|
|
216
|
-
var cookie2 =
|
|
215
|
+
var cookie1 = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max >> 2, "loading")];
|
|
216
|
+
var cookie2 = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "loading")];
|
|
217
217
|
if (cookie1 != 34821223 || cookie2 != 2310721022) {
|
|
218
218
|
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
|
|
219
219
|
}
|
|
@@ -225,6 +225,12 @@ var require_web_tree_sitter = __commonJS({
|
|
|
225
225
|
console.warn(...args2);
|
|
226
226
|
}
|
|
227
227
|
__name(dbg, "dbg");
|
|
228
|
+
(() => {
|
|
229
|
+
var h16 = new Int16Array(1);
|
|
230
|
+
var h8 = new Int8Array(h16.buffer);
|
|
231
|
+
h16[0] = 25459;
|
|
232
|
+
if (h8[0] !== 115 || h8[1] !== 99) abort("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)");
|
|
233
|
+
})();
|
|
228
234
|
function consumedModuleProp(prop) {
|
|
229
235
|
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
230
236
|
Object.defineProperty(Module, prop, {
|
|
@@ -295,29 +301,26 @@ var require_web_tree_sitter = __commonJS({
|
|
|
295
301
|
var wasmMemory;
|
|
296
302
|
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
|
|
297
303
|
var HEAP64, HEAPU64;
|
|
298
|
-
var HEAP_DATA_VIEW;
|
|
299
304
|
var runtimeInitialized = false;
|
|
300
305
|
function updateMemoryViews() {
|
|
301
306
|
var b = wasmMemory.buffer;
|
|
302
|
-
|
|
303
|
-
|
|
307
|
+
HEAP8 = new Int8Array(b);
|
|
308
|
+
HEAP16 = new Int16Array(b);
|
|
304
309
|
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
|
|
305
310
|
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
|
|
306
311
|
Module["HEAP32"] = HEAP32 = new Int32Array(b);
|
|
307
312
|
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
|
|
313
|
-
LE_HEAP_UPDATE();
|
|
313
|
+
HEAPF32 = new Float32Array(b);
|
|
314
|
+
HEAPF64 = new Float64Array(b);
|
|
315
|
+
HEAP64 = new BigInt64Array(b);
|
|
316
|
+
HEAPU64 = new BigUint64Array(b);
|
|
314
317
|
}
|
|
315
318
|
__name(updateMemoryViews, "updateMemoryViews");
|
|
316
319
|
function initMemory() {
|
|
317
320
|
if (Module["wasmMemory"]) {
|
|
318
321
|
wasmMemory = Module["wasmMemory"];
|
|
319
322
|
} else {
|
|
320
|
-
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] ||
|
|
323
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 4194304;
|
|
321
324
|
assert(INITIAL_MEMORY >= 65536, "INITIAL_MEMORY should be larger than STACK_SIZE, was " + INITIAL_MEMORY + "! (STACK_SIZE=65536)");
|
|
322
325
|
wasmMemory = new WebAssembly.Memory({
|
|
323
326
|
"initial": INITIAL_MEMORY / 65536,
|
|
@@ -559,77 +562,6 @@ var require_web_tree_sitter = __commonJS({
|
|
|
559
562
|
return rtn;
|
|
560
563
|
}
|
|
561
564
|
};
|
|
562
|
-
var LE_ATOMICS_ADD = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
563
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
564
|
-
const res = order(Atomics.add(heap, offset, order(value)));
|
|
565
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
566
|
-
}, "LE_ATOMICS_ADD");
|
|
567
|
-
var LE_ATOMICS_AND = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
568
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
569
|
-
const res = order(Atomics.and(heap, offset, order(value)));
|
|
570
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
571
|
-
}, "LE_ATOMICS_AND");
|
|
572
|
-
var LE_ATOMICS_COMPAREEXCHANGE = /* @__PURE__ */ __name((heap, offset, expected, replacement) => {
|
|
573
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
574
|
-
const res = order(Atomics.compareExchange(heap, offset, order(expected), order(replacement)));
|
|
575
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
576
|
-
}, "LE_ATOMICS_COMPAREEXCHANGE");
|
|
577
|
-
var LE_ATOMICS_EXCHANGE = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
578
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
579
|
-
const res = order(Atomics.exchange(heap, offset, order(value)));
|
|
580
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
581
|
-
}, "LE_ATOMICS_EXCHANGE");
|
|
582
|
-
var LE_ATOMICS_ISLOCKFREE = /* @__PURE__ */ __name((size) => Atomics.isLockFree(size), "LE_ATOMICS_ISLOCKFREE");
|
|
583
|
-
var LE_ATOMICS_LOAD = /* @__PURE__ */ __name((heap, offset) => {
|
|
584
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
585
|
-
const res = order(Atomics.load(heap, offset));
|
|
586
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
587
|
-
}, "LE_ATOMICS_LOAD");
|
|
588
|
-
var LE_ATOMICS_NATIVE_BYTE_ORDER = [];
|
|
589
|
-
var LE_ATOMICS_NOTIFY = /* @__PURE__ */ __name((heap, offset, count) => Atomics.notify(heap, offset, count), "LE_ATOMICS_NOTIFY");
|
|
590
|
-
var LE_ATOMICS_OR = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
591
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
592
|
-
const res = order(Atomics.or(heap, offset, order(value)));
|
|
593
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
594
|
-
}, "LE_ATOMICS_OR");
|
|
595
|
-
var LE_ATOMICS_STORE = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
596
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
597
|
-
Atomics.store(heap, offset, order(value));
|
|
598
|
-
}, "LE_ATOMICS_STORE");
|
|
599
|
-
var LE_ATOMICS_SUB = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
600
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
601
|
-
const res = order(Atomics.sub(heap, offset, order(value)));
|
|
602
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
603
|
-
}, "LE_ATOMICS_SUB");
|
|
604
|
-
var LE_ATOMICS_WAIT = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
|
|
605
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
606
|
-
return Atomics.wait(heap, offset, order(value), timeout);
|
|
607
|
-
}, "LE_ATOMICS_WAIT");
|
|
608
|
-
var LE_ATOMICS_WAITASYNC = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
|
|
609
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
610
|
-
return Atomics.waitAsync(heap, offset, order(value), timeout);
|
|
611
|
-
}, "LE_ATOMICS_WAITASYNC");
|
|
612
|
-
var LE_ATOMICS_XOR = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
613
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
614
|
-
const res = order(Atomics.xor(heap, offset, order(value)));
|
|
615
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
616
|
-
}, "LE_ATOMICS_XOR");
|
|
617
|
-
var LE_HEAP_LOAD_F32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true), "LE_HEAP_LOAD_F32");
|
|
618
|
-
var LE_HEAP_LOAD_F64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true), "LE_HEAP_LOAD_F64");
|
|
619
|
-
var LE_HEAP_LOAD_I16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true), "LE_HEAP_LOAD_I16");
|
|
620
|
-
var LE_HEAP_LOAD_I32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true), "LE_HEAP_LOAD_I32");
|
|
621
|
-
var LE_HEAP_LOAD_I64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigInt64(byteOffset, true), "LE_HEAP_LOAD_I64");
|
|
622
|
-
var LE_HEAP_LOAD_U16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint16(byteOffset, true), "LE_HEAP_LOAD_U16");
|
|
623
|
-
var LE_HEAP_LOAD_U32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true), "LE_HEAP_LOAD_U32");
|
|
624
|
-
var LE_HEAP_LOAD_U64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigUint64(byteOffset, true), "LE_HEAP_LOAD_U64");
|
|
625
|
-
var LE_HEAP_STORE_F32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true), "LE_HEAP_STORE_F32");
|
|
626
|
-
var LE_HEAP_STORE_F64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true), "LE_HEAP_STORE_F64");
|
|
627
|
-
var LE_HEAP_STORE_I16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true), "LE_HEAP_STORE_I16");
|
|
628
|
-
var LE_HEAP_STORE_I32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true), "LE_HEAP_STORE_I32");
|
|
629
|
-
var LE_HEAP_STORE_I64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigInt64(byteOffset, value, true), "LE_HEAP_STORE_I64");
|
|
630
|
-
var LE_HEAP_STORE_U16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint16(byteOffset, value, true), "LE_HEAP_STORE_U16");
|
|
631
|
-
var LE_HEAP_STORE_U32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true), "LE_HEAP_STORE_U32");
|
|
632
|
-
var LE_HEAP_STORE_U64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigUint64(byteOffset, value, true), "LE_HEAP_STORE_U64");
|
|
633
565
|
var callRuntimeCallbacks = /* @__PURE__ */ __name((callbacks) => {
|
|
634
566
|
while (callbacks.length > 0) {
|
|
635
567
|
callbacks.shift()(Module);
|
|
@@ -730,7 +662,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
730
662
|
end = binary2.length;
|
|
731
663
|
} else {
|
|
732
664
|
var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
|
|
733
|
-
var magicNumberFound = int32View[0] == 1836278016
|
|
665
|
+
var magicNumberFound = int32View[0] == 1836278016;
|
|
734
666
|
failIf(!magicNumberFound, "need to see wasm magic number");
|
|
735
667
|
failIf(binary2[8] !== 0, "need the dylink section to be first");
|
|
736
668
|
offset = 9;
|
|
@@ -802,17 +734,17 @@ var require_web_tree_sitter = __commonJS({
|
|
|
802
734
|
case "i8":
|
|
803
735
|
return HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "loading")];
|
|
804
736
|
case "i16":
|
|
805
|
-
return
|
|
737
|
+
return HEAP16[SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "loading")];
|
|
806
738
|
case "i32":
|
|
807
|
-
return
|
|
739
|
+
return HEAP32[SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "loading")];
|
|
808
740
|
case "i64":
|
|
809
|
-
return
|
|
741
|
+
return HEAP64[SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "loading")];
|
|
810
742
|
case "float":
|
|
811
|
-
return
|
|
743
|
+
return HEAPF32[SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "loading")];
|
|
812
744
|
case "double":
|
|
813
|
-
return
|
|
745
|
+
return HEAPF64[SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "loading")];
|
|
814
746
|
case "*":
|
|
815
|
-
return
|
|
747
|
+
return HEAPU32[SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "loading")];
|
|
816
748
|
default:
|
|
817
749
|
abort(`invalid type for getValue: ${type}`);
|
|
818
750
|
}
|
|
@@ -839,7 +771,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
839
771
|
newDSO("__main__", 0, wasmImports);
|
|
840
772
|
}
|
|
841
773
|
};
|
|
842
|
-
var ___heap_base =
|
|
774
|
+
var ___heap_base = 82464;
|
|
843
775
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
|
|
844
776
|
assert(alignment, "alignment argument is required");
|
|
845
777
|
return Math.ceil(size / alignment) * alignment;
|
|
@@ -934,7 +866,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
934
866
|
}, "convertJsFunctionToWasm");
|
|
935
867
|
var wasmTableMirror = [];
|
|
936
868
|
var wasmTable = new WebAssembly.Table({
|
|
937
|
-
"initial":
|
|
869
|
+
"initial": 59,
|
|
938
870
|
"element": "anyfunc"
|
|
939
871
|
});
|
|
940
872
|
var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
|
|
@@ -1095,10 +1027,10 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1095
1027
|
var tableBase = metadata.tableSize ? wasmTable.length : 0;
|
|
1096
1028
|
if (handle) {
|
|
1097
1029
|
HEAP8[SAFE_HEAP_INDEX(HEAP8, handle + 8, "storing")] = 1;
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1030
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle + 12 >> 2, "storing")] = memoryBase;
|
|
1031
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, handle + 16 >> 2, "storing")] = metadata.memorySize;
|
|
1032
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle + 20 >> 2, "storing")] = tableBase;
|
|
1033
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, handle + 24 >> 2, "storing")] = metadata.tableSize;
|
|
1102
1034
|
}
|
|
1103
1035
|
if (metadata.tableSize) {
|
|
1104
1036
|
assert(wasmTable.length == tableBase, `unexpected table size while loading ${libName}: ${wasmTable.length}`);
|
|
@@ -1300,8 +1232,8 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1300
1232
|
dso.global = flags2.global;
|
|
1301
1233
|
function loadLibData() {
|
|
1302
1234
|
if (handle2) {
|
|
1303
|
-
var data =
|
|
1304
|
-
var dataSize =
|
|
1235
|
+
var data = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle2 + 28 >> 2, "loading")];
|
|
1236
|
+
var dataSize = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle2 + 32 >> 2, "loading")];
|
|
1305
1237
|
if (data && dataSize) {
|
|
1306
1238
|
var libData = HEAP8.slice(data, data + dataSize);
|
|
1307
1239
|
return flags2.loadAsync ? Promise.resolve(libData) : libData;
|
|
@@ -1444,22 +1376,22 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1444
1376
|
HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "storing")] = value;
|
|
1445
1377
|
break;
|
|
1446
1378
|
case "i16":
|
|
1447
|
-
|
|
1379
|
+
HEAP16[SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "storing")] = value;
|
|
1448
1380
|
break;
|
|
1449
1381
|
case "i32":
|
|
1450
|
-
|
|
1382
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "storing")] = value;
|
|
1451
1383
|
break;
|
|
1452
1384
|
case "i64":
|
|
1453
|
-
|
|
1385
|
+
HEAP64[SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "storing")] = BigInt(value);
|
|
1454
1386
|
break;
|
|
1455
1387
|
case "float":
|
|
1456
|
-
|
|
1388
|
+
HEAPF32[SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "storing")] = value;
|
|
1457
1389
|
break;
|
|
1458
1390
|
case "double":
|
|
1459
|
-
|
|
1391
|
+
HEAPF64[SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "storing")] = value;
|
|
1460
1392
|
break;
|
|
1461
1393
|
case "*":
|
|
1462
|
-
|
|
1394
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "storing")] = value;
|
|
1463
1395
|
break;
|
|
1464
1396
|
default:
|
|
1465
1397
|
abort(`invalid type for setValue: ${type}`);
|
|
@@ -1470,12 +1402,12 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1470
1402
|
"value": "i32",
|
|
1471
1403
|
"mutable": false
|
|
1472
1404
|
}, 1024);
|
|
1473
|
-
var ___stack_high =
|
|
1474
|
-
var ___stack_low =
|
|
1405
|
+
var ___stack_high = 82464;
|
|
1406
|
+
var ___stack_low = 16928;
|
|
1475
1407
|
var ___stack_pointer = new WebAssembly.Global({
|
|
1476
1408
|
"value": "i32",
|
|
1477
1409
|
"mutable": true
|
|
1478
|
-
},
|
|
1410
|
+
}, 82464);
|
|
1479
1411
|
var ___table_base = new WebAssembly.Global({
|
|
1480
1412
|
"value": "i32",
|
|
1481
1413
|
"mutable": false
|
|
@@ -1565,15 +1497,15 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1565
1497
|
var _fd_write = /* @__PURE__ */ __name((fd, iov, iovcnt, pnum) => {
|
|
1566
1498
|
var num = 0;
|
|
1567
1499
|
for (var i2 = 0; i2 < iovcnt; i2++) {
|
|
1568
|
-
var ptr =
|
|
1569
|
-
var len =
|
|
1500
|
+
var ptr = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, iov >> 2, "loading")];
|
|
1501
|
+
var len = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, iov + 4 >> 2, "loading")];
|
|
1570
1502
|
iov += 8;
|
|
1571
1503
|
for (var j = 0; j < len; j++) {
|
|
1572
1504
|
printChar(fd, HEAPU8[SAFE_HEAP_INDEX(HEAPU8, ptr + j, "loading")]);
|
|
1573
1505
|
}
|
|
1574
1506
|
num += len;
|
|
1575
1507
|
}
|
|
1576
|
-
|
|
1508
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, pnum >> 2, "storing")] = num;
|
|
1577
1509
|
return 0;
|
|
1578
1510
|
}, "_fd_write");
|
|
1579
1511
|
_fd_write.sig = "iippp";
|
|
@@ -1591,10 +1523,10 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1591
1523
|
column
|
|
1592
1524
|
});
|
|
1593
1525
|
if (typeof string === "string") {
|
|
1594
|
-
|
|
1526
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >> 2, "storing")] = string.length;
|
|
1595
1527
|
stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
|
|
1596
1528
|
} else {
|
|
1597
|
-
|
|
1529
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >> 2, "storing")] = 0;
|
|
1598
1530
|
}
|
|
1599
1531
|
}
|
|
1600
1532
|
__name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
|
|
@@ -1719,30 +1651,12 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1719
1651
|
var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
|
|
1720
1652
|
for (var i2 = 0; i2 < numCharsToWrite; ++i2) {
|
|
1721
1653
|
var codeUnit = str.charCodeAt(i2);
|
|
1722
|
-
|
|
1654
|
+
HEAP16[SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing")] = codeUnit;
|
|
1723
1655
|
outPtr += 2;
|
|
1724
1656
|
}
|
|
1725
|
-
|
|
1657
|
+
HEAP16[SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing")] = 0;
|
|
1726
1658
|
return outPtr - startPtr;
|
|
1727
1659
|
}, "stringToUTF16");
|
|
1728
|
-
LE_ATOMICS_NATIVE_BYTE_ORDER = new Int8Array(new Int16Array([1]).buffer)[0] === 1 ? [
|
|
1729
|
-
/* little endian */
|
|
1730
|
-
((x) => x),
|
|
1731
|
-
((x) => x),
|
|
1732
|
-
void 0,
|
|
1733
|
-
((x) => x)
|
|
1734
|
-
] : [
|
|
1735
|
-
/* big endian */
|
|
1736
|
-
((x) => x),
|
|
1737
|
-
((x) => ((x & 65280) << 8 | (x & 255) << 24) >> 16),
|
|
1738
|
-
void 0,
|
|
1739
|
-
((x) => x >> 24 & 255 | x >> 8 & 65280 | (x & 65280) << 8 | (x & 255) << 24)
|
|
1740
|
-
];
|
|
1741
|
-
function LE_HEAP_UPDATE() {
|
|
1742
|
-
HEAPU16.unsigned = ((x) => x & 65535);
|
|
1743
|
-
HEAPU32.unsigned = ((x) => x >>> 0);
|
|
1744
|
-
}
|
|
1745
|
-
__name(LE_HEAP_UPDATE, "LE_HEAP_UPDATE");
|
|
1746
1660
|
{
|
|
1747
1661
|
initMemory();
|
|
1748
1662
|
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
@@ -1774,18 +1688,15 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1774
1688
|
}
|
|
1775
1689
|
consumedModuleProp("preInit");
|
|
1776
1690
|
}
|
|
1777
|
-
Module["setValue"] = setValue;
|
|
1778
|
-
Module["getValue"] = getValue;
|
|
1779
1691
|
Module["UTF8ToString"] = UTF8ToString;
|
|
1780
1692
|
Module["stringToUTF8"] = stringToUTF8;
|
|
1781
1693
|
Module["lengthBytesUTF8"] = lengthBytesUTF8;
|
|
1782
1694
|
Module["AsciiToString"] = AsciiToString;
|
|
1783
1695
|
Module["stringToUTF16"] = stringToUTF16;
|
|
1784
1696
|
Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
|
|
1785
|
-
Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
|
|
1786
1697
|
var missingLibrarySymbols = ["writeI53ToI64", "writeI53ToI64Clamped", "writeI53ToI64Signaling", "writeI53ToU64Clamped", "writeI53ToU64Signaling", "readI53FromI64", "readI53FromU64", "convertI32PairToI53", "convertI32PairToI53Checked", "convertU32PairToI53", "getTempRet0", "setTempRet0", "zeroMemory", "withStackSave", "strError", "inetPton4", "inetNtop4", "inetPton6", "inetNtop6", "readSockaddr", "writeSockaddr", "readEmAsmArgs", "runEmAsmFunction", "runMainThreadEmAsm", "jstoi_q", "getExecutableName", "autoResumeAudioContext", "getDynCaller", "runtimeKeepalivePush", "runtimeKeepalivePop", "callUserCallback", "maybeExit", "asmjsMangle", "mmapAlloc", "HandleAllocator", "getNativeTypeSize", "getUniqueRunDependency", "addOnInit", "addOnPreMain", "addOnExit", "STACK_SIZE", "STACK_ALIGN", "POINTER_SIZE", "ASSERTIONS", "ccall", "cwrap", "removeFunction", "intArrayFromString", "intArrayToString", "stringToAscii", "UTF16ToString", "lengthBytesUTF16", "UTF32ToString", "stringToUTF32", "lengthBytesUTF32", "stringToNewUTF8", "writeArrayToMemory", "registerKeyEventCallback", "maybeCStringToJsString", "findEventTarget", "getBoundingClientRect", "fillMouseEventData", "registerMouseEventCallback", "registerWheelEventCallback", "registerUiEventCallback", "registerFocusEventCallback", "fillDeviceOrientationEventData", "registerDeviceOrientationEventCallback", "fillDeviceMotionEventData", "registerDeviceMotionEventCallback", "screenOrientation", "fillOrientationChangeEventData", "registerOrientationChangeEventCallback", "fillFullscreenChangeEventData", "registerFullscreenChangeEventCallback", "JSEvents_requestFullscreen", "JSEvents_resizeCanvasForFullscreen", "registerRestoreOldStyle", "hideEverythingExceptGivenElement", "restoreHiddenElements", "setLetterbox", "softFullscreenResizeWebGLRenderTarget", "doRequestFullscreen", "fillPointerlockChangeEventData", "registerPointerlockChangeEventCallback", "registerPointerlockErrorEventCallback", "requestPointerLock", "fillVisibilityChangeEventData", "registerVisibilityChangeEventCallback", "registerTouchEventCallback", "fillGamepadEventData", "registerGamepadEventCallback", "registerBeforeUnloadEventCallback", "fillBatteryEventData", "registerBatteryEventCallback", "setCanvasElementSize", "getCanvasElementSize", "jsStackTrace", "getCallstack", "convertPCtoSourceLocation", "getEnvStrings", "checkWasiClock", "wasiRightsToMuslOFlags", "wasiOFlagsToMuslOFlags", "initRandomFill", "randomFill", "safeSetTimeout", "setImmediateWrapped", "safeRequestAnimationFrame", "clearImmediateWrapped", "registerPostMainLoop", "registerPreMainLoop", "getPromise", "makePromise", "idsToPromises", "makePromiseCallback", "Browser_asyncPrepareDataCounter", "isLeapYear", "ydayFromDate", "arraySum", "addDays", "getSocketFromFD", "getSocketAddress", "dlopenInternal", "heapObjectForWebGLType", "toTypedArrayIndex", "webgl_enable_ANGLE_instanced_arrays", "webgl_enable_OES_vertex_array_object", "webgl_enable_WEBGL_draw_buffers", "webgl_enable_WEBGL_multi_draw", "webgl_enable_EXT_polygon_offset_clamp", "webgl_enable_EXT_clip_control", "webgl_enable_WEBGL_polygon_mode", "emscriptenWebGLGet", "computeUnpackAlignedImageSize", "colorChannelsInGlTextureFormat", "emscriptenWebGLGetTexPixelData", "emscriptenWebGLGetUniform", "webglGetUniformLocation", "webglPrepareUniformLocationsBeforeFirstUse", "webglGetLeftBracePos", "emscriptenWebGLGetVertexAttrib", "__glGetActiveAttribOrUniform", "writeGLArray", "registerWebGlEventCallback", "runAndAbortIfError", "ALLOC_NORMAL", "ALLOC_STACK", "allocate", "writeStringToMemory", "writeAsciiToMemory", "demangle", "stackTrace"];
|
|
1787
1698
|
missingLibrarySymbols.forEach(missingLibrarySymbol);
|
|
1788
|
-
var unexportedSymbols = ["run", "out", "err", "callMain", "abort", "wasmMemory", "wasmExports", "writeStackCookie", "checkStackCookie", "INT53_MAX", "INT53_MIN", "bigintToI53Checked", "stackSave", "stackRestore", "stackAlloc", "ptrToString", "exitJS", "getHeapMax", "growMemory", "ENV", "ERRNO_CODES", "DNS", "Protocols", "Sockets", "timers", "warnOnce", "readEmAsmArgsArray", "dynCall", "handleException", "keepRuntimeAlive", "asyncLoad", "alignMemory", "wasmTable", "noExitRuntime", "addRunDependency", "removeRunDependency", "addOnPreRun", "addOnPostCtor", "addOnPostRun", "convertJsFunctionToWasm", "freeTableIndexes", "functionsInTableMap", "getEmptyTableSlot", "updateTableMap", "getFunctionAddress", "addFunction", "PATH", "PATH_FS", "UTF8Decoder", "UTF8ArrayToString", "stringToUTF8Array", "UTF16Decoder", "stringToUTF8OnStack", "JSEvents", "specialHTMLTargets", "findCanvasEventTarget", "currentFullscreenStrategy", "restoreOldWindowedStyle", "UNWIND_CACHE", "ExitStatus", "flush_NO_FILESYSTEM", "emSetImmediate", "emClearImmediate_deps", "emClearImmediate", "promiseMap", "Browser", "requestFullscreen", "requestFullScreen", "setCanvasSize", "getUserMedia", "createContext", "getPreloadedImageData__data", "wget", "MONTH_DAYS_REGULAR", "MONTH_DAYS_LEAP", "MONTH_DAYS_REGULAR_CUMULATIVE", "MONTH_DAYS_LEAP_CUMULATIVE", "SYSCALLS", "isSymbolDefined", "GOT", "currentModuleWeakSymbols", "LDSO", "getMemory", "mergeLibSymbols", "newDSO", "loadDynamicLibrary", "tempFixedLengthArray", "miniTempWebGLFloatBuffers", "miniTempWebGLIntBuffers", "GL", "AL", "GLUT", "EGL", "GLEW", "IDBStore", "SDL", "SDL_gfx", "allocateUTF8", "allocateUTF8OnStack", "print", "printErr", "jstoi_s"
|
|
1699
|
+
var unexportedSymbols = ["run", "out", "err", "callMain", "abort", "wasmMemory", "wasmExports", "HEAPF32", "HEAPF64", "HEAP8", "HEAP16", "HEAP64", "HEAPU64", "writeStackCookie", "checkStackCookie", "INT53_MAX", "INT53_MIN", "bigintToI53Checked", "stackSave", "stackRestore", "stackAlloc", "ptrToString", "exitJS", "getHeapMax", "growMemory", "ENV", "ERRNO_CODES", "DNS", "Protocols", "Sockets", "timers", "warnOnce", "readEmAsmArgsArray", "dynCall", "handleException", "keepRuntimeAlive", "asyncLoad", "alignMemory", "wasmTable", "noExitRuntime", "addRunDependency", "removeRunDependency", "addOnPreRun", "addOnPostCtor", "addOnPostRun", "convertJsFunctionToWasm", "freeTableIndexes", "functionsInTableMap", "getEmptyTableSlot", "updateTableMap", "getFunctionAddress", "addFunction", "setValue", "getValue", "PATH", "PATH_FS", "UTF8Decoder", "UTF8ArrayToString", "stringToUTF8Array", "UTF16Decoder", "stringToUTF8OnStack", "JSEvents", "specialHTMLTargets", "findCanvasEventTarget", "currentFullscreenStrategy", "restoreOldWindowedStyle", "UNWIND_CACHE", "ExitStatus", "flush_NO_FILESYSTEM", "emSetImmediate", "emClearImmediate_deps", "emClearImmediate", "promiseMap", "Browser", "requestFullscreen", "requestFullScreen", "setCanvasSize", "getUserMedia", "createContext", "getPreloadedImageData__data", "wget", "MONTH_DAYS_REGULAR", "MONTH_DAYS_LEAP", "MONTH_DAYS_REGULAR_CUMULATIVE", "MONTH_DAYS_LEAP_CUMULATIVE", "SYSCALLS", "isSymbolDefined", "GOT", "currentModuleWeakSymbols", "LDSO", "getMemory", "mergeLibSymbols", "newDSO", "loadDynamicLibrary", "tempFixedLengthArray", "miniTempWebGLFloatBuffers", "miniTempWebGLIntBuffers", "GL", "AL", "GLUT", "EGL", "GLEW", "IDBStore", "SDL", "SDL_gfx", "allocateUTF8", "allocateUTF8OnStack", "print", "printErr", "jstoi_s"];
|
|
1789
1700
|
unexportedSymbols.forEach(unexportedRuntimeSymbol);
|
|
1790
1701
|
function checkIncomingModuleAPI() {
|
|
1791
1702
|
ignoredModuleProp("fetchSettings");
|
|
@@ -1831,6 +1742,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1831
1742
|
var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = makeInvalidEarlyAccess("_ts_parser_enable_logger_wasm");
|
|
1832
1743
|
var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = makeInvalidEarlyAccess("_ts_parser_parse_wasm");
|
|
1833
1744
|
var _ts_parser_parse_limited_wasm = Module["_ts_parser_parse_limited_wasm"] = makeInvalidEarlyAccess("_ts_parser_parse_limited_wasm");
|
|
1745
|
+
var _ts_parser_last_parse_operations_wasm = Module["_ts_parser_last_parse_operations_wasm"] = makeInvalidEarlyAccess("_ts_parser_last_parse_operations_wasm");
|
|
1834
1746
|
var _ts_parser_abort_limited_wasm = Module["_ts_parser_abort_limited_wasm"] = makeInvalidEarlyAccess("_ts_parser_abort_limited_wasm");
|
|
1835
1747
|
var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = makeInvalidEarlyAccess("_ts_parser_included_ranges_wasm");
|
|
1836
1748
|
var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = makeInvalidEarlyAccess("_ts_language_type_is_named_wasm");
|
|
@@ -1856,16 +1768,12 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1856
1768
|
var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_previous_sibling_wasm");
|
|
1857
1769
|
var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_descendant_wasm");
|
|
1858
1770
|
var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_parent_wasm");
|
|
1859
|
-
var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_type_id_wasm");
|
|
1860
1771
|
var _ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_state_id_wasm");
|
|
1861
|
-
var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_is_named_wasm");
|
|
1862
|
-
var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_is_missing_wasm");
|
|
1863
1772
|
var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_id_wasm");
|
|
1864
1773
|
var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_position_wasm");
|
|
1865
1774
|
var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_position_wasm");
|
|
1866
1775
|
var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_index_wasm");
|
|
1867
1776
|
var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_index_wasm");
|
|
1868
|
-
var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_field_id_wasm");
|
|
1869
1777
|
var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth_wasm");
|
|
1870
1778
|
var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index_wasm");
|
|
1871
1779
|
var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_wasm");
|
|
@@ -1977,8 +1885,9 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1977
1885
|
Module["_ts_scanner_realloc_wasm"] = _ts_scanner_realloc_wasm = createExportWrapper("ts_scanner_realloc_wasm", 2);
|
|
1978
1886
|
Module["_ts_parser_new_wasm"] = _ts_parser_new_wasm = createExportWrapper("ts_parser_new_wasm", 0);
|
|
1979
1887
|
Module["_ts_parser_enable_logger_wasm"] = _ts_parser_enable_logger_wasm = createExportWrapper("ts_parser_enable_logger_wasm", 2);
|
|
1980
|
-
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm",
|
|
1981
|
-
Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm",
|
|
1888
|
+
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm", 3);
|
|
1889
|
+
Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm", 2);
|
|
1890
|
+
Module["_ts_parser_last_parse_operations_wasm"] = _ts_parser_last_parse_operations_wasm = createExportWrapper("ts_parser_last_parse_operations_wasm", 1);
|
|
1982
1891
|
Module["_ts_parser_abort_limited_wasm"] = _ts_parser_abort_limited_wasm = createExportWrapper("ts_parser_abort_limited_wasm", 0);
|
|
1983
1892
|
Module["_ts_parser_included_ranges_wasm"] = _ts_parser_included_ranges_wasm = createExportWrapper("ts_parser_included_ranges_wasm", 1);
|
|
1984
1893
|
Module["_ts_language_type_is_named_wasm"] = _ts_language_type_is_named_wasm = createExportWrapper("ts_language_type_is_named_wasm", 2);
|
|
@@ -1994,26 +1903,22 @@ var require_web_tree_sitter = __commonJS({
|
|
|
1994
1903
|
Module["_ts_tree_cursor_new_wasm"] = _ts_tree_cursor_new_wasm = createExportWrapper("ts_tree_cursor_new_wasm", 1);
|
|
1995
1904
|
Module["_ts_tree_cursor_copy_wasm"] = _ts_tree_cursor_copy_wasm = createExportWrapper("ts_tree_cursor_copy_wasm", 1);
|
|
1996
1905
|
Module["_ts_tree_cursor_delete_wasm"] = _ts_tree_cursor_delete_wasm = createExportWrapper("ts_tree_cursor_delete_wasm", 1);
|
|
1997
|
-
Module["_ts_tree_cursor_reset_wasm"] = _ts_tree_cursor_reset_wasm = createExportWrapper("ts_tree_cursor_reset_wasm",
|
|
1906
|
+
Module["_ts_tree_cursor_reset_wasm"] = _ts_tree_cursor_reset_wasm = createExportWrapper("ts_tree_cursor_reset_wasm", 2);
|
|
1998
1907
|
Module["_ts_tree_cursor_reset_to_wasm"] = _ts_tree_cursor_reset_to_wasm = createExportWrapper("ts_tree_cursor_reset_to_wasm", 2);
|
|
1999
1908
|
Module["_ts_tree_cursor_goto_first_child_wasm"] = _ts_tree_cursor_goto_first_child_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_wasm", 1);
|
|
2000
1909
|
Module["_ts_tree_cursor_goto_last_child_wasm"] = _ts_tree_cursor_goto_last_child_wasm = createExportWrapper("ts_tree_cursor_goto_last_child_wasm", 1);
|
|
2001
|
-
Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = _ts_tree_cursor_goto_first_child_for_index_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_for_index_wasm",
|
|
1910
|
+
Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = _ts_tree_cursor_goto_first_child_for_index_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_for_index_wasm", 2);
|
|
2002
1911
|
Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = _ts_tree_cursor_goto_first_child_for_position_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_for_position_wasm", 1);
|
|
2003
1912
|
Module["_ts_tree_cursor_goto_next_sibling_wasm"] = _ts_tree_cursor_goto_next_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_next_sibling_wasm", 1);
|
|
2004
1913
|
Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = _ts_tree_cursor_goto_previous_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_previous_sibling_wasm", 1);
|
|
2005
1914
|
Module["_ts_tree_cursor_goto_descendant_wasm"] = _ts_tree_cursor_goto_descendant_wasm = createExportWrapper("ts_tree_cursor_goto_descendant_wasm", 2);
|
|
2006
1915
|
Module["_ts_tree_cursor_goto_parent_wasm"] = _ts_tree_cursor_goto_parent_wasm = createExportWrapper("ts_tree_cursor_goto_parent_wasm", 1);
|
|
2007
|
-
Module["_ts_tree_cursor_current_node_type_id_wasm"] = _ts_tree_cursor_current_node_type_id_wasm = createExportWrapper("ts_tree_cursor_current_node_type_id_wasm", 1);
|
|
2008
1916
|
Module["_ts_tree_cursor_current_node_state_id_wasm"] = _ts_tree_cursor_current_node_state_id_wasm = createExportWrapper("ts_tree_cursor_current_node_state_id_wasm", 1);
|
|
2009
|
-
Module["_ts_tree_cursor_current_node_is_named_wasm"] = _ts_tree_cursor_current_node_is_named_wasm = createExportWrapper("ts_tree_cursor_current_node_is_named_wasm", 1);
|
|
2010
|
-
Module["_ts_tree_cursor_current_node_is_missing_wasm"] = _ts_tree_cursor_current_node_is_missing_wasm = createExportWrapper("ts_tree_cursor_current_node_is_missing_wasm", 1);
|
|
2011
1917
|
Module["_ts_tree_cursor_current_node_id_wasm"] = _ts_tree_cursor_current_node_id_wasm = createExportWrapper("ts_tree_cursor_current_node_id_wasm", 1);
|
|
2012
1918
|
Module["_ts_tree_cursor_start_position_wasm"] = _ts_tree_cursor_start_position_wasm = createExportWrapper("ts_tree_cursor_start_position_wasm", 1);
|
|
2013
1919
|
Module["_ts_tree_cursor_end_position_wasm"] = _ts_tree_cursor_end_position_wasm = createExportWrapper("ts_tree_cursor_end_position_wasm", 1);
|
|
2014
1920
|
Module["_ts_tree_cursor_start_index_wasm"] = _ts_tree_cursor_start_index_wasm = createExportWrapper("ts_tree_cursor_start_index_wasm", 1);
|
|
2015
1921
|
Module["_ts_tree_cursor_end_index_wasm"] = _ts_tree_cursor_end_index_wasm = createExportWrapper("ts_tree_cursor_end_index_wasm", 1);
|
|
2016
|
-
Module["_ts_tree_cursor_current_field_id_wasm"] = _ts_tree_cursor_current_field_id_wasm = createExportWrapper("ts_tree_cursor_current_field_id_wasm", 1);
|
|
2017
1922
|
Module["_ts_tree_cursor_current_depth_wasm"] = _ts_tree_cursor_current_depth_wasm = createExportWrapper("ts_tree_cursor_current_depth_wasm", 1);
|
|
2018
1923
|
Module["_ts_tree_cursor_current_descendant_index_wasm"] = _ts_tree_cursor_current_descendant_index_wasm = createExportWrapper("ts_tree_cursor_current_descendant_index_wasm", 1);
|
|
2019
1924
|
Module["_ts_tree_cursor_current_node_wasm"] = _ts_tree_cursor_current_node_wasm = createExportWrapper("ts_tree_cursor_current_node_wasm", 1);
|
|
@@ -2119,20 +2024,20 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2119
2024
|
/** @export */
|
|
2120
2025
|
fd_write: _fd_write,
|
|
2121
2026
|
/** @export */
|
|
2122
|
-
invoke_i,
|
|
2123
|
-
/** @export */
|
|
2124
|
-
invoke_ii,
|
|
2125
|
-
/** @export */
|
|
2126
2027
|
invoke_iii,
|
|
2127
2028
|
/** @export */
|
|
2128
2029
|
invoke_iiii,
|
|
2129
2030
|
/** @export */
|
|
2130
2031
|
invoke_iiiii,
|
|
2131
2032
|
/** @export */
|
|
2033
|
+
invoke_ji,
|
|
2034
|
+
/** @export */
|
|
2132
2035
|
invoke_vi,
|
|
2133
2036
|
/** @export */
|
|
2134
2037
|
invoke_vii,
|
|
2135
2038
|
/** @export */
|
|
2039
|
+
invoke_vj,
|
|
2040
|
+
/** @export */
|
|
2136
2041
|
memory: wasmMemory,
|
|
2137
2042
|
/** @export */
|
|
2138
2043
|
segfault,
|
|
@@ -2143,61 +2048,62 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2143
2048
|
/** @export */
|
|
2144
2049
|
tree_sitter_progress_callback: _tree_sitter_progress_callback
|
|
2145
2050
|
};
|
|
2146
|
-
function
|
|
2051
|
+
function invoke_vii(index, a1, a2) {
|
|
2147
2052
|
var sp = stackSave();
|
|
2148
2053
|
try {
|
|
2149
|
-
getWasmTableEntry(index)(a1);
|
|
2054
|
+
getWasmTableEntry(index)(a1, a2);
|
|
2150
2055
|
} catch (e) {
|
|
2151
2056
|
stackRestore(sp);
|
|
2152
2057
|
if (e !== e + 0) throw e;
|
|
2153
2058
|
_setThrew(1, 0);
|
|
2154
2059
|
}
|
|
2155
2060
|
}
|
|
2156
|
-
__name(
|
|
2157
|
-
function
|
|
2061
|
+
__name(invoke_vii, "invoke_vii");
|
|
2062
|
+
function invoke_iii(index, a1, a2) {
|
|
2158
2063
|
var sp = stackSave();
|
|
2159
2064
|
try {
|
|
2160
|
-
return getWasmTableEntry(index)();
|
|
2065
|
+
return getWasmTableEntry(index)(a1, a2);
|
|
2161
2066
|
} catch (e) {
|
|
2162
2067
|
stackRestore(sp);
|
|
2163
2068
|
if (e !== e + 0) throw e;
|
|
2164
2069
|
_setThrew(1, 0);
|
|
2165
2070
|
}
|
|
2166
2071
|
}
|
|
2167
|
-
__name(
|
|
2168
|
-
function
|
|
2072
|
+
__name(invoke_iii, "invoke_iii");
|
|
2073
|
+
function invoke_vj(index, a1) {
|
|
2169
2074
|
var sp = stackSave();
|
|
2170
2075
|
try {
|
|
2171
|
-
|
|
2076
|
+
getWasmTableEntry(index)(a1);
|
|
2172
2077
|
} catch (e) {
|
|
2173
2078
|
stackRestore(sp);
|
|
2174
2079
|
if (e !== e + 0) throw e;
|
|
2175
2080
|
_setThrew(1, 0);
|
|
2176
2081
|
}
|
|
2177
2082
|
}
|
|
2178
|
-
__name(
|
|
2179
|
-
function
|
|
2083
|
+
__name(invoke_vj, "invoke_vj");
|
|
2084
|
+
function invoke_ji(index, a1) {
|
|
2180
2085
|
var sp = stackSave();
|
|
2181
2086
|
try {
|
|
2182
|
-
return getWasmTableEntry(index)(a1
|
|
2087
|
+
return getWasmTableEntry(index)(a1);
|
|
2183
2088
|
} catch (e) {
|
|
2184
2089
|
stackRestore(sp);
|
|
2185
2090
|
if (e !== e + 0) throw e;
|
|
2186
2091
|
_setThrew(1, 0);
|
|
2092
|
+
return 0n;
|
|
2187
2093
|
}
|
|
2188
2094
|
}
|
|
2189
|
-
__name(
|
|
2190
|
-
function
|
|
2095
|
+
__name(invoke_ji, "invoke_ji");
|
|
2096
|
+
function invoke_iiiii(index, a1, a2, a3, a4) {
|
|
2191
2097
|
var sp = stackSave();
|
|
2192
2098
|
try {
|
|
2193
|
-
getWasmTableEntry(index)(a1, a2);
|
|
2099
|
+
return getWasmTableEntry(index)(a1, a2, a3, a4);
|
|
2194
2100
|
} catch (e) {
|
|
2195
2101
|
stackRestore(sp);
|
|
2196
2102
|
if (e !== e + 0) throw e;
|
|
2197
2103
|
_setThrew(1, 0);
|
|
2198
2104
|
}
|
|
2199
2105
|
}
|
|
2200
|
-
__name(
|
|
2106
|
+
__name(invoke_iiiii, "invoke_iiiii");
|
|
2201
2107
|
function invoke_iiii(index, a1, a2, a3) {
|
|
2202
2108
|
var sp = stackSave();
|
|
2203
2109
|
try {
|
|
@@ -2209,17 +2115,17 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2209
2115
|
}
|
|
2210
2116
|
}
|
|
2211
2117
|
__name(invoke_iiii, "invoke_iiii");
|
|
2212
|
-
function
|
|
2118
|
+
function invoke_vi(index, a1) {
|
|
2213
2119
|
var sp = stackSave();
|
|
2214
2120
|
try {
|
|
2215
|
-
|
|
2121
|
+
getWasmTableEntry(index)(a1);
|
|
2216
2122
|
} catch (e) {
|
|
2217
2123
|
stackRestore(sp);
|
|
2218
2124
|
if (e !== e + 0) throw e;
|
|
2219
2125
|
_setThrew(1, 0);
|
|
2220
2126
|
}
|
|
2221
2127
|
}
|
|
2222
|
-
__name(
|
|
2128
|
+
__name(invoke_vi, "invoke_vi");
|
|
2223
2129
|
var calledRun;
|
|
2224
2130
|
function callMain(args2 = []) {
|
|
2225
2131
|
assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
|
|
@@ -2231,10 +2137,10 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2231
2137
|
var argv = stackAlloc((argc + 1) * 4);
|
|
2232
2138
|
var argv_ptr = argv;
|
|
2233
2139
|
args2.forEach((arg) => {
|
|
2234
|
-
|
|
2140
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing")] = stringToUTF8OnStack(arg);
|
|
2235
2141
|
argv_ptr += 4;
|
|
2236
2142
|
});
|
|
2237
|
-
|
|
2143
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing")] = 0;
|
|
2238
2144
|
try {
|
|
2239
2145
|
var ret = entryFunction(argc, argv);
|
|
2240
2146
|
exitJS(
|
|
@@ -2249,7 +2155,7 @@ var require_web_tree_sitter = __commonJS({
|
|
|
2249
2155
|
}
|
|
2250
2156
|
__name(callMain, "callMain");
|
|
2251
2157
|
function stackCheckInit() {
|
|
2252
|
-
_emscripten_stack_set_limits(
|
|
2158
|
+
_emscripten_stack_set_limits(82464, 16928);
|
|
2253
2159
|
writeStackCookie();
|
|
2254
2160
|
}
|
|
2255
2161
|
__name(stackCheckInit, "stackCheckInit");
|
|
@@ -2352,7 +2258,7 @@ __export(index_exports, {
|
|
|
2352
2258
|
MIN_COMPATIBLE_VERSION: () => MIN_COMPATIBLE_VERSION,
|
|
2353
2259
|
Node: () => Node,
|
|
2354
2260
|
Parser: () => Parser,
|
|
2355
|
-
Tree: () =>
|
|
2261
|
+
Tree: () => Tree2,
|
|
2356
2262
|
TreeCursor: () => TreeCursor
|
|
2357
2263
|
});
|
|
2358
2264
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -2460,9 +2366,7 @@ var Edit = class {
|
|
|
2460
2366
|
};
|
|
2461
2367
|
|
|
2462
2368
|
// src/constants.ts
|
|
2463
|
-
var SIZE_OF_SHORT = 2;
|
|
2464
2369
|
var SIZE_OF_INT = 4;
|
|
2465
|
-
var SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
|
|
2466
2370
|
var SIZE_OF_NODE = 5 * SIZE_OF_INT;
|
|
2467
2371
|
var SIZE_OF_POINT = 2 * SIZE_OF_INT;
|
|
2468
2372
|
var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
|
|
@@ -2585,177 +2489,53 @@ var LookaheadIterator = class {
|
|
|
2585
2489
|
}
|
|
2586
2490
|
};
|
|
2587
2491
|
|
|
2588
|
-
// src/
|
|
2589
|
-
function getText(tree, startIndex, endIndex, startPosition) {
|
|
2590
|
-
const length = endIndex - startIndex;
|
|
2591
|
-
let result = tree.textCallback(startIndex, startPosition);
|
|
2592
|
-
if (result) {
|
|
2593
|
-
startIndex += result.length;
|
|
2594
|
-
while (startIndex < endIndex) {
|
|
2595
|
-
const string = tree.textCallback(startIndex, startPosition);
|
|
2596
|
-
if (string && string.length > 0) {
|
|
2597
|
-
startIndex += string.length;
|
|
2598
|
-
result += string;
|
|
2599
|
-
} else {
|
|
2600
|
-
break;
|
|
2601
|
-
}
|
|
2602
|
-
}
|
|
2603
|
-
if (startIndex > endIndex) {
|
|
2604
|
-
result = result.slice(0, length);
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
return result ?? "";
|
|
2608
|
-
}
|
|
2609
|
-
__name(getText, "getText");
|
|
2492
|
+
// src/tree_cursor.ts
|
|
2610
2493
|
var finalizer2 = newFinalizer((address) => {
|
|
2611
|
-
C.
|
|
2494
|
+
C._ts_tree_cursor_delete_wasm(address);
|
|
2612
2495
|
});
|
|
2613
|
-
var
|
|
2496
|
+
var TreeCursor = class _TreeCursor {
|
|
2614
2497
|
static {
|
|
2615
|
-
__name(this, "
|
|
2498
|
+
__name(this, "TreeCursor");
|
|
2616
2499
|
}
|
|
2617
2500
|
/** @internal */
|
|
2618
2501
|
[0] = 0;
|
|
2619
2502
|
// Internal handle for Wasm
|
|
2620
2503
|
/** @internal */
|
|
2621
|
-
|
|
2622
|
-
/** The language that was used to parse the syntax tree. */
|
|
2623
|
-
language;
|
|
2504
|
+
tree;
|
|
2624
2505
|
/** @internal */
|
|
2625
|
-
|
|
2626
|
-
assertInternal(internal);
|
|
2627
|
-
this[0] = address;
|
|
2628
|
-
this.language = language;
|
|
2629
|
-
this.textCallback = textCallback;
|
|
2630
|
-
finalizer2?.register(this, address, this);
|
|
2631
|
-
}
|
|
2632
|
-
/** Create a shallow copy of the syntax tree. This is very fast. */
|
|
2633
|
-
copy() {
|
|
2634
|
-
const address = C._ts_tree_copy(this[0]);
|
|
2635
|
-
return new _Tree(INTERNAL, address, this.language, this.textCallback);
|
|
2636
|
-
}
|
|
2637
|
-
/** Delete the syntax tree, freeing its resources. */
|
|
2638
|
-
delete() {
|
|
2639
|
-
finalizer2?.unregister(this);
|
|
2640
|
-
C._ts_tree_delete(this[0]);
|
|
2641
|
-
this[0] = 0;
|
|
2642
|
-
}
|
|
2643
|
-
/** Get the root node of the syntax tree. */
|
|
2644
|
-
get rootNode() {
|
|
2645
|
-
C._ts_tree_root_node_wasm(this[0]);
|
|
2646
|
-
return unmarshalNode(this);
|
|
2647
|
-
}
|
|
2648
|
-
/**
|
|
2649
|
-
* Get the root node of the syntax tree, but with its position shifted
|
|
2650
|
-
* forward by the given offset.
|
|
2651
|
-
*/
|
|
2652
|
-
rootNodeWithOffset(offsetBytes, offsetExtent) {
|
|
2653
|
-
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
2654
|
-
C.setValue(address, offsetBytes, "i32");
|
|
2655
|
-
marshalPoint(address + SIZE_OF_INT, offsetExtent);
|
|
2656
|
-
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
2657
|
-
return unmarshalNode(this);
|
|
2658
|
-
}
|
|
2659
|
-
/**
|
|
2660
|
-
* Edit the syntax tree to keep it in sync with source code that has been
|
|
2661
|
-
* edited.
|
|
2662
|
-
*
|
|
2663
|
-
* You must describe the edit both in terms of byte offsets and in terms of
|
|
2664
|
-
* row/column coordinates.
|
|
2665
|
-
*/
|
|
2666
|
-
edit(edit) {
|
|
2667
|
-
marshalEdit(edit);
|
|
2668
|
-
C._ts_tree_edit_wasm(this[0]);
|
|
2669
|
-
}
|
|
2670
|
-
/** Create a new {@link TreeCursor} starting from the root of the tree. */
|
|
2671
|
-
walk() {
|
|
2672
|
-
return this.rootNode.walk();
|
|
2673
|
-
}
|
|
2674
|
-
/**
|
|
2675
|
-
* Compare this old edited syntax tree to a new syntax tree representing
|
|
2676
|
-
* the same document, returning a sequence of ranges whose syntactic
|
|
2677
|
-
* structure has changed.
|
|
2678
|
-
*
|
|
2679
|
-
* For this to work correctly, this syntax tree must have been edited such
|
|
2680
|
-
* that its ranges match up to the new tree. Generally, you'll want to
|
|
2681
|
-
* call this method right after calling one of the [`Parser::parse`]
|
|
2682
|
-
* functions. Call it on the old tree that was passed to parse, and
|
|
2683
|
-
* pass the new tree that was returned from `parse`.
|
|
2684
|
-
*/
|
|
2685
|
-
getChangedRanges(other) {
|
|
2686
|
-
if (!(other instanceof _Tree)) {
|
|
2687
|
-
throw new TypeError("Argument must be a Tree");
|
|
2688
|
-
}
|
|
2689
|
-
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
2690
|
-
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
2691
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2692
|
-
const result = new Array(count);
|
|
2693
|
-
if (count > 0) {
|
|
2694
|
-
let address = buffer;
|
|
2695
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
2696
|
-
result[i2] = unmarshalRange(address);
|
|
2697
|
-
address += SIZE_OF_RANGE;
|
|
2698
|
-
}
|
|
2699
|
-
C._ts_free_wasm(buffer);
|
|
2700
|
-
}
|
|
2701
|
-
return result;
|
|
2702
|
-
}
|
|
2703
|
-
/** Get the included ranges that were used to parse the syntax tree. */
|
|
2704
|
-
getIncludedRanges() {
|
|
2705
|
-
C._ts_tree_included_ranges_wasm(this[0]);
|
|
2706
|
-
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
2707
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2708
|
-
const result = new Array(count);
|
|
2709
|
-
if (count > 0) {
|
|
2710
|
-
let address = buffer;
|
|
2711
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
2712
|
-
result[i2] = unmarshalRange(address);
|
|
2713
|
-
address += SIZE_OF_RANGE;
|
|
2714
|
-
}
|
|
2715
|
-
C._ts_free_wasm(buffer);
|
|
2716
|
-
}
|
|
2717
|
-
return result;
|
|
2718
|
-
}
|
|
2719
|
-
};
|
|
2720
|
-
|
|
2721
|
-
// src/tree_cursor.ts
|
|
2722
|
-
var finalizer3 = newFinalizer((handles) => {
|
|
2723
|
-
marshalTreeCursor({ handles });
|
|
2724
|
-
C._ts_tree_cursor_delete_wasm(0);
|
|
2725
|
-
});
|
|
2726
|
-
var TreeCursor = class _TreeCursor {
|
|
2727
|
-
static {
|
|
2728
|
-
__name(this, "TreeCursor");
|
|
2729
|
-
}
|
|
2506
|
+
editVersion = -1;
|
|
2730
2507
|
/** @internal */
|
|
2731
|
-
|
|
2732
|
-
// Internal handles for Wasm, shared with the finalizer.
|
|
2508
|
+
_nodeTypeId = 0;
|
|
2733
2509
|
/** @internal */
|
|
2734
|
-
|
|
2510
|
+
_fieldId = 0;
|
|
2511
|
+
/** @internal */
|
|
2512
|
+
_startIndex = 0;
|
|
2513
|
+
/** @internal */
|
|
2514
|
+
_endIndex = 0;
|
|
2515
|
+
/** @internal */
|
|
2516
|
+
_flags = 0;
|
|
2735
2517
|
/** @internal */
|
|
2736
|
-
constructor(internal, tree) {
|
|
2518
|
+
constructor(internal, tree, address) {
|
|
2737
2519
|
assertInternal(internal);
|
|
2520
|
+
this[0] = address;
|
|
2738
2521
|
this.tree = tree;
|
|
2739
|
-
|
|
2740
|
-
|
|
2522
|
+
this.readNodeCache();
|
|
2523
|
+
finalizer2?.register(this, address, this);
|
|
2741
2524
|
}
|
|
2742
2525
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
2743
2526
|
copy() {
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
return new _TreeCursor(INTERNAL, this.tree);
|
|
2527
|
+
const address = C._ts_tree_cursor_copy_wasm(this[0]);
|
|
2528
|
+
return new _TreeCursor(INTERNAL, this.tree, address);
|
|
2747
2529
|
}
|
|
2748
2530
|
/** Delete the tree cursor, freeing its resources. */
|
|
2749
2531
|
delete() {
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
this.handles.fill(0);
|
|
2532
|
+
finalizer2?.unregister(this);
|
|
2533
|
+
C._ts_tree_cursor_delete_wasm(this[0]);
|
|
2534
|
+
this[0] = 0;
|
|
2754
2535
|
}
|
|
2755
2536
|
/** Get the tree cursor's current {@link Node}. */
|
|
2756
2537
|
get currentNode() {
|
|
2757
|
-
|
|
2758
|
-
C._ts_tree_cursor_current_node_wasm(this.tree[0]);
|
|
2538
|
+
C._ts_tree_cursor_current_node_wasm(this[0]);
|
|
2759
2539
|
return unmarshalNode(this.tree);
|
|
2760
2540
|
}
|
|
2761
2541
|
/**
|
|
@@ -2764,47 +2544,41 @@ var TreeCursor = class _TreeCursor {
|
|
|
2764
2544
|
* See also {@link TreeCursor#currentFieldName}.
|
|
2765
2545
|
*/
|
|
2766
2546
|
get currentFieldId() {
|
|
2767
|
-
|
|
2768
|
-
return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
|
|
2547
|
+
return this._fieldId;
|
|
2769
2548
|
}
|
|
2770
2549
|
/** Get the field name of this tree cursor's current node. */
|
|
2771
2550
|
get currentFieldName() {
|
|
2772
|
-
return this.tree.language.fields[this.
|
|
2551
|
+
return this.tree.language.fields[this._fieldId];
|
|
2773
2552
|
}
|
|
2774
2553
|
/**
|
|
2775
2554
|
* Get the depth of the cursor's current node relative to the original
|
|
2776
2555
|
* node that the cursor was constructed with.
|
|
2777
2556
|
*/
|
|
2778
2557
|
get currentDepth() {
|
|
2779
|
-
|
|
2780
|
-
return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
|
|
2558
|
+
return C._ts_tree_cursor_current_depth_wasm(this[0]);
|
|
2781
2559
|
}
|
|
2782
2560
|
/**
|
|
2783
2561
|
* Get the index of the cursor's current node out of all of the
|
|
2784
2562
|
* descendants of the original node that the cursor was constructed with.
|
|
2785
2563
|
*/
|
|
2786
2564
|
get currentDescendantIndex() {
|
|
2787
|
-
|
|
2788
|
-
return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
|
|
2565
|
+
return C._ts_tree_cursor_current_descendant_index_wasm(this[0]);
|
|
2789
2566
|
}
|
|
2790
2567
|
/** Get the type of the cursor's current node. */
|
|
2791
2568
|
get nodeType() {
|
|
2792
|
-
return this.tree.language.types[this.
|
|
2569
|
+
return this.tree.language.types[this._nodeTypeId] || "ERROR";
|
|
2793
2570
|
}
|
|
2794
2571
|
/** Get the type id of the cursor's current node. */
|
|
2795
2572
|
get nodeTypeId() {
|
|
2796
|
-
|
|
2797
|
-
return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
|
|
2573
|
+
return this._nodeTypeId;
|
|
2798
2574
|
}
|
|
2799
2575
|
/** Get the state id of the cursor's current node. */
|
|
2800
2576
|
get nodeStateId() {
|
|
2801
|
-
|
|
2802
|
-
return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
|
|
2577
|
+
return C._ts_tree_cursor_current_node_state_id_wasm(this[0]);
|
|
2803
2578
|
}
|
|
2804
2579
|
/** Get the id of the cursor's current node. */
|
|
2805
2580
|
get nodeId() {
|
|
2806
|
-
|
|
2807
|
-
return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
|
|
2581
|
+
return C._ts_tree_cursor_current_node_id_wasm(this[0]);
|
|
2808
2582
|
}
|
|
2809
2583
|
/**
|
|
2810
2584
|
* Check if the cursor's current node is *named*.
|
|
@@ -2813,8 +2587,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
2813
2587
|
* *anonymous* nodes correspond to string literals in the grammar.
|
|
2814
2588
|
*/
|
|
2815
2589
|
get nodeIsNamed() {
|
|
2816
|
-
|
|
2817
|
-
return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
|
|
2590
|
+
return (this._flags & 1) !== 0;
|
|
2818
2591
|
}
|
|
2819
2592
|
/**
|
|
2820
2593
|
* Check if the cursor's current node is *missing*.
|
|
@@ -2823,39 +2596,32 @@ var TreeCursor = class _TreeCursor {
|
|
|
2823
2596
|
* certain kinds of syntax errors.
|
|
2824
2597
|
*/
|
|
2825
2598
|
get nodeIsMissing() {
|
|
2826
|
-
|
|
2827
|
-
return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
|
|
2599
|
+
return (this._flags & 2) !== 0;
|
|
2828
2600
|
}
|
|
2829
2601
|
/** Get the string content of the cursor's current node. */
|
|
2830
2602
|
get nodeText() {
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
2834
|
-
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
2835
|
-
const startPosition = unmarshalPoint(TRANSFER_BUFFER);
|
|
2836
|
-
return getText(this.tree, startIndex, endIndex, startPosition);
|
|
2603
|
+
this.syncIndices();
|
|
2604
|
+
return getText(this.tree, this._startIndex, this._endIndex, () => this.startPosition);
|
|
2837
2605
|
}
|
|
2838
2606
|
/** Get the start position of the cursor's current node. */
|
|
2839
2607
|
get startPosition() {
|
|
2840
|
-
|
|
2841
|
-
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
2608
|
+
C._ts_tree_cursor_start_position_wasm(this[0]);
|
|
2842
2609
|
return unmarshalPoint(TRANSFER_BUFFER);
|
|
2843
2610
|
}
|
|
2844
2611
|
/** Get the end position of the cursor's current node. */
|
|
2845
2612
|
get endPosition() {
|
|
2846
|
-
|
|
2847
|
-
C._ts_tree_cursor_end_position_wasm(this.tree[0]);
|
|
2613
|
+
C._ts_tree_cursor_end_position_wasm(this[0]);
|
|
2848
2614
|
return unmarshalPoint(TRANSFER_BUFFER);
|
|
2849
2615
|
}
|
|
2850
2616
|
/** Get the start index of the cursor's current node. */
|
|
2851
2617
|
get startIndex() {
|
|
2852
|
-
|
|
2853
|
-
return
|
|
2618
|
+
this.syncIndices();
|
|
2619
|
+
return this._startIndex;
|
|
2854
2620
|
}
|
|
2855
2621
|
/** Get the end index of the cursor's current node. */
|
|
2856
2622
|
get endIndex() {
|
|
2857
|
-
|
|
2858
|
-
return
|
|
2623
|
+
this.syncIndices();
|
|
2624
|
+
return this._endIndex;
|
|
2859
2625
|
}
|
|
2860
2626
|
/**
|
|
2861
2627
|
* Move this cursor to the first child of its current node.
|
|
@@ -2864,10 +2630,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2864
2630
|
* `false` if there were no children.
|
|
2865
2631
|
*/
|
|
2866
2632
|
gotoFirstChild() {
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
return result === 1;
|
|
2633
|
+
if (!C._ts_tree_cursor_goto_first_child_wasm(this[0])) return false;
|
|
2634
|
+
this.readNodeCache();
|
|
2635
|
+
return true;
|
|
2871
2636
|
}
|
|
2872
2637
|
/**
|
|
2873
2638
|
* Move this cursor to the last child of its current node.
|
|
@@ -2880,10 +2645,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2880
2645
|
* iterate through all the children to compute the child's position.
|
|
2881
2646
|
*/
|
|
2882
2647
|
gotoLastChild() {
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
return result === 1;
|
|
2648
|
+
if (!C._ts_tree_cursor_goto_last_child_wasm(this[0])) return false;
|
|
2649
|
+
this.readNodeCache();
|
|
2650
|
+
return true;
|
|
2887
2651
|
}
|
|
2888
2652
|
/**
|
|
2889
2653
|
* Move this cursor to the parent of its current node.
|
|
@@ -2896,10 +2660,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2896
2660
|
* of the cursor, and the cursor cannot walk outside this node.
|
|
2897
2661
|
*/
|
|
2898
2662
|
gotoParent() {
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
return result === 1;
|
|
2663
|
+
if (!C._ts_tree_cursor_goto_parent_wasm(this[0])) return false;
|
|
2664
|
+
this.readNodeCache();
|
|
2665
|
+
return true;
|
|
2903
2666
|
}
|
|
2904
2667
|
/**
|
|
2905
2668
|
* Move this cursor to the next sibling of its current node.
|
|
@@ -2911,10 +2674,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2911
2674
|
* of the cursor, and the cursor cannot walk outside this node.
|
|
2912
2675
|
*/
|
|
2913
2676
|
gotoNextSibling() {
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
return result === 1;
|
|
2677
|
+
if (!C._ts_tree_cursor_goto_next_sibling_wasm(this[0])) return false;
|
|
2678
|
+
this.readNodeCache();
|
|
2679
|
+
return true;
|
|
2918
2680
|
}
|
|
2919
2681
|
/**
|
|
2920
2682
|
* Move this cursor to the previous sibling of its current node.
|
|
@@ -2930,10 +2692,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2930
2692
|
* considered the root of the cursor, and the cursor cannot walk outside this node.
|
|
2931
2693
|
*/
|
|
2932
2694
|
gotoPreviousSibling() {
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
return result === 1;
|
|
2695
|
+
if (!C._ts_tree_cursor_goto_previous_sibling_wasm(this[0])) return false;
|
|
2696
|
+
this.readNodeCache();
|
|
2697
|
+
return true;
|
|
2937
2698
|
}
|
|
2938
2699
|
/**
|
|
2939
2700
|
* Move the cursor to the node that is the nth descendant of
|
|
@@ -2941,9 +2702,8 @@ var TreeCursor = class _TreeCursor {
|
|
|
2941
2702
|
* zero represents the original node itself.
|
|
2942
2703
|
*/
|
|
2943
2704
|
gotoDescendant(goalDescendantIndex) {
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
unmarshalTreeCursor(this);
|
|
2705
|
+
C._ts_tree_cursor_goto_descendant_wasm(this[0], goalDescendantIndex);
|
|
2706
|
+
this.readNodeCache();
|
|
2947
2707
|
}
|
|
2948
2708
|
/**
|
|
2949
2709
|
* Move this cursor to the first child of its current node that contains or
|
|
@@ -2953,11 +2713,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2953
2713
|
* `false` if no such child was found.
|
|
2954
2714
|
*/
|
|
2955
2715
|
gotoFirstChildForIndex(goalIndex) {
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
unmarshalTreeCursor(this);
|
|
2960
|
-
return result === 1;
|
|
2716
|
+
if (!C._ts_tree_cursor_goto_first_child_for_index_wasm(this[0], goalIndex)) return false;
|
|
2717
|
+
this.readNodeCache();
|
|
2718
|
+
return true;
|
|
2961
2719
|
}
|
|
2962
2720
|
/**
|
|
2963
2721
|
* Move this cursor to the first child of its current node that contains or
|
|
@@ -2967,11 +2725,10 @@ var TreeCursor = class _TreeCursor {
|
|
|
2967
2725
|
* `false` if no such child was found.
|
|
2968
2726
|
*/
|
|
2969
2727
|
gotoFirstChildForPosition(goalPosition) {
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
return result === 1;
|
|
2728
|
+
marshalPoint(TRANSFER_BUFFER, goalPosition);
|
|
2729
|
+
if (!C._ts_tree_cursor_goto_first_child_for_position_wasm(this[0])) return false;
|
|
2730
|
+
this.readNodeCache();
|
|
2731
|
+
return true;
|
|
2975
2732
|
}
|
|
2976
2733
|
/**
|
|
2977
2734
|
* Re-initialize this tree cursor to start at the original node that the
|
|
@@ -2979,10 +2736,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
2979
2736
|
*/
|
|
2980
2737
|
reset(node) {
|
|
2981
2738
|
marshalNode(node);
|
|
2982
|
-
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
2983
|
-
C._ts_tree_cursor_reset_wasm(node.tree[0]);
|
|
2984
|
-
unmarshalTreeCursor(this);
|
|
2985
2739
|
this.tree = node.tree;
|
|
2740
|
+
C._ts_tree_cursor_reset_wasm(this[0], node.tree[0]);
|
|
2741
|
+
this.readNodeCache();
|
|
2986
2742
|
}
|
|
2987
2743
|
/**
|
|
2988
2744
|
* Re-initialize a tree cursor to the same position as another cursor.
|
|
@@ -2991,11 +2747,152 @@ var TreeCursor = class _TreeCursor {
|
|
|
2991
2747
|
* information and allows reusing already created cursors.
|
|
2992
2748
|
*/
|
|
2993
2749
|
resetTo(cursor) {
|
|
2994
|
-
|
|
2995
|
-
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
2996
|
-
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
2997
|
-
unmarshalTreeCursor(this);
|
|
2750
|
+
if (cursor === this) return;
|
|
2998
2751
|
this.tree = cursor.tree;
|
|
2752
|
+
C._ts_tree_cursor_reset_to_wasm(this[0], cursor[0]);
|
|
2753
|
+
this.readNodeCache();
|
|
2754
|
+
}
|
|
2755
|
+
/** @internal */
|
|
2756
|
+
readNodeCache() {
|
|
2757
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
2758
|
+
const heap = C.HEAPU32;
|
|
2759
|
+
this._nodeTypeId = heap[base];
|
|
2760
|
+
this._fieldId = heap[base + 1];
|
|
2761
|
+
this._startIndex = heap[base + 2];
|
|
2762
|
+
this._endIndex = heap[base + 3];
|
|
2763
|
+
this._flags = heap[base + 4];
|
|
2764
|
+
this.editVersion = this.tree.editVersion;
|
|
2765
|
+
}
|
|
2766
|
+
/** @internal */
|
|
2767
|
+
syncIndices() {
|
|
2768
|
+
if (this.editVersion !== this.tree.editVersion) {
|
|
2769
|
+
this._startIndex = C._ts_tree_cursor_start_index_wasm(this[0]) >>> 0;
|
|
2770
|
+
this._endIndex = C._ts_tree_cursor_end_index_wasm(this[0]) >>> 0;
|
|
2771
|
+
this.editVersion = this.tree.editVersion;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2775
|
+
|
|
2776
|
+
// src/tree.ts
|
|
2777
|
+
function getText(tree, startIndex, endIndex, getStartPosition) {
|
|
2778
|
+
if (tree.sourceText !== void 0) {
|
|
2779
|
+
return tree.sourceText.slice(startIndex, endIndex);
|
|
2780
|
+
}
|
|
2781
|
+
const startPosition = getStartPosition();
|
|
2782
|
+
const length = endIndex - startIndex;
|
|
2783
|
+
let result = tree.textCallback(startIndex, startPosition);
|
|
2784
|
+
if (result) {
|
|
2785
|
+
startIndex += result.length;
|
|
2786
|
+
while (startIndex < endIndex) {
|
|
2787
|
+
const string = tree.textCallback(startIndex, startPosition);
|
|
2788
|
+
if (string && string.length > 0) {
|
|
2789
|
+
startIndex += string.length;
|
|
2790
|
+
result += string;
|
|
2791
|
+
} else {
|
|
2792
|
+
break;
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
if (startIndex > endIndex) {
|
|
2796
|
+
result = result.slice(0, length);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
return result ?? "";
|
|
2800
|
+
}
|
|
2801
|
+
__name(getText, "getText");
|
|
2802
|
+
var finalizer3 = newFinalizer((address) => {
|
|
2803
|
+
C._ts_tree_delete(address);
|
|
2804
|
+
});
|
|
2805
|
+
var Tree2 = class _Tree {
|
|
2806
|
+
static {
|
|
2807
|
+
__name(this, "Tree");
|
|
2808
|
+
}
|
|
2809
|
+
/** @internal */
|
|
2810
|
+
[0] = 0;
|
|
2811
|
+
// Internal handle for Wasm
|
|
2812
|
+
/** @internal */
|
|
2813
|
+
textCallback;
|
|
2814
|
+
/** @internal */
|
|
2815
|
+
sourceText;
|
|
2816
|
+
/** @internal */
|
|
2817
|
+
editVersion = 0;
|
|
2818
|
+
/** The language that was used to parse the syntax tree. */
|
|
2819
|
+
language;
|
|
2820
|
+
/** @internal */
|
|
2821
|
+
constructor(internal, address, language, textCallback, sourceText) {
|
|
2822
|
+
assertInternal(internal);
|
|
2823
|
+
this[0] = address;
|
|
2824
|
+
this.language = language;
|
|
2825
|
+
this.textCallback = textCallback;
|
|
2826
|
+
this.sourceText = sourceText;
|
|
2827
|
+
finalizer3?.register(this, address, this);
|
|
2828
|
+
}
|
|
2829
|
+
/** Create a shallow copy of the syntax tree. This is very fast. */
|
|
2830
|
+
copy() {
|
|
2831
|
+
const address = C._ts_tree_copy(this[0]);
|
|
2832
|
+
return new _Tree(INTERNAL, address, this.language, this.textCallback, this.sourceText);
|
|
2833
|
+
}
|
|
2834
|
+
/** Delete the syntax tree, freeing its resources. */
|
|
2835
|
+
delete() {
|
|
2836
|
+
finalizer3?.unregister(this);
|
|
2837
|
+
C._ts_tree_delete(this[0]);
|
|
2838
|
+
this[0] = 0;
|
|
2839
|
+
}
|
|
2840
|
+
/** Get the root node of the syntax tree. */
|
|
2841
|
+
get rootNode() {
|
|
2842
|
+
C._ts_tree_root_node_wasm(this[0]);
|
|
2843
|
+
return unmarshalNode(this);
|
|
2844
|
+
}
|
|
2845
|
+
/**
|
|
2846
|
+
* Get the root node of the syntax tree, but with its position shifted
|
|
2847
|
+
* forward by the given offset.
|
|
2848
|
+
*/
|
|
2849
|
+
rootNodeWithOffset(offsetBytes, offsetExtent) {
|
|
2850
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
2851
|
+
C.HEAP32[address >>> 2] = offsetBytes;
|
|
2852
|
+
marshalPoint(address + SIZE_OF_INT, offsetExtent);
|
|
2853
|
+
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
2854
|
+
return unmarshalNode(this);
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Edit the syntax tree to keep it in sync with source code that has been
|
|
2858
|
+
* edited.
|
|
2859
|
+
*
|
|
2860
|
+
* You must describe the edit both in terms of byte offsets and in terms of
|
|
2861
|
+
* row/column coordinates.
|
|
2862
|
+
*/
|
|
2863
|
+
edit(edit) {
|
|
2864
|
+
marshalEdit(edit);
|
|
2865
|
+
C._ts_tree_edit_wasm(this[0]);
|
|
2866
|
+
this.editVersion++;
|
|
2867
|
+
}
|
|
2868
|
+
/** Create a new {@link TreeCursor} starting from the root of the tree. */
|
|
2869
|
+
walk() {
|
|
2870
|
+
C._ts_tree_root_node_wasm(this[0]);
|
|
2871
|
+
const address = C._ts_tree_cursor_new_wasm(this[0]);
|
|
2872
|
+
return new TreeCursor(INTERNAL, this, address);
|
|
2873
|
+
}
|
|
2874
|
+
/**
|
|
2875
|
+
* Compare this old edited syntax tree to a new syntax tree representing
|
|
2876
|
+
* the same document, returning a sequence of ranges whose syntactic
|
|
2877
|
+
* structure has changed.
|
|
2878
|
+
*
|
|
2879
|
+
* For this to work correctly, this syntax tree must have been edited such
|
|
2880
|
+
* that its ranges match up to the new tree. Generally, you'll want to
|
|
2881
|
+
* call this method right after calling one of the [`Parser::parse`]
|
|
2882
|
+
* functions. Call it on the old tree that was passed to parse, and
|
|
2883
|
+
* pass the new tree that was returned from `parse`.
|
|
2884
|
+
*/
|
|
2885
|
+
getChangedRanges(other) {
|
|
2886
|
+
if (!(other instanceof _Tree)) {
|
|
2887
|
+
throw new TypeError("Argument must be a Tree");
|
|
2888
|
+
}
|
|
2889
|
+
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
2890
|
+
return unmarshalRanges();
|
|
2891
|
+
}
|
|
2892
|
+
/** Get the included ranges that were used to parse the syntax tree. */
|
|
2893
|
+
getIncludedRanges() {
|
|
2894
|
+
C._ts_tree_included_ranges_wasm(this[0]);
|
|
2895
|
+
return unmarshalRanges();
|
|
2999
2896
|
}
|
|
3000
2897
|
};
|
|
3001
2898
|
|
|
@@ -3136,7 +3033,7 @@ var Node = class {
|
|
|
3136
3033
|
}
|
|
3137
3034
|
/** Get the string content of this node. */
|
|
3138
3035
|
get text() {
|
|
3139
|
-
return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);
|
|
3036
|
+
return getText(this.tree, this.startIndex, this.endIndex, () => this.startPosition);
|
|
3140
3037
|
}
|
|
3141
3038
|
/** Get this node's parse state. */
|
|
3142
3039
|
get parseState() {
|
|
@@ -3231,24 +3128,13 @@ var Node = class {
|
|
|
3231
3128
|
childrenForFieldId(fieldId) {
|
|
3232
3129
|
marshalNode(this);
|
|
3233
3130
|
C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
|
|
3234
|
-
|
|
3235
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3236
|
-
const result = new Array(count);
|
|
3237
|
-
if (count > 0) {
|
|
3238
|
-
let address = buffer;
|
|
3239
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
3240
|
-
result[i2] = unmarshalNode(this.tree, address);
|
|
3241
|
-
address += SIZE_OF_NODE;
|
|
3242
|
-
}
|
|
3243
|
-
C._ts_free_wasm(buffer);
|
|
3244
|
-
}
|
|
3245
|
-
return result;
|
|
3131
|
+
return unmarshalNodeArray(this.tree, true);
|
|
3246
3132
|
}
|
|
3247
3133
|
/** Get the node's first child that contains or starts after the given byte offset. */
|
|
3248
3134
|
firstChildForIndex(index) {
|
|
3249
3135
|
marshalNode(this);
|
|
3250
3136
|
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3251
|
-
C.
|
|
3137
|
+
C.HEAP32[address >>> 2] = index;
|
|
3252
3138
|
C._ts_node_first_child_for_byte_wasm(this.tree[0]);
|
|
3253
3139
|
return unmarshalNode(this.tree);
|
|
3254
3140
|
}
|
|
@@ -3256,7 +3142,7 @@ var Node = class {
|
|
|
3256
3142
|
firstNamedChildForIndex(index) {
|
|
3257
3143
|
marshalNode(this);
|
|
3258
3144
|
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3259
|
-
C.
|
|
3145
|
+
C.HEAP32[address >>> 2] = index;
|
|
3260
3146
|
C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
|
|
3261
3147
|
return unmarshalNode(this.tree);
|
|
3262
3148
|
}
|
|
@@ -3308,17 +3194,7 @@ var Node = class {
|
|
|
3308
3194
|
if (!this._children) {
|
|
3309
3195
|
marshalNode(this);
|
|
3310
3196
|
C._ts_node_children_wasm(this.tree[0]);
|
|
3311
|
-
|
|
3312
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3313
|
-
this._children = new Array(count);
|
|
3314
|
-
if (count > 0) {
|
|
3315
|
-
let address = buffer;
|
|
3316
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
3317
|
-
this._children[i2] = unmarshalNode(this.tree, address);
|
|
3318
|
-
address += SIZE_OF_NODE;
|
|
3319
|
-
}
|
|
3320
|
-
C._free(buffer);
|
|
3321
|
-
}
|
|
3197
|
+
this._children = unmarshalNodeArray(this.tree);
|
|
3322
3198
|
}
|
|
3323
3199
|
return this._children;
|
|
3324
3200
|
}
|
|
@@ -3331,17 +3207,7 @@ var Node = class {
|
|
|
3331
3207
|
if (!this._namedChildren) {
|
|
3332
3208
|
marshalNode(this);
|
|
3333
3209
|
C._ts_node_named_children_wasm(this.tree[0]);
|
|
3334
|
-
|
|
3335
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3336
|
-
this._namedChildren = new Array(count);
|
|
3337
|
-
if (count > 0) {
|
|
3338
|
-
let address = buffer;
|
|
3339
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
3340
|
-
this._namedChildren[i2] = unmarshalNode(this.tree, address);
|
|
3341
|
-
address += SIZE_OF_NODE;
|
|
3342
|
-
}
|
|
3343
|
-
C._free(buffer);
|
|
3344
|
-
}
|
|
3210
|
+
this._namedChildren = unmarshalNodeArray(this.tree);
|
|
3345
3211
|
}
|
|
3346
3212
|
return this._namedChildren;
|
|
3347
3213
|
}
|
|
@@ -3365,8 +3231,9 @@ var Node = class {
|
|
|
3365
3231
|
symbols.push(65535);
|
|
3366
3232
|
}
|
|
3367
3233
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
3234
|
+
const symbolsBase = symbolsAddress >>> 2;
|
|
3368
3235
|
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
3369
|
-
C.
|
|
3236
|
+
C.HEAPU32[symbolsBase + i2] = symbols[i2];
|
|
3370
3237
|
}
|
|
3371
3238
|
marshalNode(this);
|
|
3372
3239
|
C._ts_node_descendants_of_type_wasm(
|
|
@@ -3378,17 +3245,7 @@ var Node = class {
|
|
|
3378
3245
|
endPosition.row,
|
|
3379
3246
|
endPosition.column
|
|
3380
3247
|
);
|
|
3381
|
-
const
|
|
3382
|
-
const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3383
|
-
const result = new Array(descendantCount);
|
|
3384
|
-
if (descendantCount > 0) {
|
|
3385
|
-
let address = descendantAddress;
|
|
3386
|
-
for (let i2 = 0; i2 < descendantCount; i2++) {
|
|
3387
|
-
result[i2] = unmarshalNode(this.tree, address);
|
|
3388
|
-
address += SIZE_OF_NODE;
|
|
3389
|
-
}
|
|
3390
|
-
}
|
|
3391
|
-
C._ts_free_wasm(descendantAddress);
|
|
3248
|
+
const result = unmarshalNodeArray(this.tree, true, true);
|
|
3392
3249
|
C._free(symbolsAddress);
|
|
3393
3250
|
return result;
|
|
3394
3251
|
}
|
|
@@ -3456,9 +3313,9 @@ var Node = class {
|
|
|
3456
3313
|
throw new Error("Arguments must be numbers");
|
|
3457
3314
|
}
|
|
3458
3315
|
marshalNode(this);
|
|
3459
|
-
const
|
|
3460
|
-
C.
|
|
3461
|
-
C.
|
|
3316
|
+
const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
|
|
3317
|
+
C.HEAP32[base] = start2;
|
|
3318
|
+
C.HEAP32[base + 1] = end;
|
|
3462
3319
|
C._ts_node_descendant_for_index_wasm(this.tree[0]);
|
|
3463
3320
|
return unmarshalNode(this.tree);
|
|
3464
3321
|
}
|
|
@@ -3468,9 +3325,9 @@ var Node = class {
|
|
|
3468
3325
|
throw new Error("Arguments must be numbers");
|
|
3469
3326
|
}
|
|
3470
3327
|
marshalNode(this);
|
|
3471
|
-
const
|
|
3472
|
-
C.
|
|
3473
|
-
C.
|
|
3328
|
+
const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
|
|
3329
|
+
C.HEAP32[base] = start2;
|
|
3330
|
+
C.HEAP32[base + 1] = end;
|
|
3474
3331
|
C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
|
|
3475
3332
|
return unmarshalNode(this.tree);
|
|
3476
3333
|
}
|
|
@@ -3506,8 +3363,8 @@ var Node = class {
|
|
|
3506
3363
|
*/
|
|
3507
3364
|
walk() {
|
|
3508
3365
|
marshalNode(this);
|
|
3509
|
-
C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
3510
|
-
return new TreeCursor(INTERNAL, this.tree);
|
|
3366
|
+
const address = C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
3367
|
+
return new TreeCursor(INTERNAL, this.tree, address);
|
|
3511
3368
|
}
|
|
3512
3369
|
/**
|
|
3513
3370
|
* Edit this node to keep it in-sync with source code that has been edited.
|
|
@@ -3535,86 +3392,66 @@ var Node = class {
|
|
|
3535
3392
|
|
|
3536
3393
|
// src/marshal.ts
|
|
3537
3394
|
function marshalNode(node, index = 0) {
|
|
3538
|
-
|
|
3539
|
-
C.
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
C.setValue(address, node.startPosition.column, "i32");
|
|
3546
|
-
address += SIZE_OF_INT;
|
|
3547
|
-
C.setValue(address, node[0], "i32");
|
|
3395
|
+
const base = TRANSFER_BUFFER + index * SIZE_OF_NODE >>> 2;
|
|
3396
|
+
const heap = C.HEAP32;
|
|
3397
|
+
heap[base] = node.id;
|
|
3398
|
+
heap[base + 1] = node.startIndex;
|
|
3399
|
+
heap[base + 2] = node.startPosition.row;
|
|
3400
|
+
heap[base + 3] = node.startPosition.column;
|
|
3401
|
+
heap[base + 4] = node[0];
|
|
3548
3402
|
}
|
|
3549
3403
|
__name(marshalNode, "marshalNode");
|
|
3550
3404
|
function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
3551
|
-
const
|
|
3552
|
-
|
|
3405
|
+
const base = address >>> 2;
|
|
3406
|
+
const heap = C.HEAP32;
|
|
3407
|
+
const id = heap[base];
|
|
3553
3408
|
if (id === 0) return null;
|
|
3554
|
-
const
|
|
3555
|
-
|
|
3556
|
-
const row = C.getValue(address, "i32");
|
|
3557
|
-
address += SIZE_OF_INT;
|
|
3558
|
-
const column = C.getValue(address, "i32");
|
|
3559
|
-
address += SIZE_OF_INT;
|
|
3560
|
-
const other = C.getValue(address, "i32");
|
|
3561
|
-
const result = new Node(INTERNAL, {
|
|
3409
|
+
const heapU32 = C.HEAPU32;
|
|
3410
|
+
return new Node(INTERNAL, {
|
|
3562
3411
|
id,
|
|
3563
3412
|
tree,
|
|
3564
|
-
startIndex:
|
|
3565
|
-
startPosition: { row, column },
|
|
3566
|
-
other
|
|
3413
|
+
startIndex: heapU32[base + 1],
|
|
3414
|
+
startPosition: { row: heapU32[base + 2], column: heapU32[base + 3] },
|
|
3415
|
+
other: heap[base + 4]
|
|
3567
3416
|
});
|
|
3568
|
-
return result;
|
|
3569
3417
|
}
|
|
3570
3418
|
__name(unmarshalNode, "unmarshalNode");
|
|
3571
|
-
function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
|
|
3572
|
-
C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
|
|
3573
|
-
C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
|
|
3574
|
-
C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
|
|
3575
|
-
C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
|
|
3576
|
-
}
|
|
3577
|
-
__name(marshalTreeCursor, "marshalTreeCursor");
|
|
3578
|
-
function unmarshalTreeCursor({ handles }) {
|
|
3579
|
-
handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
3580
|
-
handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
3581
|
-
handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
3582
|
-
handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
3583
|
-
}
|
|
3584
|
-
__name(unmarshalTreeCursor, "unmarshalTreeCursor");
|
|
3585
3419
|
function marshalPoint(address, point) {
|
|
3586
|
-
|
|
3587
|
-
|
|
3420
|
+
const base = address >>> 2;
|
|
3421
|
+
const heap = C.HEAP32;
|
|
3422
|
+
heap[base] = point.row;
|
|
3423
|
+
heap[base + 1] = point.column;
|
|
3588
3424
|
}
|
|
3589
3425
|
__name(marshalPoint, "marshalPoint");
|
|
3590
3426
|
function unmarshalPoint(address) {
|
|
3591
|
-
const
|
|
3592
|
-
|
|
3593
|
-
|
|
3427
|
+
const base = address >>> 2;
|
|
3428
|
+
const heap = C.HEAPU32;
|
|
3429
|
+
return {
|
|
3430
|
+
row: heap[base],
|
|
3431
|
+
column: heap[base + 1]
|
|
3594
3432
|
};
|
|
3595
|
-
return result;
|
|
3596
3433
|
}
|
|
3597
3434
|
__name(unmarshalPoint, "unmarshalPoint");
|
|
3598
3435
|
function marshalRange(address, range) {
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3436
|
+
const base = address >>> 2;
|
|
3437
|
+
const heap = C.HEAP32;
|
|
3438
|
+
heap[base] = range.startPosition.row;
|
|
3439
|
+
heap[base + 1] = range.startPosition.column;
|
|
3440
|
+
heap[base + 2] = range.endPosition.row;
|
|
3441
|
+
heap[base + 3] = range.endPosition.column;
|
|
3442
|
+
heap[base + 4] = range.startIndex;
|
|
3443
|
+
heap[base + 5] = range.endIndex;
|
|
3606
3444
|
}
|
|
3607
3445
|
__name(marshalRange, "marshalRange");
|
|
3608
3446
|
function unmarshalRange(address) {
|
|
3609
|
-
const
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
return result;
|
|
3447
|
+
const base = address >>> 2;
|
|
3448
|
+
const heap = C.HEAPU32;
|
|
3449
|
+
return {
|
|
3450
|
+
startPosition: { row: heap[base], column: heap[base + 1] },
|
|
3451
|
+
endPosition: { row: heap[base + 2], column: heap[base + 3] },
|
|
3452
|
+
startIndex: heap[base + 4],
|
|
3453
|
+
endIndex: heap[base + 5]
|
|
3454
|
+
};
|
|
3618
3455
|
}
|
|
3619
3456
|
__name(unmarshalRange, "unmarshalRange");
|
|
3620
3457
|
function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
@@ -3623,21 +3460,61 @@ function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
|
3623
3460
|
marshalPoint(address, edit.oldEndPosition);
|
|
3624
3461
|
address += SIZE_OF_POINT;
|
|
3625
3462
|
marshalPoint(address, edit.newEndPosition);
|
|
3626
|
-
address
|
|
3627
|
-
C.
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
C.setValue(address, edit.newEndIndex, "i32");
|
|
3463
|
+
const base = address + SIZE_OF_POINT >>> 2;
|
|
3464
|
+
const heap = C.HEAP32;
|
|
3465
|
+
heap[base] = edit.startIndex;
|
|
3466
|
+
heap[base + 1] = edit.oldEndIndex;
|
|
3467
|
+
heap[base + 2] = edit.newEndIndex;
|
|
3632
3468
|
}
|
|
3633
3469
|
__name(marshalEdit, "marshalEdit");
|
|
3634
3470
|
function unmarshalLanguageMetadata(address) {
|
|
3635
|
-
const
|
|
3636
|
-
const
|
|
3637
|
-
|
|
3638
|
-
|
|
3471
|
+
const base = address >>> 2;
|
|
3472
|
+
const heap = C.HEAP32;
|
|
3473
|
+
return {
|
|
3474
|
+
major_version: heap[base],
|
|
3475
|
+
minor_version: heap[base + 1],
|
|
3476
|
+
patch_version: heap[base + 2]
|
|
3477
|
+
};
|
|
3639
3478
|
}
|
|
3640
3479
|
__name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
|
|
3480
|
+
function unmarshalSymbols() {
|
|
3481
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
3482
|
+
const count = C.HEAPU32[base];
|
|
3483
|
+
const buffer = C.HEAPU32[base + 1];
|
|
3484
|
+
const result = new Array(count);
|
|
3485
|
+
if (count > 0) {
|
|
3486
|
+
const symbolBase = buffer >>> 1;
|
|
3487
|
+
const heapU16 = C.HEAPU16;
|
|
3488
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3489
|
+
result[i2] = heapU16[symbolBase + i2];
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
return result;
|
|
3493
|
+
}
|
|
3494
|
+
__name(unmarshalSymbols, "unmarshalSymbols");
|
|
3495
|
+
function unmarshalRanges(useTsFree = true) {
|
|
3496
|
+
return unmarshalArray(SIZE_OF_RANGE, unmarshalRange, useTsFree, false);
|
|
3497
|
+
}
|
|
3498
|
+
__name(unmarshalRanges, "unmarshalRanges");
|
|
3499
|
+
function unmarshalNodeArray(tree, useTsFree = false, alwaysFree = false) {
|
|
3500
|
+
return unmarshalArray(SIZE_OF_NODE, (address) => unmarshalNode(tree, address), useTsFree, alwaysFree);
|
|
3501
|
+
}
|
|
3502
|
+
__name(unmarshalNodeArray, "unmarshalNodeArray");
|
|
3503
|
+
function unmarshalArray(stride, readItem, useTsFree, alwaysFree) {
|
|
3504
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
3505
|
+
const count = C.HEAPU32[base];
|
|
3506
|
+
const buffer = C.HEAP32[base + 1];
|
|
3507
|
+
const result = new Array(count);
|
|
3508
|
+
for (let i2 = 0, address = buffer; i2 < count; i2++, address += stride) {
|
|
3509
|
+
result[i2] = readItem(address);
|
|
3510
|
+
}
|
|
3511
|
+
if (count > 0 || alwaysFree) {
|
|
3512
|
+
if (useTsFree) C._ts_free_wasm(buffer);
|
|
3513
|
+
else C._free(buffer);
|
|
3514
|
+
}
|
|
3515
|
+
return result;
|
|
3516
|
+
}
|
|
3517
|
+
__name(unmarshalArray, "unmarshalArray");
|
|
3641
3518
|
|
|
3642
3519
|
// src/language.ts
|
|
3643
3520
|
var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
|
|
@@ -3699,7 +3576,7 @@ var Language = class {
|
|
|
3699
3576
|
*/
|
|
3700
3577
|
get metadata() {
|
|
3701
3578
|
C._ts_language_metadata_wasm(this[0]);
|
|
3702
|
-
const length = C.
|
|
3579
|
+
const length = C.HEAP32[TRANSFER_BUFFER >>> 2];
|
|
3703
3580
|
if (length === 0) return null;
|
|
3704
3581
|
return unmarshalLanguageMetadata(TRANSFER_BUFFER + SIZE_OF_INT);
|
|
3705
3582
|
}
|
|
@@ -3773,34 +3650,14 @@ var Language = class {
|
|
|
3773
3650
|
*/
|
|
3774
3651
|
get supertypes() {
|
|
3775
3652
|
C._ts_language_supertypes_wasm(this[0]);
|
|
3776
|
-
|
|
3777
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3778
|
-
const result = new Array(count);
|
|
3779
|
-
if (count > 0) {
|
|
3780
|
-
let address = buffer;
|
|
3781
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
3782
|
-
result[i2] = C.getValue(address, "i16");
|
|
3783
|
-
address += SIZE_OF_SHORT;
|
|
3784
|
-
}
|
|
3785
|
-
}
|
|
3786
|
-
return result;
|
|
3653
|
+
return unmarshalSymbols();
|
|
3787
3654
|
}
|
|
3788
3655
|
/**
|
|
3789
3656
|
* Get the subtype ids for a given supertype node id.
|
|
3790
3657
|
*/
|
|
3791
3658
|
subtypes(supertype) {
|
|
3792
3659
|
C._ts_language_subtypes_wasm(this[0], supertype);
|
|
3793
|
-
|
|
3794
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3795
|
-
const result = new Array(count);
|
|
3796
|
-
if (count > 0) {
|
|
3797
|
-
let address = buffer;
|
|
3798
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
3799
|
-
result[i2] = C.getValue(address, "i16");
|
|
3800
|
-
address += SIZE_OF_SHORT;
|
|
3801
|
-
}
|
|
3802
|
-
}
|
|
3803
|
-
return result;
|
|
3660
|
+
return unmarshalSymbols();
|
|
3804
3661
|
}
|
|
3805
3662
|
/**
|
|
3806
3663
|
* Get the next state id for a given state id and node type id.
|
|
@@ -3908,8 +3765,10 @@ function checkModule() {
|
|
|
3908
3765
|
__name(checkModule, "checkModule");
|
|
3909
3766
|
|
|
3910
3767
|
// src/parser.ts
|
|
3768
|
+
var TWO_POW_32 = 4294967296;
|
|
3911
3769
|
var TRANSFER_BUFFER;
|
|
3912
3770
|
var LANGUAGE_VERSION;
|
|
3771
|
+
var MIN_COMPATIBLE_VERSION;
|
|
3913
3772
|
function assertSupportedLanguage(language) {
|
|
3914
3773
|
const version = C._ts_language_abi_version(language[0]);
|
|
3915
3774
|
if (version < MIN_COMPATIBLE_VERSION || version > LANGUAGE_VERSION) {
|
|
@@ -3919,7 +3778,6 @@ function assertSupportedLanguage(language) {
|
|
|
3919
3778
|
}
|
|
3920
3779
|
}
|
|
3921
3780
|
__name(assertSupportedLanguage, "assertSupportedLanguage");
|
|
3922
|
-
var MIN_COMPATIBLE_VERSION;
|
|
3923
3781
|
var finalizer4 = newFinalizer((addresses) => {
|
|
3924
3782
|
C._ts_parser_delete(addresses[0]);
|
|
3925
3783
|
C._free(addresses[1]);
|
|
@@ -3938,6 +3796,8 @@ var Parser = class {
|
|
|
3938
3796
|
logCallback = null;
|
|
3939
3797
|
/** The parser's current language. */
|
|
3940
3798
|
language = null;
|
|
3799
|
+
/** The number of parse operations executed by the most recent {@link Parser#parse} call. */
|
|
3800
|
+
lastParseOperations = 0;
|
|
3941
3801
|
/**
|
|
3942
3802
|
* This must always be called before creating a Parser.
|
|
3943
3803
|
*
|
|
@@ -3948,8 +3808,9 @@ var Parser = class {
|
|
|
3948
3808
|
static async init(options) {
|
|
3949
3809
|
setModule(await initializeBinding(options));
|
|
3950
3810
|
TRANSFER_BUFFER = C._ts_init();
|
|
3951
|
-
|
|
3952
|
-
|
|
3811
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
3812
|
+
LANGUAGE_VERSION = C.HEAP32[base];
|
|
3813
|
+
MIN_COMPATIBLE_VERSION = C.HEAP32[base + 1];
|
|
3953
3814
|
}
|
|
3954
3815
|
/**
|
|
3955
3816
|
* Create a new parser.
|
|
@@ -3964,8 +3825,9 @@ var Parser = class {
|
|
|
3964
3825
|
throw new Error("cannot construct a Parser before calling `init()`");
|
|
3965
3826
|
}
|
|
3966
3827
|
C._ts_parser_new_wasm();
|
|
3967
|
-
|
|
3968
|
-
this[
|
|
3828
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
3829
|
+
this[0] = C.HEAP32[base];
|
|
3830
|
+
this[1] = C.HEAP32[base + 1];
|
|
3969
3831
|
}
|
|
3970
3832
|
/** Delete the parser, freeing its resources. */
|
|
3971
3833
|
delete() {
|
|
@@ -4014,22 +3876,14 @@ var Parser = class {
|
|
|
4014
3876
|
* @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if:
|
|
4015
3877
|
* - The parser has not yet had a language assigned with {@link Parser#setLanguage}.
|
|
4016
3878
|
* - The progress callback returned true.
|
|
4017
|
-
* - The memory limit was reached.
|
|
3879
|
+
* - The memory limit was reached or the operation limit was exceeded.
|
|
4018
3880
|
*/
|
|
4019
3881
|
parse(callback, oldTree, options) {
|
|
4020
3882
|
const maxMemoryBytes = validateMemoryLimit(options?.maxMemoryBytes);
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
} else {
|
|
4026
|
-
throw new Error("Argument must be a string or a function");
|
|
4027
|
-
}
|
|
4028
|
-
if (options?.progressCallback) {
|
|
4029
|
-
C.currentProgressCallback = options.progressCallback;
|
|
4030
|
-
} else {
|
|
4031
|
-
C.currentProgressCallback = null;
|
|
4032
|
-
}
|
|
3883
|
+
const maxOperations = validateOperationLimit(options?.maxOperations);
|
|
3884
|
+
const { sourceText, textCallback } = resolveInput(callback);
|
|
3885
|
+
C.currentParseCallback = sourceText === void 0 ? textCallback : null;
|
|
3886
|
+
C.currentProgressCallback = options?.progressCallback ?? null;
|
|
4033
3887
|
if (this.logCallback) {
|
|
4034
3888
|
C.currentLogCallback = this.logCallback;
|
|
4035
3889
|
C._ts_parser_enable_logger_wasm(this[0], 1);
|
|
@@ -4037,11 +3891,24 @@ var Parser = class {
|
|
|
4037
3891
|
C.currentLogCallback = null;
|
|
4038
3892
|
C._ts_parser_enable_logger_wasm(this[0], 0);
|
|
4039
3893
|
}
|
|
3894
|
+
this.lastParseOperations = 0;
|
|
3895
|
+
const request = {
|
|
3896
|
+
parserAddress: this[0],
|
|
3897
|
+
callbackBuffer: this[1],
|
|
3898
|
+
sourceText,
|
|
3899
|
+
oldTreeAddress: oldTree ? oldTree[0] : 0,
|
|
3900
|
+
ranges: options?.includedRanges,
|
|
3901
|
+
maxOperations,
|
|
3902
|
+
hasProgressCallback: options?.progressCallback ? 1 : 0,
|
|
3903
|
+
onOperations: /* @__PURE__ */ __name((operations) => {
|
|
3904
|
+
this.lastParseOperations = operations;
|
|
3905
|
+
}, "onOperations")
|
|
3906
|
+
};
|
|
4040
3907
|
try {
|
|
4041
|
-
const treeAddress = maxMemoryBytes === void 0 ? parseOrdinaryWasm(
|
|
3908
|
+
const treeAddress = maxMemoryBytes === void 0 ? parseOrdinaryWasm(request) : parseLimitedWasm(request, maxMemoryBytes);
|
|
4042
3909
|
if (!treeAddress) return null;
|
|
4043
3910
|
if (!this.language) throw new Error("Parser must have a language to parse");
|
|
4044
|
-
return new
|
|
3911
|
+
return new Tree2(INTERNAL, treeAddress, this.language, textCallback, sourceText);
|
|
4045
3912
|
} finally {
|
|
4046
3913
|
clearCallbacks();
|
|
4047
3914
|
}
|
|
@@ -4049,7 +3916,7 @@ var Parser = class {
|
|
|
4049
3916
|
/**
|
|
4050
3917
|
* Instruct the parser to start the next parse from the beginning.
|
|
4051
3918
|
*
|
|
4052
|
-
* If the parser previously failed because of a callback,
|
|
3919
|
+
* If the parser previously failed because of a callback,
|
|
4053
3920
|
* then by default, it will resume where it left off on the
|
|
4054
3921
|
* next call to {@link Parser#parse} or other parsing functions.
|
|
4055
3922
|
* If you don't want to resume, and instead intend to use this parser to
|
|
@@ -4061,18 +3928,7 @@ var Parser = class {
|
|
|
4061
3928
|
/** Get the ranges of text that the parser will include when parsing. */
|
|
4062
3929
|
getIncludedRanges() {
|
|
4063
3930
|
C._ts_parser_included_ranges_wasm(this[0]);
|
|
4064
|
-
|
|
4065
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
4066
|
-
const result = new Array(count);
|
|
4067
|
-
if (count > 0) {
|
|
4068
|
-
let address = buffer;
|
|
4069
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
4070
|
-
result[i2] = unmarshalRange(address);
|
|
4071
|
-
address += SIZE_OF_RANGE;
|
|
4072
|
-
}
|
|
4073
|
-
C._free(buffer);
|
|
4074
|
-
}
|
|
4075
|
-
return result;
|
|
3931
|
+
return unmarshalRanges(false);
|
|
4076
3932
|
}
|
|
4077
3933
|
/** Set the logging callback that a parser should use during parsing. */
|
|
4078
3934
|
setLogger(callback) {
|
|
@@ -4097,6 +3953,88 @@ function validateMemoryLimit(maxMemoryBytes) {
|
|
|
4097
3953
|
return maxMemoryBytes;
|
|
4098
3954
|
}
|
|
4099
3955
|
__name(validateMemoryLimit, "validateMemoryLimit");
|
|
3956
|
+
function validateOperationLimit(maxOperations) {
|
|
3957
|
+
if (maxOperations !== void 0 && (!Number.isSafeInteger(maxOperations) || maxOperations <= 0)) {
|
|
3958
|
+
throw new RangeError("maxOperations must be a positive safe integer");
|
|
3959
|
+
}
|
|
3960
|
+
return maxOperations;
|
|
3961
|
+
}
|
|
3962
|
+
__name(validateOperationLimit, "validateOperationLimit");
|
|
3963
|
+
function resolveInput(callback) {
|
|
3964
|
+
if (typeof callback === "string") {
|
|
3965
|
+
return { sourceText: callback, textCallback: /* @__PURE__ */ __name((index) => callback.slice(index), "textCallback") };
|
|
3966
|
+
}
|
|
3967
|
+
if (typeof callback === "function") {
|
|
3968
|
+
return { sourceText: void 0, textCallback: callback };
|
|
3969
|
+
}
|
|
3970
|
+
throw new Error("Argument must be a string or a function");
|
|
3971
|
+
}
|
|
3972
|
+
__name(resolveInput, "resolveInput");
|
|
3973
|
+
function parseOrdinaryWasm(request) {
|
|
3974
|
+
return withPreparedParse(request, (inputBuffer) => {
|
|
3975
|
+
try {
|
|
3976
|
+
return C._ts_parser_parse_wasm(request.parserAddress, inputBuffer, request.oldTreeAddress);
|
|
3977
|
+
} catch (error) {
|
|
3978
|
+
C._ts_parser_last_parse_operations_wasm(request.parserAddress);
|
|
3979
|
+
throw error;
|
|
3980
|
+
}
|
|
3981
|
+
});
|
|
3982
|
+
}
|
|
3983
|
+
__name(parseOrdinaryWasm, "parseOrdinaryWasm");
|
|
3984
|
+
function parseLimitedWasm(request, maxMemoryBytes) {
|
|
3985
|
+
if (!C.treeSitterSetMemoryLimit(maxMemoryBytes)) return 0;
|
|
3986
|
+
try {
|
|
3987
|
+
return withPreparedParse(request, (inputBuffer) => {
|
|
3988
|
+
try {
|
|
3989
|
+
return C._ts_parser_parse_limited_wasm(request.parserAddress, inputBuffer);
|
|
3990
|
+
} catch (error) {
|
|
3991
|
+
C._ts_parser_abort_limited_wasm();
|
|
3992
|
+
throw error;
|
|
3993
|
+
}
|
|
3994
|
+
});
|
|
3995
|
+
} finally {
|
|
3996
|
+
C.treeSitterSetMemoryLimit(0);
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
__name(parseLimitedWasm, "parseLimitedWasm");
|
|
4000
|
+
function withPreparedParse(request, execute) {
|
|
4001
|
+
let sourceAddress = 0;
|
|
4002
|
+
let rangeAddress = 0;
|
|
4003
|
+
let executed = false;
|
|
4004
|
+
try {
|
|
4005
|
+
const [allocatedSource, byteLength, ok] = prepareSourceBuffer(request.sourceText);
|
|
4006
|
+
sourceAddress = allocatedSource;
|
|
4007
|
+
if (!ok) return 0;
|
|
4008
|
+
const [allocatedRanges, rangeCount] = prepareRanges(request.ranges);
|
|
4009
|
+
rangeAddress = allocatedRanges;
|
|
4010
|
+
if (rangeCount && !allocatedRanges) return 0;
|
|
4011
|
+
const isStringInput = request.sourceText !== void 0;
|
|
4012
|
+
marshalParseInputs(request.maxOperations, byteLength, allocatedRanges, rangeCount, isStringInput, request.hasProgressCallback);
|
|
4013
|
+
executed = true;
|
|
4014
|
+
return execute(isStringInput ? allocatedSource : request.callbackBuffer);
|
|
4015
|
+
} finally {
|
|
4016
|
+
if (executed) request.onOperations(unmarshalOperationCount());
|
|
4017
|
+
if (rangeAddress) C._free(rangeAddress);
|
|
4018
|
+
if (sourceAddress) C._free(sourceAddress);
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
__name(withPreparedParse, "withPreparedParse");
|
|
4022
|
+
function prepareSourceBuffer(sourceText) {
|
|
4023
|
+
if (sourceText === void 0) return [0, 0, true];
|
|
4024
|
+
const codeUnits = sourceText.length;
|
|
4025
|
+
if (codeUnits === 0) return [0, 0, true];
|
|
4026
|
+
if (codeUnits > 1073741823) return [0, 0, false];
|
|
4027
|
+
const byteLength = codeUnits * 2;
|
|
4028
|
+
const address = C._malloc(byteLength);
|
|
4029
|
+
if (!address) return [0, 0, false];
|
|
4030
|
+
const heapU16 = C.HEAPU16;
|
|
4031
|
+
const base = address >>> 1;
|
|
4032
|
+
for (let i2 = 0; i2 < codeUnits; i2++) {
|
|
4033
|
+
heapU16[base + i2] = sourceText.charCodeAt(i2);
|
|
4034
|
+
}
|
|
4035
|
+
return [address, byteLength, true];
|
|
4036
|
+
}
|
|
4037
|
+
__name(prepareSourceBuffer, "prepareSourceBuffer");
|
|
4100
4038
|
function prepareRanges(ranges) {
|
|
4101
4039
|
if (!ranges?.length) return [0, 0];
|
|
4102
4040
|
const rangeAddress = C._calloc(ranges.length, SIZE_OF_RANGE);
|
|
@@ -4109,31 +4047,23 @@ function prepareRanges(ranges) {
|
|
|
4109
4047
|
return [rangeAddress, ranges.length];
|
|
4110
4048
|
}
|
|
4111
4049
|
__name(prepareRanges, "prepareRanges");
|
|
4112
|
-
function
|
|
4113
|
-
const
|
|
4114
|
-
|
|
4115
|
-
|
|
4050
|
+
function marshalParseInputs(maxOperations, byteLength, rangeAddress, rangeCount, isStringInput, hasProgressCallback) {
|
|
4051
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
4052
|
+
const heapU32 = C.HEAPU32;
|
|
4053
|
+
heapU32[base] = maxOperations === void 0 ? 0 : maxOperations >>> 0;
|
|
4054
|
+
heapU32[base + 1] = maxOperations === void 0 ? 0 : Math.floor(maxOperations / TWO_POW_32) >>> 0;
|
|
4055
|
+
heapU32[base + 2] = byteLength;
|
|
4056
|
+
heapU32[base + 3] = rangeAddress;
|
|
4057
|
+
heapU32[base + 4] = rangeCount;
|
|
4058
|
+
heapU32[base + 5] = (isStringInput ? 1 : 0) | (hasProgressCallback ? 2 : 0);
|
|
4116
4059
|
}
|
|
4117
|
-
__name(
|
|
4118
|
-
function
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
const [address, rangeCount] = prepareRanges(ranges);
|
|
4123
|
-
rangeAddress = address;
|
|
4124
|
-
if (rangeCount && !address) return 0;
|
|
4125
|
-
try {
|
|
4126
|
-
return C._ts_parser_parse_limited_wasm(parserAddress, inputBuffer, address, rangeCount);
|
|
4127
|
-
} catch (error) {
|
|
4128
|
-
C._ts_parser_abort_limited_wasm();
|
|
4129
|
-
throw error;
|
|
4130
|
-
}
|
|
4131
|
-
} finally {
|
|
4132
|
-
if (rangeAddress) C._free(rangeAddress);
|
|
4133
|
-
C.treeSitterSetMemoryLimit(0);
|
|
4134
|
-
}
|
|
4060
|
+
__name(marshalParseInputs, "marshalParseInputs");
|
|
4061
|
+
function unmarshalOperationCount() {
|
|
4062
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
4063
|
+
const heapU32 = C.HEAPU32;
|
|
4064
|
+
return heapU32[base] + heapU32[base + 1] * TWO_POW_32;
|
|
4135
4065
|
}
|
|
4136
|
-
__name(
|
|
4066
|
+
__name(unmarshalOperationCount, "unmarshalOperationCount");
|
|
4137
4067
|
function clearCallbacks() {
|
|
4138
4068
|
C.currentParseCallback = null;
|
|
4139
4069
|
C.currentLogCallback = null;
|