@willbooster/web-tree-sitter 19.0.1 → 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 +12 -12
- 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 +11 -11
- package/web-tree-sitter.web.js +3 -3
- package/web-tree-sitter.web.js.map +4 -4
package/debug/web-tree-sitter.js
CHANGED
|
@@ -104,9 +104,7 @@ var Edit = class {
|
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
// src/constants.ts
|
|
107
|
-
var SIZE_OF_SHORT = 2;
|
|
108
107
|
var SIZE_OF_INT = 4;
|
|
109
|
-
var SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
|
|
110
108
|
var SIZE_OF_NODE = 5 * SIZE_OF_INT;
|
|
111
109
|
var SIZE_OF_POINT = 2 * SIZE_OF_INT;
|
|
112
110
|
var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
|
|
@@ -229,177 +227,53 @@ var LookaheadIterator = class {
|
|
|
229
227
|
}
|
|
230
228
|
};
|
|
231
229
|
|
|
232
|
-
// src/
|
|
233
|
-
function getText(tree, startIndex, endIndex, startPosition) {
|
|
234
|
-
const length = endIndex - startIndex;
|
|
235
|
-
let result = tree.textCallback(startIndex, startPosition);
|
|
236
|
-
if (result) {
|
|
237
|
-
startIndex += result.length;
|
|
238
|
-
while (startIndex < endIndex) {
|
|
239
|
-
const string = tree.textCallback(startIndex, startPosition);
|
|
240
|
-
if (string && string.length > 0) {
|
|
241
|
-
startIndex += string.length;
|
|
242
|
-
result += string;
|
|
243
|
-
} else {
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
if (startIndex > endIndex) {
|
|
248
|
-
result = result.slice(0, length);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return result ?? "";
|
|
252
|
-
}
|
|
253
|
-
__name(getText, "getText");
|
|
230
|
+
// src/tree_cursor.ts
|
|
254
231
|
var finalizer2 = newFinalizer((address) => {
|
|
255
|
-
C.
|
|
232
|
+
C._ts_tree_cursor_delete_wasm(address);
|
|
256
233
|
});
|
|
257
|
-
var
|
|
234
|
+
var TreeCursor = class _TreeCursor {
|
|
258
235
|
static {
|
|
259
|
-
__name(this, "
|
|
236
|
+
__name(this, "TreeCursor");
|
|
260
237
|
}
|
|
261
238
|
/** @internal */
|
|
262
239
|
[0] = 0;
|
|
263
240
|
// Internal handle for Wasm
|
|
264
241
|
/** @internal */
|
|
265
|
-
|
|
266
|
-
/** The language that was used to parse the syntax tree. */
|
|
267
|
-
language;
|
|
242
|
+
tree;
|
|
268
243
|
/** @internal */
|
|
269
|
-
|
|
270
|
-
assertInternal(internal);
|
|
271
|
-
this[0] = address;
|
|
272
|
-
this.language = language;
|
|
273
|
-
this.textCallback = textCallback;
|
|
274
|
-
finalizer2?.register(this, address, this);
|
|
275
|
-
}
|
|
276
|
-
/** Create a shallow copy of the syntax tree. This is very fast. */
|
|
277
|
-
copy() {
|
|
278
|
-
const address = C._ts_tree_copy(this[0]);
|
|
279
|
-
return new _Tree(INTERNAL, address, this.language, this.textCallback);
|
|
280
|
-
}
|
|
281
|
-
/** Delete the syntax tree, freeing its resources. */
|
|
282
|
-
delete() {
|
|
283
|
-
finalizer2?.unregister(this);
|
|
284
|
-
C._ts_tree_delete(this[0]);
|
|
285
|
-
this[0] = 0;
|
|
286
|
-
}
|
|
287
|
-
/** Get the root node of the syntax tree. */
|
|
288
|
-
get rootNode() {
|
|
289
|
-
C._ts_tree_root_node_wasm(this[0]);
|
|
290
|
-
return unmarshalNode(this);
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Get the root node of the syntax tree, but with its position shifted
|
|
294
|
-
* forward by the given offset.
|
|
295
|
-
*/
|
|
296
|
-
rootNodeWithOffset(offsetBytes, offsetExtent) {
|
|
297
|
-
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
298
|
-
C.setValue(address, offsetBytes, "i32");
|
|
299
|
-
marshalPoint(address + SIZE_OF_INT, offsetExtent);
|
|
300
|
-
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
301
|
-
return unmarshalNode(this);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Edit the syntax tree to keep it in sync with source code that has been
|
|
305
|
-
* edited.
|
|
306
|
-
*
|
|
307
|
-
* You must describe the edit both in terms of byte offsets and in terms of
|
|
308
|
-
* row/column coordinates.
|
|
309
|
-
*/
|
|
310
|
-
edit(edit) {
|
|
311
|
-
marshalEdit(edit);
|
|
312
|
-
C._ts_tree_edit_wasm(this[0]);
|
|
313
|
-
}
|
|
314
|
-
/** Create a new {@link TreeCursor} starting from the root of the tree. */
|
|
315
|
-
walk() {
|
|
316
|
-
return this.rootNode.walk();
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Compare this old edited syntax tree to a new syntax tree representing
|
|
320
|
-
* the same document, returning a sequence of ranges whose syntactic
|
|
321
|
-
* structure has changed.
|
|
322
|
-
*
|
|
323
|
-
* For this to work correctly, this syntax tree must have been edited such
|
|
324
|
-
* that its ranges match up to the new tree. Generally, you'll want to
|
|
325
|
-
* call this method right after calling one of the [`Parser::parse`]
|
|
326
|
-
* functions. Call it on the old tree that was passed to parse, and
|
|
327
|
-
* pass the new tree that was returned from `parse`.
|
|
328
|
-
*/
|
|
329
|
-
getChangedRanges(other) {
|
|
330
|
-
if (!(other instanceof _Tree)) {
|
|
331
|
-
throw new TypeError("Argument must be a Tree");
|
|
332
|
-
}
|
|
333
|
-
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
334
|
-
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
335
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
336
|
-
const result = new Array(count);
|
|
337
|
-
if (count > 0) {
|
|
338
|
-
let address = buffer;
|
|
339
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
340
|
-
result[i2] = unmarshalRange(address);
|
|
341
|
-
address += SIZE_OF_RANGE;
|
|
342
|
-
}
|
|
343
|
-
C._ts_free_wasm(buffer);
|
|
344
|
-
}
|
|
345
|
-
return result;
|
|
346
|
-
}
|
|
347
|
-
/** Get the included ranges that were used to parse the syntax tree. */
|
|
348
|
-
getIncludedRanges() {
|
|
349
|
-
C._ts_tree_included_ranges_wasm(this[0]);
|
|
350
|
-
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
351
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
352
|
-
const result = new Array(count);
|
|
353
|
-
if (count > 0) {
|
|
354
|
-
let address = buffer;
|
|
355
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
356
|
-
result[i2] = unmarshalRange(address);
|
|
357
|
-
address += SIZE_OF_RANGE;
|
|
358
|
-
}
|
|
359
|
-
C._ts_free_wasm(buffer);
|
|
360
|
-
}
|
|
361
|
-
return result;
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
// src/tree_cursor.ts
|
|
366
|
-
var finalizer3 = newFinalizer((handles) => {
|
|
367
|
-
marshalTreeCursor({ handles });
|
|
368
|
-
C._ts_tree_cursor_delete_wasm(0);
|
|
369
|
-
});
|
|
370
|
-
var TreeCursor = class _TreeCursor {
|
|
371
|
-
static {
|
|
372
|
-
__name(this, "TreeCursor");
|
|
373
|
-
}
|
|
244
|
+
editVersion = -1;
|
|
374
245
|
/** @internal */
|
|
375
|
-
|
|
376
|
-
// Internal handles for Wasm, shared with the finalizer.
|
|
246
|
+
_nodeTypeId = 0;
|
|
377
247
|
/** @internal */
|
|
378
|
-
|
|
248
|
+
_fieldId = 0;
|
|
249
|
+
/** @internal */
|
|
250
|
+
_startIndex = 0;
|
|
251
|
+
/** @internal */
|
|
252
|
+
_endIndex = 0;
|
|
379
253
|
/** @internal */
|
|
380
|
-
|
|
254
|
+
_flags = 0;
|
|
255
|
+
/** @internal */
|
|
256
|
+
constructor(internal, tree, address) {
|
|
381
257
|
assertInternal(internal);
|
|
258
|
+
this[0] = address;
|
|
382
259
|
this.tree = tree;
|
|
383
|
-
|
|
384
|
-
|
|
260
|
+
this.readNodeCache();
|
|
261
|
+
finalizer2?.register(this, address, this);
|
|
385
262
|
}
|
|
386
263
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
387
264
|
copy() {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return new _TreeCursor(INTERNAL, this.tree);
|
|
265
|
+
const address = C._ts_tree_cursor_copy_wasm(this[0]);
|
|
266
|
+
return new _TreeCursor(INTERNAL, this.tree, address);
|
|
391
267
|
}
|
|
392
268
|
/** Delete the tree cursor, freeing its resources. */
|
|
393
269
|
delete() {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
this.handles.fill(0);
|
|
270
|
+
finalizer2?.unregister(this);
|
|
271
|
+
C._ts_tree_cursor_delete_wasm(this[0]);
|
|
272
|
+
this[0] = 0;
|
|
398
273
|
}
|
|
399
274
|
/** Get the tree cursor's current {@link Node}. */
|
|
400
275
|
get currentNode() {
|
|
401
|
-
|
|
402
|
-
C._ts_tree_cursor_current_node_wasm(this.tree[0]);
|
|
276
|
+
C._ts_tree_cursor_current_node_wasm(this[0]);
|
|
403
277
|
return unmarshalNode(this.tree);
|
|
404
278
|
}
|
|
405
279
|
/**
|
|
@@ -408,47 +282,41 @@ var TreeCursor = class _TreeCursor {
|
|
|
408
282
|
* See also {@link TreeCursor#currentFieldName}.
|
|
409
283
|
*/
|
|
410
284
|
get currentFieldId() {
|
|
411
|
-
|
|
412
|
-
return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
|
|
285
|
+
return this._fieldId;
|
|
413
286
|
}
|
|
414
287
|
/** Get the field name of this tree cursor's current node. */
|
|
415
288
|
get currentFieldName() {
|
|
416
|
-
return this.tree.language.fields[this.
|
|
289
|
+
return this.tree.language.fields[this._fieldId];
|
|
417
290
|
}
|
|
418
291
|
/**
|
|
419
292
|
* Get the depth of the cursor's current node relative to the original
|
|
420
293
|
* node that the cursor was constructed with.
|
|
421
294
|
*/
|
|
422
295
|
get currentDepth() {
|
|
423
|
-
|
|
424
|
-
return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
|
|
296
|
+
return C._ts_tree_cursor_current_depth_wasm(this[0]);
|
|
425
297
|
}
|
|
426
298
|
/**
|
|
427
299
|
* Get the index of the cursor's current node out of all of the
|
|
428
300
|
* descendants of the original node that the cursor was constructed with.
|
|
429
301
|
*/
|
|
430
302
|
get currentDescendantIndex() {
|
|
431
|
-
|
|
432
|
-
return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
|
|
303
|
+
return C._ts_tree_cursor_current_descendant_index_wasm(this[0]);
|
|
433
304
|
}
|
|
434
305
|
/** Get the type of the cursor's current node. */
|
|
435
306
|
get nodeType() {
|
|
436
|
-
return this.tree.language.types[this.
|
|
307
|
+
return this.tree.language.types[this._nodeTypeId] || "ERROR";
|
|
437
308
|
}
|
|
438
309
|
/** Get the type id of the cursor's current node. */
|
|
439
310
|
get nodeTypeId() {
|
|
440
|
-
|
|
441
|
-
return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
|
|
311
|
+
return this._nodeTypeId;
|
|
442
312
|
}
|
|
443
313
|
/** Get the state id of the cursor's current node. */
|
|
444
314
|
get nodeStateId() {
|
|
445
|
-
|
|
446
|
-
return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
|
|
315
|
+
return C._ts_tree_cursor_current_node_state_id_wasm(this[0]);
|
|
447
316
|
}
|
|
448
317
|
/** Get the id of the cursor's current node. */
|
|
449
318
|
get nodeId() {
|
|
450
|
-
|
|
451
|
-
return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
|
|
319
|
+
return C._ts_tree_cursor_current_node_id_wasm(this[0]);
|
|
452
320
|
}
|
|
453
321
|
/**
|
|
454
322
|
* Check if the cursor's current node is *named*.
|
|
@@ -457,8 +325,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
457
325
|
* *anonymous* nodes correspond to string literals in the grammar.
|
|
458
326
|
*/
|
|
459
327
|
get nodeIsNamed() {
|
|
460
|
-
|
|
461
|
-
return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
|
|
328
|
+
return (this._flags & 1) !== 0;
|
|
462
329
|
}
|
|
463
330
|
/**
|
|
464
331
|
* Check if the cursor's current node is *missing*.
|
|
@@ -467,39 +334,32 @@ var TreeCursor = class _TreeCursor {
|
|
|
467
334
|
* certain kinds of syntax errors.
|
|
468
335
|
*/
|
|
469
336
|
get nodeIsMissing() {
|
|
470
|
-
|
|
471
|
-
return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
|
|
337
|
+
return (this._flags & 2) !== 0;
|
|
472
338
|
}
|
|
473
339
|
/** Get the string content of the cursor's current node. */
|
|
474
340
|
get nodeText() {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
478
|
-
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
479
|
-
const startPosition = unmarshalPoint(TRANSFER_BUFFER);
|
|
480
|
-
return getText(this.tree, startIndex, endIndex, startPosition);
|
|
341
|
+
this.syncIndices();
|
|
342
|
+
return getText(this.tree, this._startIndex, this._endIndex, () => this.startPosition);
|
|
481
343
|
}
|
|
482
344
|
/** Get the start position of the cursor's current node. */
|
|
483
345
|
get startPosition() {
|
|
484
|
-
|
|
485
|
-
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
346
|
+
C._ts_tree_cursor_start_position_wasm(this[0]);
|
|
486
347
|
return unmarshalPoint(TRANSFER_BUFFER);
|
|
487
348
|
}
|
|
488
349
|
/** Get the end position of the cursor's current node. */
|
|
489
350
|
get endPosition() {
|
|
490
|
-
|
|
491
|
-
C._ts_tree_cursor_end_position_wasm(this.tree[0]);
|
|
351
|
+
C._ts_tree_cursor_end_position_wasm(this[0]);
|
|
492
352
|
return unmarshalPoint(TRANSFER_BUFFER);
|
|
493
353
|
}
|
|
494
354
|
/** Get the start index of the cursor's current node. */
|
|
495
355
|
get startIndex() {
|
|
496
|
-
|
|
497
|
-
return
|
|
356
|
+
this.syncIndices();
|
|
357
|
+
return this._startIndex;
|
|
498
358
|
}
|
|
499
359
|
/** Get the end index of the cursor's current node. */
|
|
500
360
|
get endIndex() {
|
|
501
|
-
|
|
502
|
-
return
|
|
361
|
+
this.syncIndices();
|
|
362
|
+
return this._endIndex;
|
|
503
363
|
}
|
|
504
364
|
/**
|
|
505
365
|
* Move this cursor to the first child of its current node.
|
|
@@ -508,10 +368,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
508
368
|
* `false` if there were no children.
|
|
509
369
|
*/
|
|
510
370
|
gotoFirstChild() {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return result === 1;
|
|
371
|
+
if (!C._ts_tree_cursor_goto_first_child_wasm(this[0])) return false;
|
|
372
|
+
this.readNodeCache();
|
|
373
|
+
return true;
|
|
515
374
|
}
|
|
516
375
|
/**
|
|
517
376
|
* Move this cursor to the last child of its current node.
|
|
@@ -524,10 +383,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
524
383
|
* iterate through all the children to compute the child's position.
|
|
525
384
|
*/
|
|
526
385
|
gotoLastChild() {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
return result === 1;
|
|
386
|
+
if (!C._ts_tree_cursor_goto_last_child_wasm(this[0])) return false;
|
|
387
|
+
this.readNodeCache();
|
|
388
|
+
return true;
|
|
531
389
|
}
|
|
532
390
|
/**
|
|
533
391
|
* Move this cursor to the parent of its current node.
|
|
@@ -540,10 +398,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
540
398
|
* of the cursor, and the cursor cannot walk outside this node.
|
|
541
399
|
*/
|
|
542
400
|
gotoParent() {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
return result === 1;
|
|
401
|
+
if (!C._ts_tree_cursor_goto_parent_wasm(this[0])) return false;
|
|
402
|
+
this.readNodeCache();
|
|
403
|
+
return true;
|
|
547
404
|
}
|
|
548
405
|
/**
|
|
549
406
|
* Move this cursor to the next sibling of its current node.
|
|
@@ -555,10 +412,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
555
412
|
* of the cursor, and the cursor cannot walk outside this node.
|
|
556
413
|
*/
|
|
557
414
|
gotoNextSibling() {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
return result === 1;
|
|
415
|
+
if (!C._ts_tree_cursor_goto_next_sibling_wasm(this[0])) return false;
|
|
416
|
+
this.readNodeCache();
|
|
417
|
+
return true;
|
|
562
418
|
}
|
|
563
419
|
/**
|
|
564
420
|
* Move this cursor to the previous sibling of its current node.
|
|
@@ -574,10 +430,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
574
430
|
* considered the root of the cursor, and the cursor cannot walk outside this node.
|
|
575
431
|
*/
|
|
576
432
|
gotoPreviousSibling() {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
return result === 1;
|
|
433
|
+
if (!C._ts_tree_cursor_goto_previous_sibling_wasm(this[0])) return false;
|
|
434
|
+
this.readNodeCache();
|
|
435
|
+
return true;
|
|
581
436
|
}
|
|
582
437
|
/**
|
|
583
438
|
* Move the cursor to the node that is the nth descendant of
|
|
@@ -585,9 +440,8 @@ var TreeCursor = class _TreeCursor {
|
|
|
585
440
|
* zero represents the original node itself.
|
|
586
441
|
*/
|
|
587
442
|
gotoDescendant(goalDescendantIndex) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
unmarshalTreeCursor(this);
|
|
443
|
+
C._ts_tree_cursor_goto_descendant_wasm(this[0], goalDescendantIndex);
|
|
444
|
+
this.readNodeCache();
|
|
591
445
|
}
|
|
592
446
|
/**
|
|
593
447
|
* Move this cursor to the first child of its current node that contains or
|
|
@@ -597,11 +451,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
597
451
|
* `false` if no such child was found.
|
|
598
452
|
*/
|
|
599
453
|
gotoFirstChildForIndex(goalIndex) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
unmarshalTreeCursor(this);
|
|
604
|
-
return result === 1;
|
|
454
|
+
if (!C._ts_tree_cursor_goto_first_child_for_index_wasm(this[0], goalIndex)) return false;
|
|
455
|
+
this.readNodeCache();
|
|
456
|
+
return true;
|
|
605
457
|
}
|
|
606
458
|
/**
|
|
607
459
|
* Move this cursor to the first child of its current node that contains or
|
|
@@ -611,11 +463,10 @@ var TreeCursor = class _TreeCursor {
|
|
|
611
463
|
* `false` if no such child was found.
|
|
612
464
|
*/
|
|
613
465
|
gotoFirstChildForPosition(goalPosition) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
return result === 1;
|
|
466
|
+
marshalPoint(TRANSFER_BUFFER, goalPosition);
|
|
467
|
+
if (!C._ts_tree_cursor_goto_first_child_for_position_wasm(this[0])) return false;
|
|
468
|
+
this.readNodeCache();
|
|
469
|
+
return true;
|
|
619
470
|
}
|
|
620
471
|
/**
|
|
621
472
|
* Re-initialize this tree cursor to start at the original node that the
|
|
@@ -623,10 +474,9 @@ var TreeCursor = class _TreeCursor {
|
|
|
623
474
|
*/
|
|
624
475
|
reset(node) {
|
|
625
476
|
marshalNode(node);
|
|
626
|
-
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
627
|
-
C._ts_tree_cursor_reset_wasm(node.tree[0]);
|
|
628
|
-
unmarshalTreeCursor(this);
|
|
629
477
|
this.tree = node.tree;
|
|
478
|
+
C._ts_tree_cursor_reset_wasm(this[0], node.tree[0]);
|
|
479
|
+
this.readNodeCache();
|
|
630
480
|
}
|
|
631
481
|
/**
|
|
632
482
|
* Re-initialize a tree cursor to the same position as another cursor.
|
|
@@ -635,11 +485,152 @@ var TreeCursor = class _TreeCursor {
|
|
|
635
485
|
* information and allows reusing already created cursors.
|
|
636
486
|
*/
|
|
637
487
|
resetTo(cursor) {
|
|
638
|
-
|
|
639
|
-
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
640
|
-
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
641
|
-
unmarshalTreeCursor(this);
|
|
488
|
+
if (cursor === this) return;
|
|
642
489
|
this.tree = cursor.tree;
|
|
490
|
+
C._ts_tree_cursor_reset_to_wasm(this[0], cursor[0]);
|
|
491
|
+
this.readNodeCache();
|
|
492
|
+
}
|
|
493
|
+
/** @internal */
|
|
494
|
+
readNodeCache() {
|
|
495
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
496
|
+
const heap = C.HEAPU32;
|
|
497
|
+
this._nodeTypeId = heap[base];
|
|
498
|
+
this._fieldId = heap[base + 1];
|
|
499
|
+
this._startIndex = heap[base + 2];
|
|
500
|
+
this._endIndex = heap[base + 3];
|
|
501
|
+
this._flags = heap[base + 4];
|
|
502
|
+
this.editVersion = this.tree.editVersion;
|
|
503
|
+
}
|
|
504
|
+
/** @internal */
|
|
505
|
+
syncIndices() {
|
|
506
|
+
if (this.editVersion !== this.tree.editVersion) {
|
|
507
|
+
this._startIndex = C._ts_tree_cursor_start_index_wasm(this[0]) >>> 0;
|
|
508
|
+
this._endIndex = C._ts_tree_cursor_end_index_wasm(this[0]) >>> 0;
|
|
509
|
+
this.editVersion = this.tree.editVersion;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// src/tree.ts
|
|
515
|
+
function getText(tree, startIndex, endIndex, getStartPosition) {
|
|
516
|
+
if (tree.sourceText !== void 0) {
|
|
517
|
+
return tree.sourceText.slice(startIndex, endIndex);
|
|
518
|
+
}
|
|
519
|
+
const startPosition = getStartPosition();
|
|
520
|
+
const length = endIndex - startIndex;
|
|
521
|
+
let result = tree.textCallback(startIndex, startPosition);
|
|
522
|
+
if (result) {
|
|
523
|
+
startIndex += result.length;
|
|
524
|
+
while (startIndex < endIndex) {
|
|
525
|
+
const string = tree.textCallback(startIndex, startPosition);
|
|
526
|
+
if (string && string.length > 0) {
|
|
527
|
+
startIndex += string.length;
|
|
528
|
+
result += string;
|
|
529
|
+
} else {
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (startIndex > endIndex) {
|
|
534
|
+
result = result.slice(0, length);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return result ?? "";
|
|
538
|
+
}
|
|
539
|
+
__name(getText, "getText");
|
|
540
|
+
var finalizer3 = newFinalizer((address) => {
|
|
541
|
+
C._ts_tree_delete(address);
|
|
542
|
+
});
|
|
543
|
+
var Tree2 = class _Tree {
|
|
544
|
+
static {
|
|
545
|
+
__name(this, "Tree");
|
|
546
|
+
}
|
|
547
|
+
/** @internal */
|
|
548
|
+
[0] = 0;
|
|
549
|
+
// Internal handle for Wasm
|
|
550
|
+
/** @internal */
|
|
551
|
+
textCallback;
|
|
552
|
+
/** @internal */
|
|
553
|
+
sourceText;
|
|
554
|
+
/** @internal */
|
|
555
|
+
editVersion = 0;
|
|
556
|
+
/** The language that was used to parse the syntax tree. */
|
|
557
|
+
language;
|
|
558
|
+
/** @internal */
|
|
559
|
+
constructor(internal, address, language, textCallback, sourceText) {
|
|
560
|
+
assertInternal(internal);
|
|
561
|
+
this[0] = address;
|
|
562
|
+
this.language = language;
|
|
563
|
+
this.textCallback = textCallback;
|
|
564
|
+
this.sourceText = sourceText;
|
|
565
|
+
finalizer3?.register(this, address, this);
|
|
566
|
+
}
|
|
567
|
+
/** Create a shallow copy of the syntax tree. This is very fast. */
|
|
568
|
+
copy() {
|
|
569
|
+
const address = C._ts_tree_copy(this[0]);
|
|
570
|
+
return new _Tree(INTERNAL, address, this.language, this.textCallback, this.sourceText);
|
|
571
|
+
}
|
|
572
|
+
/** Delete the syntax tree, freeing its resources. */
|
|
573
|
+
delete() {
|
|
574
|
+
finalizer3?.unregister(this);
|
|
575
|
+
C._ts_tree_delete(this[0]);
|
|
576
|
+
this[0] = 0;
|
|
577
|
+
}
|
|
578
|
+
/** Get the root node of the syntax tree. */
|
|
579
|
+
get rootNode() {
|
|
580
|
+
C._ts_tree_root_node_wasm(this[0]);
|
|
581
|
+
return unmarshalNode(this);
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Get the root node of the syntax tree, but with its position shifted
|
|
585
|
+
* forward by the given offset.
|
|
586
|
+
*/
|
|
587
|
+
rootNodeWithOffset(offsetBytes, offsetExtent) {
|
|
588
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
589
|
+
C.HEAP32[address >>> 2] = offsetBytes;
|
|
590
|
+
marshalPoint(address + SIZE_OF_INT, offsetExtent);
|
|
591
|
+
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
592
|
+
return unmarshalNode(this);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Edit the syntax tree to keep it in sync with source code that has been
|
|
596
|
+
* edited.
|
|
597
|
+
*
|
|
598
|
+
* You must describe the edit both in terms of byte offsets and in terms of
|
|
599
|
+
* row/column coordinates.
|
|
600
|
+
*/
|
|
601
|
+
edit(edit) {
|
|
602
|
+
marshalEdit(edit);
|
|
603
|
+
C._ts_tree_edit_wasm(this[0]);
|
|
604
|
+
this.editVersion++;
|
|
605
|
+
}
|
|
606
|
+
/** Create a new {@link TreeCursor} starting from the root of the tree. */
|
|
607
|
+
walk() {
|
|
608
|
+
C._ts_tree_root_node_wasm(this[0]);
|
|
609
|
+
const address = C._ts_tree_cursor_new_wasm(this[0]);
|
|
610
|
+
return new TreeCursor(INTERNAL, this, address);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Compare this old edited syntax tree to a new syntax tree representing
|
|
614
|
+
* the same document, returning a sequence of ranges whose syntactic
|
|
615
|
+
* structure has changed.
|
|
616
|
+
*
|
|
617
|
+
* For this to work correctly, this syntax tree must have been edited such
|
|
618
|
+
* that its ranges match up to the new tree. Generally, you'll want to
|
|
619
|
+
* call this method right after calling one of the [`Parser::parse`]
|
|
620
|
+
* functions. Call it on the old tree that was passed to parse, and
|
|
621
|
+
* pass the new tree that was returned from `parse`.
|
|
622
|
+
*/
|
|
623
|
+
getChangedRanges(other) {
|
|
624
|
+
if (!(other instanceof _Tree)) {
|
|
625
|
+
throw new TypeError("Argument must be a Tree");
|
|
626
|
+
}
|
|
627
|
+
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
628
|
+
return unmarshalRanges();
|
|
629
|
+
}
|
|
630
|
+
/** Get the included ranges that were used to parse the syntax tree. */
|
|
631
|
+
getIncludedRanges() {
|
|
632
|
+
C._ts_tree_included_ranges_wasm(this[0]);
|
|
633
|
+
return unmarshalRanges();
|
|
643
634
|
}
|
|
644
635
|
};
|
|
645
636
|
|
|
@@ -780,7 +771,7 @@ var Node = class {
|
|
|
780
771
|
}
|
|
781
772
|
/** Get the string content of this node. */
|
|
782
773
|
get text() {
|
|
783
|
-
return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);
|
|
774
|
+
return getText(this.tree, this.startIndex, this.endIndex, () => this.startPosition);
|
|
784
775
|
}
|
|
785
776
|
/** Get this node's parse state. */
|
|
786
777
|
get parseState() {
|
|
@@ -875,24 +866,13 @@ var Node = class {
|
|
|
875
866
|
childrenForFieldId(fieldId) {
|
|
876
867
|
marshalNode(this);
|
|
877
868
|
C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
|
|
878
|
-
|
|
879
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
880
|
-
const result = new Array(count);
|
|
881
|
-
if (count > 0) {
|
|
882
|
-
let address = buffer;
|
|
883
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
884
|
-
result[i2] = unmarshalNode(this.tree, address);
|
|
885
|
-
address += SIZE_OF_NODE;
|
|
886
|
-
}
|
|
887
|
-
C._ts_free_wasm(buffer);
|
|
888
|
-
}
|
|
889
|
-
return result;
|
|
869
|
+
return unmarshalNodeArray(this.tree, true);
|
|
890
870
|
}
|
|
891
871
|
/** Get the node's first child that contains or starts after the given byte offset. */
|
|
892
872
|
firstChildForIndex(index) {
|
|
893
873
|
marshalNode(this);
|
|
894
874
|
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
895
|
-
C.
|
|
875
|
+
C.HEAP32[address >>> 2] = index;
|
|
896
876
|
C._ts_node_first_child_for_byte_wasm(this.tree[0]);
|
|
897
877
|
return unmarshalNode(this.tree);
|
|
898
878
|
}
|
|
@@ -900,7 +880,7 @@ var Node = class {
|
|
|
900
880
|
firstNamedChildForIndex(index) {
|
|
901
881
|
marshalNode(this);
|
|
902
882
|
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
903
|
-
C.
|
|
883
|
+
C.HEAP32[address >>> 2] = index;
|
|
904
884
|
C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
|
|
905
885
|
return unmarshalNode(this.tree);
|
|
906
886
|
}
|
|
@@ -952,17 +932,7 @@ var Node = class {
|
|
|
952
932
|
if (!this._children) {
|
|
953
933
|
marshalNode(this);
|
|
954
934
|
C._ts_node_children_wasm(this.tree[0]);
|
|
955
|
-
|
|
956
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
957
|
-
this._children = new Array(count);
|
|
958
|
-
if (count > 0) {
|
|
959
|
-
let address = buffer;
|
|
960
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
961
|
-
this._children[i2] = unmarshalNode(this.tree, address);
|
|
962
|
-
address += SIZE_OF_NODE;
|
|
963
|
-
}
|
|
964
|
-
C._free(buffer);
|
|
965
|
-
}
|
|
935
|
+
this._children = unmarshalNodeArray(this.tree);
|
|
966
936
|
}
|
|
967
937
|
return this._children;
|
|
968
938
|
}
|
|
@@ -975,17 +945,7 @@ var Node = class {
|
|
|
975
945
|
if (!this._namedChildren) {
|
|
976
946
|
marshalNode(this);
|
|
977
947
|
C._ts_node_named_children_wasm(this.tree[0]);
|
|
978
|
-
|
|
979
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
980
|
-
this._namedChildren = new Array(count);
|
|
981
|
-
if (count > 0) {
|
|
982
|
-
let address = buffer;
|
|
983
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
984
|
-
this._namedChildren[i2] = unmarshalNode(this.tree, address);
|
|
985
|
-
address += SIZE_OF_NODE;
|
|
986
|
-
}
|
|
987
|
-
C._free(buffer);
|
|
988
|
-
}
|
|
948
|
+
this._namedChildren = unmarshalNodeArray(this.tree);
|
|
989
949
|
}
|
|
990
950
|
return this._namedChildren;
|
|
991
951
|
}
|
|
@@ -1009,8 +969,9 @@ var Node = class {
|
|
|
1009
969
|
symbols.push(65535);
|
|
1010
970
|
}
|
|
1011
971
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
972
|
+
const symbolsBase = symbolsAddress >>> 2;
|
|
1012
973
|
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
1013
|
-
C.
|
|
974
|
+
C.HEAPU32[symbolsBase + i2] = symbols[i2];
|
|
1014
975
|
}
|
|
1015
976
|
marshalNode(this);
|
|
1016
977
|
C._ts_node_descendants_of_type_wasm(
|
|
@@ -1022,17 +983,7 @@ var Node = class {
|
|
|
1022
983
|
endPosition.row,
|
|
1023
984
|
endPosition.column
|
|
1024
985
|
);
|
|
1025
|
-
const
|
|
1026
|
-
const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1027
|
-
const result = new Array(descendantCount);
|
|
1028
|
-
if (descendantCount > 0) {
|
|
1029
|
-
let address = descendantAddress;
|
|
1030
|
-
for (let i2 = 0; i2 < descendantCount; i2++) {
|
|
1031
|
-
result[i2] = unmarshalNode(this.tree, address);
|
|
1032
|
-
address += SIZE_OF_NODE;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
C._ts_free_wasm(descendantAddress);
|
|
986
|
+
const result = unmarshalNodeArray(this.tree, true, true);
|
|
1036
987
|
C._free(symbolsAddress);
|
|
1037
988
|
return result;
|
|
1038
989
|
}
|
|
@@ -1100,9 +1051,9 @@ var Node = class {
|
|
|
1100
1051
|
throw new Error("Arguments must be numbers");
|
|
1101
1052
|
}
|
|
1102
1053
|
marshalNode(this);
|
|
1103
|
-
const
|
|
1104
|
-
C.
|
|
1105
|
-
C.
|
|
1054
|
+
const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
|
|
1055
|
+
C.HEAP32[base] = start2;
|
|
1056
|
+
C.HEAP32[base + 1] = end;
|
|
1106
1057
|
C._ts_node_descendant_for_index_wasm(this.tree[0]);
|
|
1107
1058
|
return unmarshalNode(this.tree);
|
|
1108
1059
|
}
|
|
@@ -1112,9 +1063,9 @@ var Node = class {
|
|
|
1112
1063
|
throw new Error("Arguments must be numbers");
|
|
1113
1064
|
}
|
|
1114
1065
|
marshalNode(this);
|
|
1115
|
-
const
|
|
1116
|
-
C.
|
|
1117
|
-
C.
|
|
1066
|
+
const base = TRANSFER_BUFFER + SIZE_OF_NODE >>> 2;
|
|
1067
|
+
C.HEAP32[base] = start2;
|
|
1068
|
+
C.HEAP32[base + 1] = end;
|
|
1118
1069
|
C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
|
|
1119
1070
|
return unmarshalNode(this.tree);
|
|
1120
1071
|
}
|
|
@@ -1150,8 +1101,8 @@ var Node = class {
|
|
|
1150
1101
|
*/
|
|
1151
1102
|
walk() {
|
|
1152
1103
|
marshalNode(this);
|
|
1153
|
-
C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
1154
|
-
return new TreeCursor(INTERNAL, this.tree);
|
|
1104
|
+
const address = C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
1105
|
+
return new TreeCursor(INTERNAL, this.tree, address);
|
|
1155
1106
|
}
|
|
1156
1107
|
/**
|
|
1157
1108
|
* Edit this node to keep it in-sync with source code that has been edited.
|
|
@@ -1179,86 +1130,66 @@ var Node = class {
|
|
|
1179
1130
|
|
|
1180
1131
|
// src/marshal.ts
|
|
1181
1132
|
function marshalNode(node, index = 0) {
|
|
1182
|
-
|
|
1183
|
-
C.
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
C.setValue(address, node.startPosition.column, "i32");
|
|
1190
|
-
address += SIZE_OF_INT;
|
|
1191
|
-
C.setValue(address, node[0], "i32");
|
|
1133
|
+
const base = TRANSFER_BUFFER + index * SIZE_OF_NODE >>> 2;
|
|
1134
|
+
const heap = C.HEAP32;
|
|
1135
|
+
heap[base] = node.id;
|
|
1136
|
+
heap[base + 1] = node.startIndex;
|
|
1137
|
+
heap[base + 2] = node.startPosition.row;
|
|
1138
|
+
heap[base + 3] = node.startPosition.column;
|
|
1139
|
+
heap[base + 4] = node[0];
|
|
1192
1140
|
}
|
|
1193
1141
|
__name(marshalNode, "marshalNode");
|
|
1194
1142
|
function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1143
|
+
const base = address >>> 2;
|
|
1144
|
+
const heap = C.HEAP32;
|
|
1145
|
+
const id = heap[base];
|
|
1197
1146
|
if (id === 0) return null;
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
const row = C.getValue(address, "i32");
|
|
1201
|
-
address += SIZE_OF_INT;
|
|
1202
|
-
const column = C.getValue(address, "i32");
|
|
1203
|
-
address += SIZE_OF_INT;
|
|
1204
|
-
const other = C.getValue(address, "i32");
|
|
1205
|
-
const result = new Node(INTERNAL, {
|
|
1147
|
+
const heapU32 = C.HEAPU32;
|
|
1148
|
+
return new Node(INTERNAL, {
|
|
1206
1149
|
id,
|
|
1207
1150
|
tree,
|
|
1208
|
-
startIndex:
|
|
1209
|
-
startPosition: { row, column },
|
|
1210
|
-
other
|
|
1151
|
+
startIndex: heapU32[base + 1],
|
|
1152
|
+
startPosition: { row: heapU32[base + 2], column: heapU32[base + 3] },
|
|
1153
|
+
other: heap[base + 4]
|
|
1211
1154
|
});
|
|
1212
|
-
return result;
|
|
1213
1155
|
}
|
|
1214
1156
|
__name(unmarshalNode, "unmarshalNode");
|
|
1215
|
-
function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
|
|
1216
|
-
C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
|
|
1217
|
-
C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
|
|
1218
|
-
C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
|
|
1219
|
-
C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
|
|
1220
|
-
}
|
|
1221
|
-
__name(marshalTreeCursor, "marshalTreeCursor");
|
|
1222
|
-
function unmarshalTreeCursor({ handles }) {
|
|
1223
|
-
handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
1224
|
-
handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
1225
|
-
handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
1226
|
-
handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
1227
|
-
}
|
|
1228
|
-
__name(unmarshalTreeCursor, "unmarshalTreeCursor");
|
|
1229
1157
|
function marshalPoint(address, point) {
|
|
1230
|
-
|
|
1231
|
-
|
|
1158
|
+
const base = address >>> 2;
|
|
1159
|
+
const heap = C.HEAP32;
|
|
1160
|
+
heap[base] = point.row;
|
|
1161
|
+
heap[base + 1] = point.column;
|
|
1232
1162
|
}
|
|
1233
1163
|
__name(marshalPoint, "marshalPoint");
|
|
1234
1164
|
function unmarshalPoint(address) {
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1237
|
-
|
|
1165
|
+
const base = address >>> 2;
|
|
1166
|
+
const heap = C.HEAPU32;
|
|
1167
|
+
return {
|
|
1168
|
+
row: heap[base],
|
|
1169
|
+
column: heap[base + 1]
|
|
1238
1170
|
};
|
|
1239
|
-
return result;
|
|
1240
1171
|
}
|
|
1241
1172
|
__name(unmarshalPoint, "unmarshalPoint");
|
|
1242
1173
|
function marshalRange(address, range) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1174
|
+
const base = address >>> 2;
|
|
1175
|
+
const heap = C.HEAP32;
|
|
1176
|
+
heap[base] = range.startPosition.row;
|
|
1177
|
+
heap[base + 1] = range.startPosition.column;
|
|
1178
|
+
heap[base + 2] = range.endPosition.row;
|
|
1179
|
+
heap[base + 3] = range.endPosition.column;
|
|
1180
|
+
heap[base + 4] = range.startIndex;
|
|
1181
|
+
heap[base + 5] = range.endIndex;
|
|
1250
1182
|
}
|
|
1251
1183
|
__name(marshalRange, "marshalRange");
|
|
1252
1184
|
function unmarshalRange(address) {
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
return result;
|
|
1185
|
+
const base = address >>> 2;
|
|
1186
|
+
const heap = C.HEAPU32;
|
|
1187
|
+
return {
|
|
1188
|
+
startPosition: { row: heap[base], column: heap[base + 1] },
|
|
1189
|
+
endPosition: { row: heap[base + 2], column: heap[base + 3] },
|
|
1190
|
+
startIndex: heap[base + 4],
|
|
1191
|
+
endIndex: heap[base + 5]
|
|
1192
|
+
};
|
|
1262
1193
|
}
|
|
1263
1194
|
__name(unmarshalRange, "unmarshalRange");
|
|
1264
1195
|
function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
@@ -1267,21 +1198,61 @@ function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
|
1267
1198
|
marshalPoint(address, edit.oldEndPosition);
|
|
1268
1199
|
address += SIZE_OF_POINT;
|
|
1269
1200
|
marshalPoint(address, edit.newEndPosition);
|
|
1270
|
-
address
|
|
1271
|
-
C.
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
C.setValue(address, edit.newEndIndex, "i32");
|
|
1201
|
+
const base = address + SIZE_OF_POINT >>> 2;
|
|
1202
|
+
const heap = C.HEAP32;
|
|
1203
|
+
heap[base] = edit.startIndex;
|
|
1204
|
+
heap[base + 1] = edit.oldEndIndex;
|
|
1205
|
+
heap[base + 2] = edit.newEndIndex;
|
|
1276
1206
|
}
|
|
1277
1207
|
__name(marshalEdit, "marshalEdit");
|
|
1278
1208
|
function unmarshalLanguageMetadata(address) {
|
|
1279
|
-
const
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
1209
|
+
const base = address >>> 2;
|
|
1210
|
+
const heap = C.HEAP32;
|
|
1211
|
+
return {
|
|
1212
|
+
major_version: heap[base],
|
|
1213
|
+
minor_version: heap[base + 1],
|
|
1214
|
+
patch_version: heap[base + 2]
|
|
1215
|
+
};
|
|
1283
1216
|
}
|
|
1284
1217
|
__name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
|
|
1218
|
+
function unmarshalSymbols() {
|
|
1219
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
1220
|
+
const count = C.HEAPU32[base];
|
|
1221
|
+
const buffer = C.HEAPU32[base + 1];
|
|
1222
|
+
const result = new Array(count);
|
|
1223
|
+
if (count > 0) {
|
|
1224
|
+
const symbolBase = buffer >>> 1;
|
|
1225
|
+
const heapU16 = C.HEAPU16;
|
|
1226
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
1227
|
+
result[i2] = heapU16[symbolBase + i2];
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
return result;
|
|
1231
|
+
}
|
|
1232
|
+
__name(unmarshalSymbols, "unmarshalSymbols");
|
|
1233
|
+
function unmarshalRanges(useTsFree = true) {
|
|
1234
|
+
return unmarshalArray(SIZE_OF_RANGE, unmarshalRange, useTsFree, false);
|
|
1235
|
+
}
|
|
1236
|
+
__name(unmarshalRanges, "unmarshalRanges");
|
|
1237
|
+
function unmarshalNodeArray(tree, useTsFree = false, alwaysFree = false) {
|
|
1238
|
+
return unmarshalArray(SIZE_OF_NODE, (address) => unmarshalNode(tree, address), useTsFree, alwaysFree);
|
|
1239
|
+
}
|
|
1240
|
+
__name(unmarshalNodeArray, "unmarshalNodeArray");
|
|
1241
|
+
function unmarshalArray(stride, readItem, useTsFree, alwaysFree) {
|
|
1242
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
1243
|
+
const count = C.HEAPU32[base];
|
|
1244
|
+
const buffer = C.HEAP32[base + 1];
|
|
1245
|
+
const result = new Array(count);
|
|
1246
|
+
for (let i2 = 0, address = buffer; i2 < count; i2++, address += stride) {
|
|
1247
|
+
result[i2] = readItem(address);
|
|
1248
|
+
}
|
|
1249
|
+
if (count > 0 || alwaysFree) {
|
|
1250
|
+
if (useTsFree) C._ts_free_wasm(buffer);
|
|
1251
|
+
else C._free(buffer);
|
|
1252
|
+
}
|
|
1253
|
+
return result;
|
|
1254
|
+
}
|
|
1255
|
+
__name(unmarshalArray, "unmarshalArray");
|
|
1285
1256
|
|
|
1286
1257
|
// src/language.ts
|
|
1287
1258
|
var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
|
|
@@ -1343,7 +1314,7 @@ var Language = class {
|
|
|
1343
1314
|
*/
|
|
1344
1315
|
get metadata() {
|
|
1345
1316
|
C._ts_language_metadata_wasm(this[0]);
|
|
1346
|
-
const length = C.
|
|
1317
|
+
const length = C.HEAP32[TRANSFER_BUFFER >>> 2];
|
|
1347
1318
|
if (length === 0) return null;
|
|
1348
1319
|
return unmarshalLanguageMetadata(TRANSFER_BUFFER + SIZE_OF_INT);
|
|
1349
1320
|
}
|
|
@@ -1417,34 +1388,14 @@ var Language = class {
|
|
|
1417
1388
|
*/
|
|
1418
1389
|
get supertypes() {
|
|
1419
1390
|
C._ts_language_supertypes_wasm(this[0]);
|
|
1420
|
-
|
|
1421
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1422
|
-
const result = new Array(count);
|
|
1423
|
-
if (count > 0) {
|
|
1424
|
-
let address = buffer;
|
|
1425
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
1426
|
-
result[i2] = C.getValue(address, "i16");
|
|
1427
|
-
address += SIZE_OF_SHORT;
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
return result;
|
|
1391
|
+
return unmarshalSymbols();
|
|
1431
1392
|
}
|
|
1432
1393
|
/**
|
|
1433
1394
|
* Get the subtype ids for a given supertype node id.
|
|
1434
1395
|
*/
|
|
1435
1396
|
subtypes(supertype) {
|
|
1436
1397
|
C._ts_language_subtypes_wasm(this[0], supertype);
|
|
1437
|
-
|
|
1438
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
1439
|
-
const result = new Array(count);
|
|
1440
|
-
if (count > 0) {
|
|
1441
|
-
let address = buffer;
|
|
1442
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
1443
|
-
result[i2] = C.getValue(address, "i16");
|
|
1444
|
-
address += SIZE_OF_SHORT;
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
return result;
|
|
1398
|
+
return unmarshalSymbols();
|
|
1448
1399
|
}
|
|
1449
1400
|
/**
|
|
1450
1401
|
* Get the next state id for a given state id and node type id.
|
|
@@ -1692,8 +1643,8 @@ async function Module2(moduleArg = {}) {
|
|
|
1692
1643
|
if (max == 0) {
|
|
1693
1644
|
max += 4;
|
|
1694
1645
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1646
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max >> 2, "storing")] = 34821223;
|
|
1647
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "storing")] = 2310721022;
|
|
1697
1648
|
}
|
|
1698
1649
|
__name(writeStackCookie, "writeStackCookie");
|
|
1699
1650
|
function checkStackCookie() {
|
|
@@ -1702,8 +1653,8 @@ async function Module2(moduleArg = {}) {
|
|
|
1702
1653
|
if (max == 0) {
|
|
1703
1654
|
max += 4;
|
|
1704
1655
|
}
|
|
1705
|
-
var cookie1 =
|
|
1706
|
-
var cookie2 =
|
|
1656
|
+
var cookie1 = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max >> 2, "loading")];
|
|
1657
|
+
var cookie2 = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "loading")];
|
|
1707
1658
|
if (cookie1 != 34821223 || cookie2 != 2310721022) {
|
|
1708
1659
|
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
|
|
1709
1660
|
}
|
|
@@ -1715,6 +1666,12 @@ async function Module2(moduleArg = {}) {
|
|
|
1715
1666
|
console.warn(...args2);
|
|
1716
1667
|
}
|
|
1717
1668
|
__name(dbg, "dbg");
|
|
1669
|
+
(() => {
|
|
1670
|
+
var h16 = new Int16Array(1);
|
|
1671
|
+
var h8 = new Int8Array(h16.buffer);
|
|
1672
|
+
h16[0] = 25459;
|
|
1673
|
+
if (h8[0] !== 115 || h8[1] !== 99) abort("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)");
|
|
1674
|
+
})();
|
|
1718
1675
|
function consumedModuleProp(prop) {
|
|
1719
1676
|
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
1720
1677
|
Object.defineProperty(Module, prop, {
|
|
@@ -1785,29 +1742,26 @@ async function Module2(moduleArg = {}) {
|
|
|
1785
1742
|
var wasmMemory;
|
|
1786
1743
|
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
|
|
1787
1744
|
var HEAP64, HEAPU64;
|
|
1788
|
-
var HEAP_DATA_VIEW;
|
|
1789
1745
|
var runtimeInitialized = false;
|
|
1790
1746
|
function updateMemoryViews() {
|
|
1791
1747
|
var b = wasmMemory.buffer;
|
|
1792
|
-
|
|
1793
|
-
|
|
1748
|
+
HEAP8 = new Int8Array(b);
|
|
1749
|
+
HEAP16 = new Int16Array(b);
|
|
1794
1750
|
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
|
|
1795
1751
|
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
|
|
1796
1752
|
Module["HEAP32"] = HEAP32 = new Int32Array(b);
|
|
1797
1753
|
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
|
|
1803
|
-
LE_HEAP_UPDATE();
|
|
1754
|
+
HEAPF32 = new Float32Array(b);
|
|
1755
|
+
HEAPF64 = new Float64Array(b);
|
|
1756
|
+
HEAP64 = new BigInt64Array(b);
|
|
1757
|
+
HEAPU64 = new BigUint64Array(b);
|
|
1804
1758
|
}
|
|
1805
1759
|
__name(updateMemoryViews, "updateMemoryViews");
|
|
1806
1760
|
function initMemory() {
|
|
1807
1761
|
if (Module["wasmMemory"]) {
|
|
1808
1762
|
wasmMemory = Module["wasmMemory"];
|
|
1809
1763
|
} else {
|
|
1810
|
-
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] ||
|
|
1764
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 4194304;
|
|
1811
1765
|
assert(INITIAL_MEMORY >= 65536, "INITIAL_MEMORY should be larger than STACK_SIZE, was " + INITIAL_MEMORY + "! (STACK_SIZE=65536)");
|
|
1812
1766
|
wasmMemory = new WebAssembly.Memory({
|
|
1813
1767
|
"initial": INITIAL_MEMORY / 65536,
|
|
@@ -2052,77 +2006,6 @@ async function Module2(moduleArg = {}) {
|
|
|
2052
2006
|
return rtn;
|
|
2053
2007
|
}
|
|
2054
2008
|
};
|
|
2055
|
-
var LE_ATOMICS_ADD = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
2056
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2057
|
-
const res = order(Atomics.add(heap, offset, order(value)));
|
|
2058
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2059
|
-
}, "LE_ATOMICS_ADD");
|
|
2060
|
-
var LE_ATOMICS_AND = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
2061
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2062
|
-
const res = order(Atomics.and(heap, offset, order(value)));
|
|
2063
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2064
|
-
}, "LE_ATOMICS_AND");
|
|
2065
|
-
var LE_ATOMICS_COMPAREEXCHANGE = /* @__PURE__ */ __name((heap, offset, expected, replacement) => {
|
|
2066
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2067
|
-
const res = order(Atomics.compareExchange(heap, offset, order(expected), order(replacement)));
|
|
2068
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2069
|
-
}, "LE_ATOMICS_COMPAREEXCHANGE");
|
|
2070
|
-
var LE_ATOMICS_EXCHANGE = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
2071
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2072
|
-
const res = order(Atomics.exchange(heap, offset, order(value)));
|
|
2073
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2074
|
-
}, "LE_ATOMICS_EXCHANGE");
|
|
2075
|
-
var LE_ATOMICS_ISLOCKFREE = /* @__PURE__ */ __name((size) => Atomics.isLockFree(size), "LE_ATOMICS_ISLOCKFREE");
|
|
2076
|
-
var LE_ATOMICS_LOAD = /* @__PURE__ */ __name((heap, offset) => {
|
|
2077
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2078
|
-
const res = order(Atomics.load(heap, offset));
|
|
2079
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2080
|
-
}, "LE_ATOMICS_LOAD");
|
|
2081
|
-
var LE_ATOMICS_NATIVE_BYTE_ORDER = [];
|
|
2082
|
-
var LE_ATOMICS_NOTIFY = /* @__PURE__ */ __name((heap, offset, count) => Atomics.notify(heap, offset, count), "LE_ATOMICS_NOTIFY");
|
|
2083
|
-
var LE_ATOMICS_OR = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
2084
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2085
|
-
const res = order(Atomics.or(heap, offset, order(value)));
|
|
2086
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2087
|
-
}, "LE_ATOMICS_OR");
|
|
2088
|
-
var LE_ATOMICS_STORE = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
2089
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2090
|
-
Atomics.store(heap, offset, order(value));
|
|
2091
|
-
}, "LE_ATOMICS_STORE");
|
|
2092
|
-
var LE_ATOMICS_SUB = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
2093
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2094
|
-
const res = order(Atomics.sub(heap, offset, order(value)));
|
|
2095
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2096
|
-
}, "LE_ATOMICS_SUB");
|
|
2097
|
-
var LE_ATOMICS_WAIT = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
|
|
2098
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2099
|
-
return Atomics.wait(heap, offset, order(value), timeout);
|
|
2100
|
-
}, "LE_ATOMICS_WAIT");
|
|
2101
|
-
var LE_ATOMICS_WAITASYNC = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
|
|
2102
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2103
|
-
return Atomics.waitAsync(heap, offset, order(value), timeout);
|
|
2104
|
-
}, "LE_ATOMICS_WAITASYNC");
|
|
2105
|
-
var LE_ATOMICS_XOR = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
2106
|
-
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
2107
|
-
const res = order(Atomics.xor(heap, offset, order(value)));
|
|
2108
|
-
return heap.unsigned ? heap.unsigned(res) : res;
|
|
2109
|
-
}, "LE_ATOMICS_XOR");
|
|
2110
|
-
var LE_HEAP_LOAD_F32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true), "LE_HEAP_LOAD_F32");
|
|
2111
|
-
var LE_HEAP_LOAD_F64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true), "LE_HEAP_LOAD_F64");
|
|
2112
|
-
var LE_HEAP_LOAD_I16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true), "LE_HEAP_LOAD_I16");
|
|
2113
|
-
var LE_HEAP_LOAD_I32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true), "LE_HEAP_LOAD_I32");
|
|
2114
|
-
var LE_HEAP_LOAD_I64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigInt64(byteOffset, true), "LE_HEAP_LOAD_I64");
|
|
2115
|
-
var LE_HEAP_LOAD_U16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint16(byteOffset, true), "LE_HEAP_LOAD_U16");
|
|
2116
|
-
var LE_HEAP_LOAD_U32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true), "LE_HEAP_LOAD_U32");
|
|
2117
|
-
var LE_HEAP_LOAD_U64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigUint64(byteOffset, true), "LE_HEAP_LOAD_U64");
|
|
2118
|
-
var LE_HEAP_STORE_F32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true), "LE_HEAP_STORE_F32");
|
|
2119
|
-
var LE_HEAP_STORE_F64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true), "LE_HEAP_STORE_F64");
|
|
2120
|
-
var LE_HEAP_STORE_I16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true), "LE_HEAP_STORE_I16");
|
|
2121
|
-
var LE_HEAP_STORE_I32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true), "LE_HEAP_STORE_I32");
|
|
2122
|
-
var LE_HEAP_STORE_I64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigInt64(byteOffset, value, true), "LE_HEAP_STORE_I64");
|
|
2123
|
-
var LE_HEAP_STORE_U16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint16(byteOffset, value, true), "LE_HEAP_STORE_U16");
|
|
2124
|
-
var LE_HEAP_STORE_U32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true), "LE_HEAP_STORE_U32");
|
|
2125
|
-
var LE_HEAP_STORE_U64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigUint64(byteOffset, value, true), "LE_HEAP_STORE_U64");
|
|
2126
2009
|
var callRuntimeCallbacks = /* @__PURE__ */ __name((callbacks) => {
|
|
2127
2010
|
while (callbacks.length > 0) {
|
|
2128
2011
|
callbacks.shift()(Module);
|
|
@@ -2223,7 +2106,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2223
2106
|
end = binary2.length;
|
|
2224
2107
|
} else {
|
|
2225
2108
|
var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
|
|
2226
|
-
var magicNumberFound = int32View[0] == 1836278016
|
|
2109
|
+
var magicNumberFound = int32View[0] == 1836278016;
|
|
2227
2110
|
failIf(!magicNumberFound, "need to see wasm magic number");
|
|
2228
2111
|
failIf(binary2[8] !== 0, "need the dylink section to be first");
|
|
2229
2112
|
offset = 9;
|
|
@@ -2295,17 +2178,17 @@ async function Module2(moduleArg = {}) {
|
|
|
2295
2178
|
case "i8":
|
|
2296
2179
|
return HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "loading")];
|
|
2297
2180
|
case "i16":
|
|
2298
|
-
return
|
|
2181
|
+
return HEAP16[SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "loading")];
|
|
2299
2182
|
case "i32":
|
|
2300
|
-
return
|
|
2183
|
+
return HEAP32[SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "loading")];
|
|
2301
2184
|
case "i64":
|
|
2302
|
-
return
|
|
2185
|
+
return HEAP64[SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "loading")];
|
|
2303
2186
|
case "float":
|
|
2304
|
-
return
|
|
2187
|
+
return HEAPF32[SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "loading")];
|
|
2305
2188
|
case "double":
|
|
2306
|
-
return
|
|
2189
|
+
return HEAPF64[SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "loading")];
|
|
2307
2190
|
case "*":
|
|
2308
|
-
return
|
|
2191
|
+
return HEAPU32[SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "loading")];
|
|
2309
2192
|
default:
|
|
2310
2193
|
abort(`invalid type for getValue: ${type}`);
|
|
2311
2194
|
}
|
|
@@ -2332,7 +2215,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2332
2215
|
newDSO("__main__", 0, wasmImports);
|
|
2333
2216
|
}
|
|
2334
2217
|
};
|
|
2335
|
-
var ___heap_base =
|
|
2218
|
+
var ___heap_base = 82464;
|
|
2336
2219
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
|
|
2337
2220
|
assert(alignment, "alignment argument is required");
|
|
2338
2221
|
return Math.ceil(size / alignment) * alignment;
|
|
@@ -2427,7 +2310,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2427
2310
|
}, "convertJsFunctionToWasm");
|
|
2428
2311
|
var wasmTableMirror = [];
|
|
2429
2312
|
var wasmTable = new WebAssembly.Table({
|
|
2430
|
-
"initial":
|
|
2313
|
+
"initial": 59,
|
|
2431
2314
|
"element": "anyfunc"
|
|
2432
2315
|
});
|
|
2433
2316
|
var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
|
|
@@ -2588,10 +2471,10 @@ async function Module2(moduleArg = {}) {
|
|
|
2588
2471
|
var tableBase = metadata.tableSize ? wasmTable.length : 0;
|
|
2589
2472
|
if (handle) {
|
|
2590
2473
|
HEAP8[SAFE_HEAP_INDEX(HEAP8, handle + 8, "storing")] = 1;
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2474
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle + 12 >> 2, "storing")] = memoryBase;
|
|
2475
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, handle + 16 >> 2, "storing")] = metadata.memorySize;
|
|
2476
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle + 20 >> 2, "storing")] = tableBase;
|
|
2477
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, handle + 24 >> 2, "storing")] = metadata.tableSize;
|
|
2595
2478
|
}
|
|
2596
2479
|
if (metadata.tableSize) {
|
|
2597
2480
|
assert(wasmTable.length == tableBase, `unexpected table size while loading ${libName}: ${wasmTable.length}`);
|
|
@@ -2793,8 +2676,8 @@ async function Module2(moduleArg = {}) {
|
|
|
2793
2676
|
dso.global = flags2.global;
|
|
2794
2677
|
function loadLibData() {
|
|
2795
2678
|
if (handle2) {
|
|
2796
|
-
var data =
|
|
2797
|
-
var dataSize =
|
|
2679
|
+
var data = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle2 + 28 >> 2, "loading")];
|
|
2680
|
+
var dataSize = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, handle2 + 32 >> 2, "loading")];
|
|
2798
2681
|
if (data && dataSize) {
|
|
2799
2682
|
var libData = HEAP8.slice(data, data + dataSize);
|
|
2800
2683
|
return flags2.loadAsync ? Promise.resolve(libData) : libData;
|
|
@@ -2937,22 +2820,22 @@ async function Module2(moduleArg = {}) {
|
|
|
2937
2820
|
HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "storing")] = value;
|
|
2938
2821
|
break;
|
|
2939
2822
|
case "i16":
|
|
2940
|
-
|
|
2823
|
+
HEAP16[SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "storing")] = value;
|
|
2941
2824
|
break;
|
|
2942
2825
|
case "i32":
|
|
2943
|
-
|
|
2826
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "storing")] = value;
|
|
2944
2827
|
break;
|
|
2945
2828
|
case "i64":
|
|
2946
|
-
|
|
2829
|
+
HEAP64[SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "storing")] = BigInt(value);
|
|
2947
2830
|
break;
|
|
2948
2831
|
case "float":
|
|
2949
|
-
|
|
2832
|
+
HEAPF32[SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "storing")] = value;
|
|
2950
2833
|
break;
|
|
2951
2834
|
case "double":
|
|
2952
|
-
|
|
2835
|
+
HEAPF64[SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "storing")] = value;
|
|
2953
2836
|
break;
|
|
2954
2837
|
case "*":
|
|
2955
|
-
|
|
2838
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "storing")] = value;
|
|
2956
2839
|
break;
|
|
2957
2840
|
default:
|
|
2958
2841
|
abort(`invalid type for setValue: ${type}`);
|
|
@@ -2963,12 +2846,12 @@ async function Module2(moduleArg = {}) {
|
|
|
2963
2846
|
"value": "i32",
|
|
2964
2847
|
"mutable": false
|
|
2965
2848
|
}, 1024);
|
|
2966
|
-
var ___stack_high =
|
|
2967
|
-
var ___stack_low =
|
|
2849
|
+
var ___stack_high = 82464;
|
|
2850
|
+
var ___stack_low = 16928;
|
|
2968
2851
|
var ___stack_pointer = new WebAssembly.Global({
|
|
2969
2852
|
"value": "i32",
|
|
2970
2853
|
"mutable": true
|
|
2971
|
-
},
|
|
2854
|
+
}, 82464);
|
|
2972
2855
|
var ___table_base = new WebAssembly.Global({
|
|
2973
2856
|
"value": "i32",
|
|
2974
2857
|
"mutable": false
|
|
@@ -3058,15 +2941,15 @@ async function Module2(moduleArg = {}) {
|
|
|
3058
2941
|
var _fd_write = /* @__PURE__ */ __name((fd, iov, iovcnt, pnum) => {
|
|
3059
2942
|
var num = 0;
|
|
3060
2943
|
for (var i2 = 0; i2 < iovcnt; i2++) {
|
|
3061
|
-
var ptr =
|
|
3062
|
-
var len =
|
|
2944
|
+
var ptr = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, iov >> 2, "loading")];
|
|
2945
|
+
var len = HEAPU32[SAFE_HEAP_INDEX(HEAPU32, iov + 4 >> 2, "loading")];
|
|
3063
2946
|
iov += 8;
|
|
3064
2947
|
for (var j = 0; j < len; j++) {
|
|
3065
2948
|
printChar(fd, HEAPU8[SAFE_HEAP_INDEX(HEAPU8, ptr + j, "loading")]);
|
|
3066
2949
|
}
|
|
3067
2950
|
num += len;
|
|
3068
2951
|
}
|
|
3069
|
-
|
|
2952
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, pnum >> 2, "storing")] = num;
|
|
3070
2953
|
return 0;
|
|
3071
2954
|
}, "_fd_write");
|
|
3072
2955
|
_fd_write.sig = "iippp";
|
|
@@ -3084,10 +2967,10 @@ async function Module2(moduleArg = {}) {
|
|
|
3084
2967
|
column
|
|
3085
2968
|
});
|
|
3086
2969
|
if (typeof string === "string") {
|
|
3087
|
-
|
|
2970
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >> 2, "storing")] = string.length;
|
|
3088
2971
|
stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
|
|
3089
2972
|
} else {
|
|
3090
|
-
|
|
2973
|
+
HEAP32[SAFE_HEAP_INDEX(HEAP32, lengthAddress >> 2, "storing")] = 0;
|
|
3091
2974
|
}
|
|
3092
2975
|
}
|
|
3093
2976
|
__name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
|
|
@@ -3212,30 +3095,12 @@ async function Module2(moduleArg = {}) {
|
|
|
3212
3095
|
var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
|
|
3213
3096
|
for (var i2 = 0; i2 < numCharsToWrite; ++i2) {
|
|
3214
3097
|
var codeUnit = str.charCodeAt(i2);
|
|
3215
|
-
|
|
3098
|
+
HEAP16[SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing")] = codeUnit;
|
|
3216
3099
|
outPtr += 2;
|
|
3217
3100
|
}
|
|
3218
|
-
|
|
3101
|
+
HEAP16[SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing")] = 0;
|
|
3219
3102
|
return outPtr - startPtr;
|
|
3220
3103
|
}, "stringToUTF16");
|
|
3221
|
-
LE_ATOMICS_NATIVE_BYTE_ORDER = new Int8Array(new Int16Array([1]).buffer)[0] === 1 ? [
|
|
3222
|
-
/* little endian */
|
|
3223
|
-
((x) => x),
|
|
3224
|
-
((x) => x),
|
|
3225
|
-
void 0,
|
|
3226
|
-
((x) => x)
|
|
3227
|
-
] : [
|
|
3228
|
-
/* big endian */
|
|
3229
|
-
((x) => x),
|
|
3230
|
-
((x) => ((x & 65280) << 8 | (x & 255) << 24) >> 16),
|
|
3231
|
-
void 0,
|
|
3232
|
-
((x) => x >> 24 & 255 | x >> 8 & 65280 | (x & 65280) << 8 | (x & 255) << 24)
|
|
3233
|
-
];
|
|
3234
|
-
function LE_HEAP_UPDATE() {
|
|
3235
|
-
HEAPU16.unsigned = ((x) => x & 65535);
|
|
3236
|
-
HEAPU32.unsigned = ((x) => x >>> 0);
|
|
3237
|
-
}
|
|
3238
|
-
__name(LE_HEAP_UPDATE, "LE_HEAP_UPDATE");
|
|
3239
3104
|
{
|
|
3240
3105
|
initMemory();
|
|
3241
3106
|
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
@@ -3267,18 +3132,15 @@ async function Module2(moduleArg = {}) {
|
|
|
3267
3132
|
}
|
|
3268
3133
|
consumedModuleProp("preInit");
|
|
3269
3134
|
}
|
|
3270
|
-
Module["setValue"] = setValue;
|
|
3271
|
-
Module["getValue"] = getValue;
|
|
3272
3135
|
Module["UTF8ToString"] = UTF8ToString;
|
|
3273
3136
|
Module["stringToUTF8"] = stringToUTF8;
|
|
3274
3137
|
Module["lengthBytesUTF8"] = lengthBytesUTF8;
|
|
3275
3138
|
Module["AsciiToString"] = AsciiToString;
|
|
3276
3139
|
Module["stringToUTF16"] = stringToUTF16;
|
|
3277
3140
|
Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
|
|
3278
|
-
Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
|
|
3279
3141
|
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"];
|
|
3280
3142
|
missingLibrarySymbols.forEach(missingLibrarySymbol);
|
|
3281
|
-
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"
|
|
3143
|
+
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"];
|
|
3282
3144
|
unexportedSymbols.forEach(unexportedRuntimeSymbol);
|
|
3283
3145
|
function checkIncomingModuleAPI() {
|
|
3284
3146
|
ignoredModuleProp("fetchSettings");
|
|
@@ -3324,6 +3186,7 @@ async function Module2(moduleArg = {}) {
|
|
|
3324
3186
|
var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = makeInvalidEarlyAccess("_ts_parser_enable_logger_wasm");
|
|
3325
3187
|
var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = makeInvalidEarlyAccess("_ts_parser_parse_wasm");
|
|
3326
3188
|
var _ts_parser_parse_limited_wasm = Module["_ts_parser_parse_limited_wasm"] = makeInvalidEarlyAccess("_ts_parser_parse_limited_wasm");
|
|
3189
|
+
var _ts_parser_last_parse_operations_wasm = Module["_ts_parser_last_parse_operations_wasm"] = makeInvalidEarlyAccess("_ts_parser_last_parse_operations_wasm");
|
|
3327
3190
|
var _ts_parser_abort_limited_wasm = Module["_ts_parser_abort_limited_wasm"] = makeInvalidEarlyAccess("_ts_parser_abort_limited_wasm");
|
|
3328
3191
|
var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = makeInvalidEarlyAccess("_ts_parser_included_ranges_wasm");
|
|
3329
3192
|
var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = makeInvalidEarlyAccess("_ts_language_type_is_named_wasm");
|
|
@@ -3349,16 +3212,12 @@ async function Module2(moduleArg = {}) {
|
|
|
3349
3212
|
var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_previous_sibling_wasm");
|
|
3350
3213
|
var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_descendant_wasm");
|
|
3351
3214
|
var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_parent_wasm");
|
|
3352
|
-
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");
|
|
3353
3215
|
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");
|
|
3354
|
-
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");
|
|
3355
|
-
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");
|
|
3356
3216
|
var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_id_wasm");
|
|
3357
3217
|
var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_position_wasm");
|
|
3358
3218
|
var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_position_wasm");
|
|
3359
3219
|
var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_index_wasm");
|
|
3360
3220
|
var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_index_wasm");
|
|
3361
|
-
var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_field_id_wasm");
|
|
3362
3221
|
var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth_wasm");
|
|
3363
3222
|
var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index_wasm");
|
|
3364
3223
|
var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_wasm");
|
|
@@ -3470,8 +3329,9 @@ async function Module2(moduleArg = {}) {
|
|
|
3470
3329
|
Module["_ts_scanner_realloc_wasm"] = _ts_scanner_realloc_wasm = createExportWrapper("ts_scanner_realloc_wasm", 2);
|
|
3471
3330
|
Module["_ts_parser_new_wasm"] = _ts_parser_new_wasm = createExportWrapper("ts_parser_new_wasm", 0);
|
|
3472
3331
|
Module["_ts_parser_enable_logger_wasm"] = _ts_parser_enable_logger_wasm = createExportWrapper("ts_parser_enable_logger_wasm", 2);
|
|
3473
|
-
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm",
|
|
3474
|
-
Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm",
|
|
3332
|
+
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm", 3);
|
|
3333
|
+
Module["_ts_parser_parse_limited_wasm"] = _ts_parser_parse_limited_wasm = createExportWrapper("ts_parser_parse_limited_wasm", 2);
|
|
3334
|
+
Module["_ts_parser_last_parse_operations_wasm"] = _ts_parser_last_parse_operations_wasm = createExportWrapper("ts_parser_last_parse_operations_wasm", 1);
|
|
3475
3335
|
Module["_ts_parser_abort_limited_wasm"] = _ts_parser_abort_limited_wasm = createExportWrapper("ts_parser_abort_limited_wasm", 0);
|
|
3476
3336
|
Module["_ts_parser_included_ranges_wasm"] = _ts_parser_included_ranges_wasm = createExportWrapper("ts_parser_included_ranges_wasm", 1);
|
|
3477
3337
|
Module["_ts_language_type_is_named_wasm"] = _ts_language_type_is_named_wasm = createExportWrapper("ts_language_type_is_named_wasm", 2);
|
|
@@ -3487,26 +3347,22 @@ async function Module2(moduleArg = {}) {
|
|
|
3487
3347
|
Module["_ts_tree_cursor_new_wasm"] = _ts_tree_cursor_new_wasm = createExportWrapper("ts_tree_cursor_new_wasm", 1);
|
|
3488
3348
|
Module["_ts_tree_cursor_copy_wasm"] = _ts_tree_cursor_copy_wasm = createExportWrapper("ts_tree_cursor_copy_wasm", 1);
|
|
3489
3349
|
Module["_ts_tree_cursor_delete_wasm"] = _ts_tree_cursor_delete_wasm = createExportWrapper("ts_tree_cursor_delete_wasm", 1);
|
|
3490
|
-
Module["_ts_tree_cursor_reset_wasm"] = _ts_tree_cursor_reset_wasm = createExportWrapper("ts_tree_cursor_reset_wasm",
|
|
3350
|
+
Module["_ts_tree_cursor_reset_wasm"] = _ts_tree_cursor_reset_wasm = createExportWrapper("ts_tree_cursor_reset_wasm", 2);
|
|
3491
3351
|
Module["_ts_tree_cursor_reset_to_wasm"] = _ts_tree_cursor_reset_to_wasm = createExportWrapper("ts_tree_cursor_reset_to_wasm", 2);
|
|
3492
3352
|
Module["_ts_tree_cursor_goto_first_child_wasm"] = _ts_tree_cursor_goto_first_child_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_wasm", 1);
|
|
3493
3353
|
Module["_ts_tree_cursor_goto_last_child_wasm"] = _ts_tree_cursor_goto_last_child_wasm = createExportWrapper("ts_tree_cursor_goto_last_child_wasm", 1);
|
|
3494
|
-
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",
|
|
3354
|
+
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);
|
|
3495
3355
|
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);
|
|
3496
3356
|
Module["_ts_tree_cursor_goto_next_sibling_wasm"] = _ts_tree_cursor_goto_next_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_next_sibling_wasm", 1);
|
|
3497
3357
|
Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = _ts_tree_cursor_goto_previous_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_previous_sibling_wasm", 1);
|
|
3498
3358
|
Module["_ts_tree_cursor_goto_descendant_wasm"] = _ts_tree_cursor_goto_descendant_wasm = createExportWrapper("ts_tree_cursor_goto_descendant_wasm", 2);
|
|
3499
3359
|
Module["_ts_tree_cursor_goto_parent_wasm"] = _ts_tree_cursor_goto_parent_wasm = createExportWrapper("ts_tree_cursor_goto_parent_wasm", 1);
|
|
3500
|
-
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);
|
|
3501
3360
|
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);
|
|
3502
|
-
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);
|
|
3503
|
-
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);
|
|
3504
3361
|
Module["_ts_tree_cursor_current_node_id_wasm"] = _ts_tree_cursor_current_node_id_wasm = createExportWrapper("ts_tree_cursor_current_node_id_wasm", 1);
|
|
3505
3362
|
Module["_ts_tree_cursor_start_position_wasm"] = _ts_tree_cursor_start_position_wasm = createExportWrapper("ts_tree_cursor_start_position_wasm", 1);
|
|
3506
3363
|
Module["_ts_tree_cursor_end_position_wasm"] = _ts_tree_cursor_end_position_wasm = createExportWrapper("ts_tree_cursor_end_position_wasm", 1);
|
|
3507
3364
|
Module["_ts_tree_cursor_start_index_wasm"] = _ts_tree_cursor_start_index_wasm = createExportWrapper("ts_tree_cursor_start_index_wasm", 1);
|
|
3508
3365
|
Module["_ts_tree_cursor_end_index_wasm"] = _ts_tree_cursor_end_index_wasm = createExportWrapper("ts_tree_cursor_end_index_wasm", 1);
|
|
3509
|
-
Module["_ts_tree_cursor_current_field_id_wasm"] = _ts_tree_cursor_current_field_id_wasm = createExportWrapper("ts_tree_cursor_current_field_id_wasm", 1);
|
|
3510
3366
|
Module["_ts_tree_cursor_current_depth_wasm"] = _ts_tree_cursor_current_depth_wasm = createExportWrapper("ts_tree_cursor_current_depth_wasm", 1);
|
|
3511
3367
|
Module["_ts_tree_cursor_current_descendant_index_wasm"] = _ts_tree_cursor_current_descendant_index_wasm = createExportWrapper("ts_tree_cursor_current_descendant_index_wasm", 1);
|
|
3512
3368
|
Module["_ts_tree_cursor_current_node_wasm"] = _ts_tree_cursor_current_node_wasm = createExportWrapper("ts_tree_cursor_current_node_wasm", 1);
|
|
@@ -3612,20 +3468,20 @@ async function Module2(moduleArg = {}) {
|
|
|
3612
3468
|
/** @export */
|
|
3613
3469
|
fd_write: _fd_write,
|
|
3614
3470
|
/** @export */
|
|
3615
|
-
invoke_i,
|
|
3616
|
-
/** @export */
|
|
3617
|
-
invoke_ii,
|
|
3618
|
-
/** @export */
|
|
3619
3471
|
invoke_iii,
|
|
3620
3472
|
/** @export */
|
|
3621
3473
|
invoke_iiii,
|
|
3622
3474
|
/** @export */
|
|
3623
3475
|
invoke_iiiii,
|
|
3624
3476
|
/** @export */
|
|
3477
|
+
invoke_ji,
|
|
3478
|
+
/** @export */
|
|
3625
3479
|
invoke_vi,
|
|
3626
3480
|
/** @export */
|
|
3627
3481
|
invoke_vii,
|
|
3628
3482
|
/** @export */
|
|
3483
|
+
invoke_vj,
|
|
3484
|
+
/** @export */
|
|
3629
3485
|
memory: wasmMemory,
|
|
3630
3486
|
/** @export */
|
|
3631
3487
|
segfault,
|
|
@@ -3636,61 +3492,62 @@ async function Module2(moduleArg = {}) {
|
|
|
3636
3492
|
/** @export */
|
|
3637
3493
|
tree_sitter_progress_callback: _tree_sitter_progress_callback
|
|
3638
3494
|
};
|
|
3639
|
-
function
|
|
3495
|
+
function invoke_vii(index, a1, a2) {
|
|
3640
3496
|
var sp = stackSave();
|
|
3641
3497
|
try {
|
|
3642
|
-
getWasmTableEntry(index)(a1);
|
|
3498
|
+
getWasmTableEntry(index)(a1, a2);
|
|
3643
3499
|
} catch (e) {
|
|
3644
3500
|
stackRestore(sp);
|
|
3645
3501
|
if (e !== e + 0) throw e;
|
|
3646
3502
|
_setThrew(1, 0);
|
|
3647
3503
|
}
|
|
3648
3504
|
}
|
|
3649
|
-
__name(
|
|
3650
|
-
function
|
|
3505
|
+
__name(invoke_vii, "invoke_vii");
|
|
3506
|
+
function invoke_iii(index, a1, a2) {
|
|
3651
3507
|
var sp = stackSave();
|
|
3652
3508
|
try {
|
|
3653
|
-
return getWasmTableEntry(index)();
|
|
3509
|
+
return getWasmTableEntry(index)(a1, a2);
|
|
3654
3510
|
} catch (e) {
|
|
3655
3511
|
stackRestore(sp);
|
|
3656
3512
|
if (e !== e + 0) throw e;
|
|
3657
3513
|
_setThrew(1, 0);
|
|
3658
3514
|
}
|
|
3659
3515
|
}
|
|
3660
|
-
__name(
|
|
3661
|
-
function
|
|
3516
|
+
__name(invoke_iii, "invoke_iii");
|
|
3517
|
+
function invoke_vj(index, a1) {
|
|
3662
3518
|
var sp = stackSave();
|
|
3663
3519
|
try {
|
|
3664
|
-
|
|
3520
|
+
getWasmTableEntry(index)(a1);
|
|
3665
3521
|
} catch (e) {
|
|
3666
3522
|
stackRestore(sp);
|
|
3667
3523
|
if (e !== e + 0) throw e;
|
|
3668
3524
|
_setThrew(1, 0);
|
|
3669
3525
|
}
|
|
3670
3526
|
}
|
|
3671
|
-
__name(
|
|
3672
|
-
function
|
|
3527
|
+
__name(invoke_vj, "invoke_vj");
|
|
3528
|
+
function invoke_ji(index, a1) {
|
|
3673
3529
|
var sp = stackSave();
|
|
3674
3530
|
try {
|
|
3675
|
-
return getWasmTableEntry(index)(a1
|
|
3531
|
+
return getWasmTableEntry(index)(a1);
|
|
3676
3532
|
} catch (e) {
|
|
3677
3533
|
stackRestore(sp);
|
|
3678
3534
|
if (e !== e + 0) throw e;
|
|
3679
3535
|
_setThrew(1, 0);
|
|
3536
|
+
return 0n;
|
|
3680
3537
|
}
|
|
3681
3538
|
}
|
|
3682
|
-
__name(
|
|
3683
|
-
function
|
|
3539
|
+
__name(invoke_ji, "invoke_ji");
|
|
3540
|
+
function invoke_iiiii(index, a1, a2, a3, a4) {
|
|
3684
3541
|
var sp = stackSave();
|
|
3685
3542
|
try {
|
|
3686
|
-
getWasmTableEntry(index)(a1, a2);
|
|
3543
|
+
return getWasmTableEntry(index)(a1, a2, a3, a4);
|
|
3687
3544
|
} catch (e) {
|
|
3688
3545
|
stackRestore(sp);
|
|
3689
3546
|
if (e !== e + 0) throw e;
|
|
3690
3547
|
_setThrew(1, 0);
|
|
3691
3548
|
}
|
|
3692
3549
|
}
|
|
3693
|
-
__name(
|
|
3550
|
+
__name(invoke_iiiii, "invoke_iiiii");
|
|
3694
3551
|
function invoke_iiii(index, a1, a2, a3) {
|
|
3695
3552
|
var sp = stackSave();
|
|
3696
3553
|
try {
|
|
@@ -3702,17 +3559,17 @@ async function Module2(moduleArg = {}) {
|
|
|
3702
3559
|
}
|
|
3703
3560
|
}
|
|
3704
3561
|
__name(invoke_iiii, "invoke_iiii");
|
|
3705
|
-
function
|
|
3562
|
+
function invoke_vi(index, a1) {
|
|
3706
3563
|
var sp = stackSave();
|
|
3707
3564
|
try {
|
|
3708
|
-
|
|
3565
|
+
getWasmTableEntry(index)(a1);
|
|
3709
3566
|
} catch (e) {
|
|
3710
3567
|
stackRestore(sp);
|
|
3711
3568
|
if (e !== e + 0) throw e;
|
|
3712
3569
|
_setThrew(1, 0);
|
|
3713
3570
|
}
|
|
3714
3571
|
}
|
|
3715
|
-
__name(
|
|
3572
|
+
__name(invoke_vi, "invoke_vi");
|
|
3716
3573
|
var calledRun;
|
|
3717
3574
|
function callMain(args2 = []) {
|
|
3718
3575
|
assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
|
|
@@ -3724,10 +3581,10 @@ async function Module2(moduleArg = {}) {
|
|
|
3724
3581
|
var argv = stackAlloc((argc + 1) * 4);
|
|
3725
3582
|
var argv_ptr = argv;
|
|
3726
3583
|
args2.forEach((arg) => {
|
|
3727
|
-
|
|
3584
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing")] = stringToUTF8OnStack(arg);
|
|
3728
3585
|
argv_ptr += 4;
|
|
3729
3586
|
});
|
|
3730
|
-
|
|
3587
|
+
HEAPU32[SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing")] = 0;
|
|
3731
3588
|
try {
|
|
3732
3589
|
var ret = entryFunction(argc, argv);
|
|
3733
3590
|
exitJS(
|
|
@@ -3742,7 +3599,7 @@ async function Module2(moduleArg = {}) {
|
|
|
3742
3599
|
}
|
|
3743
3600
|
__name(callMain, "callMain");
|
|
3744
3601
|
function stackCheckInit() {
|
|
3745
|
-
_emscripten_stack_set_limits(
|
|
3602
|
+
_emscripten_stack_set_limits(82464, 16928);
|
|
3746
3603
|
writeStackCookie();
|
|
3747
3604
|
}
|
|
3748
3605
|
__name(stackCheckInit, "stackCheckInit");
|
|
@@ -3852,8 +3709,10 @@ function checkModule() {
|
|
|
3852
3709
|
__name(checkModule, "checkModule");
|
|
3853
3710
|
|
|
3854
3711
|
// src/parser.ts
|
|
3712
|
+
var TWO_POW_32 = 4294967296;
|
|
3855
3713
|
var TRANSFER_BUFFER;
|
|
3856
3714
|
var LANGUAGE_VERSION;
|
|
3715
|
+
var MIN_COMPATIBLE_VERSION;
|
|
3857
3716
|
function assertSupportedLanguage(language) {
|
|
3858
3717
|
const version = C._ts_language_abi_version(language[0]);
|
|
3859
3718
|
if (version < MIN_COMPATIBLE_VERSION || version > LANGUAGE_VERSION) {
|
|
@@ -3863,7 +3722,6 @@ function assertSupportedLanguage(language) {
|
|
|
3863
3722
|
}
|
|
3864
3723
|
}
|
|
3865
3724
|
__name(assertSupportedLanguage, "assertSupportedLanguage");
|
|
3866
|
-
var MIN_COMPATIBLE_VERSION;
|
|
3867
3725
|
var finalizer4 = newFinalizer((addresses) => {
|
|
3868
3726
|
C._ts_parser_delete(addresses[0]);
|
|
3869
3727
|
C._free(addresses[1]);
|
|
@@ -3882,6 +3740,8 @@ var Parser = class {
|
|
|
3882
3740
|
logCallback = null;
|
|
3883
3741
|
/** The parser's current language. */
|
|
3884
3742
|
language = null;
|
|
3743
|
+
/** The number of parse operations executed by the most recent {@link Parser#parse} call. */
|
|
3744
|
+
lastParseOperations = 0;
|
|
3885
3745
|
/**
|
|
3886
3746
|
* This must always be called before creating a Parser.
|
|
3887
3747
|
*
|
|
@@ -3892,8 +3752,9 @@ var Parser = class {
|
|
|
3892
3752
|
static async init(options) {
|
|
3893
3753
|
setModule(await initializeBinding(options));
|
|
3894
3754
|
TRANSFER_BUFFER = C._ts_init();
|
|
3895
|
-
|
|
3896
|
-
|
|
3755
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
3756
|
+
LANGUAGE_VERSION = C.HEAP32[base];
|
|
3757
|
+
MIN_COMPATIBLE_VERSION = C.HEAP32[base + 1];
|
|
3897
3758
|
}
|
|
3898
3759
|
/**
|
|
3899
3760
|
* Create a new parser.
|
|
@@ -3908,8 +3769,9 @@ var Parser = class {
|
|
|
3908
3769
|
throw new Error("cannot construct a Parser before calling `init()`");
|
|
3909
3770
|
}
|
|
3910
3771
|
C._ts_parser_new_wasm();
|
|
3911
|
-
|
|
3912
|
-
this[
|
|
3772
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
3773
|
+
this[0] = C.HEAP32[base];
|
|
3774
|
+
this[1] = C.HEAP32[base + 1];
|
|
3913
3775
|
}
|
|
3914
3776
|
/** Delete the parser, freeing its resources. */
|
|
3915
3777
|
delete() {
|
|
@@ -3958,22 +3820,14 @@ var Parser = class {
|
|
|
3958
3820
|
* @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if:
|
|
3959
3821
|
* - The parser has not yet had a language assigned with {@link Parser#setLanguage}.
|
|
3960
3822
|
* - The progress callback returned true.
|
|
3961
|
-
* - The memory limit was reached.
|
|
3823
|
+
* - The memory limit was reached or the operation limit was exceeded.
|
|
3962
3824
|
*/
|
|
3963
3825
|
parse(callback, oldTree, options) {
|
|
3964
3826
|
const maxMemoryBytes = validateMemoryLimit(options?.maxMemoryBytes);
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
} else {
|
|
3970
|
-
throw new Error("Argument must be a string or a function");
|
|
3971
|
-
}
|
|
3972
|
-
if (options?.progressCallback) {
|
|
3973
|
-
C.currentProgressCallback = options.progressCallback;
|
|
3974
|
-
} else {
|
|
3975
|
-
C.currentProgressCallback = null;
|
|
3976
|
-
}
|
|
3827
|
+
const maxOperations = validateOperationLimit(options?.maxOperations);
|
|
3828
|
+
const { sourceText, textCallback } = resolveInput(callback);
|
|
3829
|
+
C.currentParseCallback = sourceText === void 0 ? textCallback : null;
|
|
3830
|
+
C.currentProgressCallback = options?.progressCallback ?? null;
|
|
3977
3831
|
if (this.logCallback) {
|
|
3978
3832
|
C.currentLogCallback = this.logCallback;
|
|
3979
3833
|
C._ts_parser_enable_logger_wasm(this[0], 1);
|
|
@@ -3981,11 +3835,24 @@ var Parser = class {
|
|
|
3981
3835
|
C.currentLogCallback = null;
|
|
3982
3836
|
C._ts_parser_enable_logger_wasm(this[0], 0);
|
|
3983
3837
|
}
|
|
3838
|
+
this.lastParseOperations = 0;
|
|
3839
|
+
const request = {
|
|
3840
|
+
parserAddress: this[0],
|
|
3841
|
+
callbackBuffer: this[1],
|
|
3842
|
+
sourceText,
|
|
3843
|
+
oldTreeAddress: oldTree ? oldTree[0] : 0,
|
|
3844
|
+
ranges: options?.includedRanges,
|
|
3845
|
+
maxOperations,
|
|
3846
|
+
hasProgressCallback: options?.progressCallback ? 1 : 0,
|
|
3847
|
+
onOperations: /* @__PURE__ */ __name((operations) => {
|
|
3848
|
+
this.lastParseOperations = operations;
|
|
3849
|
+
}, "onOperations")
|
|
3850
|
+
};
|
|
3984
3851
|
try {
|
|
3985
|
-
const treeAddress = maxMemoryBytes === void 0 ? parseOrdinaryWasm(
|
|
3852
|
+
const treeAddress = maxMemoryBytes === void 0 ? parseOrdinaryWasm(request) : parseLimitedWasm(request, maxMemoryBytes);
|
|
3986
3853
|
if (!treeAddress) return null;
|
|
3987
3854
|
if (!this.language) throw new Error("Parser must have a language to parse");
|
|
3988
|
-
return new
|
|
3855
|
+
return new Tree2(INTERNAL, treeAddress, this.language, textCallback, sourceText);
|
|
3989
3856
|
} finally {
|
|
3990
3857
|
clearCallbacks();
|
|
3991
3858
|
}
|
|
@@ -3993,7 +3860,7 @@ var Parser = class {
|
|
|
3993
3860
|
/**
|
|
3994
3861
|
* Instruct the parser to start the next parse from the beginning.
|
|
3995
3862
|
*
|
|
3996
|
-
* If the parser previously failed because of a callback,
|
|
3863
|
+
* If the parser previously failed because of a callback,
|
|
3997
3864
|
* then by default, it will resume where it left off on the
|
|
3998
3865
|
* next call to {@link Parser#parse} or other parsing functions.
|
|
3999
3866
|
* If you don't want to resume, and instead intend to use this parser to
|
|
@@ -4005,18 +3872,7 @@ var Parser = class {
|
|
|
4005
3872
|
/** Get the ranges of text that the parser will include when parsing. */
|
|
4006
3873
|
getIncludedRanges() {
|
|
4007
3874
|
C._ts_parser_included_ranges_wasm(this[0]);
|
|
4008
|
-
|
|
4009
|
-
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
4010
|
-
const result = new Array(count);
|
|
4011
|
-
if (count > 0) {
|
|
4012
|
-
let address = buffer;
|
|
4013
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
4014
|
-
result[i2] = unmarshalRange(address);
|
|
4015
|
-
address += SIZE_OF_RANGE;
|
|
4016
|
-
}
|
|
4017
|
-
C._free(buffer);
|
|
4018
|
-
}
|
|
4019
|
-
return result;
|
|
3875
|
+
return unmarshalRanges(false);
|
|
4020
3876
|
}
|
|
4021
3877
|
/** Set the logging callback that a parser should use during parsing. */
|
|
4022
3878
|
setLogger(callback) {
|
|
@@ -4041,6 +3897,88 @@ function validateMemoryLimit(maxMemoryBytes) {
|
|
|
4041
3897
|
return maxMemoryBytes;
|
|
4042
3898
|
}
|
|
4043
3899
|
__name(validateMemoryLimit, "validateMemoryLimit");
|
|
3900
|
+
function validateOperationLimit(maxOperations) {
|
|
3901
|
+
if (maxOperations !== void 0 && (!Number.isSafeInteger(maxOperations) || maxOperations <= 0)) {
|
|
3902
|
+
throw new RangeError("maxOperations must be a positive safe integer");
|
|
3903
|
+
}
|
|
3904
|
+
return maxOperations;
|
|
3905
|
+
}
|
|
3906
|
+
__name(validateOperationLimit, "validateOperationLimit");
|
|
3907
|
+
function resolveInput(callback) {
|
|
3908
|
+
if (typeof callback === "string") {
|
|
3909
|
+
return { sourceText: callback, textCallback: /* @__PURE__ */ __name((index) => callback.slice(index), "textCallback") };
|
|
3910
|
+
}
|
|
3911
|
+
if (typeof callback === "function") {
|
|
3912
|
+
return { sourceText: void 0, textCallback: callback };
|
|
3913
|
+
}
|
|
3914
|
+
throw new Error("Argument must be a string or a function");
|
|
3915
|
+
}
|
|
3916
|
+
__name(resolveInput, "resolveInput");
|
|
3917
|
+
function parseOrdinaryWasm(request) {
|
|
3918
|
+
return withPreparedParse(request, (inputBuffer) => {
|
|
3919
|
+
try {
|
|
3920
|
+
return C._ts_parser_parse_wasm(request.parserAddress, inputBuffer, request.oldTreeAddress);
|
|
3921
|
+
} catch (error) {
|
|
3922
|
+
C._ts_parser_last_parse_operations_wasm(request.parserAddress);
|
|
3923
|
+
throw error;
|
|
3924
|
+
}
|
|
3925
|
+
});
|
|
3926
|
+
}
|
|
3927
|
+
__name(parseOrdinaryWasm, "parseOrdinaryWasm");
|
|
3928
|
+
function parseLimitedWasm(request, maxMemoryBytes) {
|
|
3929
|
+
if (!C.treeSitterSetMemoryLimit(maxMemoryBytes)) return 0;
|
|
3930
|
+
try {
|
|
3931
|
+
return withPreparedParse(request, (inputBuffer) => {
|
|
3932
|
+
try {
|
|
3933
|
+
return C._ts_parser_parse_limited_wasm(request.parserAddress, inputBuffer);
|
|
3934
|
+
} catch (error) {
|
|
3935
|
+
C._ts_parser_abort_limited_wasm();
|
|
3936
|
+
throw error;
|
|
3937
|
+
}
|
|
3938
|
+
});
|
|
3939
|
+
} finally {
|
|
3940
|
+
C.treeSitterSetMemoryLimit(0);
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
__name(parseLimitedWasm, "parseLimitedWasm");
|
|
3944
|
+
function withPreparedParse(request, execute) {
|
|
3945
|
+
let sourceAddress = 0;
|
|
3946
|
+
let rangeAddress = 0;
|
|
3947
|
+
let executed = false;
|
|
3948
|
+
try {
|
|
3949
|
+
const [allocatedSource, byteLength, ok] = prepareSourceBuffer(request.sourceText);
|
|
3950
|
+
sourceAddress = allocatedSource;
|
|
3951
|
+
if (!ok) return 0;
|
|
3952
|
+
const [allocatedRanges, rangeCount] = prepareRanges(request.ranges);
|
|
3953
|
+
rangeAddress = allocatedRanges;
|
|
3954
|
+
if (rangeCount && !allocatedRanges) return 0;
|
|
3955
|
+
const isStringInput = request.sourceText !== void 0;
|
|
3956
|
+
marshalParseInputs(request.maxOperations, byteLength, allocatedRanges, rangeCount, isStringInput, request.hasProgressCallback);
|
|
3957
|
+
executed = true;
|
|
3958
|
+
return execute(isStringInput ? allocatedSource : request.callbackBuffer);
|
|
3959
|
+
} finally {
|
|
3960
|
+
if (executed) request.onOperations(unmarshalOperationCount());
|
|
3961
|
+
if (rangeAddress) C._free(rangeAddress);
|
|
3962
|
+
if (sourceAddress) C._free(sourceAddress);
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
__name(withPreparedParse, "withPreparedParse");
|
|
3966
|
+
function prepareSourceBuffer(sourceText) {
|
|
3967
|
+
if (sourceText === void 0) return [0, 0, true];
|
|
3968
|
+
const codeUnits = sourceText.length;
|
|
3969
|
+
if (codeUnits === 0) return [0, 0, true];
|
|
3970
|
+
if (codeUnits > 1073741823) return [0, 0, false];
|
|
3971
|
+
const byteLength = codeUnits * 2;
|
|
3972
|
+
const address = C._malloc(byteLength);
|
|
3973
|
+
if (!address) return [0, 0, false];
|
|
3974
|
+
const heapU16 = C.HEAPU16;
|
|
3975
|
+
const base = address >>> 1;
|
|
3976
|
+
for (let i2 = 0; i2 < codeUnits; i2++) {
|
|
3977
|
+
heapU16[base + i2] = sourceText.charCodeAt(i2);
|
|
3978
|
+
}
|
|
3979
|
+
return [address, byteLength, true];
|
|
3980
|
+
}
|
|
3981
|
+
__name(prepareSourceBuffer, "prepareSourceBuffer");
|
|
4044
3982
|
function prepareRanges(ranges) {
|
|
4045
3983
|
if (!ranges?.length) return [0, 0];
|
|
4046
3984
|
const rangeAddress = C._calloc(ranges.length, SIZE_OF_RANGE);
|
|
@@ -4053,31 +3991,23 @@ function prepareRanges(ranges) {
|
|
|
4053
3991
|
return [rangeAddress, ranges.length];
|
|
4054
3992
|
}
|
|
4055
3993
|
__name(prepareRanges, "prepareRanges");
|
|
4056
|
-
function
|
|
4057
|
-
const
|
|
4058
|
-
|
|
4059
|
-
|
|
3994
|
+
function marshalParseInputs(maxOperations, byteLength, rangeAddress, rangeCount, isStringInput, hasProgressCallback) {
|
|
3995
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
3996
|
+
const heapU32 = C.HEAPU32;
|
|
3997
|
+
heapU32[base] = maxOperations === void 0 ? 0 : maxOperations >>> 0;
|
|
3998
|
+
heapU32[base + 1] = maxOperations === void 0 ? 0 : Math.floor(maxOperations / TWO_POW_32) >>> 0;
|
|
3999
|
+
heapU32[base + 2] = byteLength;
|
|
4000
|
+
heapU32[base + 3] = rangeAddress;
|
|
4001
|
+
heapU32[base + 4] = rangeCount;
|
|
4002
|
+
heapU32[base + 5] = (isStringInput ? 1 : 0) | (hasProgressCallback ? 2 : 0);
|
|
4060
4003
|
}
|
|
4061
|
-
__name(
|
|
4062
|
-
function
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
const [address, rangeCount] = prepareRanges(ranges);
|
|
4067
|
-
rangeAddress = address;
|
|
4068
|
-
if (rangeCount && !address) return 0;
|
|
4069
|
-
try {
|
|
4070
|
-
return C._ts_parser_parse_limited_wasm(parserAddress, inputBuffer, address, rangeCount);
|
|
4071
|
-
} catch (error) {
|
|
4072
|
-
C._ts_parser_abort_limited_wasm();
|
|
4073
|
-
throw error;
|
|
4074
|
-
}
|
|
4075
|
-
} finally {
|
|
4076
|
-
if (rangeAddress) C._free(rangeAddress);
|
|
4077
|
-
C.treeSitterSetMemoryLimit(0);
|
|
4078
|
-
}
|
|
4004
|
+
__name(marshalParseInputs, "marshalParseInputs");
|
|
4005
|
+
function unmarshalOperationCount() {
|
|
4006
|
+
const base = TRANSFER_BUFFER >>> 2;
|
|
4007
|
+
const heapU32 = C.HEAPU32;
|
|
4008
|
+
return heapU32[base] + heapU32[base + 1] * TWO_POW_32;
|
|
4079
4009
|
}
|
|
4080
|
-
__name(
|
|
4010
|
+
__name(unmarshalOperationCount, "unmarshalOperationCount");
|
|
4081
4011
|
function clearCallbacks() {
|
|
4082
4012
|
C.currentParseCallback = null;
|
|
4083
4013
|
C.currentLogCallback = null;
|
|
@@ -4092,7 +4022,7 @@ export {
|
|
|
4092
4022
|
MIN_COMPATIBLE_VERSION,
|
|
4093
4023
|
Node,
|
|
4094
4024
|
Parser,
|
|
4095
|
-
Tree,
|
|
4025
|
+
Tree2 as Tree,
|
|
4096
4026
|
TreeCursor
|
|
4097
4027
|
};
|
|
4098
4028
|
//# sourceMappingURL=web-tree-sitter.js.map
|