@mrclrchtr/supi-code-intelligence 1.5.0 → 1.7.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/README.md +42 -24
- package/node_modules/@mrclrchtr/supi-core/package.json +6 -2
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +12 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +12 -1
- package/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +116 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +6 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +12 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +12 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +116 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +10 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +8 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +79 -190
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +38 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +61 -387
- package/node_modules/@mrclrchtr/supi-lsp/src/format.ts +16 -8
- package/node_modules/@mrclrchtr/supi-lsp/src/lsp.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/pattern-matcher.ts +11 -184
- package/node_modules/@mrclrchtr/supi-lsp/src/session/lsp-state.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/guidance.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/tool/tool-specs.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +6 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +12 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +12 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +116 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/README.md +265 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +4661 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +4605 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +57 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +100 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +4063 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +1025 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +58 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +1025 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +58 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +4007 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +7 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +55 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +2 -2
- package/package.json +4 -4
- package/src/actions/affected-action.ts +67 -54
- package/src/actions/brief-action.ts +142 -5
- package/src/actions/callees-action.ts +1 -1
- package/src/actions/callers-action.ts +38 -67
- package/src/actions/implementations-action.ts +27 -63
- package/src/actions/map-action.ts +206 -0
- package/src/actions/pattern-action.ts +1 -1
- package/src/api.ts +1 -0
- package/src/brief-focused.ts +5 -5
- package/src/brief.ts +3 -3
- package/src/code-intelligence.ts +6 -75
- package/src/index.ts +1 -0
- package/src/pattern-structured.ts +1 -1
- package/src/prioritization-signals.ts +13 -26
- package/src/query-params.ts +15 -0
- package/src/resolve-target.ts +2 -2
- package/src/search-helpers.ts +2 -2
- package/src/target-resolution.ts +27 -102
- package/src/tool/execute-affected.ts +25 -0
- package/src/tool/execute-brief.ts +25 -0
- package/src/tool/execute-map.ts +32 -0
- package/src/tool/execute-pattern.ts +26 -0
- package/src/tool/execute-relations.ts +48 -0
- package/src/tool/guidance.ts +24 -13
- package/src/tool/register-tools.ts +32 -0
- package/src/tool/tool-specs.ts +184 -0
- package/src/tool/validation.ts +43 -0
- package/src/types.ts +10 -0
- package/src/actions/index-action.ts +0 -187
- package/src/tool/action-specs.ts +0 -66
- package/src/tool-actions.ts +0 -100
|
@@ -0,0 +1,4661 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name2 in all)
|
|
14
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
|
|
34
|
+
// lib/web-tree-sitter.cjs
|
|
35
|
+
var require_web_tree_sitter = __commonJS({
|
|
36
|
+
"lib/web-tree-sitter.cjs"(exports, module) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var Module = (() => {
|
|
39
|
+
var _scriptName = typeof document != "undefined" ? document.currentScript?.src : void 0;
|
|
40
|
+
return async function(moduleArg = {}) {
|
|
41
|
+
var moduleRtn;
|
|
42
|
+
var Module = moduleArg;
|
|
43
|
+
var ENVIRONMENT_IS_WEB = typeof window == "object";
|
|
44
|
+
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
|
|
45
|
+
var ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
|
|
46
|
+
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
47
|
+
Module.currentQueryProgressCallback = null;
|
|
48
|
+
Module.currentProgressCallback = null;
|
|
49
|
+
Module.currentLogCallback = null;
|
|
50
|
+
Module.currentParseCallback = null;
|
|
51
|
+
var arguments_ = [];
|
|
52
|
+
var thisProgram = "./this.program";
|
|
53
|
+
var quit_ = /* @__PURE__ */ __name((status, toThrow) => {
|
|
54
|
+
throw toThrow;
|
|
55
|
+
}, "quit_");
|
|
56
|
+
if (typeof __filename != "undefined") {
|
|
57
|
+
_scriptName = __filename;
|
|
58
|
+
} else if (ENVIRONMENT_IS_WORKER) {
|
|
59
|
+
_scriptName = self.location.href;
|
|
60
|
+
}
|
|
61
|
+
var scriptDirectory = "";
|
|
62
|
+
function locateFile(path) {
|
|
63
|
+
if (Module["locateFile"]) {
|
|
64
|
+
return Module["locateFile"](path, scriptDirectory);
|
|
65
|
+
}
|
|
66
|
+
return scriptDirectory + path;
|
|
67
|
+
}
|
|
68
|
+
__name(locateFile, "locateFile");
|
|
69
|
+
var readAsync, readBinary;
|
|
70
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
71
|
+
const isNode = typeof process == "object" && process.versions?.node && process.type != "renderer";
|
|
72
|
+
if (!isNode) throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");
|
|
73
|
+
var nodeVersion = process.versions.node;
|
|
74
|
+
var numericVersion = nodeVersion.split(".").slice(0, 3);
|
|
75
|
+
numericVersion = numericVersion[0] * 1e4 + numericVersion[1] * 100 + numericVersion[2].split("-")[0] * 1;
|
|
76
|
+
if (numericVersion < 16e4) {
|
|
77
|
+
throw new Error("This emscripten-generated code requires node v16.0.0 (detected v" + nodeVersion + ")");
|
|
78
|
+
}
|
|
79
|
+
var fs = require("fs");
|
|
80
|
+
scriptDirectory = __dirname + "/";
|
|
81
|
+
readBinary = /* @__PURE__ */ __name((filename) => {
|
|
82
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
83
|
+
var ret = fs.readFileSync(filename);
|
|
84
|
+
assert(Buffer.isBuffer(ret));
|
|
85
|
+
return ret;
|
|
86
|
+
}, "readBinary");
|
|
87
|
+
readAsync = /* @__PURE__ */ __name(async (filename, binary2 = true) => {
|
|
88
|
+
filename = isFileURI(filename) ? new URL(filename) : filename;
|
|
89
|
+
var ret = fs.readFileSync(filename, binary2 ? void 0 : "utf8");
|
|
90
|
+
assert(binary2 ? Buffer.isBuffer(ret) : typeof ret == "string");
|
|
91
|
+
return ret;
|
|
92
|
+
}, "readAsync");
|
|
93
|
+
if (process.argv.length > 1) {
|
|
94
|
+
thisProgram = process.argv[1].replace(/\\/g, "/");
|
|
95
|
+
}
|
|
96
|
+
arguments_ = process.argv.slice(2);
|
|
97
|
+
quit_ = /* @__PURE__ */ __name((status, toThrow) => {
|
|
98
|
+
process.exitCode = status;
|
|
99
|
+
throw toThrow;
|
|
100
|
+
}, "quit_");
|
|
101
|
+
} else if (ENVIRONMENT_IS_SHELL) {
|
|
102
|
+
const isNode = typeof process == "object" && process.versions?.node && process.type != "renderer";
|
|
103
|
+
if (isNode || typeof window == "object" || typeof WorkerGlobalScope != "undefined") throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");
|
|
104
|
+
} else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
105
|
+
try {
|
|
106
|
+
scriptDirectory = new URL(".", _scriptName).href;
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
if (!(typeof window == "object" || typeof WorkerGlobalScope != "undefined")) throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");
|
|
110
|
+
{
|
|
111
|
+
if (ENVIRONMENT_IS_WORKER) {
|
|
112
|
+
readBinary = /* @__PURE__ */ __name((url) => {
|
|
113
|
+
var xhr = new XMLHttpRequest();
|
|
114
|
+
xhr.open("GET", url, false);
|
|
115
|
+
xhr.responseType = "arraybuffer";
|
|
116
|
+
xhr.send(null);
|
|
117
|
+
return new Uint8Array(
|
|
118
|
+
/** @type{!ArrayBuffer} */
|
|
119
|
+
xhr.response
|
|
120
|
+
);
|
|
121
|
+
}, "readBinary");
|
|
122
|
+
}
|
|
123
|
+
readAsync = /* @__PURE__ */ __name(async (url) => {
|
|
124
|
+
if (isFileURI(url)) {
|
|
125
|
+
return new Promise((resolve, reject) => {
|
|
126
|
+
var xhr = new XMLHttpRequest();
|
|
127
|
+
xhr.open("GET", url, true);
|
|
128
|
+
xhr.responseType = "arraybuffer";
|
|
129
|
+
xhr.onload = () => {
|
|
130
|
+
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
131
|
+
resolve(xhr.response);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
reject(xhr.status);
|
|
135
|
+
};
|
|
136
|
+
xhr.onerror = reject;
|
|
137
|
+
xhr.send(null);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
var response = await fetch(url, {
|
|
141
|
+
credentials: "same-origin"
|
|
142
|
+
});
|
|
143
|
+
if (response.ok) {
|
|
144
|
+
return response.arrayBuffer();
|
|
145
|
+
}
|
|
146
|
+
throw new Error(response.status + " : " + response.url);
|
|
147
|
+
}, "readAsync");
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
throw new Error("environment detection error");
|
|
151
|
+
}
|
|
152
|
+
var out = console.log.bind(console);
|
|
153
|
+
var err = console.error.bind(console);
|
|
154
|
+
var IDBFS = "IDBFS is no longer included by default; build with -lidbfs.js";
|
|
155
|
+
var PROXYFS = "PROXYFS is no longer included by default; build with -lproxyfs.js";
|
|
156
|
+
var WORKERFS = "WORKERFS is no longer included by default; build with -lworkerfs.js";
|
|
157
|
+
var FETCHFS = "FETCHFS is no longer included by default; build with -lfetchfs.js";
|
|
158
|
+
var ICASEFS = "ICASEFS is no longer included by default; build with -licasefs.js";
|
|
159
|
+
var JSFILEFS = "JSFILEFS is no longer included by default; build with -ljsfilefs.js";
|
|
160
|
+
var OPFS = "OPFS is no longer included by default; build with -lopfs.js";
|
|
161
|
+
var NODEFS = "NODEFS is no longer included by default; build with -lnodefs.js";
|
|
162
|
+
assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.");
|
|
163
|
+
var dynamicLibraries = [];
|
|
164
|
+
var wasmBinary;
|
|
165
|
+
if (typeof WebAssembly != "object") {
|
|
166
|
+
err("no native wasm support detected");
|
|
167
|
+
}
|
|
168
|
+
var ABORT = false;
|
|
169
|
+
var EXITSTATUS;
|
|
170
|
+
function assert(condition, text) {
|
|
171
|
+
if (!condition) {
|
|
172
|
+
abort("Assertion failed" + (text ? ": " + text : ""));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
__name(assert, "assert");
|
|
176
|
+
var isFileURI = /* @__PURE__ */ __name((filename) => filename.startsWith("file://"), "isFileURI");
|
|
177
|
+
function writeStackCookie() {
|
|
178
|
+
var max = _emscripten_stack_get_end();
|
|
179
|
+
assert((max & 3) == 0);
|
|
180
|
+
if (max == 0) {
|
|
181
|
+
max += 4;
|
|
182
|
+
}
|
|
183
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, max >> 2, "storing") * 4, 34821223);
|
|
184
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "storing") * 4, 2310721022);
|
|
185
|
+
}
|
|
186
|
+
__name(writeStackCookie, "writeStackCookie");
|
|
187
|
+
function checkStackCookie() {
|
|
188
|
+
if (ABORT) return;
|
|
189
|
+
var max = _emscripten_stack_get_end();
|
|
190
|
+
if (max == 0) {
|
|
191
|
+
max += 4;
|
|
192
|
+
}
|
|
193
|
+
var cookie1 = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, max >> 2, "loading") * 4);
|
|
194
|
+
var cookie2 = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, max + 4 >> 2, "loading") * 4);
|
|
195
|
+
if (cookie1 != 34821223 || cookie2 != 2310721022) {
|
|
196
|
+
abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
__name(checkStackCookie, "checkStackCookie");
|
|
200
|
+
var runtimeDebug = true;
|
|
201
|
+
function dbg(...args2) {
|
|
202
|
+
if (!runtimeDebug && typeof runtimeDebug != "undefined") return;
|
|
203
|
+
console.warn(...args2);
|
|
204
|
+
}
|
|
205
|
+
__name(dbg, "dbg");
|
|
206
|
+
function consumedModuleProp(prop) {
|
|
207
|
+
if (!Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
208
|
+
Object.defineProperty(Module, prop, {
|
|
209
|
+
configurable: true,
|
|
210
|
+
set() {
|
|
211
|
+
abort(`Attempt to set \`Module.${prop}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
__name(consumedModuleProp, "consumedModuleProp");
|
|
217
|
+
function makeInvalidEarlyAccess(name2) {
|
|
218
|
+
return () => assert(false, `call to '${name2}' via reference taken before Wasm module initialization`);
|
|
219
|
+
}
|
|
220
|
+
__name(makeInvalidEarlyAccess, "makeInvalidEarlyAccess");
|
|
221
|
+
function ignoredModuleProp(prop) {
|
|
222
|
+
if (Object.getOwnPropertyDescriptor(Module, prop)) {
|
|
223
|
+
abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
__name(ignoredModuleProp, "ignoredModuleProp");
|
|
227
|
+
function isExportedByForceFilesystem(name2) {
|
|
228
|
+
return name2 === "FS_createPath" || name2 === "FS_createDataFile" || name2 === "FS_createPreloadedFile" || name2 === "FS_preloadFile" || name2 === "FS_unlink" || name2 === "addRunDependency" || // The old FS has some functionality that WasmFS lacks.
|
|
229
|
+
name2 === "FS_createLazyFile" || name2 === "FS_createDevice" || name2 === "removeRunDependency";
|
|
230
|
+
}
|
|
231
|
+
__name(isExportedByForceFilesystem, "isExportedByForceFilesystem");
|
|
232
|
+
function missingLibrarySymbol(sym) {
|
|
233
|
+
unexportedRuntimeSymbol(sym);
|
|
234
|
+
}
|
|
235
|
+
__name(missingLibrarySymbol, "missingLibrarySymbol");
|
|
236
|
+
function unexportedRuntimeSymbol(sym) {
|
|
237
|
+
if (!Object.getOwnPropertyDescriptor(Module, sym)) {
|
|
238
|
+
Object.defineProperty(Module, sym, {
|
|
239
|
+
configurable: true,
|
|
240
|
+
get() {
|
|
241
|
+
var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
|
|
242
|
+
if (isExportedByForceFilesystem(sym)) {
|
|
243
|
+
msg += ". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you";
|
|
244
|
+
}
|
|
245
|
+
abort(msg);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
__name(unexportedRuntimeSymbol, "unexportedRuntimeSymbol");
|
|
251
|
+
function SAFE_HEAP_INDEX(arr, idx, action) {
|
|
252
|
+
const bytes = arr.BYTES_PER_ELEMENT;
|
|
253
|
+
const dest = idx * bytes;
|
|
254
|
+
if (idx <= 0) abort(`segmentation fault ${action} ${bytes} bytes at address ${dest}`);
|
|
255
|
+
if (runtimeInitialized) {
|
|
256
|
+
var brk = _sbrk(0);
|
|
257
|
+
if (dest + bytes > brk) abort(`segmentation fault, exceeded the top of the available dynamic heap when ${action} ${bytes} bytes at address ${dest}. DYNAMICTOP=${brk}`);
|
|
258
|
+
if (brk < _emscripten_stack_get_base()) abort(`brk >= _emscripten_stack_get_base() (brk=${brk}, _emscripten_stack_get_base()=${_emscripten_stack_get_base()})`);
|
|
259
|
+
if (brk > wasmMemory.buffer.byteLength) abort(`brk <= wasmMemory.buffer.byteLength (brk=${brk}, wasmMemory.buffer.byteLength=${wasmMemory.buffer.byteLength})`);
|
|
260
|
+
}
|
|
261
|
+
return idx;
|
|
262
|
+
}
|
|
263
|
+
__name(SAFE_HEAP_INDEX, "SAFE_HEAP_INDEX");
|
|
264
|
+
function segfault() {
|
|
265
|
+
abort("segmentation fault");
|
|
266
|
+
}
|
|
267
|
+
__name(segfault, "segfault");
|
|
268
|
+
function alignfault() {
|
|
269
|
+
abort("alignment fault");
|
|
270
|
+
}
|
|
271
|
+
__name(alignfault, "alignfault");
|
|
272
|
+
var readyPromiseResolve, readyPromiseReject;
|
|
273
|
+
var wasmMemory;
|
|
274
|
+
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
|
|
275
|
+
var HEAP64, HEAPU64;
|
|
276
|
+
var HEAP_DATA_VIEW;
|
|
277
|
+
var runtimeInitialized = false;
|
|
278
|
+
function updateMemoryViews() {
|
|
279
|
+
var b = wasmMemory.buffer;
|
|
280
|
+
Module["HEAP8"] = HEAP8 = new Int8Array(b);
|
|
281
|
+
Module["HEAP16"] = HEAP16 = new Int16Array(b);
|
|
282
|
+
Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
|
|
283
|
+
Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
|
|
284
|
+
Module["HEAP32"] = HEAP32 = new Int32Array(b);
|
|
285
|
+
Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
|
|
286
|
+
Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
|
|
287
|
+
Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
|
|
288
|
+
Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
|
|
289
|
+
Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
|
|
290
|
+
Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
|
|
291
|
+
LE_HEAP_UPDATE();
|
|
292
|
+
}
|
|
293
|
+
__name(updateMemoryViews, "updateMemoryViews");
|
|
294
|
+
function initMemory() {
|
|
295
|
+
if (Module["wasmMemory"]) {
|
|
296
|
+
wasmMemory = Module["wasmMemory"];
|
|
297
|
+
} else {
|
|
298
|
+
var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432;
|
|
299
|
+
assert(INITIAL_MEMORY >= 65536, "INITIAL_MEMORY should be larger than STACK_SIZE, was " + INITIAL_MEMORY + "! (STACK_SIZE=65536)");
|
|
300
|
+
wasmMemory = new WebAssembly.Memory({
|
|
301
|
+
"initial": INITIAL_MEMORY / 65536,
|
|
302
|
+
// In theory we should not need to emit the maximum if we want "unlimited"
|
|
303
|
+
// or 4GB of memory, but VMs error on that atm, see
|
|
304
|
+
// https://github.com/emscripten-core/emscripten/issues/14130
|
|
305
|
+
// And in the pthreads case we definitely need to emit a maximum. So
|
|
306
|
+
// always emit one.
|
|
307
|
+
"maximum": 32768
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
updateMemoryViews();
|
|
311
|
+
}
|
|
312
|
+
__name(initMemory, "initMemory");
|
|
313
|
+
assert(typeof Int32Array != "undefined" && typeof Float64Array !== "undefined" && Int32Array.prototype.subarray != void 0 && Int32Array.prototype.set != void 0, "JS engine does not provide full typed array support");
|
|
314
|
+
var __RELOC_FUNCS__ = [];
|
|
315
|
+
function preRun() {
|
|
316
|
+
if (Module["preRun"]) {
|
|
317
|
+
if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
|
|
318
|
+
while (Module["preRun"].length) {
|
|
319
|
+
addOnPreRun(Module["preRun"].shift());
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
consumedModuleProp("preRun");
|
|
323
|
+
callRuntimeCallbacks(onPreRuns);
|
|
324
|
+
}
|
|
325
|
+
__name(preRun, "preRun");
|
|
326
|
+
function initRuntime() {
|
|
327
|
+
assert(!runtimeInitialized);
|
|
328
|
+
runtimeInitialized = true;
|
|
329
|
+
checkStackCookie();
|
|
330
|
+
callRuntimeCallbacks(__RELOC_FUNCS__);
|
|
331
|
+
wasmExports["__wasm_call_ctors"]();
|
|
332
|
+
callRuntimeCallbacks(onPostCtors);
|
|
333
|
+
}
|
|
334
|
+
__name(initRuntime, "initRuntime");
|
|
335
|
+
function preMain() {
|
|
336
|
+
checkStackCookie();
|
|
337
|
+
}
|
|
338
|
+
__name(preMain, "preMain");
|
|
339
|
+
function postRun() {
|
|
340
|
+
checkStackCookie();
|
|
341
|
+
if (Module["postRun"]) {
|
|
342
|
+
if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
|
|
343
|
+
while (Module["postRun"].length) {
|
|
344
|
+
addOnPostRun(Module["postRun"].shift());
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
consumedModuleProp("postRun");
|
|
348
|
+
callRuntimeCallbacks(onPostRuns);
|
|
349
|
+
}
|
|
350
|
+
__name(postRun, "postRun");
|
|
351
|
+
function abort(what) {
|
|
352
|
+
Module["onAbort"]?.(what);
|
|
353
|
+
what = "Aborted(" + what + ")";
|
|
354
|
+
err(what);
|
|
355
|
+
ABORT = true;
|
|
356
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
357
|
+
readyPromiseReject?.(e);
|
|
358
|
+
throw e;
|
|
359
|
+
}
|
|
360
|
+
__name(abort, "abort");
|
|
361
|
+
var FS = {
|
|
362
|
+
error() {
|
|
363
|
+
abort("Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM");
|
|
364
|
+
},
|
|
365
|
+
init() {
|
|
366
|
+
FS.error();
|
|
367
|
+
},
|
|
368
|
+
createDataFile() {
|
|
369
|
+
FS.error();
|
|
370
|
+
},
|
|
371
|
+
createPreloadedFile() {
|
|
372
|
+
FS.error();
|
|
373
|
+
},
|
|
374
|
+
createLazyFile() {
|
|
375
|
+
FS.error();
|
|
376
|
+
},
|
|
377
|
+
open() {
|
|
378
|
+
FS.error();
|
|
379
|
+
},
|
|
380
|
+
mkdev() {
|
|
381
|
+
FS.error();
|
|
382
|
+
},
|
|
383
|
+
registerDevice() {
|
|
384
|
+
FS.error();
|
|
385
|
+
},
|
|
386
|
+
analyzePath() {
|
|
387
|
+
FS.error();
|
|
388
|
+
},
|
|
389
|
+
ErrnoError() {
|
|
390
|
+
FS.error();
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
function createExportWrapper(name2, nargs) {
|
|
394
|
+
return (...args2) => {
|
|
395
|
+
assert(runtimeInitialized, `native function \`${name2}\` called before runtime initialization`);
|
|
396
|
+
var f = wasmExports[name2];
|
|
397
|
+
assert(f, `exported native function \`${name2}\` not found`);
|
|
398
|
+
assert(args2.length <= nargs, `native function \`${name2}\` called with ${args2.length} args but expects ${nargs}`);
|
|
399
|
+
return f(...args2);
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
__name(createExportWrapper, "createExportWrapper");
|
|
403
|
+
var wasmBinaryFile;
|
|
404
|
+
function findWasmBinary() {
|
|
405
|
+
return locateFile("web-tree-sitter.wasm");
|
|
406
|
+
}
|
|
407
|
+
__name(findWasmBinary, "findWasmBinary");
|
|
408
|
+
function getBinarySync(file) {
|
|
409
|
+
if (file == wasmBinaryFile && wasmBinary) {
|
|
410
|
+
return new Uint8Array(wasmBinary);
|
|
411
|
+
}
|
|
412
|
+
if (readBinary) {
|
|
413
|
+
return readBinary(file);
|
|
414
|
+
}
|
|
415
|
+
throw "both async and sync fetching of the wasm failed";
|
|
416
|
+
}
|
|
417
|
+
__name(getBinarySync, "getBinarySync");
|
|
418
|
+
async function getWasmBinary(binaryFile) {
|
|
419
|
+
if (!wasmBinary) {
|
|
420
|
+
try {
|
|
421
|
+
var response = await readAsync(binaryFile);
|
|
422
|
+
return new Uint8Array(response);
|
|
423
|
+
} catch {
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return getBinarySync(binaryFile);
|
|
427
|
+
}
|
|
428
|
+
__name(getWasmBinary, "getWasmBinary");
|
|
429
|
+
async function instantiateArrayBuffer(binaryFile, imports) {
|
|
430
|
+
try {
|
|
431
|
+
var binary2 = await getWasmBinary(binaryFile);
|
|
432
|
+
var instance2 = await WebAssembly.instantiate(binary2, imports);
|
|
433
|
+
return instance2;
|
|
434
|
+
} catch (reason) {
|
|
435
|
+
err(`failed to asynchronously prepare wasm: ${reason}`);
|
|
436
|
+
if (isFileURI(binaryFile)) {
|
|
437
|
+
err(`warning: Loading from a file URI (${binaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`);
|
|
438
|
+
}
|
|
439
|
+
abort(reason);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
__name(instantiateArrayBuffer, "instantiateArrayBuffer");
|
|
443
|
+
async function instantiateAsync(binary2, binaryFile, imports) {
|
|
444
|
+
if (!binary2 && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE) {
|
|
445
|
+
try {
|
|
446
|
+
var response = fetch(binaryFile, {
|
|
447
|
+
credentials: "same-origin"
|
|
448
|
+
});
|
|
449
|
+
var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
|
|
450
|
+
return instantiationResult;
|
|
451
|
+
} catch (reason) {
|
|
452
|
+
err(`wasm streaming compile failed: ${reason}`);
|
|
453
|
+
err("falling back to ArrayBuffer instantiation");
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return instantiateArrayBuffer(binaryFile, imports);
|
|
457
|
+
}
|
|
458
|
+
__name(instantiateAsync, "instantiateAsync");
|
|
459
|
+
function getWasmImports() {
|
|
460
|
+
return {
|
|
461
|
+
"env": wasmImports,
|
|
462
|
+
"wasi_snapshot_preview1": wasmImports,
|
|
463
|
+
"GOT.mem": new Proxy(wasmImports, GOTHandler),
|
|
464
|
+
"GOT.func": new Proxy(wasmImports, GOTHandler)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
__name(getWasmImports, "getWasmImports");
|
|
468
|
+
async function createWasm() {
|
|
469
|
+
function receiveInstance(instance2, module2) {
|
|
470
|
+
wasmExports = instance2.exports;
|
|
471
|
+
wasmExports = relocateExports(wasmExports, 1024);
|
|
472
|
+
var metadata2 = getDylinkMetadata(module2);
|
|
473
|
+
if (metadata2.neededDynlibs) {
|
|
474
|
+
dynamicLibraries = metadata2.neededDynlibs.concat(dynamicLibraries);
|
|
475
|
+
}
|
|
476
|
+
mergeLibSymbols(wasmExports, "main");
|
|
477
|
+
LDSO.init();
|
|
478
|
+
loadDylibs();
|
|
479
|
+
__RELOC_FUNCS__.push(wasmExports["__wasm_apply_data_relocs"]);
|
|
480
|
+
assignWasmExports(wasmExports);
|
|
481
|
+
return wasmExports;
|
|
482
|
+
}
|
|
483
|
+
__name(receiveInstance, "receiveInstance");
|
|
484
|
+
var trueModule = Module;
|
|
485
|
+
function receiveInstantiationResult(result2) {
|
|
486
|
+
assert(Module === trueModule, "the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?");
|
|
487
|
+
trueModule = null;
|
|
488
|
+
return receiveInstance(result2["instance"], result2["module"]);
|
|
489
|
+
}
|
|
490
|
+
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
491
|
+
var info2 = getWasmImports();
|
|
492
|
+
if (Module["instantiateWasm"]) {
|
|
493
|
+
return new Promise((resolve, reject) => {
|
|
494
|
+
try {
|
|
495
|
+
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
496
|
+
resolve(receiveInstance(mod, inst));
|
|
497
|
+
});
|
|
498
|
+
} catch (e) {
|
|
499
|
+
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
500
|
+
reject(e);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
wasmBinaryFile ??= findWasmBinary();
|
|
505
|
+
var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info2);
|
|
506
|
+
var exports2 = receiveInstantiationResult(result);
|
|
507
|
+
return exports2;
|
|
508
|
+
}
|
|
509
|
+
__name(createWasm, "createWasm");
|
|
510
|
+
class ExitStatus {
|
|
511
|
+
static {
|
|
512
|
+
__name(this, "ExitStatus");
|
|
513
|
+
}
|
|
514
|
+
name = "ExitStatus";
|
|
515
|
+
constructor(status) {
|
|
516
|
+
this.message = `Program terminated with exit(${status})`;
|
|
517
|
+
this.status = status;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
var GOT = {};
|
|
521
|
+
var currentModuleWeakSymbols = /* @__PURE__ */ new Set([]);
|
|
522
|
+
var GOTHandler = {
|
|
523
|
+
get(obj, symName) {
|
|
524
|
+
var rtn = GOT[symName];
|
|
525
|
+
if (!rtn) {
|
|
526
|
+
rtn = GOT[symName] = new WebAssembly.Global({
|
|
527
|
+
"value": "i32",
|
|
528
|
+
"mutable": true
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
if (!currentModuleWeakSymbols.has(symName)) {
|
|
532
|
+
rtn.required = true;
|
|
533
|
+
}
|
|
534
|
+
return rtn;
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
var LE_ATOMICS_ADD = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
538
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
539
|
+
const res = order(Atomics.add(heap, offset, order(value)));
|
|
540
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
541
|
+
}, "LE_ATOMICS_ADD");
|
|
542
|
+
var LE_ATOMICS_AND = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
543
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
544
|
+
const res = order(Atomics.and(heap, offset, order(value)));
|
|
545
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
546
|
+
}, "LE_ATOMICS_AND");
|
|
547
|
+
var LE_ATOMICS_COMPAREEXCHANGE = /* @__PURE__ */ __name((heap, offset, expected, replacement) => {
|
|
548
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
549
|
+
const res = order(Atomics.compareExchange(heap, offset, order(expected), order(replacement)));
|
|
550
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
551
|
+
}, "LE_ATOMICS_COMPAREEXCHANGE");
|
|
552
|
+
var LE_ATOMICS_EXCHANGE = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
553
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
554
|
+
const res = order(Atomics.exchange(heap, offset, order(value)));
|
|
555
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
556
|
+
}, "LE_ATOMICS_EXCHANGE");
|
|
557
|
+
var LE_ATOMICS_ISLOCKFREE = /* @__PURE__ */ __name((size) => Atomics.isLockFree(size), "LE_ATOMICS_ISLOCKFREE");
|
|
558
|
+
var LE_ATOMICS_LOAD = /* @__PURE__ */ __name((heap, offset) => {
|
|
559
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
560
|
+
const res = order(Atomics.load(heap, offset));
|
|
561
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
562
|
+
}, "LE_ATOMICS_LOAD");
|
|
563
|
+
var LE_ATOMICS_NATIVE_BYTE_ORDER = [];
|
|
564
|
+
var LE_ATOMICS_NOTIFY = /* @__PURE__ */ __name((heap, offset, count) => Atomics.notify(heap, offset, count), "LE_ATOMICS_NOTIFY");
|
|
565
|
+
var LE_ATOMICS_OR = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
566
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
567
|
+
const res = order(Atomics.or(heap, offset, order(value)));
|
|
568
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
569
|
+
}, "LE_ATOMICS_OR");
|
|
570
|
+
var LE_ATOMICS_STORE = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
571
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
572
|
+
Atomics.store(heap, offset, order(value));
|
|
573
|
+
}, "LE_ATOMICS_STORE");
|
|
574
|
+
var LE_ATOMICS_SUB = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
575
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
576
|
+
const res = order(Atomics.sub(heap, offset, order(value)));
|
|
577
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
578
|
+
}, "LE_ATOMICS_SUB");
|
|
579
|
+
var LE_ATOMICS_WAIT = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
|
|
580
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
581
|
+
return Atomics.wait(heap, offset, order(value), timeout);
|
|
582
|
+
}, "LE_ATOMICS_WAIT");
|
|
583
|
+
var LE_ATOMICS_WAITASYNC = /* @__PURE__ */ __name((heap, offset, value, timeout) => {
|
|
584
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
585
|
+
return Atomics.waitAsync(heap, offset, order(value), timeout);
|
|
586
|
+
}, "LE_ATOMICS_WAITASYNC");
|
|
587
|
+
var LE_ATOMICS_XOR = /* @__PURE__ */ __name((heap, offset, value) => {
|
|
588
|
+
const order = LE_ATOMICS_NATIVE_BYTE_ORDER[heap.BYTES_PER_ELEMENT - 1];
|
|
589
|
+
const res = order(Atomics.xor(heap, offset, order(value)));
|
|
590
|
+
return heap.unsigned ? heap.unsigned(res) : res;
|
|
591
|
+
}, "LE_ATOMICS_XOR");
|
|
592
|
+
var LE_HEAP_LOAD_F32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true), "LE_HEAP_LOAD_F32");
|
|
593
|
+
var LE_HEAP_LOAD_F64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true), "LE_HEAP_LOAD_F64");
|
|
594
|
+
var LE_HEAP_LOAD_I16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true), "LE_HEAP_LOAD_I16");
|
|
595
|
+
var LE_HEAP_LOAD_I32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true), "LE_HEAP_LOAD_I32");
|
|
596
|
+
var LE_HEAP_LOAD_I64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigInt64(byteOffset, true), "LE_HEAP_LOAD_I64");
|
|
597
|
+
var LE_HEAP_LOAD_U16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint16(byteOffset, true), "LE_HEAP_LOAD_U16");
|
|
598
|
+
var LE_HEAP_LOAD_U32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true), "LE_HEAP_LOAD_U32");
|
|
599
|
+
var LE_HEAP_LOAD_U64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getBigUint64(byteOffset, true), "LE_HEAP_LOAD_U64");
|
|
600
|
+
var LE_HEAP_STORE_F32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true), "LE_HEAP_STORE_F32");
|
|
601
|
+
var LE_HEAP_STORE_F64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true), "LE_HEAP_STORE_F64");
|
|
602
|
+
var LE_HEAP_STORE_I16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true), "LE_HEAP_STORE_I16");
|
|
603
|
+
var LE_HEAP_STORE_I32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true), "LE_HEAP_STORE_I32");
|
|
604
|
+
var LE_HEAP_STORE_I64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigInt64(byteOffset, value, true), "LE_HEAP_STORE_I64");
|
|
605
|
+
var LE_HEAP_STORE_U16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint16(byteOffset, value, true), "LE_HEAP_STORE_U16");
|
|
606
|
+
var LE_HEAP_STORE_U32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true), "LE_HEAP_STORE_U32");
|
|
607
|
+
var LE_HEAP_STORE_U64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setBigUint64(byteOffset, value, true), "LE_HEAP_STORE_U64");
|
|
608
|
+
var callRuntimeCallbacks = /* @__PURE__ */ __name((callbacks) => {
|
|
609
|
+
while (callbacks.length > 0) {
|
|
610
|
+
callbacks.shift()(Module);
|
|
611
|
+
}
|
|
612
|
+
}, "callRuntimeCallbacks");
|
|
613
|
+
var onPostRuns = [];
|
|
614
|
+
var addOnPostRun = /* @__PURE__ */ __name((cb) => onPostRuns.push(cb), "addOnPostRun");
|
|
615
|
+
var onPreRuns = [];
|
|
616
|
+
var addOnPreRun = /* @__PURE__ */ __name((cb) => onPreRuns.push(cb), "addOnPreRun");
|
|
617
|
+
var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder() : void 0;
|
|
618
|
+
var findStringEnd = /* @__PURE__ */ __name((heapOrArray, idx, maxBytesToRead, ignoreNul) => {
|
|
619
|
+
var maxIdx = idx + maxBytesToRead;
|
|
620
|
+
if (ignoreNul) return maxIdx;
|
|
621
|
+
while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
|
|
622
|
+
return idx;
|
|
623
|
+
}, "findStringEnd");
|
|
624
|
+
var warnOnce = /* @__PURE__ */ __name((text) => {
|
|
625
|
+
warnOnce.shown ||= {};
|
|
626
|
+
if (!warnOnce.shown[text]) {
|
|
627
|
+
warnOnce.shown[text] = 1;
|
|
628
|
+
if (ENVIRONMENT_IS_NODE) text = "warning: " + text;
|
|
629
|
+
err(text);
|
|
630
|
+
}
|
|
631
|
+
}, "warnOnce");
|
|
632
|
+
var UTF8ArrayToString = /* @__PURE__ */ __name((heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
|
|
633
|
+
var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
|
|
634
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
635
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
636
|
+
}
|
|
637
|
+
var str = "";
|
|
638
|
+
while (idx < endPtr) {
|
|
639
|
+
var u0 = heapOrArray[idx++];
|
|
640
|
+
if (!(u0 & 128)) {
|
|
641
|
+
str += String.fromCharCode(u0);
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
645
|
+
if ((u0 & 224) == 192) {
|
|
646
|
+
str += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
650
|
+
if ((u0 & 240) == 224) {
|
|
651
|
+
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
652
|
+
} else {
|
|
653
|
+
if ((u0 & 248) != 240) warnOnce("Invalid UTF-8 leading byte " + ptrToString(u0) + " encountered when deserializing a UTF-8 string in wasm memory to a JS string!");
|
|
654
|
+
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
|
|
655
|
+
}
|
|
656
|
+
if (u0 < 65536) {
|
|
657
|
+
str += String.fromCharCode(u0);
|
|
658
|
+
} else {
|
|
659
|
+
var ch = u0 - 65536;
|
|
660
|
+
str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return str;
|
|
664
|
+
}, "UTF8ArrayToString");
|
|
665
|
+
var getDylinkMetadata = /* @__PURE__ */ __name((binary2) => {
|
|
666
|
+
var offset = 0;
|
|
667
|
+
var end = 0;
|
|
668
|
+
function getU8() {
|
|
669
|
+
return binary2[offset++];
|
|
670
|
+
}
|
|
671
|
+
__name(getU8, "getU8");
|
|
672
|
+
function getLEB() {
|
|
673
|
+
var ret = 0;
|
|
674
|
+
var mul = 1;
|
|
675
|
+
while (1) {
|
|
676
|
+
var byte = binary2[offset++];
|
|
677
|
+
ret += (byte & 127) * mul;
|
|
678
|
+
mul *= 128;
|
|
679
|
+
if (!(byte & 128)) break;
|
|
680
|
+
}
|
|
681
|
+
return ret;
|
|
682
|
+
}
|
|
683
|
+
__name(getLEB, "getLEB");
|
|
684
|
+
function getString() {
|
|
685
|
+
var len = getLEB();
|
|
686
|
+
offset += len;
|
|
687
|
+
return UTF8ArrayToString(binary2, offset - len, len);
|
|
688
|
+
}
|
|
689
|
+
__name(getString, "getString");
|
|
690
|
+
function getStringList() {
|
|
691
|
+
var count2 = getLEB();
|
|
692
|
+
var rtn = [];
|
|
693
|
+
while (count2--) rtn.push(getString());
|
|
694
|
+
return rtn;
|
|
695
|
+
}
|
|
696
|
+
__name(getStringList, "getStringList");
|
|
697
|
+
function failIf(condition, message) {
|
|
698
|
+
if (condition) throw new Error(message);
|
|
699
|
+
}
|
|
700
|
+
__name(failIf, "failIf");
|
|
701
|
+
if (binary2 instanceof WebAssembly.Module) {
|
|
702
|
+
var dylinkSection = WebAssembly.Module.customSections(binary2, "dylink.0");
|
|
703
|
+
failIf(dylinkSection.length === 0, "need dylink section");
|
|
704
|
+
binary2 = new Uint8Array(dylinkSection[0]);
|
|
705
|
+
end = binary2.length;
|
|
706
|
+
} else {
|
|
707
|
+
var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
|
|
708
|
+
var magicNumberFound = int32View[0] == 1836278016 || int32View[0] == 6386541;
|
|
709
|
+
failIf(!magicNumberFound, "need to see wasm magic number");
|
|
710
|
+
failIf(binary2[8] !== 0, "need the dylink section to be first");
|
|
711
|
+
offset = 9;
|
|
712
|
+
var section_size = getLEB();
|
|
713
|
+
end = offset + section_size;
|
|
714
|
+
var name2 = getString();
|
|
715
|
+
failIf(name2 !== "dylink.0");
|
|
716
|
+
}
|
|
717
|
+
var customSection = {
|
|
718
|
+
neededDynlibs: [],
|
|
719
|
+
tlsExports: /* @__PURE__ */ new Set(),
|
|
720
|
+
weakImports: /* @__PURE__ */ new Set(),
|
|
721
|
+
runtimePaths: []
|
|
722
|
+
};
|
|
723
|
+
var WASM_DYLINK_MEM_INFO = 1;
|
|
724
|
+
var WASM_DYLINK_NEEDED = 2;
|
|
725
|
+
var WASM_DYLINK_EXPORT_INFO = 3;
|
|
726
|
+
var WASM_DYLINK_IMPORT_INFO = 4;
|
|
727
|
+
var WASM_DYLINK_RUNTIME_PATH = 5;
|
|
728
|
+
var WASM_SYMBOL_TLS = 256;
|
|
729
|
+
var WASM_SYMBOL_BINDING_MASK = 3;
|
|
730
|
+
var WASM_SYMBOL_BINDING_WEAK = 1;
|
|
731
|
+
while (offset < end) {
|
|
732
|
+
var subsectionType = getU8();
|
|
733
|
+
var subsectionSize = getLEB();
|
|
734
|
+
if (subsectionType === WASM_DYLINK_MEM_INFO) {
|
|
735
|
+
customSection.memorySize = getLEB();
|
|
736
|
+
customSection.memoryAlign = getLEB();
|
|
737
|
+
customSection.tableSize = getLEB();
|
|
738
|
+
customSection.tableAlign = getLEB();
|
|
739
|
+
} else if (subsectionType === WASM_DYLINK_NEEDED) {
|
|
740
|
+
customSection.neededDynlibs = getStringList();
|
|
741
|
+
} else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
|
|
742
|
+
var count = getLEB();
|
|
743
|
+
while (count--) {
|
|
744
|
+
var symname = getString();
|
|
745
|
+
var flags2 = getLEB();
|
|
746
|
+
if (flags2 & WASM_SYMBOL_TLS) {
|
|
747
|
+
customSection.tlsExports.add(symname);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
} else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
|
|
751
|
+
var count = getLEB();
|
|
752
|
+
while (count--) {
|
|
753
|
+
var modname = getString();
|
|
754
|
+
var symname = getString();
|
|
755
|
+
var flags2 = getLEB();
|
|
756
|
+
if ((flags2 & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
|
|
757
|
+
customSection.weakImports.add(symname);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
} else if (subsectionType === WASM_DYLINK_RUNTIME_PATH) {
|
|
761
|
+
customSection.runtimePaths = getStringList();
|
|
762
|
+
} else {
|
|
763
|
+
err("unknown dylink.0 subsection:", subsectionType);
|
|
764
|
+
offset += subsectionSize;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
var tableAlign = Math.pow(2, customSection.tableAlign);
|
|
768
|
+
assert(tableAlign === 1, `invalid tableAlign ${tableAlign}`);
|
|
769
|
+
assert(offset == end);
|
|
770
|
+
return customSection;
|
|
771
|
+
}, "getDylinkMetadata");
|
|
772
|
+
function getValue(ptr, type = "i8") {
|
|
773
|
+
if (type.endsWith("*")) type = "*";
|
|
774
|
+
switch (type) {
|
|
775
|
+
case "i1":
|
|
776
|
+
return HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "loading")];
|
|
777
|
+
case "i8":
|
|
778
|
+
return HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "loading")];
|
|
779
|
+
case "i16":
|
|
780
|
+
return LE_HEAP_LOAD_I16(SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "loading") * 2);
|
|
781
|
+
case "i32":
|
|
782
|
+
return LE_HEAP_LOAD_I32(SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "loading") * 4);
|
|
783
|
+
case "i64":
|
|
784
|
+
return LE_HEAP_LOAD_I64(SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "loading") * 8);
|
|
785
|
+
case "float":
|
|
786
|
+
return LE_HEAP_LOAD_F32(SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "loading") * 4);
|
|
787
|
+
case "double":
|
|
788
|
+
return LE_HEAP_LOAD_F64(SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "loading") * 8);
|
|
789
|
+
case "*":
|
|
790
|
+
return LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "loading") * 4);
|
|
791
|
+
default:
|
|
792
|
+
abort(`invalid type for getValue: ${type}`);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
__name(getValue, "getValue");
|
|
796
|
+
var newDSO = /* @__PURE__ */ __name((name2, handle2, syms) => {
|
|
797
|
+
var dso = {
|
|
798
|
+
refcount: Infinity,
|
|
799
|
+
name: name2,
|
|
800
|
+
exports: syms,
|
|
801
|
+
global: true
|
|
802
|
+
};
|
|
803
|
+
LDSO.loadedLibsByName[name2] = dso;
|
|
804
|
+
if (handle2 != void 0) {
|
|
805
|
+
LDSO.loadedLibsByHandle[handle2] = dso;
|
|
806
|
+
}
|
|
807
|
+
return dso;
|
|
808
|
+
}, "newDSO");
|
|
809
|
+
var LDSO = {
|
|
810
|
+
loadedLibsByName: {},
|
|
811
|
+
loadedLibsByHandle: {},
|
|
812
|
+
init() {
|
|
813
|
+
assert(wasmImports);
|
|
814
|
+
newDSO("__main__", 0, wasmImports);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
var ___heap_base = 78224;
|
|
818
|
+
var alignMemory = /* @__PURE__ */ __name((size, alignment) => {
|
|
819
|
+
assert(alignment, "alignment argument is required");
|
|
820
|
+
return Math.ceil(size / alignment) * alignment;
|
|
821
|
+
}, "alignMemory");
|
|
822
|
+
var getMemory = /* @__PURE__ */ __name((size) => {
|
|
823
|
+
if (runtimeInitialized) {
|
|
824
|
+
return _calloc(size, 1);
|
|
825
|
+
}
|
|
826
|
+
var ret = ___heap_base;
|
|
827
|
+
var end = ret + alignMemory(size, 16);
|
|
828
|
+
assert(end <= HEAP8.length, "failure to getMemory - memory growth etc. is not supported there, call malloc/sbrk directly or increase INITIAL_MEMORY");
|
|
829
|
+
___heap_base = end;
|
|
830
|
+
GOT["__heap_base"].value = end;
|
|
831
|
+
return ret;
|
|
832
|
+
}, "getMemory");
|
|
833
|
+
var isInternalSym = /* @__PURE__ */ __name((symName) => ["__cpp_exception", "__c_longjmp", "__wasm_apply_data_relocs", "__dso_handle", "__tls_size", "__tls_align", "__set_stack_limits", "_emscripten_tls_init", "__wasm_init_tls", "__wasm_call_ctors", "__start_em_asm", "__stop_em_asm", "__start_em_js", "__stop_em_js"].includes(symName) || symName.startsWith("__em_js__"), "isInternalSym");
|
|
834
|
+
var uleb128EncodeWithLen = /* @__PURE__ */ __name((arr) => {
|
|
835
|
+
const n = arr.length;
|
|
836
|
+
assert(n < 16384);
|
|
837
|
+
return [n % 128 | 128, n >> 7, ...arr];
|
|
838
|
+
}, "uleb128EncodeWithLen");
|
|
839
|
+
var wasmTypeCodes = {
|
|
840
|
+
"i": 127,
|
|
841
|
+
// i32
|
|
842
|
+
"p": 127,
|
|
843
|
+
// i32
|
|
844
|
+
"j": 126,
|
|
845
|
+
// i64
|
|
846
|
+
"f": 125,
|
|
847
|
+
// f32
|
|
848
|
+
"d": 124,
|
|
849
|
+
// f64
|
|
850
|
+
"e": 111
|
|
851
|
+
};
|
|
852
|
+
var generateTypePack = /* @__PURE__ */ __name((types) => uleb128EncodeWithLen(Array.from(types, (type) => {
|
|
853
|
+
var code = wasmTypeCodes[type];
|
|
854
|
+
assert(code, `invalid signature char: ${type}`);
|
|
855
|
+
return code;
|
|
856
|
+
})), "generateTypePack");
|
|
857
|
+
var convertJsFunctionToWasm = /* @__PURE__ */ __name((func2, sig) => {
|
|
858
|
+
var bytes = Uint8Array.of(
|
|
859
|
+
0,
|
|
860
|
+
97,
|
|
861
|
+
115,
|
|
862
|
+
109,
|
|
863
|
+
// magic ("\0asm")
|
|
864
|
+
1,
|
|
865
|
+
0,
|
|
866
|
+
0,
|
|
867
|
+
0,
|
|
868
|
+
// version: 1
|
|
869
|
+
1,
|
|
870
|
+
...uleb128EncodeWithLen([
|
|
871
|
+
1,
|
|
872
|
+
// count: 1
|
|
873
|
+
96,
|
|
874
|
+
// param types
|
|
875
|
+
...generateTypePack(sig.slice(1)),
|
|
876
|
+
// return types (for now only supporting [] if `void` and single [T] otherwise)
|
|
877
|
+
...generateTypePack(sig[0] === "v" ? "" : sig[0])
|
|
878
|
+
]),
|
|
879
|
+
// The rest of the module is static
|
|
880
|
+
2,
|
|
881
|
+
7,
|
|
882
|
+
// import section
|
|
883
|
+
// (import "e" "f" (func 0 (type 0)))
|
|
884
|
+
1,
|
|
885
|
+
1,
|
|
886
|
+
101,
|
|
887
|
+
1,
|
|
888
|
+
102,
|
|
889
|
+
0,
|
|
890
|
+
0,
|
|
891
|
+
7,
|
|
892
|
+
5,
|
|
893
|
+
// export section
|
|
894
|
+
// (export "f" (func 0 (type 0)))
|
|
895
|
+
1,
|
|
896
|
+
1,
|
|
897
|
+
102,
|
|
898
|
+
0,
|
|
899
|
+
0
|
|
900
|
+
);
|
|
901
|
+
var module2 = new WebAssembly.Module(bytes);
|
|
902
|
+
var instance2 = new WebAssembly.Instance(module2, {
|
|
903
|
+
"e": {
|
|
904
|
+
"f": func2
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
var wrappedFunc = instance2.exports["f"];
|
|
908
|
+
return wrappedFunc;
|
|
909
|
+
}, "convertJsFunctionToWasm");
|
|
910
|
+
var wasmTableMirror = [];
|
|
911
|
+
var wasmTable = new WebAssembly.Table({
|
|
912
|
+
"initial": 31,
|
|
913
|
+
"element": "anyfunc"
|
|
914
|
+
});
|
|
915
|
+
var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
|
|
916
|
+
var func2 = wasmTableMirror[funcPtr];
|
|
917
|
+
if (!func2) {
|
|
918
|
+
wasmTableMirror[funcPtr] = func2 = wasmTable.get(funcPtr);
|
|
919
|
+
}
|
|
920
|
+
assert(wasmTable.get(funcPtr) == func2, "JavaScript-side Wasm function table mirror is out of date!");
|
|
921
|
+
return func2;
|
|
922
|
+
}, "getWasmTableEntry");
|
|
923
|
+
var updateTableMap = /* @__PURE__ */ __name((offset, count) => {
|
|
924
|
+
if (functionsInTableMap) {
|
|
925
|
+
for (var i2 = offset; i2 < offset + count; i2++) {
|
|
926
|
+
var item = getWasmTableEntry(i2);
|
|
927
|
+
if (item) {
|
|
928
|
+
functionsInTableMap.set(item, i2);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}, "updateTableMap");
|
|
933
|
+
var functionsInTableMap;
|
|
934
|
+
var getFunctionAddress = /* @__PURE__ */ __name((func2) => {
|
|
935
|
+
if (!functionsInTableMap) {
|
|
936
|
+
functionsInTableMap = /* @__PURE__ */ new WeakMap();
|
|
937
|
+
updateTableMap(0, wasmTable.length);
|
|
938
|
+
}
|
|
939
|
+
return functionsInTableMap.get(func2) || 0;
|
|
940
|
+
}, "getFunctionAddress");
|
|
941
|
+
var freeTableIndexes = [];
|
|
942
|
+
var getEmptyTableSlot = /* @__PURE__ */ __name(() => {
|
|
943
|
+
if (freeTableIndexes.length) {
|
|
944
|
+
return freeTableIndexes.pop();
|
|
945
|
+
}
|
|
946
|
+
try {
|
|
947
|
+
return wasmTable["grow"](1);
|
|
948
|
+
} catch (err2) {
|
|
949
|
+
if (!(err2 instanceof RangeError)) {
|
|
950
|
+
throw err2;
|
|
951
|
+
}
|
|
952
|
+
abort("Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.");
|
|
953
|
+
}
|
|
954
|
+
}, "getEmptyTableSlot");
|
|
955
|
+
var setWasmTableEntry = /* @__PURE__ */ __name((idx, func2) => {
|
|
956
|
+
wasmTable.set(idx, func2);
|
|
957
|
+
wasmTableMirror[idx] = wasmTable.get(idx);
|
|
958
|
+
}, "setWasmTableEntry");
|
|
959
|
+
var addFunction = /* @__PURE__ */ __name((func2, sig) => {
|
|
960
|
+
assert(typeof func2 != "undefined");
|
|
961
|
+
var rtn = getFunctionAddress(func2);
|
|
962
|
+
if (rtn) {
|
|
963
|
+
return rtn;
|
|
964
|
+
}
|
|
965
|
+
var ret = getEmptyTableSlot();
|
|
966
|
+
try {
|
|
967
|
+
setWasmTableEntry(ret, func2);
|
|
968
|
+
} catch (err2) {
|
|
969
|
+
if (!(err2 instanceof TypeError)) {
|
|
970
|
+
throw err2;
|
|
971
|
+
}
|
|
972
|
+
assert(typeof sig != "undefined", "Missing signature argument to addFunction: " + func2);
|
|
973
|
+
var wrapped = convertJsFunctionToWasm(func2, sig);
|
|
974
|
+
setWasmTableEntry(ret, wrapped);
|
|
975
|
+
}
|
|
976
|
+
functionsInTableMap.set(func2, ret);
|
|
977
|
+
return ret;
|
|
978
|
+
}, "addFunction");
|
|
979
|
+
var updateGOT = /* @__PURE__ */ __name((exports2, replace) => {
|
|
980
|
+
for (var symName in exports2) {
|
|
981
|
+
if (isInternalSym(symName)) {
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
var value = exports2[symName];
|
|
985
|
+
GOT[symName] ||= new WebAssembly.Global({
|
|
986
|
+
"value": "i32",
|
|
987
|
+
"mutable": true
|
|
988
|
+
});
|
|
989
|
+
if (replace || GOT[symName].value == 0) {
|
|
990
|
+
if (typeof value == "function") {
|
|
991
|
+
GOT[symName].value = addFunction(value);
|
|
992
|
+
} else if (typeof value == "number") {
|
|
993
|
+
GOT[symName].value = value;
|
|
994
|
+
} else {
|
|
995
|
+
err(`unhandled export type for '${symName}': ${typeof value}`);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}, "updateGOT");
|
|
1000
|
+
var relocateExports = /* @__PURE__ */ __name((exports2, memoryBase2, replace) => {
|
|
1001
|
+
var relocated = {};
|
|
1002
|
+
for (var e in exports2) {
|
|
1003
|
+
var value = exports2[e];
|
|
1004
|
+
if (typeof value == "object") {
|
|
1005
|
+
value = value.value;
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof value == "number") {
|
|
1008
|
+
value += memoryBase2;
|
|
1009
|
+
}
|
|
1010
|
+
relocated[e] = value;
|
|
1011
|
+
}
|
|
1012
|
+
updateGOT(relocated, replace);
|
|
1013
|
+
return relocated;
|
|
1014
|
+
}, "relocateExports");
|
|
1015
|
+
var isSymbolDefined = /* @__PURE__ */ __name((symName) => {
|
|
1016
|
+
var existing = wasmImports[symName];
|
|
1017
|
+
if (!existing || existing.stub) {
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
return true;
|
|
1021
|
+
}, "isSymbolDefined");
|
|
1022
|
+
var dynCall = /* @__PURE__ */ __name((sig, ptr, args2 = [], promising = false) => {
|
|
1023
|
+
assert(!promising, "async dynCall is not supported in this mode");
|
|
1024
|
+
assert(getWasmTableEntry(ptr), `missing table entry in dynCall: ${ptr}`);
|
|
1025
|
+
var func2 = getWasmTableEntry(ptr);
|
|
1026
|
+
var rtn = func2(...args2);
|
|
1027
|
+
function convert(rtn2) {
|
|
1028
|
+
return rtn2;
|
|
1029
|
+
}
|
|
1030
|
+
__name(convert, "convert");
|
|
1031
|
+
return convert(rtn);
|
|
1032
|
+
}, "dynCall");
|
|
1033
|
+
var stackSave = /* @__PURE__ */ __name(() => _emscripten_stack_get_current(), "stackSave");
|
|
1034
|
+
var stackRestore = /* @__PURE__ */ __name((val) => __emscripten_stack_restore(val), "stackRestore");
|
|
1035
|
+
var createInvokeFunction = /* @__PURE__ */ __name((sig) => (ptr, ...args2) => {
|
|
1036
|
+
var sp = stackSave();
|
|
1037
|
+
try {
|
|
1038
|
+
return dynCall(sig, ptr, args2);
|
|
1039
|
+
} catch (e) {
|
|
1040
|
+
stackRestore(sp);
|
|
1041
|
+
if (e !== e + 0) throw e;
|
|
1042
|
+
_setThrew(1, 0);
|
|
1043
|
+
if (sig[0] == "j") return 0n;
|
|
1044
|
+
}
|
|
1045
|
+
}, "createInvokeFunction");
|
|
1046
|
+
var resolveGlobalSymbol = /* @__PURE__ */ __name((symName, direct = false) => {
|
|
1047
|
+
var sym;
|
|
1048
|
+
if (isSymbolDefined(symName)) {
|
|
1049
|
+
sym = wasmImports[symName];
|
|
1050
|
+
} else if (symName.startsWith("invoke_")) {
|
|
1051
|
+
sym = wasmImports[symName] = createInvokeFunction(symName.split("_")[1]);
|
|
1052
|
+
}
|
|
1053
|
+
return {
|
|
1054
|
+
sym,
|
|
1055
|
+
name: symName
|
|
1056
|
+
};
|
|
1057
|
+
}, "resolveGlobalSymbol");
|
|
1058
|
+
var onPostCtors = [];
|
|
1059
|
+
var addOnPostCtor = /* @__PURE__ */ __name((cb) => onPostCtors.push(cb), "addOnPostCtor");
|
|
1060
|
+
var UTF8ToString = /* @__PURE__ */ __name((ptr, maxBytesToRead, ignoreNul) => {
|
|
1061
|
+
assert(typeof ptr == "number", `UTF8ToString expects a number (got ${typeof ptr})`);
|
|
1062
|
+
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : "";
|
|
1063
|
+
}, "UTF8ToString");
|
|
1064
|
+
var loadWebAssemblyModule = /* @__PURE__ */ __name((binary, flags, libName, localScope, handle) => {
|
|
1065
|
+
var metadata = getDylinkMetadata(binary);
|
|
1066
|
+
function loadModule() {
|
|
1067
|
+
var originalTable = wasmTable;
|
|
1068
|
+
var memAlign = Math.pow(2, metadata.memoryAlign);
|
|
1069
|
+
var memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0;
|
|
1070
|
+
var tableBase = metadata.tableSize ? wasmTable.length : 0;
|
|
1071
|
+
if (handle) {
|
|
1072
|
+
HEAP8[SAFE_HEAP_INDEX(HEAP8, handle + 8, "storing")] = 1;
|
|
1073
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, handle + 12 >> 2, "storing") * 4, memoryBase);
|
|
1074
|
+
LE_HEAP_STORE_I32(SAFE_HEAP_INDEX(HEAP32, handle + 16 >> 2, "storing") * 4, metadata.memorySize);
|
|
1075
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, handle + 20 >> 2, "storing") * 4, tableBase);
|
|
1076
|
+
LE_HEAP_STORE_I32(SAFE_HEAP_INDEX(HEAP32, handle + 24 >> 2, "storing") * 4, metadata.tableSize);
|
|
1077
|
+
}
|
|
1078
|
+
if (metadata.tableSize) {
|
|
1079
|
+
assert(wasmTable.length == tableBase, `unexpected table size while loading ${libName}: ${wasmTable.length}`);
|
|
1080
|
+
wasmTable.grow(metadata.tableSize);
|
|
1081
|
+
}
|
|
1082
|
+
var moduleExports;
|
|
1083
|
+
function resolveSymbol(sym) {
|
|
1084
|
+
var resolved = resolveGlobalSymbol(sym).sym;
|
|
1085
|
+
if (!resolved && localScope) {
|
|
1086
|
+
resolved = localScope[sym];
|
|
1087
|
+
}
|
|
1088
|
+
if (!resolved) {
|
|
1089
|
+
resolved = moduleExports[sym];
|
|
1090
|
+
}
|
|
1091
|
+
assert(resolved, `undefined symbol '${sym}'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment`);
|
|
1092
|
+
return resolved;
|
|
1093
|
+
}
|
|
1094
|
+
__name(resolveSymbol, "resolveSymbol");
|
|
1095
|
+
var proxyHandler = {
|
|
1096
|
+
get(stubs, prop) {
|
|
1097
|
+
switch (prop) {
|
|
1098
|
+
case "__memory_base":
|
|
1099
|
+
return memoryBase;
|
|
1100
|
+
case "__table_base":
|
|
1101
|
+
return tableBase;
|
|
1102
|
+
}
|
|
1103
|
+
if (prop in wasmImports && !wasmImports[prop].stub) {
|
|
1104
|
+
var res = wasmImports[prop];
|
|
1105
|
+
return res;
|
|
1106
|
+
}
|
|
1107
|
+
if (!(prop in stubs)) {
|
|
1108
|
+
var resolved;
|
|
1109
|
+
stubs[prop] = (...args2) => {
|
|
1110
|
+
resolved ||= resolveSymbol(prop);
|
|
1111
|
+
return resolved(...args2);
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
return stubs[prop];
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
var proxy = new Proxy({}, proxyHandler);
|
|
1118
|
+
currentModuleWeakSymbols = metadata.weakImports;
|
|
1119
|
+
var info = {
|
|
1120
|
+
"GOT.mem": new Proxy({}, GOTHandler),
|
|
1121
|
+
"GOT.func": new Proxy({}, GOTHandler),
|
|
1122
|
+
"env": proxy,
|
|
1123
|
+
"wasi_snapshot_preview1": proxy
|
|
1124
|
+
};
|
|
1125
|
+
function postInstantiation(module, instance) {
|
|
1126
|
+
assert(wasmTable === originalTable);
|
|
1127
|
+
updateTableMap(tableBase, metadata.tableSize);
|
|
1128
|
+
moduleExports = relocateExports(instance.exports, memoryBase);
|
|
1129
|
+
if (!flags.allowUndefined) {
|
|
1130
|
+
reportUndefinedSymbols();
|
|
1131
|
+
}
|
|
1132
|
+
function addEmAsm(addr, body) {
|
|
1133
|
+
var args = [];
|
|
1134
|
+
var arity = 0;
|
|
1135
|
+
for (; arity < 16; arity++) {
|
|
1136
|
+
if (body.indexOf("$" + arity) != -1) {
|
|
1137
|
+
args.push("$" + arity);
|
|
1138
|
+
} else {
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
args = args.join(",");
|
|
1143
|
+
var func = `(${args}) => { ${body} };`;
|
|
1144
|
+
ASM_CONSTS[start] = eval(func);
|
|
1145
|
+
}
|
|
1146
|
+
__name(addEmAsm, "addEmAsm");
|
|
1147
|
+
if ("__start_em_asm" in moduleExports) {
|
|
1148
|
+
var start = moduleExports["__start_em_asm"];
|
|
1149
|
+
var stop = moduleExports["__stop_em_asm"];
|
|
1150
|
+
while (start < stop) {
|
|
1151
|
+
var jsString = UTF8ToString(start);
|
|
1152
|
+
addEmAsm(start, jsString);
|
|
1153
|
+
start = HEAPU8.indexOf(0, start) + 1;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
function addEmJs(name, cSig, body) {
|
|
1157
|
+
var jsArgs = [];
|
|
1158
|
+
cSig = cSig.slice(1, -1);
|
|
1159
|
+
if (cSig != "void") {
|
|
1160
|
+
cSig = cSig.split(",");
|
|
1161
|
+
for (var i in cSig) {
|
|
1162
|
+
var jsArg = cSig[i].split(" ").pop();
|
|
1163
|
+
jsArgs.push(jsArg.replace("*", ""));
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
var func = `(${jsArgs}) => ${body};`;
|
|
1167
|
+
moduleExports[name] = eval(func);
|
|
1168
|
+
}
|
|
1169
|
+
__name(addEmJs, "addEmJs");
|
|
1170
|
+
for (var name in moduleExports) {
|
|
1171
|
+
if (name.startsWith("__em_js__")) {
|
|
1172
|
+
var start = moduleExports[name];
|
|
1173
|
+
var jsString = UTF8ToString(start);
|
|
1174
|
+
var parts = jsString.split("<::>");
|
|
1175
|
+
addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]);
|
|
1176
|
+
delete moduleExports[name];
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
var applyRelocs = moduleExports["__wasm_apply_data_relocs"];
|
|
1180
|
+
if (applyRelocs) {
|
|
1181
|
+
if (runtimeInitialized) {
|
|
1182
|
+
applyRelocs();
|
|
1183
|
+
} else {
|
|
1184
|
+
__RELOC_FUNCS__.push(applyRelocs);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
var init = moduleExports["__wasm_call_ctors"];
|
|
1188
|
+
if (init) {
|
|
1189
|
+
if (runtimeInitialized) {
|
|
1190
|
+
init();
|
|
1191
|
+
} else {
|
|
1192
|
+
addOnPostCtor(init);
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
return moduleExports;
|
|
1196
|
+
}
|
|
1197
|
+
__name(postInstantiation, "postInstantiation");
|
|
1198
|
+
if (flags.loadAsync) {
|
|
1199
|
+
return (async () => {
|
|
1200
|
+
var instance2;
|
|
1201
|
+
if (binary instanceof WebAssembly.Module) {
|
|
1202
|
+
instance2 = new WebAssembly.Instance(binary, info);
|
|
1203
|
+
} else {
|
|
1204
|
+
({ module: binary, instance: instance2 } = await WebAssembly.instantiate(binary, info));
|
|
1205
|
+
}
|
|
1206
|
+
return postInstantiation(binary, instance2);
|
|
1207
|
+
})();
|
|
1208
|
+
}
|
|
1209
|
+
var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary);
|
|
1210
|
+
var instance = new WebAssembly.Instance(module, info);
|
|
1211
|
+
return postInstantiation(module, instance);
|
|
1212
|
+
}
|
|
1213
|
+
__name(loadModule, "loadModule");
|
|
1214
|
+
flags = {
|
|
1215
|
+
...flags,
|
|
1216
|
+
rpath: {
|
|
1217
|
+
parentLibPath: libName,
|
|
1218
|
+
paths: metadata.runtimePaths
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
if (flags.loadAsync) {
|
|
1222
|
+
return metadata.neededDynlibs.reduce((chain, dynNeeded) => chain.then(() => loadDynamicLibrary(dynNeeded, flags, localScope)), Promise.resolve()).then(loadModule);
|
|
1223
|
+
}
|
|
1224
|
+
metadata.neededDynlibs.forEach((needed) => loadDynamicLibrary(needed, flags, localScope));
|
|
1225
|
+
return loadModule();
|
|
1226
|
+
}, "loadWebAssemblyModule");
|
|
1227
|
+
var mergeLibSymbols = /* @__PURE__ */ __name((exports2, libName2) => {
|
|
1228
|
+
for (var [sym, exp] of Object.entries(exports2)) {
|
|
1229
|
+
const setImport = /* @__PURE__ */ __name((target) => {
|
|
1230
|
+
if (!isSymbolDefined(target)) {
|
|
1231
|
+
wasmImports[target] = exp;
|
|
1232
|
+
}
|
|
1233
|
+
}, "setImport");
|
|
1234
|
+
setImport(sym);
|
|
1235
|
+
const main_alias = "__main_argc_argv";
|
|
1236
|
+
if (sym == "main") {
|
|
1237
|
+
setImport(main_alias);
|
|
1238
|
+
}
|
|
1239
|
+
if (sym == main_alias) {
|
|
1240
|
+
setImport("main");
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}, "mergeLibSymbols");
|
|
1244
|
+
var asyncLoad = /* @__PURE__ */ __name(async (url) => {
|
|
1245
|
+
var arrayBuffer = await readAsync(url);
|
|
1246
|
+
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
|
|
1247
|
+
return new Uint8Array(arrayBuffer);
|
|
1248
|
+
}, "asyncLoad");
|
|
1249
|
+
function loadDynamicLibrary(libName2, flags2 = {
|
|
1250
|
+
global: true,
|
|
1251
|
+
nodelete: true
|
|
1252
|
+
}, localScope2, handle2) {
|
|
1253
|
+
var dso = LDSO.loadedLibsByName[libName2];
|
|
1254
|
+
if (dso) {
|
|
1255
|
+
assert(dso.exports !== "loading", `Attempt to load '${libName2}' twice before the first load completed`);
|
|
1256
|
+
if (!flags2.global) {
|
|
1257
|
+
if (localScope2) {
|
|
1258
|
+
Object.assign(localScope2, dso.exports);
|
|
1259
|
+
}
|
|
1260
|
+
} else if (!dso.global) {
|
|
1261
|
+
dso.global = true;
|
|
1262
|
+
mergeLibSymbols(dso.exports, libName2);
|
|
1263
|
+
}
|
|
1264
|
+
if (flags2.nodelete && dso.refcount !== Infinity) {
|
|
1265
|
+
dso.refcount = Infinity;
|
|
1266
|
+
}
|
|
1267
|
+
dso.refcount++;
|
|
1268
|
+
if (handle2) {
|
|
1269
|
+
LDSO.loadedLibsByHandle[handle2] = dso;
|
|
1270
|
+
}
|
|
1271
|
+
return flags2.loadAsync ? Promise.resolve(true) : true;
|
|
1272
|
+
}
|
|
1273
|
+
dso = newDSO(libName2, handle2, "loading");
|
|
1274
|
+
dso.refcount = flags2.nodelete ? Infinity : 1;
|
|
1275
|
+
dso.global = flags2.global;
|
|
1276
|
+
function loadLibData() {
|
|
1277
|
+
if (handle2) {
|
|
1278
|
+
var data = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, handle2 + 28 >> 2, "loading") * 4);
|
|
1279
|
+
var dataSize = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, handle2 + 32 >> 2, "loading") * 4);
|
|
1280
|
+
if (data && dataSize) {
|
|
1281
|
+
var libData = HEAP8.slice(data, data + dataSize);
|
|
1282
|
+
return flags2.loadAsync ? Promise.resolve(libData) : libData;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
var libFile = locateFile(libName2);
|
|
1286
|
+
if (flags2.loadAsync) {
|
|
1287
|
+
return asyncLoad(libFile);
|
|
1288
|
+
}
|
|
1289
|
+
if (!readBinary) {
|
|
1290
|
+
throw new Error(`${libFile}: file not found, and synchronous loading of external files is not available`);
|
|
1291
|
+
}
|
|
1292
|
+
return readBinary(libFile);
|
|
1293
|
+
}
|
|
1294
|
+
__name(loadLibData, "loadLibData");
|
|
1295
|
+
function getExports() {
|
|
1296
|
+
if (flags2.loadAsync) {
|
|
1297
|
+
return loadLibData().then((libData) => loadWebAssemblyModule(libData, flags2, libName2, localScope2, handle2));
|
|
1298
|
+
}
|
|
1299
|
+
return loadWebAssemblyModule(loadLibData(), flags2, libName2, localScope2, handle2);
|
|
1300
|
+
}
|
|
1301
|
+
__name(getExports, "getExports");
|
|
1302
|
+
function moduleLoaded(exports2) {
|
|
1303
|
+
if (dso.global) {
|
|
1304
|
+
mergeLibSymbols(exports2, libName2);
|
|
1305
|
+
} else if (localScope2) {
|
|
1306
|
+
Object.assign(localScope2, exports2);
|
|
1307
|
+
}
|
|
1308
|
+
dso.exports = exports2;
|
|
1309
|
+
}
|
|
1310
|
+
__name(moduleLoaded, "moduleLoaded");
|
|
1311
|
+
if (flags2.loadAsync) {
|
|
1312
|
+
return getExports().then((exports2) => {
|
|
1313
|
+
moduleLoaded(exports2);
|
|
1314
|
+
return true;
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
moduleLoaded(getExports());
|
|
1318
|
+
return true;
|
|
1319
|
+
}
|
|
1320
|
+
__name(loadDynamicLibrary, "loadDynamicLibrary");
|
|
1321
|
+
var reportUndefinedSymbols = /* @__PURE__ */ __name(() => {
|
|
1322
|
+
for (var [symName, entry] of Object.entries(GOT)) {
|
|
1323
|
+
if (entry.value == 0) {
|
|
1324
|
+
var value = resolveGlobalSymbol(symName, true).sym;
|
|
1325
|
+
if (!value && !entry.required) {
|
|
1326
|
+
continue;
|
|
1327
|
+
}
|
|
1328
|
+
assert(value, `undefined symbol '${symName}'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment`);
|
|
1329
|
+
if (typeof value == "function") {
|
|
1330
|
+
entry.value = addFunction(value, value.sig);
|
|
1331
|
+
} else if (typeof value == "number") {
|
|
1332
|
+
entry.value = value;
|
|
1333
|
+
} else {
|
|
1334
|
+
throw new Error(`bad export type for '${symName}': ${typeof value}`);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}, "reportUndefinedSymbols");
|
|
1339
|
+
var runDependencies = 0;
|
|
1340
|
+
var dependenciesFulfilled = null;
|
|
1341
|
+
var runDependencyTracking = {};
|
|
1342
|
+
var runDependencyWatcher = null;
|
|
1343
|
+
var removeRunDependency = /* @__PURE__ */ __name((id) => {
|
|
1344
|
+
runDependencies--;
|
|
1345
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
1346
|
+
assert(id, "removeRunDependency requires an ID");
|
|
1347
|
+
assert(runDependencyTracking[id]);
|
|
1348
|
+
delete runDependencyTracking[id];
|
|
1349
|
+
if (runDependencies == 0) {
|
|
1350
|
+
if (runDependencyWatcher !== null) {
|
|
1351
|
+
clearInterval(runDependencyWatcher);
|
|
1352
|
+
runDependencyWatcher = null;
|
|
1353
|
+
}
|
|
1354
|
+
if (dependenciesFulfilled) {
|
|
1355
|
+
var callback = dependenciesFulfilled;
|
|
1356
|
+
dependenciesFulfilled = null;
|
|
1357
|
+
callback();
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}, "removeRunDependency");
|
|
1361
|
+
var addRunDependency = /* @__PURE__ */ __name((id) => {
|
|
1362
|
+
runDependencies++;
|
|
1363
|
+
Module["monitorRunDependencies"]?.(runDependencies);
|
|
1364
|
+
assert(id, "addRunDependency requires an ID");
|
|
1365
|
+
assert(!runDependencyTracking[id]);
|
|
1366
|
+
runDependencyTracking[id] = 1;
|
|
1367
|
+
if (runDependencyWatcher === null && typeof setInterval != "undefined") {
|
|
1368
|
+
runDependencyWatcher = setInterval(() => {
|
|
1369
|
+
if (ABORT) {
|
|
1370
|
+
clearInterval(runDependencyWatcher);
|
|
1371
|
+
runDependencyWatcher = null;
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
var shown = false;
|
|
1375
|
+
for (var dep in runDependencyTracking) {
|
|
1376
|
+
if (!shown) {
|
|
1377
|
+
shown = true;
|
|
1378
|
+
err("still waiting on run dependencies:");
|
|
1379
|
+
}
|
|
1380
|
+
err(`dependency: ${dep}`);
|
|
1381
|
+
}
|
|
1382
|
+
if (shown) {
|
|
1383
|
+
err("(end of list)");
|
|
1384
|
+
}
|
|
1385
|
+
}, 1e4);
|
|
1386
|
+
runDependencyWatcher.unref?.();
|
|
1387
|
+
}
|
|
1388
|
+
}, "addRunDependency");
|
|
1389
|
+
var loadDylibs = /* @__PURE__ */ __name(async () => {
|
|
1390
|
+
if (!dynamicLibraries.length) {
|
|
1391
|
+
reportUndefinedSymbols();
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
addRunDependency("loadDylibs");
|
|
1395
|
+
for (var lib of dynamicLibraries) {
|
|
1396
|
+
await loadDynamicLibrary(lib, {
|
|
1397
|
+
loadAsync: true,
|
|
1398
|
+
global: true,
|
|
1399
|
+
nodelete: true,
|
|
1400
|
+
allowUndefined: true
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
reportUndefinedSymbols();
|
|
1404
|
+
removeRunDependency("loadDylibs");
|
|
1405
|
+
}, "loadDylibs");
|
|
1406
|
+
var noExitRuntime = true;
|
|
1407
|
+
var ptrToString = /* @__PURE__ */ __name((ptr) => {
|
|
1408
|
+
assert(typeof ptr === "number");
|
|
1409
|
+
ptr >>>= 0;
|
|
1410
|
+
return "0x" + ptr.toString(16).padStart(8, "0");
|
|
1411
|
+
}, "ptrToString");
|
|
1412
|
+
function setValue(ptr, value, type = "i8") {
|
|
1413
|
+
if (type.endsWith("*")) type = "*";
|
|
1414
|
+
switch (type) {
|
|
1415
|
+
case "i1":
|
|
1416
|
+
HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "storing")] = value;
|
|
1417
|
+
break;
|
|
1418
|
+
case "i8":
|
|
1419
|
+
HEAP8[SAFE_HEAP_INDEX(HEAP8, ptr, "storing")] = value;
|
|
1420
|
+
break;
|
|
1421
|
+
case "i16":
|
|
1422
|
+
LE_HEAP_STORE_I16(SAFE_HEAP_INDEX(HEAP16, ptr >> 1, "storing") * 2, value);
|
|
1423
|
+
break;
|
|
1424
|
+
case "i32":
|
|
1425
|
+
LE_HEAP_STORE_I32(SAFE_HEAP_INDEX(HEAP32, ptr >> 2, "storing") * 4, value);
|
|
1426
|
+
break;
|
|
1427
|
+
case "i64":
|
|
1428
|
+
LE_HEAP_STORE_I64(SAFE_HEAP_INDEX(HEAP64, ptr >> 3, "storing") * 8, BigInt(value));
|
|
1429
|
+
break;
|
|
1430
|
+
case "float":
|
|
1431
|
+
LE_HEAP_STORE_F32(SAFE_HEAP_INDEX(HEAPF32, ptr >> 2, "storing") * 4, value);
|
|
1432
|
+
break;
|
|
1433
|
+
case "double":
|
|
1434
|
+
LE_HEAP_STORE_F64(SAFE_HEAP_INDEX(HEAPF64, ptr >> 3, "storing") * 8, value);
|
|
1435
|
+
break;
|
|
1436
|
+
case "*":
|
|
1437
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, ptr >> 2, "storing") * 4, value);
|
|
1438
|
+
break;
|
|
1439
|
+
default:
|
|
1440
|
+
abort(`invalid type for setValue: ${type}`);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
__name(setValue, "setValue");
|
|
1444
|
+
var ___memory_base = new WebAssembly.Global({
|
|
1445
|
+
"value": "i32",
|
|
1446
|
+
"mutable": false
|
|
1447
|
+
}, 1024);
|
|
1448
|
+
var ___stack_high = 78224;
|
|
1449
|
+
var ___stack_low = 12688;
|
|
1450
|
+
var ___stack_pointer = new WebAssembly.Global({
|
|
1451
|
+
"value": "i32",
|
|
1452
|
+
"mutable": true
|
|
1453
|
+
}, 78224);
|
|
1454
|
+
var ___table_base = new WebAssembly.Global({
|
|
1455
|
+
"value": "i32",
|
|
1456
|
+
"mutable": false
|
|
1457
|
+
}, 1);
|
|
1458
|
+
var __abort_js = /* @__PURE__ */ __name(() => abort("native code called abort()"), "__abort_js");
|
|
1459
|
+
__abort_js.sig = "v";
|
|
1460
|
+
var getHeapMax = /* @__PURE__ */ __name(() => (
|
|
1461
|
+
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
1462
|
+
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
|
|
1463
|
+
// for any code that deals with heap sizes, which would require special
|
|
1464
|
+
// casing all heap size related code to treat 0 specially.
|
|
1465
|
+
2147483648
|
|
1466
|
+
), "getHeapMax");
|
|
1467
|
+
var growMemory = /* @__PURE__ */ __name((size) => {
|
|
1468
|
+
var oldHeapSize = wasmMemory.buffer.byteLength;
|
|
1469
|
+
var pages = (size - oldHeapSize + 65535) / 65536 | 0;
|
|
1470
|
+
try {
|
|
1471
|
+
wasmMemory.grow(pages);
|
|
1472
|
+
updateMemoryViews();
|
|
1473
|
+
return 1;
|
|
1474
|
+
} catch (e) {
|
|
1475
|
+
err(`growMemory: Attempted to grow heap from ${oldHeapSize} bytes to ${size} bytes, but got error: ${e}`);
|
|
1476
|
+
}
|
|
1477
|
+
}, "growMemory");
|
|
1478
|
+
var _emscripten_resize_heap = /* @__PURE__ */ __name((requestedSize) => {
|
|
1479
|
+
var oldSize = HEAPU8.length;
|
|
1480
|
+
requestedSize >>>= 0;
|
|
1481
|
+
assert(requestedSize > oldSize);
|
|
1482
|
+
var maxHeapSize = getHeapMax();
|
|
1483
|
+
if (requestedSize > maxHeapSize) {
|
|
1484
|
+
err(`Cannot enlarge memory, requested ${requestedSize} bytes, but the limit is ${maxHeapSize} bytes!`);
|
|
1485
|
+
return false;
|
|
1486
|
+
}
|
|
1487
|
+
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
|
|
1488
|
+
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
|
|
1489
|
+
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
1490
|
+
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
1491
|
+
var replacement = growMemory(newSize);
|
|
1492
|
+
if (replacement) {
|
|
1493
|
+
return true;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
err(`Failed to grow the heap from ${oldSize} bytes to ${newSize} bytes, not enough memory!`);
|
|
1497
|
+
return false;
|
|
1498
|
+
}, "_emscripten_resize_heap");
|
|
1499
|
+
_emscripten_resize_heap.sig = "ip";
|
|
1500
|
+
var SYSCALLS = {
|
|
1501
|
+
varargs: void 0,
|
|
1502
|
+
getStr(ptr) {
|
|
1503
|
+
var ret = UTF8ToString(ptr);
|
|
1504
|
+
return ret;
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
var _fd_close = /* @__PURE__ */ __name((fd) => {
|
|
1508
|
+
abort("fd_close called without SYSCALLS_REQUIRE_FILESYSTEM");
|
|
1509
|
+
}, "_fd_close");
|
|
1510
|
+
_fd_close.sig = "ii";
|
|
1511
|
+
var INT53_MAX = 9007199254740992;
|
|
1512
|
+
var INT53_MIN = -9007199254740992;
|
|
1513
|
+
var bigintToI53Checked = /* @__PURE__ */ __name((num) => num < INT53_MIN || num > INT53_MAX ? NaN : Number(num), "bigintToI53Checked");
|
|
1514
|
+
function _fd_seek(fd, offset, whence, newOffset) {
|
|
1515
|
+
offset = bigintToI53Checked(offset);
|
|
1516
|
+
return 70;
|
|
1517
|
+
}
|
|
1518
|
+
__name(_fd_seek, "_fd_seek");
|
|
1519
|
+
_fd_seek.sig = "iijip";
|
|
1520
|
+
var printCharBuffers = [null, [], []];
|
|
1521
|
+
var printChar = /* @__PURE__ */ __name((stream, curr) => {
|
|
1522
|
+
var buffer = printCharBuffers[stream];
|
|
1523
|
+
assert(buffer);
|
|
1524
|
+
if (curr === 0 || curr === 10) {
|
|
1525
|
+
(stream === 1 ? out : err)(UTF8ArrayToString(buffer));
|
|
1526
|
+
buffer.length = 0;
|
|
1527
|
+
} else {
|
|
1528
|
+
buffer.push(curr);
|
|
1529
|
+
}
|
|
1530
|
+
}, "printChar");
|
|
1531
|
+
var flush_NO_FILESYSTEM = /* @__PURE__ */ __name(() => {
|
|
1532
|
+
_fflush(0);
|
|
1533
|
+
if (printCharBuffers[1].length) printChar(1, 10);
|
|
1534
|
+
if (printCharBuffers[2].length) printChar(2, 10);
|
|
1535
|
+
}, "flush_NO_FILESYSTEM");
|
|
1536
|
+
var _fd_write = /* @__PURE__ */ __name((fd, iov, iovcnt, pnum) => {
|
|
1537
|
+
var num = 0;
|
|
1538
|
+
for (var i2 = 0; i2 < iovcnt; i2++) {
|
|
1539
|
+
var ptr = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, iov >> 2, "loading") * 4);
|
|
1540
|
+
var len = LE_HEAP_LOAD_U32(SAFE_HEAP_INDEX(HEAPU32, iov + 4 >> 2, "loading") * 4);
|
|
1541
|
+
iov += 8;
|
|
1542
|
+
for (var j = 0; j < len; j++) {
|
|
1543
|
+
printChar(fd, HEAPU8[SAFE_HEAP_INDEX(HEAPU8, ptr + j, "loading")]);
|
|
1544
|
+
}
|
|
1545
|
+
num += len;
|
|
1546
|
+
}
|
|
1547
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, pnum >> 2, "storing") * 4, num);
|
|
1548
|
+
return 0;
|
|
1549
|
+
}, "_fd_write");
|
|
1550
|
+
_fd_write.sig = "iippp";
|
|
1551
|
+
function _tree_sitter_log_callback(isLexMessage, messageAddress) {
|
|
1552
|
+
if (Module.currentLogCallback) {
|
|
1553
|
+
const message = UTF8ToString(messageAddress);
|
|
1554
|
+
Module.currentLogCallback(message, isLexMessage !== 0);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
__name(_tree_sitter_log_callback, "_tree_sitter_log_callback");
|
|
1558
|
+
function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
|
|
1559
|
+
const INPUT_BUFFER_SIZE = 10 * 1024;
|
|
1560
|
+
const string = Module.currentParseCallback(index, {
|
|
1561
|
+
row,
|
|
1562
|
+
column
|
|
1563
|
+
});
|
|
1564
|
+
if (typeof string === "string") {
|
|
1565
|
+
setValue(lengthAddress, string.length, "i32");
|
|
1566
|
+
stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
|
|
1567
|
+
} else {
|
|
1568
|
+
setValue(lengthAddress, 0, "i32");
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
__name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
|
|
1572
|
+
function _tree_sitter_progress_callback(currentOffset, hasError) {
|
|
1573
|
+
if (Module.currentProgressCallback) {
|
|
1574
|
+
return Module.currentProgressCallback({
|
|
1575
|
+
currentOffset,
|
|
1576
|
+
hasError
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
return false;
|
|
1580
|
+
}
|
|
1581
|
+
__name(_tree_sitter_progress_callback, "_tree_sitter_progress_callback");
|
|
1582
|
+
function _tree_sitter_query_progress_callback(currentOffset) {
|
|
1583
|
+
if (Module.currentQueryProgressCallback) {
|
|
1584
|
+
return Module.currentQueryProgressCallback({
|
|
1585
|
+
currentOffset
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
return false;
|
|
1589
|
+
}
|
|
1590
|
+
__name(_tree_sitter_query_progress_callback, "_tree_sitter_query_progress_callback");
|
|
1591
|
+
var runtimeKeepaliveCounter = 0;
|
|
1592
|
+
var keepRuntimeAlive = /* @__PURE__ */ __name(() => noExitRuntime || runtimeKeepaliveCounter > 0, "keepRuntimeAlive");
|
|
1593
|
+
var _proc_exit = /* @__PURE__ */ __name((code) => {
|
|
1594
|
+
EXITSTATUS = code;
|
|
1595
|
+
if (!keepRuntimeAlive()) {
|
|
1596
|
+
Module["onExit"]?.(code);
|
|
1597
|
+
ABORT = true;
|
|
1598
|
+
}
|
|
1599
|
+
quit_(code, new ExitStatus(code));
|
|
1600
|
+
}, "_proc_exit");
|
|
1601
|
+
_proc_exit.sig = "vi";
|
|
1602
|
+
var exitJS = /* @__PURE__ */ __name((status, implicit) => {
|
|
1603
|
+
EXITSTATUS = status;
|
|
1604
|
+
checkUnflushedContent();
|
|
1605
|
+
if (keepRuntimeAlive() && !implicit) {
|
|
1606
|
+
var msg = `program exited (with status: ${status}), but keepRuntimeAlive() is set (counter=${runtimeKeepaliveCounter}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;
|
|
1607
|
+
readyPromiseReject?.(msg);
|
|
1608
|
+
err(msg);
|
|
1609
|
+
}
|
|
1610
|
+
_proc_exit(status);
|
|
1611
|
+
}, "exitJS");
|
|
1612
|
+
var handleException = /* @__PURE__ */ __name((e) => {
|
|
1613
|
+
if (e instanceof ExitStatus || e == "unwind") {
|
|
1614
|
+
return EXITSTATUS;
|
|
1615
|
+
}
|
|
1616
|
+
checkStackCookie();
|
|
1617
|
+
if (e instanceof WebAssembly.RuntimeError) {
|
|
1618
|
+
if (_emscripten_stack_get_current() <= 0) {
|
|
1619
|
+
err("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)");
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
quit_(1, e);
|
|
1623
|
+
}, "handleException");
|
|
1624
|
+
var lengthBytesUTF8 = /* @__PURE__ */ __name((str) => {
|
|
1625
|
+
var len = 0;
|
|
1626
|
+
for (var i2 = 0; i2 < str.length; ++i2) {
|
|
1627
|
+
var c = str.charCodeAt(i2);
|
|
1628
|
+
if (c <= 127) {
|
|
1629
|
+
len++;
|
|
1630
|
+
} else if (c <= 2047) {
|
|
1631
|
+
len += 2;
|
|
1632
|
+
} else if (c >= 55296 && c <= 57343) {
|
|
1633
|
+
len += 4;
|
|
1634
|
+
++i2;
|
|
1635
|
+
} else {
|
|
1636
|
+
len += 3;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
return len;
|
|
1640
|
+
}, "lengthBytesUTF8");
|
|
1641
|
+
var stringToUTF8Array = /* @__PURE__ */ __name((str, heap, outIdx, maxBytesToWrite) => {
|
|
1642
|
+
assert(typeof str === "string", `stringToUTF8Array expects a string (got ${typeof str})`);
|
|
1643
|
+
if (!(maxBytesToWrite > 0)) return 0;
|
|
1644
|
+
var startIdx = outIdx;
|
|
1645
|
+
var endIdx = outIdx + maxBytesToWrite - 1;
|
|
1646
|
+
for (var i2 = 0; i2 < str.length; ++i2) {
|
|
1647
|
+
var u = str.codePointAt(i2);
|
|
1648
|
+
if (u <= 127) {
|
|
1649
|
+
if (outIdx >= endIdx) break;
|
|
1650
|
+
heap[outIdx++] = u;
|
|
1651
|
+
} else if (u <= 2047) {
|
|
1652
|
+
if (outIdx + 1 >= endIdx) break;
|
|
1653
|
+
heap[outIdx++] = 192 | u >> 6;
|
|
1654
|
+
heap[outIdx++] = 128 | u & 63;
|
|
1655
|
+
} else if (u <= 65535) {
|
|
1656
|
+
if (outIdx + 2 >= endIdx) break;
|
|
1657
|
+
heap[outIdx++] = 224 | u >> 12;
|
|
1658
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
1659
|
+
heap[outIdx++] = 128 | u & 63;
|
|
1660
|
+
} else {
|
|
1661
|
+
if (outIdx + 3 >= endIdx) break;
|
|
1662
|
+
if (u > 1114111) warnOnce("Invalid Unicode code point " + ptrToString(u) + " encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).");
|
|
1663
|
+
heap[outIdx++] = 240 | u >> 18;
|
|
1664
|
+
heap[outIdx++] = 128 | u >> 12 & 63;
|
|
1665
|
+
heap[outIdx++] = 128 | u >> 6 & 63;
|
|
1666
|
+
heap[outIdx++] = 128 | u & 63;
|
|
1667
|
+
i2++;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
heap[outIdx] = 0;
|
|
1671
|
+
return outIdx - startIdx;
|
|
1672
|
+
}, "stringToUTF8Array");
|
|
1673
|
+
var stringToUTF8 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => {
|
|
1674
|
+
assert(typeof maxBytesToWrite == "number", "stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
|
|
1675
|
+
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
1676
|
+
}, "stringToUTF8");
|
|
1677
|
+
var stackAlloc = /* @__PURE__ */ __name((sz) => __emscripten_stack_alloc(sz), "stackAlloc");
|
|
1678
|
+
var stringToUTF8OnStack = /* @__PURE__ */ __name((str) => {
|
|
1679
|
+
var size = lengthBytesUTF8(str) + 1;
|
|
1680
|
+
var ret = stackAlloc(size);
|
|
1681
|
+
stringToUTF8(str, ret, size);
|
|
1682
|
+
return ret;
|
|
1683
|
+
}, "stringToUTF8OnStack");
|
|
1684
|
+
var AsciiToString = /* @__PURE__ */ __name((ptr) => {
|
|
1685
|
+
var str = "";
|
|
1686
|
+
while (1) {
|
|
1687
|
+
var ch = HEAPU8[SAFE_HEAP_INDEX(HEAPU8, ptr++, "loading")];
|
|
1688
|
+
if (!ch) return str;
|
|
1689
|
+
str += String.fromCharCode(ch);
|
|
1690
|
+
}
|
|
1691
|
+
}, "AsciiToString");
|
|
1692
|
+
var stringToUTF16 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => {
|
|
1693
|
+
assert(outPtr % 2 == 0, "Pointer passed to stringToUTF16 must be aligned to two bytes!");
|
|
1694
|
+
assert(typeof maxBytesToWrite == "number", "stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");
|
|
1695
|
+
maxBytesToWrite ??= 2147483647;
|
|
1696
|
+
if (maxBytesToWrite < 2) return 0;
|
|
1697
|
+
maxBytesToWrite -= 2;
|
|
1698
|
+
var startPtr = outPtr;
|
|
1699
|
+
var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
|
|
1700
|
+
for (var i2 = 0; i2 < numCharsToWrite; ++i2) {
|
|
1701
|
+
var codeUnit = str.charCodeAt(i2);
|
|
1702
|
+
LE_HEAP_STORE_I16(SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing") * 2, codeUnit);
|
|
1703
|
+
outPtr += 2;
|
|
1704
|
+
}
|
|
1705
|
+
LE_HEAP_STORE_I16(SAFE_HEAP_INDEX(HEAP16, outPtr >> 1, "storing") * 2, 0);
|
|
1706
|
+
return outPtr - startPtr;
|
|
1707
|
+
}, "stringToUTF16");
|
|
1708
|
+
LE_ATOMICS_NATIVE_BYTE_ORDER = new Int8Array(new Int16Array([1]).buffer)[0] === 1 ? [
|
|
1709
|
+
/* little endian */
|
|
1710
|
+
((x) => x),
|
|
1711
|
+
((x) => x),
|
|
1712
|
+
void 0,
|
|
1713
|
+
((x) => x)
|
|
1714
|
+
] : [
|
|
1715
|
+
/* big endian */
|
|
1716
|
+
((x) => x),
|
|
1717
|
+
((x) => ((x & 65280) << 8 | (x & 255) << 24) >> 16),
|
|
1718
|
+
void 0,
|
|
1719
|
+
((x) => x >> 24 & 255 | x >> 8 & 65280 | (x & 65280) << 8 | (x & 255) << 24)
|
|
1720
|
+
];
|
|
1721
|
+
function LE_HEAP_UPDATE() {
|
|
1722
|
+
HEAPU16.unsigned = ((x) => x & 65535);
|
|
1723
|
+
HEAPU32.unsigned = ((x) => x >>> 0);
|
|
1724
|
+
}
|
|
1725
|
+
__name(LE_HEAP_UPDATE, "LE_HEAP_UPDATE");
|
|
1726
|
+
{
|
|
1727
|
+
initMemory();
|
|
1728
|
+
if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
|
|
1729
|
+
if (Module["print"]) out = Module["print"];
|
|
1730
|
+
if (Module["printErr"]) err = Module["printErr"];
|
|
1731
|
+
if (Module["dynamicLibraries"]) dynamicLibraries = Module["dynamicLibraries"];
|
|
1732
|
+
if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
|
|
1733
|
+
Module["FS_createDataFile"] = FS.createDataFile;
|
|
1734
|
+
Module["FS_createPreloadedFile"] = FS.createPreloadedFile;
|
|
1735
|
+
checkIncomingModuleAPI();
|
|
1736
|
+
if (Module["arguments"]) arguments_ = Module["arguments"];
|
|
1737
|
+
if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
|
|
1738
|
+
assert(typeof Module["memoryInitializerPrefixURL"] == "undefined", "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead");
|
|
1739
|
+
assert(typeof Module["pthreadMainPrefixURL"] == "undefined", "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead");
|
|
1740
|
+
assert(typeof Module["cdInitializerPrefixURL"] == "undefined", "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead");
|
|
1741
|
+
assert(typeof Module["filePackagePrefixURL"] == "undefined", "Module.filePackagePrefixURL option was removed, use Module.locateFile instead");
|
|
1742
|
+
assert(typeof Module["read"] == "undefined", "Module.read option was removed");
|
|
1743
|
+
assert(typeof Module["readAsync"] == "undefined", "Module.readAsync option was removed (modify readAsync in JS)");
|
|
1744
|
+
assert(typeof Module["readBinary"] == "undefined", "Module.readBinary option was removed (modify readBinary in JS)");
|
|
1745
|
+
assert(typeof Module["setWindowTitle"] == "undefined", "Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)");
|
|
1746
|
+
assert(typeof Module["TOTAL_MEMORY"] == "undefined", "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY");
|
|
1747
|
+
assert(typeof Module["ENVIRONMENT"] == "undefined", "Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");
|
|
1748
|
+
assert(typeof Module["STACK_SIZE"] == "undefined", "STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time");
|
|
1749
|
+
if (Module["preInit"]) {
|
|
1750
|
+
if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
|
|
1751
|
+
while (Module["preInit"].length > 0) {
|
|
1752
|
+
Module["preInit"].shift()();
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
consumedModuleProp("preInit");
|
|
1756
|
+
}
|
|
1757
|
+
Module["setValue"] = setValue;
|
|
1758
|
+
Module["getValue"] = getValue;
|
|
1759
|
+
Module["UTF8ToString"] = UTF8ToString;
|
|
1760
|
+
Module["stringToUTF8"] = stringToUTF8;
|
|
1761
|
+
Module["lengthBytesUTF8"] = lengthBytesUTF8;
|
|
1762
|
+
Module["AsciiToString"] = AsciiToString;
|
|
1763
|
+
Module["stringToUTF16"] = stringToUTF16;
|
|
1764
|
+
Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
|
|
1765
|
+
Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
|
|
1766
|
+
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"];
|
|
1767
|
+
missingLibrarySymbols.forEach(missingLibrarySymbol);
|
|
1768
|
+
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", "LE_HEAP_STORE_U16", "LE_HEAP_STORE_I16", "LE_HEAP_STORE_U32", "LE_HEAP_STORE_I32", "LE_HEAP_STORE_U64", "LE_HEAP_STORE_F32", "LE_HEAP_STORE_F64", "LE_HEAP_LOAD_U16", "LE_HEAP_LOAD_I16", "LE_HEAP_LOAD_U32", "LE_HEAP_LOAD_I32", "LE_HEAP_LOAD_U64", "LE_HEAP_LOAD_I64", "LE_HEAP_LOAD_F32", "LE_HEAP_LOAD_F64", "LE_ATOMICS_NATIVE_BYTE_ORDER", "LE_ATOMICS_ADD", "LE_ATOMICS_AND", "LE_ATOMICS_COMPAREEXCHANGE", "LE_ATOMICS_EXCHANGE", "LE_ATOMICS_ISLOCKFREE", "LE_ATOMICS_LOAD", "LE_ATOMICS_NOTIFY", "LE_ATOMICS_OR", "LE_ATOMICS_STORE", "LE_ATOMICS_SUB", "LE_ATOMICS_WAIT", "LE_ATOMICS_WAITASYNC", "LE_ATOMICS_XOR"];
|
|
1769
|
+
unexportedSymbols.forEach(unexportedRuntimeSymbol);
|
|
1770
|
+
function checkIncomingModuleAPI() {
|
|
1771
|
+
ignoredModuleProp("fetchSettings");
|
|
1772
|
+
}
|
|
1773
|
+
__name(checkIncomingModuleAPI, "checkIncomingModuleAPI");
|
|
1774
|
+
var ASM_CONSTS = {};
|
|
1775
|
+
var _malloc = Module["_malloc"] = makeInvalidEarlyAccess("_malloc");
|
|
1776
|
+
var _calloc = Module["_calloc"] = makeInvalidEarlyAccess("_calloc");
|
|
1777
|
+
var _realloc = Module["_realloc"] = makeInvalidEarlyAccess("_realloc");
|
|
1778
|
+
var _free = Module["_free"] = makeInvalidEarlyAccess("_free");
|
|
1779
|
+
var _ts_range_edit = Module["_ts_range_edit"] = makeInvalidEarlyAccess("_ts_range_edit");
|
|
1780
|
+
var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = makeInvalidEarlyAccess("_ts_language_symbol_count");
|
|
1781
|
+
var _ts_language_state_count = Module["_ts_language_state_count"] = makeInvalidEarlyAccess("_ts_language_state_count");
|
|
1782
|
+
var _ts_language_abi_version = Module["_ts_language_abi_version"] = makeInvalidEarlyAccess("_ts_language_abi_version");
|
|
1783
|
+
var _ts_language_name = Module["_ts_language_name"] = makeInvalidEarlyAccess("_ts_language_name");
|
|
1784
|
+
var _ts_language_field_count = Module["_ts_language_field_count"] = makeInvalidEarlyAccess("_ts_language_field_count");
|
|
1785
|
+
var _ts_language_next_state = Module["_ts_language_next_state"] = makeInvalidEarlyAccess("_ts_language_next_state");
|
|
1786
|
+
var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = makeInvalidEarlyAccess("_ts_language_symbol_name");
|
|
1787
|
+
var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = makeInvalidEarlyAccess("_ts_language_symbol_for_name");
|
|
1788
|
+
var _strncmp = Module["_strncmp"] = makeInvalidEarlyAccess("_strncmp");
|
|
1789
|
+
var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = makeInvalidEarlyAccess("_ts_language_symbol_type");
|
|
1790
|
+
var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = makeInvalidEarlyAccess("_ts_language_field_name_for_id");
|
|
1791
|
+
var _ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_new");
|
|
1792
|
+
var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_delete");
|
|
1793
|
+
var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset_state");
|
|
1794
|
+
var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_reset");
|
|
1795
|
+
var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_next");
|
|
1796
|
+
var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = makeInvalidEarlyAccess("_ts_lookahead_iterator_current_symbol");
|
|
1797
|
+
var _ts_point_edit = Module["_ts_point_edit"] = makeInvalidEarlyAccess("_ts_point_edit");
|
|
1798
|
+
var _ts_parser_delete = Module["_ts_parser_delete"] = makeInvalidEarlyAccess("_ts_parser_delete");
|
|
1799
|
+
var _ts_parser_set_language = Module["_ts_parser_set_language"] = makeInvalidEarlyAccess("_ts_parser_set_language");
|
|
1800
|
+
var _ts_parser_reset = Module["_ts_parser_reset"] = makeInvalidEarlyAccess("_ts_parser_reset");
|
|
1801
|
+
var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = makeInvalidEarlyAccess("_ts_parser_set_included_ranges");
|
|
1802
|
+
var _ts_query_new = Module["_ts_query_new"] = makeInvalidEarlyAccess("_ts_query_new");
|
|
1803
|
+
var _ts_query_delete = Module["_ts_query_delete"] = makeInvalidEarlyAccess("_ts_query_delete");
|
|
1804
|
+
var _iswspace = Module["_iswspace"] = makeInvalidEarlyAccess("_iswspace");
|
|
1805
|
+
var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = makeInvalidEarlyAccess("_ts_query_pattern_count");
|
|
1806
|
+
var _ts_query_capture_count = Module["_ts_query_capture_count"] = makeInvalidEarlyAccess("_ts_query_capture_count");
|
|
1807
|
+
var _ts_query_string_count = Module["_ts_query_string_count"] = makeInvalidEarlyAccess("_ts_query_string_count");
|
|
1808
|
+
var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = makeInvalidEarlyAccess("_ts_query_capture_name_for_id");
|
|
1809
|
+
var _ts_query_capture_quantifier_for_id = Module["_ts_query_capture_quantifier_for_id"] = makeInvalidEarlyAccess("_ts_query_capture_quantifier_for_id");
|
|
1810
|
+
var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = makeInvalidEarlyAccess("_ts_query_string_value_for_id");
|
|
1811
|
+
var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = makeInvalidEarlyAccess("_ts_query_predicates_for_pattern");
|
|
1812
|
+
var _ts_query_start_byte_for_pattern = Module["_ts_query_start_byte_for_pattern"] = makeInvalidEarlyAccess("_ts_query_start_byte_for_pattern");
|
|
1813
|
+
var _ts_query_end_byte_for_pattern = Module["_ts_query_end_byte_for_pattern"] = makeInvalidEarlyAccess("_ts_query_end_byte_for_pattern");
|
|
1814
|
+
var _ts_query_is_pattern_rooted = Module["_ts_query_is_pattern_rooted"] = makeInvalidEarlyAccess("_ts_query_is_pattern_rooted");
|
|
1815
|
+
var _ts_query_is_pattern_non_local = Module["_ts_query_is_pattern_non_local"] = makeInvalidEarlyAccess("_ts_query_is_pattern_non_local");
|
|
1816
|
+
var _ts_query_is_pattern_guaranteed_at_step = Module["_ts_query_is_pattern_guaranteed_at_step"] = makeInvalidEarlyAccess("_ts_query_is_pattern_guaranteed_at_step");
|
|
1817
|
+
var _ts_query_disable_capture = Module["_ts_query_disable_capture"] = makeInvalidEarlyAccess("_ts_query_disable_capture");
|
|
1818
|
+
var _ts_query_disable_pattern = Module["_ts_query_disable_pattern"] = makeInvalidEarlyAccess("_ts_query_disable_pattern");
|
|
1819
|
+
var _memcmp = Module["_memcmp"] = makeInvalidEarlyAccess("_memcmp");
|
|
1820
|
+
var _ts_tree_copy = Module["_ts_tree_copy"] = makeInvalidEarlyAccess("_ts_tree_copy");
|
|
1821
|
+
var _ts_tree_delete = Module["_ts_tree_delete"] = makeInvalidEarlyAccess("_ts_tree_delete");
|
|
1822
|
+
var _iswalnum = Module["_iswalnum"] = makeInvalidEarlyAccess("_iswalnum");
|
|
1823
|
+
var _ts_init = Module["_ts_init"] = makeInvalidEarlyAccess("_ts_init");
|
|
1824
|
+
var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = makeInvalidEarlyAccess("_ts_parser_new_wasm");
|
|
1825
|
+
var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = makeInvalidEarlyAccess("_ts_parser_enable_logger_wasm");
|
|
1826
|
+
var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = makeInvalidEarlyAccess("_ts_parser_parse_wasm");
|
|
1827
|
+
var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = makeInvalidEarlyAccess("_ts_parser_included_ranges_wasm");
|
|
1828
|
+
var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = makeInvalidEarlyAccess("_ts_language_type_is_named_wasm");
|
|
1829
|
+
var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = makeInvalidEarlyAccess("_ts_language_type_is_visible_wasm");
|
|
1830
|
+
var _ts_language_metadata_wasm = Module["_ts_language_metadata_wasm"] = makeInvalidEarlyAccess("_ts_language_metadata_wasm");
|
|
1831
|
+
var _ts_language_supertypes_wasm = Module["_ts_language_supertypes_wasm"] = makeInvalidEarlyAccess("_ts_language_supertypes_wasm");
|
|
1832
|
+
var _ts_language_subtypes_wasm = Module["_ts_language_subtypes_wasm"] = makeInvalidEarlyAccess("_ts_language_subtypes_wasm");
|
|
1833
|
+
var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_root_node_wasm");
|
|
1834
|
+
var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = makeInvalidEarlyAccess("_ts_tree_root_node_with_offset_wasm");
|
|
1835
|
+
var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = makeInvalidEarlyAccess("_ts_tree_edit_wasm");
|
|
1836
|
+
var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = makeInvalidEarlyAccess("_ts_tree_included_ranges_wasm");
|
|
1837
|
+
var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = makeInvalidEarlyAccess("_ts_tree_get_changed_ranges_wasm");
|
|
1838
|
+
var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_new_wasm");
|
|
1839
|
+
var _ts_tree_cursor_copy_wasm = Module["_ts_tree_cursor_copy_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_copy_wasm");
|
|
1840
|
+
var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_delete_wasm");
|
|
1841
|
+
var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_reset_wasm");
|
|
1842
|
+
var _ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_reset_to_wasm");
|
|
1843
|
+
var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_first_child_wasm");
|
|
1844
|
+
var _ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_last_child_wasm");
|
|
1845
|
+
var _ts_tree_cursor_goto_first_child_for_index_wasm = Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_first_child_for_index_wasm");
|
|
1846
|
+
var _ts_tree_cursor_goto_first_child_for_position_wasm = Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_first_child_for_position_wasm");
|
|
1847
|
+
var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_next_sibling_wasm");
|
|
1848
|
+
var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_previous_sibling_wasm");
|
|
1849
|
+
var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_descendant_wasm");
|
|
1850
|
+
var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_goto_parent_wasm");
|
|
1851
|
+
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");
|
|
1852
|
+
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");
|
|
1853
|
+
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");
|
|
1854
|
+
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");
|
|
1855
|
+
var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_id_wasm");
|
|
1856
|
+
var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_position_wasm");
|
|
1857
|
+
var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_position_wasm");
|
|
1858
|
+
var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_start_index_wasm");
|
|
1859
|
+
var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_end_index_wasm");
|
|
1860
|
+
var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_field_id_wasm");
|
|
1861
|
+
var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_depth_wasm");
|
|
1862
|
+
var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_descendant_index_wasm");
|
|
1863
|
+
var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = makeInvalidEarlyAccess("_ts_tree_cursor_current_node_wasm");
|
|
1864
|
+
var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = makeInvalidEarlyAccess("_ts_node_symbol_wasm");
|
|
1865
|
+
var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = makeInvalidEarlyAccess("_ts_node_field_name_for_child_wasm");
|
|
1866
|
+
var _ts_node_field_name_for_named_child_wasm = Module["_ts_node_field_name_for_named_child_wasm"] = makeInvalidEarlyAccess("_ts_node_field_name_for_named_child_wasm");
|
|
1867
|
+
var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = makeInvalidEarlyAccess("_ts_node_children_by_field_id_wasm");
|
|
1868
|
+
var _ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = makeInvalidEarlyAccess("_ts_node_first_child_for_byte_wasm");
|
|
1869
|
+
var _ts_node_first_named_child_for_byte_wasm = Module["_ts_node_first_named_child_for_byte_wasm"] = makeInvalidEarlyAccess("_ts_node_first_named_child_for_byte_wasm");
|
|
1870
|
+
var _ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = makeInvalidEarlyAccess("_ts_node_grammar_symbol_wasm");
|
|
1871
|
+
var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = makeInvalidEarlyAccess("_ts_node_child_count_wasm");
|
|
1872
|
+
var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = makeInvalidEarlyAccess("_ts_node_named_child_count_wasm");
|
|
1873
|
+
var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = makeInvalidEarlyAccess("_ts_node_child_wasm");
|
|
1874
|
+
var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = makeInvalidEarlyAccess("_ts_node_named_child_wasm");
|
|
1875
|
+
var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = makeInvalidEarlyAccess("_ts_node_child_by_field_id_wasm");
|
|
1876
|
+
var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = makeInvalidEarlyAccess("_ts_node_next_sibling_wasm");
|
|
1877
|
+
var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = makeInvalidEarlyAccess("_ts_node_prev_sibling_wasm");
|
|
1878
|
+
var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = makeInvalidEarlyAccess("_ts_node_next_named_sibling_wasm");
|
|
1879
|
+
var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = makeInvalidEarlyAccess("_ts_node_prev_named_sibling_wasm");
|
|
1880
|
+
var _ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = makeInvalidEarlyAccess("_ts_node_descendant_count_wasm");
|
|
1881
|
+
var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = makeInvalidEarlyAccess("_ts_node_parent_wasm");
|
|
1882
|
+
var _ts_node_child_with_descendant_wasm = Module["_ts_node_child_with_descendant_wasm"] = makeInvalidEarlyAccess("_ts_node_child_with_descendant_wasm");
|
|
1883
|
+
var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = makeInvalidEarlyAccess("_ts_node_descendant_for_index_wasm");
|
|
1884
|
+
var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_index_wasm");
|
|
1885
|
+
var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_descendant_for_position_wasm");
|
|
1886
|
+
var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = makeInvalidEarlyAccess("_ts_node_named_descendant_for_position_wasm");
|
|
1887
|
+
var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = makeInvalidEarlyAccess("_ts_node_start_point_wasm");
|
|
1888
|
+
var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = makeInvalidEarlyAccess("_ts_node_end_point_wasm");
|
|
1889
|
+
var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = makeInvalidEarlyAccess("_ts_node_start_index_wasm");
|
|
1890
|
+
var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = makeInvalidEarlyAccess("_ts_node_end_index_wasm");
|
|
1891
|
+
var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = makeInvalidEarlyAccess("_ts_node_to_string_wasm");
|
|
1892
|
+
var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = makeInvalidEarlyAccess("_ts_node_children_wasm");
|
|
1893
|
+
var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = makeInvalidEarlyAccess("_ts_node_named_children_wasm");
|
|
1894
|
+
var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = makeInvalidEarlyAccess("_ts_node_descendants_of_type_wasm");
|
|
1895
|
+
var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = makeInvalidEarlyAccess("_ts_node_is_named_wasm");
|
|
1896
|
+
var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = makeInvalidEarlyAccess("_ts_node_has_changes_wasm");
|
|
1897
|
+
var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = makeInvalidEarlyAccess("_ts_node_has_error_wasm");
|
|
1898
|
+
var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = makeInvalidEarlyAccess("_ts_node_is_error_wasm");
|
|
1899
|
+
var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = makeInvalidEarlyAccess("_ts_node_is_missing_wasm");
|
|
1900
|
+
var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = makeInvalidEarlyAccess("_ts_node_is_extra_wasm");
|
|
1901
|
+
var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_parse_state_wasm");
|
|
1902
|
+
var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = makeInvalidEarlyAccess("_ts_node_next_parse_state_wasm");
|
|
1903
|
+
var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = makeInvalidEarlyAccess("_ts_query_matches_wasm");
|
|
1904
|
+
var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = makeInvalidEarlyAccess("_ts_query_captures_wasm");
|
|
1905
|
+
var _memset = Module["_memset"] = makeInvalidEarlyAccess("_memset");
|
|
1906
|
+
var _memcpy = Module["_memcpy"] = makeInvalidEarlyAccess("_memcpy");
|
|
1907
|
+
var _memmove = Module["_memmove"] = makeInvalidEarlyAccess("_memmove");
|
|
1908
|
+
var _fflush = makeInvalidEarlyAccess("_fflush");
|
|
1909
|
+
var _strlen = Module["_strlen"] = makeInvalidEarlyAccess("_strlen");
|
|
1910
|
+
var _iswalpha = Module["_iswalpha"] = makeInvalidEarlyAccess("_iswalpha");
|
|
1911
|
+
var _iswblank = Module["_iswblank"] = makeInvalidEarlyAccess("_iswblank");
|
|
1912
|
+
var _iswdigit = Module["_iswdigit"] = makeInvalidEarlyAccess("_iswdigit");
|
|
1913
|
+
var _iswlower = Module["_iswlower"] = makeInvalidEarlyAccess("_iswlower");
|
|
1914
|
+
var _iswupper = Module["_iswupper"] = makeInvalidEarlyAccess("_iswupper");
|
|
1915
|
+
var _iswxdigit = Module["_iswxdigit"] = makeInvalidEarlyAccess("_iswxdigit");
|
|
1916
|
+
var _memchr = Module["_memchr"] = makeInvalidEarlyAccess("_memchr");
|
|
1917
|
+
var _emscripten_stack_get_end = makeInvalidEarlyAccess("_emscripten_stack_get_end");
|
|
1918
|
+
var _emscripten_stack_get_base = makeInvalidEarlyAccess("_emscripten_stack_get_base");
|
|
1919
|
+
var _strcmp = Module["_strcmp"] = makeInvalidEarlyAccess("_strcmp");
|
|
1920
|
+
var _strncat = Module["_strncat"] = makeInvalidEarlyAccess("_strncat");
|
|
1921
|
+
var _strncpy = Module["_strncpy"] = makeInvalidEarlyAccess("_strncpy");
|
|
1922
|
+
var _towlower = Module["_towlower"] = makeInvalidEarlyAccess("_towlower");
|
|
1923
|
+
var _towupper = Module["_towupper"] = makeInvalidEarlyAccess("_towupper");
|
|
1924
|
+
var _sbrk = makeInvalidEarlyAccess("_sbrk");
|
|
1925
|
+
var _emscripten_get_sbrk_ptr = makeInvalidEarlyAccess("_emscripten_get_sbrk_ptr");
|
|
1926
|
+
var _setThrew = makeInvalidEarlyAccess("_setThrew");
|
|
1927
|
+
var _emscripten_stack_set_limits = makeInvalidEarlyAccess("_emscripten_stack_set_limits");
|
|
1928
|
+
var _emscripten_stack_get_free = makeInvalidEarlyAccess("_emscripten_stack_get_free");
|
|
1929
|
+
var __emscripten_stack_restore = makeInvalidEarlyAccess("__emscripten_stack_restore");
|
|
1930
|
+
var __emscripten_stack_alloc = makeInvalidEarlyAccess("__emscripten_stack_alloc");
|
|
1931
|
+
var _emscripten_stack_get_current = makeInvalidEarlyAccess("_emscripten_stack_get_current");
|
|
1932
|
+
var ___wasm_apply_data_relocs = makeInvalidEarlyAccess("___wasm_apply_data_relocs");
|
|
1933
|
+
function assignWasmExports(wasmExports2) {
|
|
1934
|
+
Module["_malloc"] = _malloc = createExportWrapper("malloc", 1);
|
|
1935
|
+
Module["_calloc"] = _calloc = createExportWrapper("calloc", 2);
|
|
1936
|
+
Module["_realloc"] = _realloc = createExportWrapper("realloc", 2);
|
|
1937
|
+
Module["_free"] = _free = createExportWrapper("free", 1);
|
|
1938
|
+
Module["_ts_range_edit"] = _ts_range_edit = createExportWrapper("ts_range_edit", 2);
|
|
1939
|
+
Module["_ts_language_symbol_count"] = _ts_language_symbol_count = createExportWrapper("ts_language_symbol_count", 1);
|
|
1940
|
+
Module["_ts_language_state_count"] = _ts_language_state_count = createExportWrapper("ts_language_state_count", 1);
|
|
1941
|
+
Module["_ts_language_abi_version"] = _ts_language_abi_version = createExportWrapper("ts_language_abi_version", 1);
|
|
1942
|
+
Module["_ts_language_name"] = _ts_language_name = createExportWrapper("ts_language_name", 1);
|
|
1943
|
+
Module["_ts_language_field_count"] = _ts_language_field_count = createExportWrapper("ts_language_field_count", 1);
|
|
1944
|
+
Module["_ts_language_next_state"] = _ts_language_next_state = createExportWrapper("ts_language_next_state", 3);
|
|
1945
|
+
Module["_ts_language_symbol_name"] = _ts_language_symbol_name = createExportWrapper("ts_language_symbol_name", 2);
|
|
1946
|
+
Module["_ts_language_symbol_for_name"] = _ts_language_symbol_for_name = createExportWrapper("ts_language_symbol_for_name", 4);
|
|
1947
|
+
Module["_strncmp"] = _strncmp = createExportWrapper("strncmp", 3);
|
|
1948
|
+
Module["_ts_language_symbol_type"] = _ts_language_symbol_type = createExportWrapper("ts_language_symbol_type", 2);
|
|
1949
|
+
Module["_ts_language_field_name_for_id"] = _ts_language_field_name_for_id = createExportWrapper("ts_language_field_name_for_id", 2);
|
|
1950
|
+
Module["_ts_lookahead_iterator_new"] = _ts_lookahead_iterator_new = createExportWrapper("ts_lookahead_iterator_new", 2);
|
|
1951
|
+
Module["_ts_lookahead_iterator_delete"] = _ts_lookahead_iterator_delete = createExportWrapper("ts_lookahead_iterator_delete", 1);
|
|
1952
|
+
Module["_ts_lookahead_iterator_reset_state"] = _ts_lookahead_iterator_reset_state = createExportWrapper("ts_lookahead_iterator_reset_state", 2);
|
|
1953
|
+
Module["_ts_lookahead_iterator_reset"] = _ts_lookahead_iterator_reset = createExportWrapper("ts_lookahead_iterator_reset", 3);
|
|
1954
|
+
Module["_ts_lookahead_iterator_next"] = _ts_lookahead_iterator_next = createExportWrapper("ts_lookahead_iterator_next", 1);
|
|
1955
|
+
Module["_ts_lookahead_iterator_current_symbol"] = _ts_lookahead_iterator_current_symbol = createExportWrapper("ts_lookahead_iterator_current_symbol", 1);
|
|
1956
|
+
Module["_ts_point_edit"] = _ts_point_edit = createExportWrapper("ts_point_edit", 3);
|
|
1957
|
+
Module["_ts_parser_delete"] = _ts_parser_delete = createExportWrapper("ts_parser_delete", 1);
|
|
1958
|
+
Module["_ts_parser_set_language"] = _ts_parser_set_language = createExportWrapper("ts_parser_set_language", 2);
|
|
1959
|
+
Module["_ts_parser_reset"] = _ts_parser_reset = createExportWrapper("ts_parser_reset", 1);
|
|
1960
|
+
Module["_ts_parser_set_included_ranges"] = _ts_parser_set_included_ranges = createExportWrapper("ts_parser_set_included_ranges", 3);
|
|
1961
|
+
Module["_ts_query_new"] = _ts_query_new = createExportWrapper("ts_query_new", 5);
|
|
1962
|
+
Module["_ts_query_delete"] = _ts_query_delete = createExportWrapper("ts_query_delete", 1);
|
|
1963
|
+
Module["_iswspace"] = _iswspace = createExportWrapper("iswspace", 1);
|
|
1964
|
+
Module["_ts_query_pattern_count"] = _ts_query_pattern_count = createExportWrapper("ts_query_pattern_count", 1);
|
|
1965
|
+
Module["_ts_query_capture_count"] = _ts_query_capture_count = createExportWrapper("ts_query_capture_count", 1);
|
|
1966
|
+
Module["_ts_query_string_count"] = _ts_query_string_count = createExportWrapper("ts_query_string_count", 1);
|
|
1967
|
+
Module["_ts_query_capture_name_for_id"] = _ts_query_capture_name_for_id = createExportWrapper("ts_query_capture_name_for_id", 3);
|
|
1968
|
+
Module["_ts_query_capture_quantifier_for_id"] = _ts_query_capture_quantifier_for_id = createExportWrapper("ts_query_capture_quantifier_for_id", 3);
|
|
1969
|
+
Module["_ts_query_string_value_for_id"] = _ts_query_string_value_for_id = createExportWrapper("ts_query_string_value_for_id", 3);
|
|
1970
|
+
Module["_ts_query_predicates_for_pattern"] = _ts_query_predicates_for_pattern = createExportWrapper("ts_query_predicates_for_pattern", 3);
|
|
1971
|
+
Module["_ts_query_start_byte_for_pattern"] = _ts_query_start_byte_for_pattern = createExportWrapper("ts_query_start_byte_for_pattern", 2);
|
|
1972
|
+
Module["_ts_query_end_byte_for_pattern"] = _ts_query_end_byte_for_pattern = createExportWrapper("ts_query_end_byte_for_pattern", 2);
|
|
1973
|
+
Module["_ts_query_is_pattern_rooted"] = _ts_query_is_pattern_rooted = createExportWrapper("ts_query_is_pattern_rooted", 2);
|
|
1974
|
+
Module["_ts_query_is_pattern_non_local"] = _ts_query_is_pattern_non_local = createExportWrapper("ts_query_is_pattern_non_local", 2);
|
|
1975
|
+
Module["_ts_query_is_pattern_guaranteed_at_step"] = _ts_query_is_pattern_guaranteed_at_step = createExportWrapper("ts_query_is_pattern_guaranteed_at_step", 2);
|
|
1976
|
+
Module["_ts_query_disable_capture"] = _ts_query_disable_capture = createExportWrapper("ts_query_disable_capture", 3);
|
|
1977
|
+
Module["_ts_query_disable_pattern"] = _ts_query_disable_pattern = createExportWrapper("ts_query_disable_pattern", 2);
|
|
1978
|
+
Module["_memcmp"] = _memcmp = createExportWrapper("memcmp", 3);
|
|
1979
|
+
Module["_ts_tree_copy"] = _ts_tree_copy = createExportWrapper("ts_tree_copy", 1);
|
|
1980
|
+
Module["_ts_tree_delete"] = _ts_tree_delete = createExportWrapper("ts_tree_delete", 1);
|
|
1981
|
+
Module["_iswalnum"] = _iswalnum = createExportWrapper("iswalnum", 1);
|
|
1982
|
+
Module["_ts_init"] = _ts_init = createExportWrapper("ts_init", 0);
|
|
1983
|
+
Module["_ts_parser_new_wasm"] = _ts_parser_new_wasm = createExportWrapper("ts_parser_new_wasm", 0);
|
|
1984
|
+
Module["_ts_parser_enable_logger_wasm"] = _ts_parser_enable_logger_wasm = createExportWrapper("ts_parser_enable_logger_wasm", 2);
|
|
1985
|
+
Module["_ts_parser_parse_wasm"] = _ts_parser_parse_wasm = createExportWrapper("ts_parser_parse_wasm", 5);
|
|
1986
|
+
Module["_ts_parser_included_ranges_wasm"] = _ts_parser_included_ranges_wasm = createExportWrapper("ts_parser_included_ranges_wasm", 1);
|
|
1987
|
+
Module["_ts_language_type_is_named_wasm"] = _ts_language_type_is_named_wasm = createExportWrapper("ts_language_type_is_named_wasm", 2);
|
|
1988
|
+
Module["_ts_language_type_is_visible_wasm"] = _ts_language_type_is_visible_wasm = createExportWrapper("ts_language_type_is_visible_wasm", 2);
|
|
1989
|
+
Module["_ts_language_metadata_wasm"] = _ts_language_metadata_wasm = createExportWrapper("ts_language_metadata_wasm", 1);
|
|
1990
|
+
Module["_ts_language_supertypes_wasm"] = _ts_language_supertypes_wasm = createExportWrapper("ts_language_supertypes_wasm", 1);
|
|
1991
|
+
Module["_ts_language_subtypes_wasm"] = _ts_language_subtypes_wasm = createExportWrapper("ts_language_subtypes_wasm", 2);
|
|
1992
|
+
Module["_ts_tree_root_node_wasm"] = _ts_tree_root_node_wasm = createExportWrapper("ts_tree_root_node_wasm", 1);
|
|
1993
|
+
Module["_ts_tree_root_node_with_offset_wasm"] = _ts_tree_root_node_with_offset_wasm = createExportWrapper("ts_tree_root_node_with_offset_wasm", 1);
|
|
1994
|
+
Module["_ts_tree_edit_wasm"] = _ts_tree_edit_wasm = createExportWrapper("ts_tree_edit_wasm", 1);
|
|
1995
|
+
Module["_ts_tree_included_ranges_wasm"] = _ts_tree_included_ranges_wasm = createExportWrapper("ts_tree_included_ranges_wasm", 1);
|
|
1996
|
+
Module["_ts_tree_get_changed_ranges_wasm"] = _ts_tree_get_changed_ranges_wasm = createExportWrapper("ts_tree_get_changed_ranges_wasm", 2);
|
|
1997
|
+
Module["_ts_tree_cursor_new_wasm"] = _ts_tree_cursor_new_wasm = createExportWrapper("ts_tree_cursor_new_wasm", 1);
|
|
1998
|
+
Module["_ts_tree_cursor_copy_wasm"] = _ts_tree_cursor_copy_wasm = createExportWrapper("ts_tree_cursor_copy_wasm", 1);
|
|
1999
|
+
Module["_ts_tree_cursor_delete_wasm"] = _ts_tree_cursor_delete_wasm = createExportWrapper("ts_tree_cursor_delete_wasm", 1);
|
|
2000
|
+
Module["_ts_tree_cursor_reset_wasm"] = _ts_tree_cursor_reset_wasm = createExportWrapper("ts_tree_cursor_reset_wasm", 1);
|
|
2001
|
+
Module["_ts_tree_cursor_reset_to_wasm"] = _ts_tree_cursor_reset_to_wasm = createExportWrapper("ts_tree_cursor_reset_to_wasm", 2);
|
|
2002
|
+
Module["_ts_tree_cursor_goto_first_child_wasm"] = _ts_tree_cursor_goto_first_child_wasm = createExportWrapper("ts_tree_cursor_goto_first_child_wasm", 1);
|
|
2003
|
+
Module["_ts_tree_cursor_goto_last_child_wasm"] = _ts_tree_cursor_goto_last_child_wasm = createExportWrapper("ts_tree_cursor_goto_last_child_wasm", 1);
|
|
2004
|
+
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", 1);
|
|
2005
|
+
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);
|
|
2006
|
+
Module["_ts_tree_cursor_goto_next_sibling_wasm"] = _ts_tree_cursor_goto_next_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_next_sibling_wasm", 1);
|
|
2007
|
+
Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = _ts_tree_cursor_goto_previous_sibling_wasm = createExportWrapper("ts_tree_cursor_goto_previous_sibling_wasm", 1);
|
|
2008
|
+
Module["_ts_tree_cursor_goto_descendant_wasm"] = _ts_tree_cursor_goto_descendant_wasm = createExportWrapper("ts_tree_cursor_goto_descendant_wasm", 2);
|
|
2009
|
+
Module["_ts_tree_cursor_goto_parent_wasm"] = _ts_tree_cursor_goto_parent_wasm = createExportWrapper("ts_tree_cursor_goto_parent_wasm", 1);
|
|
2010
|
+
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);
|
|
2011
|
+
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);
|
|
2012
|
+
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);
|
|
2013
|
+
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);
|
|
2014
|
+
Module["_ts_tree_cursor_current_node_id_wasm"] = _ts_tree_cursor_current_node_id_wasm = createExportWrapper("ts_tree_cursor_current_node_id_wasm", 1);
|
|
2015
|
+
Module["_ts_tree_cursor_start_position_wasm"] = _ts_tree_cursor_start_position_wasm = createExportWrapper("ts_tree_cursor_start_position_wasm", 1);
|
|
2016
|
+
Module["_ts_tree_cursor_end_position_wasm"] = _ts_tree_cursor_end_position_wasm = createExportWrapper("ts_tree_cursor_end_position_wasm", 1);
|
|
2017
|
+
Module["_ts_tree_cursor_start_index_wasm"] = _ts_tree_cursor_start_index_wasm = createExportWrapper("ts_tree_cursor_start_index_wasm", 1);
|
|
2018
|
+
Module["_ts_tree_cursor_end_index_wasm"] = _ts_tree_cursor_end_index_wasm = createExportWrapper("ts_tree_cursor_end_index_wasm", 1);
|
|
2019
|
+
Module["_ts_tree_cursor_current_field_id_wasm"] = _ts_tree_cursor_current_field_id_wasm = createExportWrapper("ts_tree_cursor_current_field_id_wasm", 1);
|
|
2020
|
+
Module["_ts_tree_cursor_current_depth_wasm"] = _ts_tree_cursor_current_depth_wasm = createExportWrapper("ts_tree_cursor_current_depth_wasm", 1);
|
|
2021
|
+
Module["_ts_tree_cursor_current_descendant_index_wasm"] = _ts_tree_cursor_current_descendant_index_wasm = createExportWrapper("ts_tree_cursor_current_descendant_index_wasm", 1);
|
|
2022
|
+
Module["_ts_tree_cursor_current_node_wasm"] = _ts_tree_cursor_current_node_wasm = createExportWrapper("ts_tree_cursor_current_node_wasm", 1);
|
|
2023
|
+
Module["_ts_node_symbol_wasm"] = _ts_node_symbol_wasm = createExportWrapper("ts_node_symbol_wasm", 1);
|
|
2024
|
+
Module["_ts_node_field_name_for_child_wasm"] = _ts_node_field_name_for_child_wasm = createExportWrapper("ts_node_field_name_for_child_wasm", 2);
|
|
2025
|
+
Module["_ts_node_field_name_for_named_child_wasm"] = _ts_node_field_name_for_named_child_wasm = createExportWrapper("ts_node_field_name_for_named_child_wasm", 2);
|
|
2026
|
+
Module["_ts_node_children_by_field_id_wasm"] = _ts_node_children_by_field_id_wasm = createExportWrapper("ts_node_children_by_field_id_wasm", 2);
|
|
2027
|
+
Module["_ts_node_first_child_for_byte_wasm"] = _ts_node_first_child_for_byte_wasm = createExportWrapper("ts_node_first_child_for_byte_wasm", 1);
|
|
2028
|
+
Module["_ts_node_first_named_child_for_byte_wasm"] = _ts_node_first_named_child_for_byte_wasm = createExportWrapper("ts_node_first_named_child_for_byte_wasm", 1);
|
|
2029
|
+
Module["_ts_node_grammar_symbol_wasm"] = _ts_node_grammar_symbol_wasm = createExportWrapper("ts_node_grammar_symbol_wasm", 1);
|
|
2030
|
+
Module["_ts_node_child_count_wasm"] = _ts_node_child_count_wasm = createExportWrapper("ts_node_child_count_wasm", 1);
|
|
2031
|
+
Module["_ts_node_named_child_count_wasm"] = _ts_node_named_child_count_wasm = createExportWrapper("ts_node_named_child_count_wasm", 1);
|
|
2032
|
+
Module["_ts_node_child_wasm"] = _ts_node_child_wasm = createExportWrapper("ts_node_child_wasm", 2);
|
|
2033
|
+
Module["_ts_node_named_child_wasm"] = _ts_node_named_child_wasm = createExportWrapper("ts_node_named_child_wasm", 2);
|
|
2034
|
+
Module["_ts_node_child_by_field_id_wasm"] = _ts_node_child_by_field_id_wasm = createExportWrapper("ts_node_child_by_field_id_wasm", 2);
|
|
2035
|
+
Module["_ts_node_next_sibling_wasm"] = _ts_node_next_sibling_wasm = createExportWrapper("ts_node_next_sibling_wasm", 1);
|
|
2036
|
+
Module["_ts_node_prev_sibling_wasm"] = _ts_node_prev_sibling_wasm = createExportWrapper("ts_node_prev_sibling_wasm", 1);
|
|
2037
|
+
Module["_ts_node_next_named_sibling_wasm"] = _ts_node_next_named_sibling_wasm = createExportWrapper("ts_node_next_named_sibling_wasm", 1);
|
|
2038
|
+
Module["_ts_node_prev_named_sibling_wasm"] = _ts_node_prev_named_sibling_wasm = createExportWrapper("ts_node_prev_named_sibling_wasm", 1);
|
|
2039
|
+
Module["_ts_node_descendant_count_wasm"] = _ts_node_descendant_count_wasm = createExportWrapper("ts_node_descendant_count_wasm", 1);
|
|
2040
|
+
Module["_ts_node_parent_wasm"] = _ts_node_parent_wasm = createExportWrapper("ts_node_parent_wasm", 1);
|
|
2041
|
+
Module["_ts_node_child_with_descendant_wasm"] = _ts_node_child_with_descendant_wasm = createExportWrapper("ts_node_child_with_descendant_wasm", 1);
|
|
2042
|
+
Module["_ts_node_descendant_for_index_wasm"] = _ts_node_descendant_for_index_wasm = createExportWrapper("ts_node_descendant_for_index_wasm", 1);
|
|
2043
|
+
Module["_ts_node_named_descendant_for_index_wasm"] = _ts_node_named_descendant_for_index_wasm = createExportWrapper("ts_node_named_descendant_for_index_wasm", 1);
|
|
2044
|
+
Module["_ts_node_descendant_for_position_wasm"] = _ts_node_descendant_for_position_wasm = createExportWrapper("ts_node_descendant_for_position_wasm", 1);
|
|
2045
|
+
Module["_ts_node_named_descendant_for_position_wasm"] = _ts_node_named_descendant_for_position_wasm = createExportWrapper("ts_node_named_descendant_for_position_wasm", 1);
|
|
2046
|
+
Module["_ts_node_start_point_wasm"] = _ts_node_start_point_wasm = createExportWrapper("ts_node_start_point_wasm", 1);
|
|
2047
|
+
Module["_ts_node_end_point_wasm"] = _ts_node_end_point_wasm = createExportWrapper("ts_node_end_point_wasm", 1);
|
|
2048
|
+
Module["_ts_node_start_index_wasm"] = _ts_node_start_index_wasm = createExportWrapper("ts_node_start_index_wasm", 1);
|
|
2049
|
+
Module["_ts_node_end_index_wasm"] = _ts_node_end_index_wasm = createExportWrapper("ts_node_end_index_wasm", 1);
|
|
2050
|
+
Module["_ts_node_to_string_wasm"] = _ts_node_to_string_wasm = createExportWrapper("ts_node_to_string_wasm", 1);
|
|
2051
|
+
Module["_ts_node_children_wasm"] = _ts_node_children_wasm = createExportWrapper("ts_node_children_wasm", 1);
|
|
2052
|
+
Module["_ts_node_named_children_wasm"] = _ts_node_named_children_wasm = createExportWrapper("ts_node_named_children_wasm", 1);
|
|
2053
|
+
Module["_ts_node_descendants_of_type_wasm"] = _ts_node_descendants_of_type_wasm = createExportWrapper("ts_node_descendants_of_type_wasm", 7);
|
|
2054
|
+
Module["_ts_node_is_named_wasm"] = _ts_node_is_named_wasm = createExportWrapper("ts_node_is_named_wasm", 1);
|
|
2055
|
+
Module["_ts_node_has_changes_wasm"] = _ts_node_has_changes_wasm = createExportWrapper("ts_node_has_changes_wasm", 1);
|
|
2056
|
+
Module["_ts_node_has_error_wasm"] = _ts_node_has_error_wasm = createExportWrapper("ts_node_has_error_wasm", 1);
|
|
2057
|
+
Module["_ts_node_is_error_wasm"] = _ts_node_is_error_wasm = createExportWrapper("ts_node_is_error_wasm", 1);
|
|
2058
|
+
Module["_ts_node_is_missing_wasm"] = _ts_node_is_missing_wasm = createExportWrapper("ts_node_is_missing_wasm", 1);
|
|
2059
|
+
Module["_ts_node_is_extra_wasm"] = _ts_node_is_extra_wasm = createExportWrapper("ts_node_is_extra_wasm", 1);
|
|
2060
|
+
Module["_ts_node_parse_state_wasm"] = _ts_node_parse_state_wasm = createExportWrapper("ts_node_parse_state_wasm", 1);
|
|
2061
|
+
Module["_ts_node_next_parse_state_wasm"] = _ts_node_next_parse_state_wasm = createExportWrapper("ts_node_next_parse_state_wasm", 1);
|
|
2062
|
+
Module["_ts_query_matches_wasm"] = _ts_query_matches_wasm = createExportWrapper("ts_query_matches_wasm", 16);
|
|
2063
|
+
Module["_ts_query_captures_wasm"] = _ts_query_captures_wasm = createExportWrapper("ts_query_captures_wasm", 16);
|
|
2064
|
+
Module["_memset"] = _memset = createExportWrapper("memset", 3);
|
|
2065
|
+
Module["_memcpy"] = _memcpy = createExportWrapper("memcpy", 3);
|
|
2066
|
+
Module["_memmove"] = _memmove = createExportWrapper("memmove", 3);
|
|
2067
|
+
_fflush = createExportWrapper("fflush", 1);
|
|
2068
|
+
Module["_strlen"] = _strlen = createExportWrapper("strlen", 1);
|
|
2069
|
+
Module["_iswalpha"] = _iswalpha = createExportWrapper("iswalpha", 1);
|
|
2070
|
+
Module["_iswblank"] = _iswblank = createExportWrapper("iswblank", 1);
|
|
2071
|
+
Module["_iswdigit"] = _iswdigit = createExportWrapper("iswdigit", 1);
|
|
2072
|
+
Module["_iswlower"] = _iswlower = createExportWrapper("iswlower", 1);
|
|
2073
|
+
Module["_iswupper"] = _iswupper = createExportWrapper("iswupper", 1);
|
|
2074
|
+
Module["_iswxdigit"] = _iswxdigit = createExportWrapper("iswxdigit", 1);
|
|
2075
|
+
Module["_memchr"] = _memchr = createExportWrapper("memchr", 3);
|
|
2076
|
+
_emscripten_stack_get_end = wasmExports2["emscripten_stack_get_end"];
|
|
2077
|
+
_emscripten_stack_get_base = wasmExports2["emscripten_stack_get_base"];
|
|
2078
|
+
Module["_strcmp"] = _strcmp = createExportWrapper("strcmp", 2);
|
|
2079
|
+
Module["_strncat"] = _strncat = createExportWrapper("strncat", 3);
|
|
2080
|
+
Module["_strncpy"] = _strncpy = createExportWrapper("strncpy", 3);
|
|
2081
|
+
Module["_towlower"] = _towlower = createExportWrapper("towlower", 1);
|
|
2082
|
+
Module["_towupper"] = _towupper = createExportWrapper("towupper", 1);
|
|
2083
|
+
_sbrk = createExportWrapper("sbrk", 1);
|
|
2084
|
+
_emscripten_get_sbrk_ptr = createExportWrapper("emscripten_get_sbrk_ptr", 0);
|
|
2085
|
+
_setThrew = createExportWrapper("setThrew", 2);
|
|
2086
|
+
_emscripten_stack_set_limits = wasmExports2["emscripten_stack_set_limits"];
|
|
2087
|
+
_emscripten_stack_get_free = wasmExports2["emscripten_stack_get_free"];
|
|
2088
|
+
__emscripten_stack_restore = wasmExports2["_emscripten_stack_restore"];
|
|
2089
|
+
__emscripten_stack_alloc = wasmExports2["_emscripten_stack_alloc"];
|
|
2090
|
+
_emscripten_stack_get_current = wasmExports2["emscripten_stack_get_current"];
|
|
2091
|
+
___wasm_apply_data_relocs = createExportWrapper("__wasm_apply_data_relocs", 0);
|
|
2092
|
+
}
|
|
2093
|
+
__name(assignWasmExports, "assignWasmExports");
|
|
2094
|
+
var wasmImports = {
|
|
2095
|
+
/** @export */
|
|
2096
|
+
__heap_base: ___heap_base,
|
|
2097
|
+
/** @export */
|
|
2098
|
+
__indirect_function_table: wasmTable,
|
|
2099
|
+
/** @export */
|
|
2100
|
+
__memory_base: ___memory_base,
|
|
2101
|
+
/** @export */
|
|
2102
|
+
__stack_high: ___stack_high,
|
|
2103
|
+
/** @export */
|
|
2104
|
+
__stack_low: ___stack_low,
|
|
2105
|
+
/** @export */
|
|
2106
|
+
__stack_pointer: ___stack_pointer,
|
|
2107
|
+
/** @export */
|
|
2108
|
+
__table_base: ___table_base,
|
|
2109
|
+
/** @export */
|
|
2110
|
+
_abort_js: __abort_js,
|
|
2111
|
+
/** @export */
|
|
2112
|
+
alignfault,
|
|
2113
|
+
/** @export */
|
|
2114
|
+
emscripten_resize_heap: _emscripten_resize_heap,
|
|
2115
|
+
/** @export */
|
|
2116
|
+
fd_close: _fd_close,
|
|
2117
|
+
/** @export */
|
|
2118
|
+
fd_seek: _fd_seek,
|
|
2119
|
+
/** @export */
|
|
2120
|
+
fd_write: _fd_write,
|
|
2121
|
+
/** @export */
|
|
2122
|
+
memory: wasmMemory,
|
|
2123
|
+
/** @export */
|
|
2124
|
+
segfault,
|
|
2125
|
+
/** @export */
|
|
2126
|
+
tree_sitter_log_callback: _tree_sitter_log_callback,
|
|
2127
|
+
/** @export */
|
|
2128
|
+
tree_sitter_parse_callback: _tree_sitter_parse_callback,
|
|
2129
|
+
/** @export */
|
|
2130
|
+
tree_sitter_progress_callback: _tree_sitter_progress_callback,
|
|
2131
|
+
/** @export */
|
|
2132
|
+
tree_sitter_query_progress_callback: _tree_sitter_query_progress_callback
|
|
2133
|
+
};
|
|
2134
|
+
var calledRun;
|
|
2135
|
+
function callMain(args2 = []) {
|
|
2136
|
+
assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])');
|
|
2137
|
+
assert(typeof onPreRuns === "undefined" || onPreRuns.length == 0, "cannot call main when preRun functions remain to be called");
|
|
2138
|
+
var entryFunction = resolveGlobalSymbol("main").sym;
|
|
2139
|
+
if (!entryFunction) return;
|
|
2140
|
+
args2.unshift(thisProgram);
|
|
2141
|
+
var argc = args2.length;
|
|
2142
|
+
var argv = stackAlloc((argc + 1) * 4);
|
|
2143
|
+
var argv_ptr = argv;
|
|
2144
|
+
args2.forEach((arg) => {
|
|
2145
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing") * 4, stringToUTF8OnStack(arg));
|
|
2146
|
+
argv_ptr += 4;
|
|
2147
|
+
});
|
|
2148
|
+
LE_HEAP_STORE_U32(SAFE_HEAP_INDEX(HEAPU32, argv_ptr >> 2, "storing") * 4, 0);
|
|
2149
|
+
try {
|
|
2150
|
+
var ret = entryFunction(argc, argv);
|
|
2151
|
+
exitJS(
|
|
2152
|
+
ret,
|
|
2153
|
+
/* implicit = */
|
|
2154
|
+
true
|
|
2155
|
+
);
|
|
2156
|
+
return ret;
|
|
2157
|
+
} catch (e) {
|
|
2158
|
+
return handleException(e);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
__name(callMain, "callMain");
|
|
2162
|
+
function stackCheckInit() {
|
|
2163
|
+
_emscripten_stack_set_limits(78224, 12688);
|
|
2164
|
+
writeStackCookie();
|
|
2165
|
+
}
|
|
2166
|
+
__name(stackCheckInit, "stackCheckInit");
|
|
2167
|
+
function run(args2 = arguments_) {
|
|
2168
|
+
if (runDependencies > 0) {
|
|
2169
|
+
dependenciesFulfilled = run;
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
2172
|
+
stackCheckInit();
|
|
2173
|
+
preRun();
|
|
2174
|
+
if (runDependencies > 0) {
|
|
2175
|
+
dependenciesFulfilled = run;
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
function doRun() {
|
|
2179
|
+
assert(!calledRun);
|
|
2180
|
+
calledRun = true;
|
|
2181
|
+
Module["calledRun"] = true;
|
|
2182
|
+
if (ABORT) return;
|
|
2183
|
+
initRuntime();
|
|
2184
|
+
preMain();
|
|
2185
|
+
readyPromiseResolve?.(Module);
|
|
2186
|
+
Module["onRuntimeInitialized"]?.();
|
|
2187
|
+
consumedModuleProp("onRuntimeInitialized");
|
|
2188
|
+
var noInitialRun = Module["noInitialRun"] || false;
|
|
2189
|
+
if (!noInitialRun) callMain(args2);
|
|
2190
|
+
postRun();
|
|
2191
|
+
}
|
|
2192
|
+
__name(doRun, "doRun");
|
|
2193
|
+
if (Module["setStatus"]) {
|
|
2194
|
+
Module["setStatus"]("Running...");
|
|
2195
|
+
setTimeout(() => {
|
|
2196
|
+
setTimeout(() => Module["setStatus"](""), 1);
|
|
2197
|
+
doRun();
|
|
2198
|
+
}, 1);
|
|
2199
|
+
} else {
|
|
2200
|
+
doRun();
|
|
2201
|
+
}
|
|
2202
|
+
checkStackCookie();
|
|
2203
|
+
}
|
|
2204
|
+
__name(run, "run");
|
|
2205
|
+
function checkUnflushedContent() {
|
|
2206
|
+
var oldOut = out;
|
|
2207
|
+
var oldErr = err;
|
|
2208
|
+
var has = false;
|
|
2209
|
+
out = err = /* @__PURE__ */ __name((x) => {
|
|
2210
|
+
has = true;
|
|
2211
|
+
}, "err");
|
|
2212
|
+
try {
|
|
2213
|
+
flush_NO_FILESYSTEM();
|
|
2214
|
+
} catch (e) {
|
|
2215
|
+
}
|
|
2216
|
+
out = oldOut;
|
|
2217
|
+
err = oldErr;
|
|
2218
|
+
if (has) {
|
|
2219
|
+
warnOnce("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.");
|
|
2220
|
+
warnOnce("(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)");
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
__name(checkUnflushedContent, "checkUnflushedContent");
|
|
2224
|
+
var wasmExports;
|
|
2225
|
+
wasmExports = await createWasm();
|
|
2226
|
+
run();
|
|
2227
|
+
if (runtimeInitialized) {
|
|
2228
|
+
moduleRtn = Module;
|
|
2229
|
+
} else {
|
|
2230
|
+
moduleRtn = new Promise((resolve, reject) => {
|
|
2231
|
+
readyPromiseResolve = resolve;
|
|
2232
|
+
readyPromiseReject = reject;
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
for (const prop of Object.keys(Module)) {
|
|
2236
|
+
if (!(prop in moduleArg)) {
|
|
2237
|
+
Object.defineProperty(moduleArg, prop, {
|
|
2238
|
+
configurable: true,
|
|
2239
|
+
get() {
|
|
2240
|
+
abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`);
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
return moduleRtn;
|
|
2246
|
+
};
|
|
2247
|
+
})();
|
|
2248
|
+
if (typeof exports === "object" && typeof module === "object") {
|
|
2249
|
+
module.exports = Module;
|
|
2250
|
+
module.exports.default = Module;
|
|
2251
|
+
} else if (typeof define === "function" && define["amd"])
|
|
2252
|
+
define([], () => Module);
|
|
2253
|
+
}
|
|
2254
|
+
});
|
|
2255
|
+
|
|
2256
|
+
// src/index.ts
|
|
2257
|
+
var index_exports = {};
|
|
2258
|
+
__export(index_exports, {
|
|
2259
|
+
CaptureQuantifier: () => CaptureQuantifier,
|
|
2260
|
+
Edit: () => Edit,
|
|
2261
|
+
LANGUAGE_VERSION: () => LANGUAGE_VERSION,
|
|
2262
|
+
Language: () => Language,
|
|
2263
|
+
LookaheadIterator: () => LookaheadIterator,
|
|
2264
|
+
MIN_COMPATIBLE_VERSION: () => MIN_COMPATIBLE_VERSION,
|
|
2265
|
+
Node: () => Node,
|
|
2266
|
+
Parser: () => Parser,
|
|
2267
|
+
Query: () => Query,
|
|
2268
|
+
Tree: () => Tree,
|
|
2269
|
+
TreeCursor: () => TreeCursor
|
|
2270
|
+
});
|
|
2271
|
+
module.exports = __toCommonJS(index_exports);
|
|
2272
|
+
|
|
2273
|
+
// src/edit.ts
|
|
2274
|
+
var Edit = class {
|
|
2275
|
+
static {
|
|
2276
|
+
__name(this, "Edit");
|
|
2277
|
+
}
|
|
2278
|
+
/** The start position of the change. */
|
|
2279
|
+
startPosition;
|
|
2280
|
+
/** The end position of the change before the edit. */
|
|
2281
|
+
oldEndPosition;
|
|
2282
|
+
/** The end position of the change after the edit. */
|
|
2283
|
+
newEndPosition;
|
|
2284
|
+
/** The start index of the change. */
|
|
2285
|
+
startIndex;
|
|
2286
|
+
/** The end index of the change before the edit. */
|
|
2287
|
+
oldEndIndex;
|
|
2288
|
+
/** The end index of the change after the edit. */
|
|
2289
|
+
newEndIndex;
|
|
2290
|
+
constructor({
|
|
2291
|
+
startIndex,
|
|
2292
|
+
oldEndIndex,
|
|
2293
|
+
newEndIndex,
|
|
2294
|
+
startPosition,
|
|
2295
|
+
oldEndPosition,
|
|
2296
|
+
newEndPosition
|
|
2297
|
+
}) {
|
|
2298
|
+
this.startIndex = startIndex >>> 0;
|
|
2299
|
+
this.oldEndIndex = oldEndIndex >>> 0;
|
|
2300
|
+
this.newEndIndex = newEndIndex >>> 0;
|
|
2301
|
+
this.startPosition = startPosition;
|
|
2302
|
+
this.oldEndPosition = oldEndPosition;
|
|
2303
|
+
this.newEndPosition = newEndPosition;
|
|
2304
|
+
}
|
|
2305
|
+
/**
|
|
2306
|
+
* Edit a point and index to keep it in-sync with source code that has been edited.
|
|
2307
|
+
*
|
|
2308
|
+
* This function updates a single point's byte offset and row/column position
|
|
2309
|
+
* based on an edit operation. This is useful for editing points without
|
|
2310
|
+
* requiring a tree or node instance.
|
|
2311
|
+
*/
|
|
2312
|
+
editPoint(point, index) {
|
|
2313
|
+
let newIndex = index;
|
|
2314
|
+
const newPoint = { ...point };
|
|
2315
|
+
if (index >= this.oldEndIndex) {
|
|
2316
|
+
newIndex = this.newEndIndex + (index - this.oldEndIndex);
|
|
2317
|
+
const originalRow = point.row;
|
|
2318
|
+
newPoint.row = this.newEndPosition.row + (point.row - this.oldEndPosition.row);
|
|
2319
|
+
newPoint.column = originalRow === this.oldEndPosition.row ? this.newEndPosition.column + (point.column - this.oldEndPosition.column) : point.column;
|
|
2320
|
+
} else if (index > this.startIndex) {
|
|
2321
|
+
newIndex = this.newEndIndex;
|
|
2322
|
+
newPoint.row = this.newEndPosition.row;
|
|
2323
|
+
newPoint.column = this.newEndPosition.column;
|
|
2324
|
+
}
|
|
2325
|
+
return { point: newPoint, index: newIndex };
|
|
2326
|
+
}
|
|
2327
|
+
/**
|
|
2328
|
+
* Edit a range to keep it in-sync with source code that has been edited.
|
|
2329
|
+
*
|
|
2330
|
+
* This function updates a range's start and end positions based on an edit
|
|
2331
|
+
* operation. This is useful for editing ranges without requiring a tree
|
|
2332
|
+
* or node instance.
|
|
2333
|
+
*/
|
|
2334
|
+
editRange(range) {
|
|
2335
|
+
const newRange = {
|
|
2336
|
+
startIndex: range.startIndex,
|
|
2337
|
+
startPosition: { ...range.startPosition },
|
|
2338
|
+
endIndex: range.endIndex,
|
|
2339
|
+
endPosition: { ...range.endPosition }
|
|
2340
|
+
};
|
|
2341
|
+
if (range.endIndex >= this.oldEndIndex) {
|
|
2342
|
+
if (range.endIndex !== Number.MAX_SAFE_INTEGER) {
|
|
2343
|
+
newRange.endIndex = this.newEndIndex + (range.endIndex - this.oldEndIndex);
|
|
2344
|
+
newRange.endPosition = {
|
|
2345
|
+
row: this.newEndPosition.row + (range.endPosition.row - this.oldEndPosition.row),
|
|
2346
|
+
column: range.endPosition.row === this.oldEndPosition.row ? this.newEndPosition.column + (range.endPosition.column - this.oldEndPosition.column) : range.endPosition.column
|
|
2347
|
+
};
|
|
2348
|
+
if (newRange.endIndex < this.newEndIndex) {
|
|
2349
|
+
newRange.endIndex = Number.MAX_SAFE_INTEGER;
|
|
2350
|
+
newRange.endPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
} else if (range.endIndex > this.startIndex) {
|
|
2354
|
+
newRange.endIndex = this.startIndex;
|
|
2355
|
+
newRange.endPosition = { ...this.startPosition };
|
|
2356
|
+
}
|
|
2357
|
+
if (range.startIndex >= this.oldEndIndex) {
|
|
2358
|
+
newRange.startIndex = this.newEndIndex + (range.startIndex - this.oldEndIndex);
|
|
2359
|
+
newRange.startPosition = {
|
|
2360
|
+
row: this.newEndPosition.row + (range.startPosition.row - this.oldEndPosition.row),
|
|
2361
|
+
column: range.startPosition.row === this.oldEndPosition.row ? this.newEndPosition.column + (range.startPosition.column - this.oldEndPosition.column) : range.startPosition.column
|
|
2362
|
+
};
|
|
2363
|
+
if (newRange.startIndex < this.newEndIndex) {
|
|
2364
|
+
newRange.startIndex = Number.MAX_SAFE_INTEGER;
|
|
2365
|
+
newRange.startPosition = { row: Number.MAX_SAFE_INTEGER, column: Number.MAX_SAFE_INTEGER };
|
|
2366
|
+
}
|
|
2367
|
+
} else if (range.startIndex > this.startIndex) {
|
|
2368
|
+
newRange.startIndex = this.startIndex;
|
|
2369
|
+
newRange.startPosition = { ...this.startPosition };
|
|
2370
|
+
}
|
|
2371
|
+
return newRange;
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
|
|
2375
|
+
// src/constants.ts
|
|
2376
|
+
var SIZE_OF_SHORT = 2;
|
|
2377
|
+
var SIZE_OF_INT = 4;
|
|
2378
|
+
var SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
|
|
2379
|
+
var SIZE_OF_NODE = 5 * SIZE_OF_INT;
|
|
2380
|
+
var SIZE_OF_POINT = 2 * SIZE_OF_INT;
|
|
2381
|
+
var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
|
|
2382
|
+
var ZERO_POINT = { row: 0, column: 0 };
|
|
2383
|
+
var INTERNAL = /* @__PURE__ */ Symbol("INTERNAL");
|
|
2384
|
+
function assertInternal(x) {
|
|
2385
|
+
if (x !== INTERNAL) throw new Error("Illegal constructor");
|
|
2386
|
+
}
|
|
2387
|
+
__name(assertInternal, "assertInternal");
|
|
2388
|
+
function isPoint(point) {
|
|
2389
|
+
return !!point && typeof point.row === "number" && typeof point.column === "number";
|
|
2390
|
+
}
|
|
2391
|
+
__name(isPoint, "isPoint");
|
|
2392
|
+
function setModule(module2) {
|
|
2393
|
+
C = module2;
|
|
2394
|
+
}
|
|
2395
|
+
__name(setModule, "setModule");
|
|
2396
|
+
var C;
|
|
2397
|
+
|
|
2398
|
+
// src/lookahead_iterator.ts
|
|
2399
|
+
var LookaheadIterator = class {
|
|
2400
|
+
static {
|
|
2401
|
+
__name(this, "LookaheadIterator");
|
|
2402
|
+
}
|
|
2403
|
+
/** @internal */
|
|
2404
|
+
[0] = 0;
|
|
2405
|
+
// Internal handle for Wasm
|
|
2406
|
+
/** @internal */
|
|
2407
|
+
language;
|
|
2408
|
+
/** @internal */
|
|
2409
|
+
constructor(internal, address, language) {
|
|
2410
|
+
assertInternal(internal);
|
|
2411
|
+
this[0] = address;
|
|
2412
|
+
this.language = language;
|
|
2413
|
+
}
|
|
2414
|
+
/** Get the current symbol of the lookahead iterator. */
|
|
2415
|
+
get currentTypeId() {
|
|
2416
|
+
return C._ts_lookahead_iterator_current_symbol(this[0]);
|
|
2417
|
+
}
|
|
2418
|
+
/** Get the current symbol name of the lookahead iterator. */
|
|
2419
|
+
get currentType() {
|
|
2420
|
+
return this.language.types[this.currentTypeId] || "ERROR";
|
|
2421
|
+
}
|
|
2422
|
+
/** Delete the lookahead iterator, freeing its resources. */
|
|
2423
|
+
delete() {
|
|
2424
|
+
C._ts_lookahead_iterator_delete(this[0]);
|
|
2425
|
+
this[0] = 0;
|
|
2426
|
+
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Reset the lookahead iterator.
|
|
2429
|
+
*
|
|
2430
|
+
* This returns `true` if the language was set successfully and `false`
|
|
2431
|
+
* otherwise.
|
|
2432
|
+
*/
|
|
2433
|
+
reset(language, stateId) {
|
|
2434
|
+
if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
|
|
2435
|
+
this.language = language;
|
|
2436
|
+
return true;
|
|
2437
|
+
}
|
|
2438
|
+
return false;
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Reset the lookahead iterator to another state.
|
|
2442
|
+
*
|
|
2443
|
+
* This returns `true` if the iterator was reset to the given state and
|
|
2444
|
+
* `false` otherwise.
|
|
2445
|
+
*/
|
|
2446
|
+
resetState(stateId) {
|
|
2447
|
+
return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* Returns an iterator that iterates over the symbols of the lookahead iterator.
|
|
2451
|
+
*
|
|
2452
|
+
* The iterator will yield the current symbol name as a string for each step
|
|
2453
|
+
* until there are no more symbols to iterate over.
|
|
2454
|
+
*/
|
|
2455
|
+
[Symbol.iterator]() {
|
|
2456
|
+
return {
|
|
2457
|
+
next: /* @__PURE__ */ __name(() => {
|
|
2458
|
+
if (C._ts_lookahead_iterator_next(this[0])) {
|
|
2459
|
+
return { done: false, value: this.currentType };
|
|
2460
|
+
}
|
|
2461
|
+
return { done: true, value: "" };
|
|
2462
|
+
}, "next")
|
|
2463
|
+
};
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
|
|
2467
|
+
// src/tree.ts
|
|
2468
|
+
function getText(tree, startIndex, endIndex, startPosition) {
|
|
2469
|
+
const length = endIndex - startIndex;
|
|
2470
|
+
let result = tree.textCallback(startIndex, startPosition);
|
|
2471
|
+
if (result) {
|
|
2472
|
+
startIndex += result.length;
|
|
2473
|
+
while (startIndex < endIndex) {
|
|
2474
|
+
const string = tree.textCallback(startIndex, startPosition);
|
|
2475
|
+
if (string && string.length > 0) {
|
|
2476
|
+
startIndex += string.length;
|
|
2477
|
+
result += string;
|
|
2478
|
+
} else {
|
|
2479
|
+
break;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
if (startIndex > endIndex) {
|
|
2483
|
+
result = result.slice(0, length);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
return result ?? "";
|
|
2487
|
+
}
|
|
2488
|
+
__name(getText, "getText");
|
|
2489
|
+
var Tree = class _Tree {
|
|
2490
|
+
static {
|
|
2491
|
+
__name(this, "Tree");
|
|
2492
|
+
}
|
|
2493
|
+
/** @internal */
|
|
2494
|
+
[0] = 0;
|
|
2495
|
+
// Internal handle for Wasm
|
|
2496
|
+
/** @internal */
|
|
2497
|
+
textCallback;
|
|
2498
|
+
/** The language that was used to parse the syntax tree. */
|
|
2499
|
+
language;
|
|
2500
|
+
/** @internal */
|
|
2501
|
+
constructor(internal, address, language, textCallback) {
|
|
2502
|
+
assertInternal(internal);
|
|
2503
|
+
this[0] = address;
|
|
2504
|
+
this.language = language;
|
|
2505
|
+
this.textCallback = textCallback;
|
|
2506
|
+
}
|
|
2507
|
+
/** Create a shallow copy of the syntax tree. This is very fast. */
|
|
2508
|
+
copy() {
|
|
2509
|
+
const address = C._ts_tree_copy(this[0]);
|
|
2510
|
+
return new _Tree(INTERNAL, address, this.language, this.textCallback);
|
|
2511
|
+
}
|
|
2512
|
+
/** Delete the syntax tree, freeing its resources. */
|
|
2513
|
+
delete() {
|
|
2514
|
+
C._ts_tree_delete(this[0]);
|
|
2515
|
+
this[0] = 0;
|
|
2516
|
+
}
|
|
2517
|
+
/** Get the root node of the syntax tree. */
|
|
2518
|
+
get rootNode() {
|
|
2519
|
+
C._ts_tree_root_node_wasm(this[0]);
|
|
2520
|
+
return unmarshalNode(this);
|
|
2521
|
+
}
|
|
2522
|
+
/**
|
|
2523
|
+
* Get the root node of the syntax tree, but with its position shifted
|
|
2524
|
+
* forward by the given offset.
|
|
2525
|
+
*/
|
|
2526
|
+
rootNodeWithOffset(offsetBytes, offsetExtent) {
|
|
2527
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
2528
|
+
C.setValue(address, offsetBytes, "i32");
|
|
2529
|
+
marshalPoint(address + SIZE_OF_INT, offsetExtent);
|
|
2530
|
+
C._ts_tree_root_node_with_offset_wasm(this[0]);
|
|
2531
|
+
return unmarshalNode(this);
|
|
2532
|
+
}
|
|
2533
|
+
/**
|
|
2534
|
+
* Edit the syntax tree to keep it in sync with source code that has been
|
|
2535
|
+
* edited.
|
|
2536
|
+
*
|
|
2537
|
+
* You must describe the edit both in terms of byte offsets and in terms of
|
|
2538
|
+
* row/column coordinates.
|
|
2539
|
+
*/
|
|
2540
|
+
edit(edit) {
|
|
2541
|
+
marshalEdit(edit);
|
|
2542
|
+
C._ts_tree_edit_wasm(this[0]);
|
|
2543
|
+
}
|
|
2544
|
+
/** Create a new {@link TreeCursor} starting from the root of the tree. */
|
|
2545
|
+
walk() {
|
|
2546
|
+
return this.rootNode.walk();
|
|
2547
|
+
}
|
|
2548
|
+
/**
|
|
2549
|
+
* Compare this old edited syntax tree to a new syntax tree representing
|
|
2550
|
+
* the same document, returning a sequence of ranges whose syntactic
|
|
2551
|
+
* structure has changed.
|
|
2552
|
+
*
|
|
2553
|
+
* For this to work correctly, this syntax tree must have been edited such
|
|
2554
|
+
* that its ranges match up to the new tree. Generally, you'll want to
|
|
2555
|
+
* call this method right after calling one of the [`Parser::parse`]
|
|
2556
|
+
* functions. Call it on the old tree that was passed to parse, and
|
|
2557
|
+
* pass the new tree that was returned from `parse`.
|
|
2558
|
+
*/
|
|
2559
|
+
getChangedRanges(other) {
|
|
2560
|
+
if (!(other instanceof _Tree)) {
|
|
2561
|
+
throw new TypeError("Argument must be a Tree");
|
|
2562
|
+
}
|
|
2563
|
+
C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
|
|
2564
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
2565
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2566
|
+
const result = new Array(count);
|
|
2567
|
+
if (count > 0) {
|
|
2568
|
+
let address = buffer;
|
|
2569
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
2570
|
+
result[i2] = unmarshalRange(address);
|
|
2571
|
+
address += SIZE_OF_RANGE;
|
|
2572
|
+
}
|
|
2573
|
+
C._free(buffer);
|
|
2574
|
+
}
|
|
2575
|
+
return result;
|
|
2576
|
+
}
|
|
2577
|
+
/** Get the included ranges that were used to parse the syntax tree. */
|
|
2578
|
+
getIncludedRanges() {
|
|
2579
|
+
C._ts_tree_included_ranges_wasm(this[0]);
|
|
2580
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
2581
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2582
|
+
const result = new Array(count);
|
|
2583
|
+
if (count > 0) {
|
|
2584
|
+
let address = buffer;
|
|
2585
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
2586
|
+
result[i2] = unmarshalRange(address);
|
|
2587
|
+
address += SIZE_OF_RANGE;
|
|
2588
|
+
}
|
|
2589
|
+
C._free(buffer);
|
|
2590
|
+
}
|
|
2591
|
+
return result;
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
2594
|
+
|
|
2595
|
+
// src/tree_cursor.ts
|
|
2596
|
+
var TreeCursor = class _TreeCursor {
|
|
2597
|
+
static {
|
|
2598
|
+
__name(this, "TreeCursor");
|
|
2599
|
+
}
|
|
2600
|
+
/** @internal */
|
|
2601
|
+
// @ts-expect-error: never read
|
|
2602
|
+
[0] = 0;
|
|
2603
|
+
// Internal handle for Wasm
|
|
2604
|
+
/** @internal */
|
|
2605
|
+
// @ts-expect-error: never read
|
|
2606
|
+
[1] = 0;
|
|
2607
|
+
// Internal handle for Wasm
|
|
2608
|
+
/** @internal */
|
|
2609
|
+
// @ts-expect-error: never read
|
|
2610
|
+
[2] = 0;
|
|
2611
|
+
// Internal handle for Wasm
|
|
2612
|
+
/** @internal */
|
|
2613
|
+
// @ts-expect-error: never read
|
|
2614
|
+
[3] = 0;
|
|
2615
|
+
// Internal handle for Wasm
|
|
2616
|
+
/** @internal */
|
|
2617
|
+
tree;
|
|
2618
|
+
/** @internal */
|
|
2619
|
+
constructor(internal, tree) {
|
|
2620
|
+
assertInternal(internal);
|
|
2621
|
+
this.tree = tree;
|
|
2622
|
+
unmarshalTreeCursor(this);
|
|
2623
|
+
}
|
|
2624
|
+
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
2625
|
+
copy() {
|
|
2626
|
+
const copy = new _TreeCursor(INTERNAL, this.tree);
|
|
2627
|
+
C._ts_tree_cursor_copy_wasm(this.tree[0]);
|
|
2628
|
+
unmarshalTreeCursor(copy);
|
|
2629
|
+
return copy;
|
|
2630
|
+
}
|
|
2631
|
+
/** Delete the tree cursor, freeing its resources. */
|
|
2632
|
+
delete() {
|
|
2633
|
+
marshalTreeCursor(this);
|
|
2634
|
+
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
2635
|
+
this[0] = this[1] = this[2] = 0;
|
|
2636
|
+
}
|
|
2637
|
+
/** Get the tree cursor's current {@link Node}. */
|
|
2638
|
+
get currentNode() {
|
|
2639
|
+
marshalTreeCursor(this);
|
|
2640
|
+
C._ts_tree_cursor_current_node_wasm(this.tree[0]);
|
|
2641
|
+
return unmarshalNode(this.tree);
|
|
2642
|
+
}
|
|
2643
|
+
/**
|
|
2644
|
+
* Get the numerical field id of this tree cursor's current node.
|
|
2645
|
+
*
|
|
2646
|
+
* See also {@link TreeCursor#currentFieldName}.
|
|
2647
|
+
*/
|
|
2648
|
+
get currentFieldId() {
|
|
2649
|
+
marshalTreeCursor(this);
|
|
2650
|
+
return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
|
|
2651
|
+
}
|
|
2652
|
+
/** Get the field name of this tree cursor's current node. */
|
|
2653
|
+
get currentFieldName() {
|
|
2654
|
+
return this.tree.language.fields[this.currentFieldId];
|
|
2655
|
+
}
|
|
2656
|
+
/**
|
|
2657
|
+
* Get the depth of the cursor's current node relative to the original
|
|
2658
|
+
* node that the cursor was constructed with.
|
|
2659
|
+
*/
|
|
2660
|
+
get currentDepth() {
|
|
2661
|
+
marshalTreeCursor(this);
|
|
2662
|
+
return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
|
|
2663
|
+
}
|
|
2664
|
+
/**
|
|
2665
|
+
* Get the index of the cursor's current node out of all of the
|
|
2666
|
+
* descendants of the original node that the cursor was constructed with.
|
|
2667
|
+
*/
|
|
2668
|
+
get currentDescendantIndex() {
|
|
2669
|
+
marshalTreeCursor(this);
|
|
2670
|
+
return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
|
|
2671
|
+
}
|
|
2672
|
+
/** Get the type of the cursor's current node. */
|
|
2673
|
+
get nodeType() {
|
|
2674
|
+
return this.tree.language.types[this.nodeTypeId] || "ERROR";
|
|
2675
|
+
}
|
|
2676
|
+
/** Get the type id of the cursor's current node. */
|
|
2677
|
+
get nodeTypeId() {
|
|
2678
|
+
marshalTreeCursor(this);
|
|
2679
|
+
return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
|
|
2680
|
+
}
|
|
2681
|
+
/** Get the state id of the cursor's current node. */
|
|
2682
|
+
get nodeStateId() {
|
|
2683
|
+
marshalTreeCursor(this);
|
|
2684
|
+
return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
|
|
2685
|
+
}
|
|
2686
|
+
/** Get the id of the cursor's current node. */
|
|
2687
|
+
get nodeId() {
|
|
2688
|
+
marshalTreeCursor(this);
|
|
2689
|
+
return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
|
|
2690
|
+
}
|
|
2691
|
+
/**
|
|
2692
|
+
* Check if the cursor's current node is *named*.
|
|
2693
|
+
*
|
|
2694
|
+
* Named nodes correspond to named rules in the grammar, whereas
|
|
2695
|
+
* *anonymous* nodes correspond to string literals in the grammar.
|
|
2696
|
+
*/
|
|
2697
|
+
get nodeIsNamed() {
|
|
2698
|
+
marshalTreeCursor(this);
|
|
2699
|
+
return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
|
|
2700
|
+
}
|
|
2701
|
+
/**
|
|
2702
|
+
* Check if the cursor's current node is *missing*.
|
|
2703
|
+
*
|
|
2704
|
+
* Missing nodes are inserted by the parser in order to recover from
|
|
2705
|
+
* certain kinds of syntax errors.
|
|
2706
|
+
*/
|
|
2707
|
+
get nodeIsMissing() {
|
|
2708
|
+
marshalTreeCursor(this);
|
|
2709
|
+
return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
|
|
2710
|
+
}
|
|
2711
|
+
/** Get the string content of the cursor's current node. */
|
|
2712
|
+
get nodeText() {
|
|
2713
|
+
marshalTreeCursor(this);
|
|
2714
|
+
const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
|
|
2715
|
+
const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
2716
|
+
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
2717
|
+
const startPosition = unmarshalPoint(TRANSFER_BUFFER);
|
|
2718
|
+
return getText(this.tree, startIndex, endIndex, startPosition);
|
|
2719
|
+
}
|
|
2720
|
+
/** Get the start position of the cursor's current node. */
|
|
2721
|
+
get startPosition() {
|
|
2722
|
+
marshalTreeCursor(this);
|
|
2723
|
+
C._ts_tree_cursor_start_position_wasm(this.tree[0]);
|
|
2724
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
2725
|
+
}
|
|
2726
|
+
/** Get the end position of the cursor's current node. */
|
|
2727
|
+
get endPosition() {
|
|
2728
|
+
marshalTreeCursor(this);
|
|
2729
|
+
C._ts_tree_cursor_end_position_wasm(this.tree[0]);
|
|
2730
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
2731
|
+
}
|
|
2732
|
+
/** Get the start index of the cursor's current node. */
|
|
2733
|
+
get startIndex() {
|
|
2734
|
+
marshalTreeCursor(this);
|
|
2735
|
+
return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
|
|
2736
|
+
}
|
|
2737
|
+
/** Get the end index of the cursor's current node. */
|
|
2738
|
+
get endIndex() {
|
|
2739
|
+
marshalTreeCursor(this);
|
|
2740
|
+
return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
|
|
2741
|
+
}
|
|
2742
|
+
/**
|
|
2743
|
+
* Move this cursor to the first child of its current node.
|
|
2744
|
+
*
|
|
2745
|
+
* This returns `true` if the cursor successfully moved, and returns
|
|
2746
|
+
* `false` if there were no children.
|
|
2747
|
+
*/
|
|
2748
|
+
gotoFirstChild() {
|
|
2749
|
+
marshalTreeCursor(this);
|
|
2750
|
+
const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
|
|
2751
|
+
unmarshalTreeCursor(this);
|
|
2752
|
+
return result === 1;
|
|
2753
|
+
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Move this cursor to the last child of its current node.
|
|
2756
|
+
*
|
|
2757
|
+
* This returns `true` if the cursor successfully moved, and returns
|
|
2758
|
+
* `false` if there were no children.
|
|
2759
|
+
*
|
|
2760
|
+
* Note that this function may be slower than
|
|
2761
|
+
* {@link TreeCursor#gotoFirstChild} because it needs to
|
|
2762
|
+
* iterate through all the children to compute the child's position.
|
|
2763
|
+
*/
|
|
2764
|
+
gotoLastChild() {
|
|
2765
|
+
marshalTreeCursor(this);
|
|
2766
|
+
const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
|
|
2767
|
+
unmarshalTreeCursor(this);
|
|
2768
|
+
return result === 1;
|
|
2769
|
+
}
|
|
2770
|
+
/**
|
|
2771
|
+
* Move this cursor to the parent of its current node.
|
|
2772
|
+
*
|
|
2773
|
+
* This returns `true` if the cursor successfully moved, and returns
|
|
2774
|
+
* `false` if there was no parent node (the cursor was already on the
|
|
2775
|
+
* root node).
|
|
2776
|
+
*
|
|
2777
|
+
* Note that the node the cursor was constructed with is considered the root
|
|
2778
|
+
* of the cursor, and the cursor cannot walk outside this node.
|
|
2779
|
+
*/
|
|
2780
|
+
gotoParent() {
|
|
2781
|
+
marshalTreeCursor(this);
|
|
2782
|
+
const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
|
|
2783
|
+
unmarshalTreeCursor(this);
|
|
2784
|
+
return result === 1;
|
|
2785
|
+
}
|
|
2786
|
+
/**
|
|
2787
|
+
* Move this cursor to the next sibling of its current node.
|
|
2788
|
+
*
|
|
2789
|
+
* This returns `true` if the cursor successfully moved, and returns
|
|
2790
|
+
* `false` if there was no next sibling node.
|
|
2791
|
+
*
|
|
2792
|
+
* Note that the node the cursor was constructed with is considered the root
|
|
2793
|
+
* of the cursor, and the cursor cannot walk outside this node.
|
|
2794
|
+
*/
|
|
2795
|
+
gotoNextSibling() {
|
|
2796
|
+
marshalTreeCursor(this);
|
|
2797
|
+
const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
|
|
2798
|
+
unmarshalTreeCursor(this);
|
|
2799
|
+
return result === 1;
|
|
2800
|
+
}
|
|
2801
|
+
/**
|
|
2802
|
+
* Move this cursor to the previous sibling of its current node.
|
|
2803
|
+
*
|
|
2804
|
+
* This returns `true` if the cursor successfully moved, and returns
|
|
2805
|
+
* `false` if there was no previous sibling node.
|
|
2806
|
+
*
|
|
2807
|
+
* Note that this function may be slower than
|
|
2808
|
+
* {@link TreeCursor#gotoNextSibling} due to how node
|
|
2809
|
+
* positions are stored. In the worst case, this will need to iterate
|
|
2810
|
+
* through all the children up to the previous sibling node to recalculate
|
|
2811
|
+
* its position. Also note that the node the cursor was constructed with is
|
|
2812
|
+
* considered the root of the cursor, and the cursor cannot walk outside this node.
|
|
2813
|
+
*/
|
|
2814
|
+
gotoPreviousSibling() {
|
|
2815
|
+
marshalTreeCursor(this);
|
|
2816
|
+
const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
|
|
2817
|
+
unmarshalTreeCursor(this);
|
|
2818
|
+
return result === 1;
|
|
2819
|
+
}
|
|
2820
|
+
/**
|
|
2821
|
+
* Move the cursor to the node that is the nth descendant of
|
|
2822
|
+
* the original node that the cursor was constructed with, where
|
|
2823
|
+
* zero represents the original node itself.
|
|
2824
|
+
*/
|
|
2825
|
+
gotoDescendant(goalDescendantIndex) {
|
|
2826
|
+
marshalTreeCursor(this);
|
|
2827
|
+
C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantIndex);
|
|
2828
|
+
unmarshalTreeCursor(this);
|
|
2829
|
+
}
|
|
2830
|
+
/**
|
|
2831
|
+
* Move this cursor to the first child of its current node that contains or
|
|
2832
|
+
* starts after the given byte offset.
|
|
2833
|
+
*
|
|
2834
|
+
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
2835
|
+
* `false` if no such child was found.
|
|
2836
|
+
*/
|
|
2837
|
+
gotoFirstChildForIndex(goalIndex) {
|
|
2838
|
+
marshalTreeCursor(this);
|
|
2839
|
+
C.setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
|
|
2840
|
+
const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
|
|
2841
|
+
unmarshalTreeCursor(this);
|
|
2842
|
+
return result === 1;
|
|
2843
|
+
}
|
|
2844
|
+
/**
|
|
2845
|
+
* Move this cursor to the first child of its current node that contains or
|
|
2846
|
+
* starts after the given byte offset.
|
|
2847
|
+
*
|
|
2848
|
+
* This returns the index of the child node if one was found, and returns
|
|
2849
|
+
* `null` if no such child was found.
|
|
2850
|
+
*/
|
|
2851
|
+
gotoFirstChildForPosition(goalPosition) {
|
|
2852
|
+
marshalTreeCursor(this);
|
|
2853
|
+
marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
|
|
2854
|
+
const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
|
|
2855
|
+
unmarshalTreeCursor(this);
|
|
2856
|
+
return result === 1;
|
|
2857
|
+
}
|
|
2858
|
+
/**
|
|
2859
|
+
* Re-initialize this tree cursor to start at the original node that the
|
|
2860
|
+
* cursor was constructed with.
|
|
2861
|
+
*/
|
|
2862
|
+
reset(node) {
|
|
2863
|
+
marshalNode(node);
|
|
2864
|
+
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
2865
|
+
C._ts_tree_cursor_reset_wasm(this.tree[0]);
|
|
2866
|
+
unmarshalTreeCursor(this);
|
|
2867
|
+
}
|
|
2868
|
+
/**
|
|
2869
|
+
* Re-initialize a tree cursor to the same position as another cursor.
|
|
2870
|
+
*
|
|
2871
|
+
* Unlike {@link TreeCursor#reset}, this will not lose parent
|
|
2872
|
+
* information and allows reusing already created cursors.
|
|
2873
|
+
*/
|
|
2874
|
+
resetTo(cursor) {
|
|
2875
|
+
marshalTreeCursor(this, TRANSFER_BUFFER);
|
|
2876
|
+
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
2877
|
+
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
2878
|
+
unmarshalTreeCursor(this);
|
|
2879
|
+
}
|
|
2880
|
+
};
|
|
2881
|
+
|
|
2882
|
+
// src/node.ts
|
|
2883
|
+
var Node = class {
|
|
2884
|
+
static {
|
|
2885
|
+
__name(this, "Node");
|
|
2886
|
+
}
|
|
2887
|
+
/** @internal */
|
|
2888
|
+
// @ts-expect-error: never read
|
|
2889
|
+
[0] = 0;
|
|
2890
|
+
// Internal handle for Wasm
|
|
2891
|
+
/** @internal */
|
|
2892
|
+
_children;
|
|
2893
|
+
/** @internal */
|
|
2894
|
+
_namedChildren;
|
|
2895
|
+
/** @internal */
|
|
2896
|
+
constructor(internal, {
|
|
2897
|
+
id,
|
|
2898
|
+
tree,
|
|
2899
|
+
startIndex,
|
|
2900
|
+
startPosition,
|
|
2901
|
+
other
|
|
2902
|
+
}) {
|
|
2903
|
+
assertInternal(internal);
|
|
2904
|
+
this[0] = other;
|
|
2905
|
+
this.id = id;
|
|
2906
|
+
this.tree = tree;
|
|
2907
|
+
this.startIndex = startIndex;
|
|
2908
|
+
this.startPosition = startPosition;
|
|
2909
|
+
}
|
|
2910
|
+
/**
|
|
2911
|
+
* The numeric id for this node that is unique.
|
|
2912
|
+
*
|
|
2913
|
+
* Within a given syntax tree, no two nodes have the same id. However:
|
|
2914
|
+
*
|
|
2915
|
+
* * If a new tree is created based on an older tree, and a node from the old tree is reused in
|
|
2916
|
+
* the process, then that node will have the same id in both trees.
|
|
2917
|
+
*
|
|
2918
|
+
* * A node not marked as having changes does not guarantee it was reused.
|
|
2919
|
+
*
|
|
2920
|
+
* * If a node is marked as having changed in the old tree, it will not be reused.
|
|
2921
|
+
*/
|
|
2922
|
+
id;
|
|
2923
|
+
/** The byte index where this node starts. */
|
|
2924
|
+
startIndex;
|
|
2925
|
+
/** The position where this node starts. */
|
|
2926
|
+
startPosition;
|
|
2927
|
+
/** The tree that this node belongs to. */
|
|
2928
|
+
tree;
|
|
2929
|
+
/** Get this node's type as a numerical id. */
|
|
2930
|
+
get typeId() {
|
|
2931
|
+
marshalNode(this);
|
|
2932
|
+
return C._ts_node_symbol_wasm(this.tree[0]);
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Get the node's type as a numerical id as it appears in the grammar,
|
|
2936
|
+
* ignoring aliases.
|
|
2937
|
+
*/
|
|
2938
|
+
get grammarId() {
|
|
2939
|
+
marshalNode(this);
|
|
2940
|
+
return C._ts_node_grammar_symbol_wasm(this.tree[0]);
|
|
2941
|
+
}
|
|
2942
|
+
/** Get this node's type as a string. */
|
|
2943
|
+
get type() {
|
|
2944
|
+
return this.tree.language.types[this.typeId] || "ERROR";
|
|
2945
|
+
}
|
|
2946
|
+
/**
|
|
2947
|
+
* Get this node's symbol name as it appears in the grammar, ignoring
|
|
2948
|
+
* aliases as a string.
|
|
2949
|
+
*/
|
|
2950
|
+
get grammarType() {
|
|
2951
|
+
return this.tree.language.types[this.grammarId] || "ERROR";
|
|
2952
|
+
}
|
|
2953
|
+
/**
|
|
2954
|
+
* Check if this node is *named*.
|
|
2955
|
+
*
|
|
2956
|
+
* Named nodes correspond to named rules in the grammar, whereas
|
|
2957
|
+
* *anonymous* nodes correspond to string literals in the grammar.
|
|
2958
|
+
*/
|
|
2959
|
+
get isNamed() {
|
|
2960
|
+
marshalNode(this);
|
|
2961
|
+
return C._ts_node_is_named_wasm(this.tree[0]) === 1;
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Check if this node is *extra*.
|
|
2965
|
+
*
|
|
2966
|
+
* Extra nodes represent things like comments, which are not required
|
|
2967
|
+
* by the grammar, but can appear anywhere.
|
|
2968
|
+
*/
|
|
2969
|
+
get isExtra() {
|
|
2970
|
+
marshalNode(this);
|
|
2971
|
+
return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
|
|
2972
|
+
}
|
|
2973
|
+
/**
|
|
2974
|
+
* Check if this node represents a syntax error.
|
|
2975
|
+
*
|
|
2976
|
+
* Syntax errors represent parts of the code that could not be incorporated
|
|
2977
|
+
* into a valid syntax tree.
|
|
2978
|
+
*/
|
|
2979
|
+
get isError() {
|
|
2980
|
+
marshalNode(this);
|
|
2981
|
+
return C._ts_node_is_error_wasm(this.tree[0]) === 1;
|
|
2982
|
+
}
|
|
2983
|
+
/**
|
|
2984
|
+
* Check if this node is *missing*.
|
|
2985
|
+
*
|
|
2986
|
+
* Missing nodes are inserted by the parser in order to recover from
|
|
2987
|
+
* certain kinds of syntax errors.
|
|
2988
|
+
*/
|
|
2989
|
+
get isMissing() {
|
|
2990
|
+
marshalNode(this);
|
|
2991
|
+
return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
|
|
2992
|
+
}
|
|
2993
|
+
/** Check if this node has been edited. */
|
|
2994
|
+
get hasChanges() {
|
|
2995
|
+
marshalNode(this);
|
|
2996
|
+
return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
|
|
2997
|
+
}
|
|
2998
|
+
/**
|
|
2999
|
+
* Check if this node represents a syntax error or contains any syntax
|
|
3000
|
+
* errors anywhere within it.
|
|
3001
|
+
*/
|
|
3002
|
+
get hasError() {
|
|
3003
|
+
marshalNode(this);
|
|
3004
|
+
return C._ts_node_has_error_wasm(this.tree[0]) === 1;
|
|
3005
|
+
}
|
|
3006
|
+
/** Get the byte index where this node ends. */
|
|
3007
|
+
get endIndex() {
|
|
3008
|
+
marshalNode(this);
|
|
3009
|
+
return C._ts_node_end_index_wasm(this.tree[0]);
|
|
3010
|
+
}
|
|
3011
|
+
/** Get the position where this node ends. */
|
|
3012
|
+
get endPosition() {
|
|
3013
|
+
marshalNode(this);
|
|
3014
|
+
C._ts_node_end_point_wasm(this.tree[0]);
|
|
3015
|
+
return unmarshalPoint(TRANSFER_BUFFER);
|
|
3016
|
+
}
|
|
3017
|
+
/** Get the string content of this node. */
|
|
3018
|
+
get text() {
|
|
3019
|
+
return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);
|
|
3020
|
+
}
|
|
3021
|
+
/** Get this node's parse state. */
|
|
3022
|
+
get parseState() {
|
|
3023
|
+
marshalNode(this);
|
|
3024
|
+
return C._ts_node_parse_state_wasm(this.tree[0]);
|
|
3025
|
+
}
|
|
3026
|
+
/** Get the parse state after this node. */
|
|
3027
|
+
get nextParseState() {
|
|
3028
|
+
marshalNode(this);
|
|
3029
|
+
return C._ts_node_next_parse_state_wasm(this.tree[0]);
|
|
3030
|
+
}
|
|
3031
|
+
/** Check if this node is equal to another node. */
|
|
3032
|
+
equals(other) {
|
|
3033
|
+
return this.tree === other.tree && this.id === other.id;
|
|
3034
|
+
}
|
|
3035
|
+
/**
|
|
3036
|
+
* Get the node's child at the given index, where zero represents the first child.
|
|
3037
|
+
*
|
|
3038
|
+
* This method is fairly fast, but its cost is technically log(n), so if
|
|
3039
|
+
* you might be iterating over a long list of children, you should use
|
|
3040
|
+
* {@link Node#children} instead.
|
|
3041
|
+
*/
|
|
3042
|
+
child(index) {
|
|
3043
|
+
marshalNode(this);
|
|
3044
|
+
C._ts_node_child_wasm(this.tree[0], index);
|
|
3045
|
+
return unmarshalNode(this.tree);
|
|
3046
|
+
}
|
|
3047
|
+
/**
|
|
3048
|
+
* Get this node's *named* child at the given index.
|
|
3049
|
+
*
|
|
3050
|
+
* See also {@link Node#isNamed}.
|
|
3051
|
+
* This method is fairly fast, but its cost is technically log(n), so if
|
|
3052
|
+
* you might be iterating over a long list of children, you should use
|
|
3053
|
+
* {@link Node#namedChildren} instead.
|
|
3054
|
+
*/
|
|
3055
|
+
namedChild(index) {
|
|
3056
|
+
marshalNode(this);
|
|
3057
|
+
C._ts_node_named_child_wasm(this.tree[0], index);
|
|
3058
|
+
return unmarshalNode(this.tree);
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Get this node's child with the given numerical field id.
|
|
3062
|
+
*
|
|
3063
|
+
* See also {@link Node#childForFieldName}. You can
|
|
3064
|
+
* convert a field name to an id using {@link Language#fieldIdForName}.
|
|
3065
|
+
*/
|
|
3066
|
+
childForFieldId(fieldId) {
|
|
3067
|
+
marshalNode(this);
|
|
3068
|
+
C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId);
|
|
3069
|
+
return unmarshalNode(this.tree);
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Get the first child with the given field name.
|
|
3073
|
+
*
|
|
3074
|
+
* If multiple children may have the same field name, access them using
|
|
3075
|
+
* {@link Node#childrenForFieldName}.
|
|
3076
|
+
*/
|
|
3077
|
+
childForFieldName(fieldName) {
|
|
3078
|
+
const fieldId = this.tree.language.fields.indexOf(fieldName);
|
|
3079
|
+
if (fieldId !== -1) return this.childForFieldId(fieldId);
|
|
3080
|
+
return null;
|
|
3081
|
+
}
|
|
3082
|
+
/** Get the field name of this node's child at the given index. */
|
|
3083
|
+
fieldNameForChild(index) {
|
|
3084
|
+
marshalNode(this);
|
|
3085
|
+
const address = C._ts_node_field_name_for_child_wasm(this.tree[0], index);
|
|
3086
|
+
if (!address) return null;
|
|
3087
|
+
return C.AsciiToString(address);
|
|
3088
|
+
}
|
|
3089
|
+
/** Get the field name of this node's named child at the given index. */
|
|
3090
|
+
fieldNameForNamedChild(index) {
|
|
3091
|
+
marshalNode(this);
|
|
3092
|
+
const address = C._ts_node_field_name_for_named_child_wasm(this.tree[0], index);
|
|
3093
|
+
if (!address) return null;
|
|
3094
|
+
return C.AsciiToString(address);
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* Get an array of this node's children with a given field name.
|
|
3098
|
+
*
|
|
3099
|
+
* See also {@link Node#children}.
|
|
3100
|
+
*/
|
|
3101
|
+
childrenForFieldName(fieldName) {
|
|
3102
|
+
const fieldId = this.tree.language.fields.indexOf(fieldName);
|
|
3103
|
+
if (fieldId !== -1 && fieldId !== 0) return this.childrenForFieldId(fieldId);
|
|
3104
|
+
return [];
|
|
3105
|
+
}
|
|
3106
|
+
/**
|
|
3107
|
+
* Get an array of this node's children with a given field id.
|
|
3108
|
+
*
|
|
3109
|
+
* See also {@link Node#childrenForFieldName}.
|
|
3110
|
+
*/
|
|
3111
|
+
childrenForFieldId(fieldId) {
|
|
3112
|
+
marshalNode(this);
|
|
3113
|
+
C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
|
|
3114
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3115
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3116
|
+
const result = new Array(count);
|
|
3117
|
+
if (count > 0) {
|
|
3118
|
+
let address = buffer;
|
|
3119
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3120
|
+
result[i2] = unmarshalNode(this.tree, address);
|
|
3121
|
+
address += SIZE_OF_NODE;
|
|
3122
|
+
}
|
|
3123
|
+
C._free(buffer);
|
|
3124
|
+
}
|
|
3125
|
+
return result;
|
|
3126
|
+
}
|
|
3127
|
+
/** Get the node's first child that contains or starts after the given byte offset. */
|
|
3128
|
+
firstChildForIndex(index) {
|
|
3129
|
+
marshalNode(this);
|
|
3130
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3131
|
+
C.setValue(address, index, "i32");
|
|
3132
|
+
C._ts_node_first_child_for_byte_wasm(this.tree[0]);
|
|
3133
|
+
return unmarshalNode(this.tree);
|
|
3134
|
+
}
|
|
3135
|
+
/** Get the node's first named child that contains or starts after the given byte offset. */
|
|
3136
|
+
firstNamedChildForIndex(index) {
|
|
3137
|
+
marshalNode(this);
|
|
3138
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3139
|
+
C.setValue(address, index, "i32");
|
|
3140
|
+
C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
|
|
3141
|
+
return unmarshalNode(this.tree);
|
|
3142
|
+
}
|
|
3143
|
+
/** Get this node's number of children. */
|
|
3144
|
+
get childCount() {
|
|
3145
|
+
marshalNode(this);
|
|
3146
|
+
return C._ts_node_child_count_wasm(this.tree[0]);
|
|
3147
|
+
}
|
|
3148
|
+
/**
|
|
3149
|
+
* Get this node's number of *named* children.
|
|
3150
|
+
*
|
|
3151
|
+
* See also {@link Node#isNamed}.
|
|
3152
|
+
*/
|
|
3153
|
+
get namedChildCount() {
|
|
3154
|
+
marshalNode(this);
|
|
3155
|
+
return C._ts_node_named_child_count_wasm(this.tree[0]);
|
|
3156
|
+
}
|
|
3157
|
+
/** Get this node's first child. */
|
|
3158
|
+
get firstChild() {
|
|
3159
|
+
return this.child(0);
|
|
3160
|
+
}
|
|
3161
|
+
/**
|
|
3162
|
+
* Get this node's first named child.
|
|
3163
|
+
*
|
|
3164
|
+
* See also {@link Node#isNamed}.
|
|
3165
|
+
*/
|
|
3166
|
+
get firstNamedChild() {
|
|
3167
|
+
return this.namedChild(0);
|
|
3168
|
+
}
|
|
3169
|
+
/** Get this node's last child. */
|
|
3170
|
+
get lastChild() {
|
|
3171
|
+
return this.child(this.childCount - 1);
|
|
3172
|
+
}
|
|
3173
|
+
/**
|
|
3174
|
+
* Get this node's last named child.
|
|
3175
|
+
*
|
|
3176
|
+
* See also {@link Node#isNamed}.
|
|
3177
|
+
*/
|
|
3178
|
+
get lastNamedChild() {
|
|
3179
|
+
return this.namedChild(this.namedChildCount - 1);
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Iterate over this node's children.
|
|
3183
|
+
*
|
|
3184
|
+
* If you're walking the tree recursively, you may want to use the
|
|
3185
|
+
* {@link TreeCursor} APIs directly instead.
|
|
3186
|
+
*/
|
|
3187
|
+
get children() {
|
|
3188
|
+
if (!this._children) {
|
|
3189
|
+
marshalNode(this);
|
|
3190
|
+
C._ts_node_children_wasm(this.tree[0]);
|
|
3191
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3192
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3193
|
+
this._children = new Array(count);
|
|
3194
|
+
if (count > 0) {
|
|
3195
|
+
let address = buffer;
|
|
3196
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3197
|
+
this._children[i2] = unmarshalNode(this.tree, address);
|
|
3198
|
+
address += SIZE_OF_NODE;
|
|
3199
|
+
}
|
|
3200
|
+
C._free(buffer);
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
return this._children;
|
|
3204
|
+
}
|
|
3205
|
+
/**
|
|
3206
|
+
* Iterate over this node's named children.
|
|
3207
|
+
*
|
|
3208
|
+
* See also {@link Node#children}.
|
|
3209
|
+
*/
|
|
3210
|
+
get namedChildren() {
|
|
3211
|
+
if (!this._namedChildren) {
|
|
3212
|
+
marshalNode(this);
|
|
3213
|
+
C._ts_node_named_children_wasm(this.tree[0]);
|
|
3214
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3215
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3216
|
+
this._namedChildren = new Array(count);
|
|
3217
|
+
if (count > 0) {
|
|
3218
|
+
let address = buffer;
|
|
3219
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3220
|
+
this._namedChildren[i2] = unmarshalNode(this.tree, address);
|
|
3221
|
+
address += SIZE_OF_NODE;
|
|
3222
|
+
}
|
|
3223
|
+
C._free(buffer);
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
return this._namedChildren;
|
|
3227
|
+
}
|
|
3228
|
+
/**
|
|
3229
|
+
* Get the descendants of this node that are the given type, or in the given types array.
|
|
3230
|
+
*
|
|
3231
|
+
* The types array should contain node type strings, which can be retrieved from {@link Language#types}.
|
|
3232
|
+
*
|
|
3233
|
+
* Additionally, a `startPosition` and `endPosition` can be passed in to restrict the search to a byte range.
|
|
3234
|
+
*/
|
|
3235
|
+
descendantsOfType(types, startPosition = ZERO_POINT, endPosition = ZERO_POINT) {
|
|
3236
|
+
if (!Array.isArray(types)) types = [types];
|
|
3237
|
+
const symbols = [];
|
|
3238
|
+
const typesBySymbol = this.tree.language.types;
|
|
3239
|
+
for (const node_type of types) {
|
|
3240
|
+
if (node_type == "ERROR") {
|
|
3241
|
+
symbols.push(65535);
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
3245
|
+
if (types.includes(typesBySymbol[i2])) {
|
|
3246
|
+
symbols.push(i2);
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
3250
|
+
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
3251
|
+
C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
3252
|
+
}
|
|
3253
|
+
marshalNode(this);
|
|
3254
|
+
C._ts_node_descendants_of_type_wasm(
|
|
3255
|
+
this.tree[0],
|
|
3256
|
+
symbolsAddress,
|
|
3257
|
+
symbols.length,
|
|
3258
|
+
startPosition.row,
|
|
3259
|
+
startPosition.column,
|
|
3260
|
+
endPosition.row,
|
|
3261
|
+
endPosition.column
|
|
3262
|
+
);
|
|
3263
|
+
const descendantCount = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3264
|
+
const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3265
|
+
const result = new Array(descendantCount);
|
|
3266
|
+
if (descendantCount > 0) {
|
|
3267
|
+
let address = descendantAddress;
|
|
3268
|
+
for (let i2 = 0; i2 < descendantCount; i2++) {
|
|
3269
|
+
result[i2] = unmarshalNode(this.tree, address);
|
|
3270
|
+
address += SIZE_OF_NODE;
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
C._free(descendantAddress);
|
|
3274
|
+
C._free(symbolsAddress);
|
|
3275
|
+
return result;
|
|
3276
|
+
}
|
|
3277
|
+
/** Get this node's next sibling. */
|
|
3278
|
+
get nextSibling() {
|
|
3279
|
+
marshalNode(this);
|
|
3280
|
+
C._ts_node_next_sibling_wasm(this.tree[0]);
|
|
3281
|
+
return unmarshalNode(this.tree);
|
|
3282
|
+
}
|
|
3283
|
+
/** Get this node's previous sibling. */
|
|
3284
|
+
get previousSibling() {
|
|
3285
|
+
marshalNode(this);
|
|
3286
|
+
C._ts_node_prev_sibling_wasm(this.tree[0]);
|
|
3287
|
+
return unmarshalNode(this.tree);
|
|
3288
|
+
}
|
|
3289
|
+
/**
|
|
3290
|
+
* Get this node's next *named* sibling.
|
|
3291
|
+
*
|
|
3292
|
+
* See also {@link Node#isNamed}.
|
|
3293
|
+
*/
|
|
3294
|
+
get nextNamedSibling() {
|
|
3295
|
+
marshalNode(this);
|
|
3296
|
+
C._ts_node_next_named_sibling_wasm(this.tree[0]);
|
|
3297
|
+
return unmarshalNode(this.tree);
|
|
3298
|
+
}
|
|
3299
|
+
/**
|
|
3300
|
+
* Get this node's previous *named* sibling.
|
|
3301
|
+
*
|
|
3302
|
+
* See also {@link Node#isNamed}.
|
|
3303
|
+
*/
|
|
3304
|
+
get previousNamedSibling() {
|
|
3305
|
+
marshalNode(this);
|
|
3306
|
+
C._ts_node_prev_named_sibling_wasm(this.tree[0]);
|
|
3307
|
+
return unmarshalNode(this.tree);
|
|
3308
|
+
}
|
|
3309
|
+
/** Get the node's number of descendants, including one for the node itself. */
|
|
3310
|
+
get descendantCount() {
|
|
3311
|
+
marshalNode(this);
|
|
3312
|
+
return C._ts_node_descendant_count_wasm(this.tree[0]);
|
|
3313
|
+
}
|
|
3314
|
+
/**
|
|
3315
|
+
* Get this node's immediate parent.
|
|
3316
|
+
* Prefer {@link Node#childWithDescendant} for iterating over this node's ancestors.
|
|
3317
|
+
*/
|
|
3318
|
+
get parent() {
|
|
3319
|
+
marshalNode(this);
|
|
3320
|
+
C._ts_node_parent_wasm(this.tree[0]);
|
|
3321
|
+
return unmarshalNode(this.tree);
|
|
3322
|
+
}
|
|
3323
|
+
/**
|
|
3324
|
+
* Get the node that contains `descendant`.
|
|
3325
|
+
*
|
|
3326
|
+
* Note that this can return `descendant` itself.
|
|
3327
|
+
*/
|
|
3328
|
+
childWithDescendant(descendant) {
|
|
3329
|
+
marshalNode(this);
|
|
3330
|
+
marshalNode(descendant, 1);
|
|
3331
|
+
C._ts_node_child_with_descendant_wasm(this.tree[0]);
|
|
3332
|
+
return unmarshalNode(this.tree);
|
|
3333
|
+
}
|
|
3334
|
+
/** Get the smallest node within this node that spans the given byte range. */
|
|
3335
|
+
descendantForIndex(start2, end = start2) {
|
|
3336
|
+
if (typeof start2 !== "number" || typeof end !== "number") {
|
|
3337
|
+
throw new Error("Arguments must be numbers");
|
|
3338
|
+
}
|
|
3339
|
+
marshalNode(this);
|
|
3340
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3341
|
+
C.setValue(address, start2, "i32");
|
|
3342
|
+
C.setValue(address + SIZE_OF_INT, end, "i32");
|
|
3343
|
+
C._ts_node_descendant_for_index_wasm(this.tree[0]);
|
|
3344
|
+
return unmarshalNode(this.tree);
|
|
3345
|
+
}
|
|
3346
|
+
/** Get the smallest named node within this node that spans the given byte range. */
|
|
3347
|
+
namedDescendantForIndex(start2, end = start2) {
|
|
3348
|
+
if (typeof start2 !== "number" || typeof end !== "number") {
|
|
3349
|
+
throw new Error("Arguments must be numbers");
|
|
3350
|
+
}
|
|
3351
|
+
marshalNode(this);
|
|
3352
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3353
|
+
C.setValue(address, start2, "i32");
|
|
3354
|
+
C.setValue(address + SIZE_OF_INT, end, "i32");
|
|
3355
|
+
C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
|
|
3356
|
+
return unmarshalNode(this.tree);
|
|
3357
|
+
}
|
|
3358
|
+
/** Get the smallest node within this node that spans the given point range. */
|
|
3359
|
+
descendantForPosition(start2, end = start2) {
|
|
3360
|
+
if (!isPoint(start2) || !isPoint(end)) {
|
|
3361
|
+
throw new Error("Arguments must be {row, column} objects");
|
|
3362
|
+
}
|
|
3363
|
+
marshalNode(this);
|
|
3364
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3365
|
+
marshalPoint(address, start2);
|
|
3366
|
+
marshalPoint(address + SIZE_OF_POINT, end);
|
|
3367
|
+
C._ts_node_descendant_for_position_wasm(this.tree[0]);
|
|
3368
|
+
return unmarshalNode(this.tree);
|
|
3369
|
+
}
|
|
3370
|
+
/** Get the smallest named node within this node that spans the given point range. */
|
|
3371
|
+
namedDescendantForPosition(start2, end = start2) {
|
|
3372
|
+
if (!isPoint(start2) || !isPoint(end)) {
|
|
3373
|
+
throw new Error("Arguments must be {row, column} objects");
|
|
3374
|
+
}
|
|
3375
|
+
marshalNode(this);
|
|
3376
|
+
const address = TRANSFER_BUFFER + SIZE_OF_NODE;
|
|
3377
|
+
marshalPoint(address, start2);
|
|
3378
|
+
marshalPoint(address + SIZE_OF_POINT, end);
|
|
3379
|
+
C._ts_node_named_descendant_for_position_wasm(this.tree[0]);
|
|
3380
|
+
return unmarshalNode(this.tree);
|
|
3381
|
+
}
|
|
3382
|
+
/**
|
|
3383
|
+
* Create a new {@link TreeCursor} starting from this node.
|
|
3384
|
+
*
|
|
3385
|
+
* Note that the given node is considered the root of the cursor,
|
|
3386
|
+
* and the cursor cannot walk outside this node.
|
|
3387
|
+
*/
|
|
3388
|
+
walk() {
|
|
3389
|
+
marshalNode(this);
|
|
3390
|
+
C._ts_tree_cursor_new_wasm(this.tree[0]);
|
|
3391
|
+
return new TreeCursor(INTERNAL, this.tree);
|
|
3392
|
+
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Edit this node to keep it in-sync with source code that has been edited.
|
|
3395
|
+
*
|
|
3396
|
+
* This function is only rarely needed. When you edit a syntax tree with
|
|
3397
|
+
* the {@link Tree#edit} method, all of the nodes that you retrieve from
|
|
3398
|
+
* the tree afterward will already reflect the edit. You only need to
|
|
3399
|
+
* use {@link Node#edit} when you have a specific {@link Node} instance that
|
|
3400
|
+
* you want to keep and continue to use after an edit.
|
|
3401
|
+
*/
|
|
3402
|
+
edit(edit) {
|
|
3403
|
+
if (this.startIndex >= edit.oldEndIndex) {
|
|
3404
|
+
this.startIndex = edit.newEndIndex + (this.startIndex - edit.oldEndIndex);
|
|
3405
|
+
let subbedPointRow;
|
|
3406
|
+
let subbedPointColumn;
|
|
3407
|
+
if (this.startPosition.row > edit.oldEndPosition.row) {
|
|
3408
|
+
subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
|
|
3409
|
+
subbedPointColumn = this.startPosition.column;
|
|
3410
|
+
} else {
|
|
3411
|
+
subbedPointRow = 0;
|
|
3412
|
+
subbedPointColumn = this.startPosition.column;
|
|
3413
|
+
if (this.startPosition.column >= edit.oldEndPosition.column) {
|
|
3414
|
+
subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
if (subbedPointRow > 0) {
|
|
3418
|
+
this.startPosition.row += subbedPointRow;
|
|
3419
|
+
this.startPosition.column = subbedPointColumn;
|
|
3420
|
+
} else {
|
|
3421
|
+
this.startPosition.column += subbedPointColumn;
|
|
3422
|
+
}
|
|
3423
|
+
} else if (this.startIndex > edit.startIndex) {
|
|
3424
|
+
this.startIndex = edit.newEndIndex;
|
|
3425
|
+
this.startPosition.row = edit.newEndPosition.row;
|
|
3426
|
+
this.startPosition.column = edit.newEndPosition.column;
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
/** Get the S-expression representation of this node. */
|
|
3430
|
+
toString() {
|
|
3431
|
+
marshalNode(this);
|
|
3432
|
+
const address = C._ts_node_to_string_wasm(this.tree[0]);
|
|
3433
|
+
const result = C.AsciiToString(address);
|
|
3434
|
+
C._free(address);
|
|
3435
|
+
return result;
|
|
3436
|
+
}
|
|
3437
|
+
};
|
|
3438
|
+
|
|
3439
|
+
// src/marshal.ts
|
|
3440
|
+
function unmarshalCaptures(query, tree, address, patternIndex, result) {
|
|
3441
|
+
for (let i2 = 0, n = result.length; i2 < n; i2++) {
|
|
3442
|
+
const captureIndex = C.getValue(address, "i32");
|
|
3443
|
+
address += SIZE_OF_INT;
|
|
3444
|
+
const node = unmarshalNode(tree, address);
|
|
3445
|
+
address += SIZE_OF_NODE;
|
|
3446
|
+
result[i2] = { patternIndex, name: query.captureNames[captureIndex], node };
|
|
3447
|
+
}
|
|
3448
|
+
return address;
|
|
3449
|
+
}
|
|
3450
|
+
__name(unmarshalCaptures, "unmarshalCaptures");
|
|
3451
|
+
function marshalNode(node, index = 0) {
|
|
3452
|
+
let address = TRANSFER_BUFFER + index * SIZE_OF_NODE;
|
|
3453
|
+
C.setValue(address, node.id, "i32");
|
|
3454
|
+
address += SIZE_OF_INT;
|
|
3455
|
+
C.setValue(address, node.startIndex, "i32");
|
|
3456
|
+
address += SIZE_OF_INT;
|
|
3457
|
+
C.setValue(address, node.startPosition.row, "i32");
|
|
3458
|
+
address += SIZE_OF_INT;
|
|
3459
|
+
C.setValue(address, node.startPosition.column, "i32");
|
|
3460
|
+
address += SIZE_OF_INT;
|
|
3461
|
+
C.setValue(address, node[0], "i32");
|
|
3462
|
+
}
|
|
3463
|
+
__name(marshalNode, "marshalNode");
|
|
3464
|
+
function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
3465
|
+
const id = C.getValue(address, "i32");
|
|
3466
|
+
address += SIZE_OF_INT;
|
|
3467
|
+
if (id === 0) return null;
|
|
3468
|
+
const index = C.getValue(address, "i32");
|
|
3469
|
+
address += SIZE_OF_INT;
|
|
3470
|
+
const row = C.getValue(address, "i32");
|
|
3471
|
+
address += SIZE_OF_INT;
|
|
3472
|
+
const column = C.getValue(address, "i32");
|
|
3473
|
+
address += SIZE_OF_INT;
|
|
3474
|
+
const other = C.getValue(address, "i32");
|
|
3475
|
+
const result = new Node(INTERNAL, {
|
|
3476
|
+
id,
|
|
3477
|
+
tree,
|
|
3478
|
+
startIndex: index,
|
|
3479
|
+
startPosition: { row, column },
|
|
3480
|
+
other
|
|
3481
|
+
});
|
|
3482
|
+
return result;
|
|
3483
|
+
}
|
|
3484
|
+
__name(unmarshalNode, "unmarshalNode");
|
|
3485
|
+
function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
|
|
3486
|
+
C.setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
|
|
3487
|
+
C.setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
|
|
3488
|
+
C.setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
|
|
3489
|
+
C.setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
|
|
3490
|
+
}
|
|
3491
|
+
__name(marshalTreeCursor, "marshalTreeCursor");
|
|
3492
|
+
function unmarshalTreeCursor(cursor) {
|
|
3493
|
+
cursor[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
3494
|
+
cursor[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
3495
|
+
cursor[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
3496
|
+
cursor[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
3497
|
+
}
|
|
3498
|
+
__name(unmarshalTreeCursor, "unmarshalTreeCursor");
|
|
3499
|
+
function marshalPoint(address, point) {
|
|
3500
|
+
C.setValue(address, point.row, "i32");
|
|
3501
|
+
C.setValue(address + SIZE_OF_INT, point.column, "i32");
|
|
3502
|
+
}
|
|
3503
|
+
__name(marshalPoint, "marshalPoint");
|
|
3504
|
+
function unmarshalPoint(address) {
|
|
3505
|
+
const result = {
|
|
3506
|
+
row: C.getValue(address, "i32") >>> 0,
|
|
3507
|
+
column: C.getValue(address + SIZE_OF_INT, "i32") >>> 0
|
|
3508
|
+
};
|
|
3509
|
+
return result;
|
|
3510
|
+
}
|
|
3511
|
+
__name(unmarshalPoint, "unmarshalPoint");
|
|
3512
|
+
function marshalRange(address, range) {
|
|
3513
|
+
marshalPoint(address, range.startPosition);
|
|
3514
|
+
address += SIZE_OF_POINT;
|
|
3515
|
+
marshalPoint(address, range.endPosition);
|
|
3516
|
+
address += SIZE_OF_POINT;
|
|
3517
|
+
C.setValue(address, range.startIndex, "i32");
|
|
3518
|
+
address += SIZE_OF_INT;
|
|
3519
|
+
C.setValue(address, range.endIndex, "i32");
|
|
3520
|
+
address += SIZE_OF_INT;
|
|
3521
|
+
}
|
|
3522
|
+
__name(marshalRange, "marshalRange");
|
|
3523
|
+
function unmarshalRange(address) {
|
|
3524
|
+
const result = {};
|
|
3525
|
+
result.startPosition = unmarshalPoint(address);
|
|
3526
|
+
address += SIZE_OF_POINT;
|
|
3527
|
+
result.endPosition = unmarshalPoint(address);
|
|
3528
|
+
address += SIZE_OF_POINT;
|
|
3529
|
+
result.startIndex = C.getValue(address, "i32") >>> 0;
|
|
3530
|
+
address += SIZE_OF_INT;
|
|
3531
|
+
result.endIndex = C.getValue(address, "i32") >>> 0;
|
|
3532
|
+
return result;
|
|
3533
|
+
}
|
|
3534
|
+
__name(unmarshalRange, "unmarshalRange");
|
|
3535
|
+
function marshalEdit(edit, address = TRANSFER_BUFFER) {
|
|
3536
|
+
marshalPoint(address, edit.startPosition);
|
|
3537
|
+
address += SIZE_OF_POINT;
|
|
3538
|
+
marshalPoint(address, edit.oldEndPosition);
|
|
3539
|
+
address += SIZE_OF_POINT;
|
|
3540
|
+
marshalPoint(address, edit.newEndPosition);
|
|
3541
|
+
address += SIZE_OF_POINT;
|
|
3542
|
+
C.setValue(address, edit.startIndex, "i32");
|
|
3543
|
+
address += SIZE_OF_INT;
|
|
3544
|
+
C.setValue(address, edit.oldEndIndex, "i32");
|
|
3545
|
+
address += SIZE_OF_INT;
|
|
3546
|
+
C.setValue(address, edit.newEndIndex, "i32");
|
|
3547
|
+
address += SIZE_OF_INT;
|
|
3548
|
+
}
|
|
3549
|
+
__name(marshalEdit, "marshalEdit");
|
|
3550
|
+
function unmarshalLanguageMetadata(address) {
|
|
3551
|
+
const major_version = C.getValue(address, "i32");
|
|
3552
|
+
const minor_version = C.getValue(address += SIZE_OF_INT, "i32");
|
|
3553
|
+
const patch_version = C.getValue(address += SIZE_OF_INT, "i32");
|
|
3554
|
+
return { major_version, minor_version, patch_version };
|
|
3555
|
+
}
|
|
3556
|
+
__name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
|
|
3557
|
+
|
|
3558
|
+
// src/language.ts
|
|
3559
|
+
var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
|
|
3560
|
+
var Language = class _Language {
|
|
3561
|
+
static {
|
|
3562
|
+
__name(this, "Language");
|
|
3563
|
+
}
|
|
3564
|
+
/** @internal */
|
|
3565
|
+
[0] = 0;
|
|
3566
|
+
// Internal handle for Wasm
|
|
3567
|
+
/**
|
|
3568
|
+
* A list of all node types in the language. The index of each type in this
|
|
3569
|
+
* array is its node type id.
|
|
3570
|
+
*/
|
|
3571
|
+
types;
|
|
3572
|
+
/**
|
|
3573
|
+
* A list of all field names in the language. The index of each field name in
|
|
3574
|
+
* this array is its field id.
|
|
3575
|
+
*/
|
|
3576
|
+
fields;
|
|
3577
|
+
/** @internal */
|
|
3578
|
+
constructor(internal, address) {
|
|
3579
|
+
assertInternal(internal);
|
|
3580
|
+
this[0] = address;
|
|
3581
|
+
this.types = new Array(C._ts_language_symbol_count(this[0]));
|
|
3582
|
+
for (let i2 = 0, n = this.types.length; i2 < n; i2++) {
|
|
3583
|
+
if (C._ts_language_symbol_type(this[0], i2) < 2) {
|
|
3584
|
+
this.types[i2] = C.UTF8ToString(C._ts_language_symbol_name(this[0], i2));
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
|
|
3588
|
+
for (let i2 = 0, n = this.fields.length; i2 < n; i2++) {
|
|
3589
|
+
const fieldName = C._ts_language_field_name_for_id(this[0], i2);
|
|
3590
|
+
if (fieldName !== 0) {
|
|
3591
|
+
this.fields[i2] = C.UTF8ToString(fieldName);
|
|
3592
|
+
} else {
|
|
3593
|
+
this.fields[i2] = null;
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
/**
|
|
3598
|
+
* Gets the name of the language.
|
|
3599
|
+
*/
|
|
3600
|
+
get name() {
|
|
3601
|
+
const ptr = C._ts_language_name(this[0]);
|
|
3602
|
+
if (ptr === 0) return null;
|
|
3603
|
+
return C.UTF8ToString(ptr);
|
|
3604
|
+
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Gets the ABI version of the language.
|
|
3607
|
+
*/
|
|
3608
|
+
get abiVersion() {
|
|
3609
|
+
return C._ts_language_abi_version(this[0]);
|
|
3610
|
+
}
|
|
3611
|
+
/**
|
|
3612
|
+
* Get the metadata for this language. This information is generated by the
|
|
3613
|
+
* CLI, and relies on the language author providing the correct metadata in
|
|
3614
|
+
* the language's `tree-sitter.json` file.
|
|
3615
|
+
*/
|
|
3616
|
+
get metadata() {
|
|
3617
|
+
C._ts_language_metadata_wasm(this[0]);
|
|
3618
|
+
const length = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3619
|
+
if (length === 0) return null;
|
|
3620
|
+
return unmarshalLanguageMetadata(TRANSFER_BUFFER + SIZE_OF_INT);
|
|
3621
|
+
}
|
|
3622
|
+
/**
|
|
3623
|
+
* Gets the number of fields in the language.
|
|
3624
|
+
*/
|
|
3625
|
+
get fieldCount() {
|
|
3626
|
+
return this.fields.length - 1;
|
|
3627
|
+
}
|
|
3628
|
+
/**
|
|
3629
|
+
* Gets the number of states in the language.
|
|
3630
|
+
*/
|
|
3631
|
+
get stateCount() {
|
|
3632
|
+
return C._ts_language_state_count(this[0]);
|
|
3633
|
+
}
|
|
3634
|
+
/**
|
|
3635
|
+
* Get the field id for a field name.
|
|
3636
|
+
*/
|
|
3637
|
+
fieldIdForName(fieldName) {
|
|
3638
|
+
const result = this.fields.indexOf(fieldName);
|
|
3639
|
+
return result !== -1 ? result : null;
|
|
3640
|
+
}
|
|
3641
|
+
/**
|
|
3642
|
+
* Get the field name for a field id.
|
|
3643
|
+
*/
|
|
3644
|
+
fieldNameForId(fieldId) {
|
|
3645
|
+
return this.fields[fieldId] ?? null;
|
|
3646
|
+
}
|
|
3647
|
+
/**
|
|
3648
|
+
* Get the node type id for a node type name.
|
|
3649
|
+
*/
|
|
3650
|
+
idForNodeType(type, named) {
|
|
3651
|
+
const typeLength = C.lengthBytesUTF8(type);
|
|
3652
|
+
const typeAddress = C._malloc(typeLength + 1);
|
|
3653
|
+
C.stringToUTF8(type, typeAddress, typeLength + 1);
|
|
3654
|
+
const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named ? 1 : 0);
|
|
3655
|
+
C._free(typeAddress);
|
|
3656
|
+
return result || null;
|
|
3657
|
+
}
|
|
3658
|
+
/**
|
|
3659
|
+
* Gets the number of node types in the language.
|
|
3660
|
+
*/
|
|
3661
|
+
get nodeTypeCount() {
|
|
3662
|
+
return C._ts_language_symbol_count(this[0]);
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Get the node type name for a node type id.
|
|
3666
|
+
*/
|
|
3667
|
+
nodeTypeForId(typeId) {
|
|
3668
|
+
const name2 = C._ts_language_symbol_name(this[0], typeId);
|
|
3669
|
+
return name2 ? C.UTF8ToString(name2) : null;
|
|
3670
|
+
}
|
|
3671
|
+
/**
|
|
3672
|
+
* Check if a node type is named.
|
|
3673
|
+
*
|
|
3674
|
+
* @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/2-basic-parsing.html#named-vs-anonymous-nodes}
|
|
3675
|
+
*/
|
|
3676
|
+
nodeTypeIsNamed(typeId) {
|
|
3677
|
+
return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false;
|
|
3678
|
+
}
|
|
3679
|
+
/**
|
|
3680
|
+
* Check if a node type is visible.
|
|
3681
|
+
*/
|
|
3682
|
+
nodeTypeIsVisible(typeId) {
|
|
3683
|
+
return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false;
|
|
3684
|
+
}
|
|
3685
|
+
/**
|
|
3686
|
+
* Get the supertypes ids of this language.
|
|
3687
|
+
*
|
|
3688
|
+
* @see {@link https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types.html?highlight=supertype#supertype-nodes}
|
|
3689
|
+
*/
|
|
3690
|
+
get supertypes() {
|
|
3691
|
+
C._ts_language_supertypes_wasm(this[0]);
|
|
3692
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3693
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3694
|
+
const result = new Array(count);
|
|
3695
|
+
if (count > 0) {
|
|
3696
|
+
let address = buffer;
|
|
3697
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3698
|
+
result[i2] = C.getValue(address, "i16");
|
|
3699
|
+
address += SIZE_OF_SHORT;
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
return result;
|
|
3703
|
+
}
|
|
3704
|
+
/**
|
|
3705
|
+
* Get the subtype ids for a given supertype node id.
|
|
3706
|
+
*/
|
|
3707
|
+
subtypes(supertype) {
|
|
3708
|
+
C._ts_language_subtypes_wasm(this[0], supertype);
|
|
3709
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3710
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3711
|
+
const result = new Array(count);
|
|
3712
|
+
if (count > 0) {
|
|
3713
|
+
let address = buffer;
|
|
3714
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3715
|
+
result[i2] = C.getValue(address, "i16");
|
|
3716
|
+
address += SIZE_OF_SHORT;
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
return result;
|
|
3720
|
+
}
|
|
3721
|
+
/**
|
|
3722
|
+
* Get the next state id for a given state id and node type id.
|
|
3723
|
+
*/
|
|
3724
|
+
nextState(stateId, typeId) {
|
|
3725
|
+
return C._ts_language_next_state(this[0], stateId, typeId);
|
|
3726
|
+
}
|
|
3727
|
+
/**
|
|
3728
|
+
* Create a new lookahead iterator for this language and parse state.
|
|
3729
|
+
*
|
|
3730
|
+
* This returns `null` if state is invalid for this language.
|
|
3731
|
+
*
|
|
3732
|
+
* Iterating {@link LookaheadIterator} will yield valid symbols in the given
|
|
3733
|
+
* parse state. Newly created lookahead iterators will return the `ERROR`
|
|
3734
|
+
* symbol from {@link LookaheadIterator#currentType}.
|
|
3735
|
+
*
|
|
3736
|
+
* Lookahead iterators can be useful for generating suggestions and improving
|
|
3737
|
+
* syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
|
|
3738
|
+
* lookahead iterator on its first leaf node state. For `MISSING` nodes, a
|
|
3739
|
+
* lookahead iterator created on the previous non-extra leaf node may be
|
|
3740
|
+
* appropriate.
|
|
3741
|
+
*/
|
|
3742
|
+
lookaheadIterator(stateId) {
|
|
3743
|
+
const address = C._ts_lookahead_iterator_new(this[0], stateId);
|
|
3744
|
+
if (address) return new LookaheadIterator(INTERNAL, address, this);
|
|
3745
|
+
return null;
|
|
3746
|
+
}
|
|
3747
|
+
/**
|
|
3748
|
+
* Load a language from a WebAssembly module.
|
|
3749
|
+
* The module can be provided as a path to a file or as a buffer.
|
|
3750
|
+
*/
|
|
3751
|
+
static async load(input) {
|
|
3752
|
+
let binary2;
|
|
3753
|
+
if (input instanceof Uint8Array) {
|
|
3754
|
+
binary2 = input;
|
|
3755
|
+
} else if (globalThis.process?.versions.node) {
|
|
3756
|
+
const fs2 = await import("fs/promises");
|
|
3757
|
+
binary2 = await fs2.readFile(input);
|
|
3758
|
+
} else {
|
|
3759
|
+
const response = await fetch(input);
|
|
3760
|
+
if (!response.ok) {
|
|
3761
|
+
const body2 = await response.text();
|
|
3762
|
+
throw new Error(`Language.load failed with status ${response.status}.
|
|
3763
|
+
|
|
3764
|
+
${body2}`);
|
|
3765
|
+
}
|
|
3766
|
+
const retryResp = response.clone();
|
|
3767
|
+
try {
|
|
3768
|
+
binary2 = await WebAssembly.compileStreaming(response);
|
|
3769
|
+
} catch (reason) {
|
|
3770
|
+
console.error("wasm streaming compile failed:", reason);
|
|
3771
|
+
console.error("falling back to ArrayBuffer instantiation");
|
|
3772
|
+
binary2 = new Uint8Array(await retryResp.arrayBuffer());
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
|
|
3776
|
+
const symbolNames = Object.keys(mod);
|
|
3777
|
+
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
|
|
3778
|
+
if (!functionName) {
|
|
3779
|
+
console.log(`Couldn't find language function in Wasm file. Symbols:
|
|
3780
|
+
${JSON.stringify(symbolNames, null, 2)}`);
|
|
3781
|
+
throw new Error("Language.load failed: no language function found in Wasm file");
|
|
3782
|
+
}
|
|
3783
|
+
const languageAddress = mod[functionName]();
|
|
3784
|
+
return new _Language(INTERNAL, languageAddress);
|
|
3785
|
+
}
|
|
3786
|
+
};
|
|
3787
|
+
|
|
3788
|
+
// src/bindings.ts
|
|
3789
|
+
var import_web_tree_sitter = __toESM(require_web_tree_sitter(), 1);
|
|
3790
|
+
var Module2 = null;
|
|
3791
|
+
async function initializeBinding(moduleOptions) {
|
|
3792
|
+
return Module2 ??= await (0, import_web_tree_sitter.default)(moduleOptions);
|
|
3793
|
+
}
|
|
3794
|
+
__name(initializeBinding, "initializeBinding");
|
|
3795
|
+
function checkModule() {
|
|
3796
|
+
return !!Module2;
|
|
3797
|
+
}
|
|
3798
|
+
__name(checkModule, "checkModule");
|
|
3799
|
+
|
|
3800
|
+
// src/parser.ts
|
|
3801
|
+
var TRANSFER_BUFFER;
|
|
3802
|
+
var LANGUAGE_VERSION;
|
|
3803
|
+
var MIN_COMPATIBLE_VERSION;
|
|
3804
|
+
var Parser = class {
|
|
3805
|
+
static {
|
|
3806
|
+
__name(this, "Parser");
|
|
3807
|
+
}
|
|
3808
|
+
/** @internal */
|
|
3809
|
+
[0] = 0;
|
|
3810
|
+
// Internal handle for Wasm
|
|
3811
|
+
/** @internal */
|
|
3812
|
+
[1] = 0;
|
|
3813
|
+
// Internal handle for Wasm
|
|
3814
|
+
/** @internal */
|
|
3815
|
+
logCallback = null;
|
|
3816
|
+
/** The parser's current language. */
|
|
3817
|
+
language = null;
|
|
3818
|
+
/**
|
|
3819
|
+
* This must always be called before creating a Parser.
|
|
3820
|
+
*
|
|
3821
|
+
* You can optionally pass in options to configure the Wasm module, the most common
|
|
3822
|
+
* one being `locateFile` to help the module find the `.wasm` file.
|
|
3823
|
+
*/
|
|
3824
|
+
static async init(moduleOptions) {
|
|
3825
|
+
setModule(await initializeBinding(moduleOptions));
|
|
3826
|
+
TRANSFER_BUFFER = C._ts_init();
|
|
3827
|
+
LANGUAGE_VERSION = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3828
|
+
MIN_COMPATIBLE_VERSION = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3829
|
+
}
|
|
3830
|
+
/**
|
|
3831
|
+
* Create a new parser.
|
|
3832
|
+
*/
|
|
3833
|
+
constructor() {
|
|
3834
|
+
this.initialize();
|
|
3835
|
+
}
|
|
3836
|
+
/** @internal */
|
|
3837
|
+
initialize() {
|
|
3838
|
+
if (!checkModule()) {
|
|
3839
|
+
throw new Error("cannot construct a Parser before calling `init()`");
|
|
3840
|
+
}
|
|
3841
|
+
C._ts_parser_new_wasm();
|
|
3842
|
+
this[0] = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3843
|
+
this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3844
|
+
}
|
|
3845
|
+
/** Delete the parser, freeing its resources. */
|
|
3846
|
+
delete() {
|
|
3847
|
+
C._ts_parser_delete(this[0]);
|
|
3848
|
+
C._free(this[1]);
|
|
3849
|
+
this[0] = 0;
|
|
3850
|
+
this[1] = 0;
|
|
3851
|
+
}
|
|
3852
|
+
/**
|
|
3853
|
+
* Set the language that the parser should use for parsing.
|
|
3854
|
+
*
|
|
3855
|
+
* If the language was not successfully assigned, an error will be thrown.
|
|
3856
|
+
* This happens if the language was generated with an incompatible
|
|
3857
|
+
* version of the Tree-sitter CLI. Check the language's version using
|
|
3858
|
+
* {@link Language#version} and compare it to this library's
|
|
3859
|
+
* {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants.
|
|
3860
|
+
*/
|
|
3861
|
+
setLanguage(language) {
|
|
3862
|
+
let address;
|
|
3863
|
+
if (!language) {
|
|
3864
|
+
address = 0;
|
|
3865
|
+
this.language = null;
|
|
3866
|
+
} else if (language.constructor === Language) {
|
|
3867
|
+
address = language[0];
|
|
3868
|
+
const version = C._ts_language_abi_version(address);
|
|
3869
|
+
if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
|
|
3870
|
+
throw new Error(
|
|
3871
|
+
`Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`
|
|
3872
|
+
);
|
|
3873
|
+
}
|
|
3874
|
+
this.language = language;
|
|
3875
|
+
} else {
|
|
3876
|
+
throw new Error("Argument must be a Language");
|
|
3877
|
+
}
|
|
3878
|
+
C._ts_parser_set_language(this[0], address);
|
|
3879
|
+
return this;
|
|
3880
|
+
}
|
|
3881
|
+
/**
|
|
3882
|
+
* Parse a slice of UTF8 text.
|
|
3883
|
+
*
|
|
3884
|
+
* @param {string | ParseCallback} callback - The UTF8-encoded text to parse or a callback function.
|
|
3885
|
+
*
|
|
3886
|
+
* @param {Tree | null} [oldTree] - A previous syntax tree parsed from the same document. If the text of the
|
|
3887
|
+
* document has changed since `oldTree` was created, then you must edit `oldTree` to match
|
|
3888
|
+
* the new text using {@link Tree#edit}.
|
|
3889
|
+
*
|
|
3890
|
+
* @param {ParseOptions} [options] - Options for parsing the text.
|
|
3891
|
+
* This can be used to set the included ranges, or a progress callback.
|
|
3892
|
+
*
|
|
3893
|
+
* @returns {Tree | null} A {@link Tree} if parsing succeeded, or `null` if:
|
|
3894
|
+
* - The parser has not yet had a language assigned with {@link Parser#setLanguage}.
|
|
3895
|
+
* - The progress callback returned true.
|
|
3896
|
+
*/
|
|
3897
|
+
parse(callback, oldTree, options) {
|
|
3898
|
+
if (typeof callback === "string") {
|
|
3899
|
+
C.currentParseCallback = (index) => callback.slice(index);
|
|
3900
|
+
} else if (typeof callback === "function") {
|
|
3901
|
+
C.currentParseCallback = callback;
|
|
3902
|
+
} else {
|
|
3903
|
+
throw new Error("Argument must be a string or a function");
|
|
3904
|
+
}
|
|
3905
|
+
if (options?.progressCallback) {
|
|
3906
|
+
C.currentProgressCallback = options.progressCallback;
|
|
3907
|
+
} else {
|
|
3908
|
+
C.currentProgressCallback = null;
|
|
3909
|
+
}
|
|
3910
|
+
if (this.logCallback) {
|
|
3911
|
+
C.currentLogCallback = this.logCallback;
|
|
3912
|
+
C._ts_parser_enable_logger_wasm(this[0], 1);
|
|
3913
|
+
} else {
|
|
3914
|
+
C.currentLogCallback = null;
|
|
3915
|
+
C._ts_parser_enable_logger_wasm(this[0], 0);
|
|
3916
|
+
}
|
|
3917
|
+
let rangeCount = 0;
|
|
3918
|
+
let rangeAddress = 0;
|
|
3919
|
+
if (options?.includedRanges) {
|
|
3920
|
+
rangeCount = options.includedRanges.length;
|
|
3921
|
+
rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);
|
|
3922
|
+
let address = rangeAddress;
|
|
3923
|
+
for (let i2 = 0; i2 < rangeCount; i2++) {
|
|
3924
|
+
marshalRange(address, options.includedRanges[i2]);
|
|
3925
|
+
address += SIZE_OF_RANGE;
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
const treeAddress = C._ts_parser_parse_wasm(
|
|
3929
|
+
this[0],
|
|
3930
|
+
this[1],
|
|
3931
|
+
oldTree ? oldTree[0] : 0,
|
|
3932
|
+
rangeAddress,
|
|
3933
|
+
rangeCount
|
|
3934
|
+
);
|
|
3935
|
+
if (!treeAddress) {
|
|
3936
|
+
C.currentParseCallback = null;
|
|
3937
|
+
C.currentLogCallback = null;
|
|
3938
|
+
C.currentProgressCallback = null;
|
|
3939
|
+
return null;
|
|
3940
|
+
}
|
|
3941
|
+
if (!this.language) {
|
|
3942
|
+
throw new Error("Parser must have a language to parse");
|
|
3943
|
+
}
|
|
3944
|
+
const result = new Tree(INTERNAL, treeAddress, this.language, C.currentParseCallback);
|
|
3945
|
+
C.currentParseCallback = null;
|
|
3946
|
+
C.currentLogCallback = null;
|
|
3947
|
+
C.currentProgressCallback = null;
|
|
3948
|
+
return result;
|
|
3949
|
+
}
|
|
3950
|
+
/**
|
|
3951
|
+
* Instruct the parser to start the next parse from the beginning.
|
|
3952
|
+
*
|
|
3953
|
+
* If the parser previously failed because of a callback,
|
|
3954
|
+
* then by default, it will resume where it left off on the
|
|
3955
|
+
* next call to {@link Parser#parse} or other parsing functions.
|
|
3956
|
+
* If you don't want to resume, and instead intend to use this parser to
|
|
3957
|
+
* parse some other document, you must call `reset` first.
|
|
3958
|
+
*/
|
|
3959
|
+
reset() {
|
|
3960
|
+
C._ts_parser_reset(this[0]);
|
|
3961
|
+
}
|
|
3962
|
+
/** Get the ranges of text that the parser will include when parsing. */
|
|
3963
|
+
getIncludedRanges() {
|
|
3964
|
+
C._ts_parser_included_ranges_wasm(this[0]);
|
|
3965
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
3966
|
+
const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
3967
|
+
const result = new Array(count);
|
|
3968
|
+
if (count > 0) {
|
|
3969
|
+
let address = buffer;
|
|
3970
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3971
|
+
result[i2] = unmarshalRange(address);
|
|
3972
|
+
address += SIZE_OF_RANGE;
|
|
3973
|
+
}
|
|
3974
|
+
C._free(buffer);
|
|
3975
|
+
}
|
|
3976
|
+
return result;
|
|
3977
|
+
}
|
|
3978
|
+
/** Set the logging callback that a parser should use during parsing. */
|
|
3979
|
+
setLogger(callback) {
|
|
3980
|
+
if (!callback) {
|
|
3981
|
+
this.logCallback = null;
|
|
3982
|
+
} else if (typeof callback !== "function") {
|
|
3983
|
+
throw new Error("Logger callback must be a function");
|
|
3984
|
+
} else {
|
|
3985
|
+
this.logCallback = callback;
|
|
3986
|
+
}
|
|
3987
|
+
return this;
|
|
3988
|
+
}
|
|
3989
|
+
/** Get the parser's current logger. */
|
|
3990
|
+
getLogger() {
|
|
3991
|
+
return this.logCallback;
|
|
3992
|
+
}
|
|
3993
|
+
};
|
|
3994
|
+
|
|
3995
|
+
// src/query.ts
|
|
3996
|
+
var PREDICATE_STEP_TYPE_CAPTURE = 1;
|
|
3997
|
+
var PREDICATE_STEP_TYPE_STRING = 2;
|
|
3998
|
+
var QUERY_WORD_REGEX = /[\w-]+/g;
|
|
3999
|
+
var CaptureQuantifier = {
|
|
4000
|
+
Zero: 0,
|
|
4001
|
+
ZeroOrOne: 1,
|
|
4002
|
+
ZeroOrMore: 2,
|
|
4003
|
+
One: 3,
|
|
4004
|
+
OneOrMore: 4
|
|
4005
|
+
};
|
|
4006
|
+
var isCaptureStep = /* @__PURE__ */ __name((step) => step.type === "capture", "isCaptureStep");
|
|
4007
|
+
var isStringStep = /* @__PURE__ */ __name((step) => step.type === "string", "isStringStep");
|
|
4008
|
+
var QueryErrorKind = {
|
|
4009
|
+
Syntax: 1,
|
|
4010
|
+
NodeName: 2,
|
|
4011
|
+
FieldName: 3,
|
|
4012
|
+
CaptureName: 4,
|
|
4013
|
+
PatternStructure: 5
|
|
4014
|
+
};
|
|
4015
|
+
var QueryError = class _QueryError extends Error {
|
|
4016
|
+
constructor(kind, info2, index, length) {
|
|
4017
|
+
super(_QueryError.formatMessage(kind, info2));
|
|
4018
|
+
this.kind = kind;
|
|
4019
|
+
this.info = info2;
|
|
4020
|
+
this.index = index;
|
|
4021
|
+
this.length = length;
|
|
4022
|
+
this.name = "QueryError";
|
|
4023
|
+
}
|
|
4024
|
+
static {
|
|
4025
|
+
__name(this, "QueryError");
|
|
4026
|
+
}
|
|
4027
|
+
/** Formats an error message based on the error kind and info */
|
|
4028
|
+
static formatMessage(kind, info2) {
|
|
4029
|
+
switch (kind) {
|
|
4030
|
+
case QueryErrorKind.NodeName:
|
|
4031
|
+
return `Bad node name '${info2.word}'`;
|
|
4032
|
+
case QueryErrorKind.FieldName:
|
|
4033
|
+
return `Bad field name '${info2.word}'`;
|
|
4034
|
+
case QueryErrorKind.CaptureName:
|
|
4035
|
+
return `Bad capture name @${info2.word}`;
|
|
4036
|
+
case QueryErrorKind.PatternStructure:
|
|
4037
|
+
return `Bad pattern structure at offset ${info2.suffix}`;
|
|
4038
|
+
case QueryErrorKind.Syntax:
|
|
4039
|
+
return `Bad syntax at offset ${info2.suffix}`;
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4042
|
+
};
|
|
4043
|
+
function parseAnyPredicate(steps, index, operator, textPredicates) {
|
|
4044
|
+
if (steps.length !== 3) {
|
|
4045
|
+
throw new Error(
|
|
4046
|
+
`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}`
|
|
4047
|
+
);
|
|
4048
|
+
}
|
|
4049
|
+
if (!isCaptureStep(steps[1])) {
|
|
4050
|
+
throw new Error(
|
|
4051
|
+
`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`
|
|
4052
|
+
);
|
|
4053
|
+
}
|
|
4054
|
+
const isPositive = operator === "eq?" || operator === "any-eq?";
|
|
4055
|
+
const matchAll = !operator.startsWith("any-");
|
|
4056
|
+
if (isCaptureStep(steps[2])) {
|
|
4057
|
+
const captureName1 = steps[1].name;
|
|
4058
|
+
const captureName2 = steps[2].name;
|
|
4059
|
+
textPredicates[index].push((captures) => {
|
|
4060
|
+
const nodes1 = [];
|
|
4061
|
+
const nodes2 = [];
|
|
4062
|
+
for (const c of captures) {
|
|
4063
|
+
if (c.name === captureName1) nodes1.push(c.node);
|
|
4064
|
+
if (c.name === captureName2) nodes2.push(c.node);
|
|
4065
|
+
}
|
|
4066
|
+
const compare = /* @__PURE__ */ __name((n1, n2, positive) => {
|
|
4067
|
+
return positive ? n1.text === n2.text : n1.text !== n2.text;
|
|
4068
|
+
}, "compare");
|
|
4069
|
+
return matchAll ? nodes1.every((n1) => nodes2.some((n2) => compare(n1, n2, isPositive))) : nodes1.some((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)));
|
|
4070
|
+
});
|
|
4071
|
+
} else {
|
|
4072
|
+
const captureName = steps[1].name;
|
|
4073
|
+
const stringValue = steps[2].value;
|
|
4074
|
+
const matches = /* @__PURE__ */ __name((n) => n.text === stringValue, "matches");
|
|
4075
|
+
const doesNotMatch = /* @__PURE__ */ __name((n) => n.text !== stringValue, "doesNotMatch");
|
|
4076
|
+
textPredicates[index].push((captures) => {
|
|
4077
|
+
const nodes = [];
|
|
4078
|
+
for (const c of captures) {
|
|
4079
|
+
if (c.name === captureName) nodes.push(c.node);
|
|
4080
|
+
}
|
|
4081
|
+
const test = isPositive ? matches : doesNotMatch;
|
|
4082
|
+
return matchAll ? nodes.every(test) : nodes.some(test);
|
|
4083
|
+
});
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
__name(parseAnyPredicate, "parseAnyPredicate");
|
|
4087
|
+
function parseMatchPredicate(steps, index, operator, textPredicates) {
|
|
4088
|
+
if (steps.length !== 3) {
|
|
4089
|
+
throw new Error(
|
|
4090
|
+
`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}.`
|
|
4091
|
+
);
|
|
4092
|
+
}
|
|
4093
|
+
if (steps[1].type !== "capture") {
|
|
4094
|
+
throw new Error(
|
|
4095
|
+
`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`
|
|
4096
|
+
);
|
|
4097
|
+
}
|
|
4098
|
+
if (steps[2].type !== "string") {
|
|
4099
|
+
throw new Error(
|
|
4100
|
+
`Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].name}.`
|
|
4101
|
+
);
|
|
4102
|
+
}
|
|
4103
|
+
const isPositive = operator === "match?" || operator === "any-match?";
|
|
4104
|
+
const matchAll = !operator.startsWith("any-");
|
|
4105
|
+
const captureName = steps[1].name;
|
|
4106
|
+
const regex = new RegExp(steps[2].value);
|
|
4107
|
+
textPredicates[index].push((captures) => {
|
|
4108
|
+
const nodes = [];
|
|
4109
|
+
for (const c of captures) {
|
|
4110
|
+
if (c.name === captureName) nodes.push(c.node.text);
|
|
4111
|
+
}
|
|
4112
|
+
const test = /* @__PURE__ */ __name((text, positive) => {
|
|
4113
|
+
return positive ? regex.test(text) : !regex.test(text);
|
|
4114
|
+
}, "test");
|
|
4115
|
+
if (nodes.length === 0) return !isPositive;
|
|
4116
|
+
return matchAll ? nodes.every((text) => test(text, isPositive)) : nodes.some((text) => test(text, isPositive));
|
|
4117
|
+
});
|
|
4118
|
+
}
|
|
4119
|
+
__name(parseMatchPredicate, "parseMatchPredicate");
|
|
4120
|
+
function parseAnyOfPredicate(steps, index, operator, textPredicates) {
|
|
4121
|
+
if (steps.length < 2) {
|
|
4122
|
+
throw new Error(
|
|
4123
|
+
`Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length - 1}.`
|
|
4124
|
+
);
|
|
4125
|
+
}
|
|
4126
|
+
if (steps[1].type !== "capture") {
|
|
4127
|
+
throw new Error(
|
|
4128
|
+
`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`
|
|
4129
|
+
);
|
|
4130
|
+
}
|
|
4131
|
+
const isPositive = operator === "any-of?";
|
|
4132
|
+
const captureName = steps[1].name;
|
|
4133
|
+
const stringSteps = steps.slice(2);
|
|
4134
|
+
if (!stringSteps.every(isStringStep)) {
|
|
4135
|
+
throw new Error(
|
|
4136
|
+
`Arguments to \`#${operator}\` predicate must be strings.".`
|
|
4137
|
+
);
|
|
4138
|
+
}
|
|
4139
|
+
const values = stringSteps.map((s) => s.value);
|
|
4140
|
+
textPredicates[index].push((captures) => {
|
|
4141
|
+
const nodes = [];
|
|
4142
|
+
for (const c of captures) {
|
|
4143
|
+
if (c.name === captureName) nodes.push(c.node.text);
|
|
4144
|
+
}
|
|
4145
|
+
if (nodes.length === 0) return !isPositive;
|
|
4146
|
+
return nodes.every((text) => values.includes(text)) === isPositive;
|
|
4147
|
+
});
|
|
4148
|
+
}
|
|
4149
|
+
__name(parseAnyOfPredicate, "parseAnyOfPredicate");
|
|
4150
|
+
function parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties) {
|
|
4151
|
+
if (steps.length < 2 || steps.length > 3) {
|
|
4152
|
+
throw new Error(
|
|
4153
|
+
`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`
|
|
4154
|
+
);
|
|
4155
|
+
}
|
|
4156
|
+
if (!steps.every(isStringStep)) {
|
|
4157
|
+
throw new Error(
|
|
4158
|
+
`Arguments to \`#${operator}\` predicate must be strings.".`
|
|
4159
|
+
);
|
|
4160
|
+
}
|
|
4161
|
+
const properties = operator === "is?" ? assertedProperties : refutedProperties;
|
|
4162
|
+
if (!properties[index]) properties[index] = {};
|
|
4163
|
+
properties[index][steps[1].value] = steps[2]?.value ?? null;
|
|
4164
|
+
}
|
|
4165
|
+
__name(parseIsPredicate, "parseIsPredicate");
|
|
4166
|
+
function parseSetDirective(steps, index, setProperties) {
|
|
4167
|
+
if (steps.length < 2 || steps.length > 3) {
|
|
4168
|
+
throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
|
|
4169
|
+
}
|
|
4170
|
+
if (!steps.every(isStringStep)) {
|
|
4171
|
+
throw new Error(`Arguments to \`#set!\` predicate must be strings.".`);
|
|
4172
|
+
}
|
|
4173
|
+
if (!setProperties[index]) setProperties[index] = {};
|
|
4174
|
+
setProperties[index][steps[1].value] = steps[2]?.value ?? null;
|
|
4175
|
+
}
|
|
4176
|
+
__name(parseSetDirective, "parseSetDirective");
|
|
4177
|
+
function parsePattern(index, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
|
|
4178
|
+
if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
|
|
4179
|
+
const name2 = captureNames[stepValueId];
|
|
4180
|
+
steps.push({ type: "capture", name: name2 });
|
|
4181
|
+
} else if (stepType === PREDICATE_STEP_TYPE_STRING) {
|
|
4182
|
+
steps.push({ type: "string", value: stringValues[stepValueId] });
|
|
4183
|
+
} else if (steps.length > 0) {
|
|
4184
|
+
if (steps[0].type !== "string") {
|
|
4185
|
+
throw new Error("Predicates must begin with a literal value");
|
|
4186
|
+
}
|
|
4187
|
+
const operator = steps[0].value;
|
|
4188
|
+
switch (operator) {
|
|
4189
|
+
case "any-not-eq?":
|
|
4190
|
+
case "not-eq?":
|
|
4191
|
+
case "any-eq?":
|
|
4192
|
+
case "eq?":
|
|
4193
|
+
parseAnyPredicate(steps, index, operator, textPredicates);
|
|
4194
|
+
break;
|
|
4195
|
+
case "any-not-match?":
|
|
4196
|
+
case "not-match?":
|
|
4197
|
+
case "any-match?":
|
|
4198
|
+
case "match?":
|
|
4199
|
+
parseMatchPredicate(steps, index, operator, textPredicates);
|
|
4200
|
+
break;
|
|
4201
|
+
case "not-any-of?":
|
|
4202
|
+
case "any-of?":
|
|
4203
|
+
parseAnyOfPredicate(steps, index, operator, textPredicates);
|
|
4204
|
+
break;
|
|
4205
|
+
case "is?":
|
|
4206
|
+
case "is-not?":
|
|
4207
|
+
parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties);
|
|
4208
|
+
break;
|
|
4209
|
+
case "set!":
|
|
4210
|
+
parseSetDirective(steps, index, setProperties);
|
|
4211
|
+
break;
|
|
4212
|
+
default:
|
|
4213
|
+
predicates[index].push({ operator, operands: steps.slice(1) });
|
|
4214
|
+
}
|
|
4215
|
+
steps.length = 0;
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
__name(parsePattern, "parsePattern");
|
|
4219
|
+
var Query = class {
|
|
4220
|
+
static {
|
|
4221
|
+
__name(this, "Query");
|
|
4222
|
+
}
|
|
4223
|
+
/** @internal */
|
|
4224
|
+
[0] = 0;
|
|
4225
|
+
// Internal handle for Wasm
|
|
4226
|
+
/** @internal */
|
|
4227
|
+
exceededMatchLimit;
|
|
4228
|
+
/** @internal */
|
|
4229
|
+
textPredicates;
|
|
4230
|
+
/** The names of the captures used in the query. */
|
|
4231
|
+
captureNames;
|
|
4232
|
+
/** The quantifiers of the captures used in the query. */
|
|
4233
|
+
captureQuantifiers;
|
|
4234
|
+
/**
|
|
4235
|
+
* The other user-defined predicates associated with the given index.
|
|
4236
|
+
*
|
|
4237
|
+
* This includes predicates with operators other than:
|
|
4238
|
+
* - `match?`
|
|
4239
|
+
* - `eq?` and `not-eq?`
|
|
4240
|
+
* - `any-of?` and `not-any-of?`
|
|
4241
|
+
* - `is?` and `is-not?`
|
|
4242
|
+
* - `set!`
|
|
4243
|
+
*/
|
|
4244
|
+
predicates;
|
|
4245
|
+
/** The properties for predicates with the operator `set!`. */
|
|
4246
|
+
setProperties;
|
|
4247
|
+
/** The properties for predicates with the operator `is?`. */
|
|
4248
|
+
assertedProperties;
|
|
4249
|
+
/** The properties for predicates with the operator `is-not?`. */
|
|
4250
|
+
refutedProperties;
|
|
4251
|
+
/** The maximum number of in-progress matches for this cursor. */
|
|
4252
|
+
matchLimit;
|
|
4253
|
+
/**
|
|
4254
|
+
* Create a new query from a string containing one or more S-expression
|
|
4255
|
+
* patterns.
|
|
4256
|
+
*
|
|
4257
|
+
* The query is associated with a particular language, and can only be run
|
|
4258
|
+
* on syntax nodes parsed with that language. References to Queries can be
|
|
4259
|
+
* shared between multiple threads.
|
|
4260
|
+
*
|
|
4261
|
+
* @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
|
|
4262
|
+
*/
|
|
4263
|
+
constructor(language, source) {
|
|
4264
|
+
const sourceLength = C.lengthBytesUTF8(source);
|
|
4265
|
+
const sourceAddress = C._malloc(sourceLength + 1);
|
|
4266
|
+
C.stringToUTF8(source, sourceAddress, sourceLength + 1);
|
|
4267
|
+
const address = C._ts_query_new(
|
|
4268
|
+
language[0],
|
|
4269
|
+
sourceAddress,
|
|
4270
|
+
sourceLength,
|
|
4271
|
+
TRANSFER_BUFFER,
|
|
4272
|
+
TRANSFER_BUFFER + SIZE_OF_INT
|
|
4273
|
+
);
|
|
4274
|
+
if (!address) {
|
|
4275
|
+
const errorId = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
4276
|
+
const errorByte = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4277
|
+
const errorIndex = C.UTF8ToString(sourceAddress, errorByte).length;
|
|
4278
|
+
const suffix = source.slice(errorIndex, errorIndex + 100).split("\n")[0];
|
|
4279
|
+
const word = suffix.match(QUERY_WORD_REGEX)?.[0] ?? "";
|
|
4280
|
+
C._free(sourceAddress);
|
|
4281
|
+
switch (errorId) {
|
|
4282
|
+
case QueryErrorKind.Syntax:
|
|
4283
|
+
throw new QueryError(QueryErrorKind.Syntax, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
|
|
4284
|
+
case QueryErrorKind.NodeName:
|
|
4285
|
+
throw new QueryError(errorId, { word }, errorIndex, word.length);
|
|
4286
|
+
case QueryErrorKind.FieldName:
|
|
4287
|
+
throw new QueryError(errorId, { word }, errorIndex, word.length);
|
|
4288
|
+
case QueryErrorKind.CaptureName:
|
|
4289
|
+
throw new QueryError(errorId, { word }, errorIndex, word.length);
|
|
4290
|
+
case QueryErrorKind.PatternStructure:
|
|
4291
|
+
throw new QueryError(errorId, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
|
|
4292
|
+
}
|
|
4293
|
+
}
|
|
4294
|
+
const stringCount = C._ts_query_string_count(address);
|
|
4295
|
+
const captureCount = C._ts_query_capture_count(address);
|
|
4296
|
+
const patternCount = C._ts_query_pattern_count(address);
|
|
4297
|
+
const captureNames = new Array(captureCount);
|
|
4298
|
+
const captureQuantifiers = new Array(patternCount);
|
|
4299
|
+
const stringValues = new Array(stringCount);
|
|
4300
|
+
for (let i2 = 0; i2 < captureCount; i2++) {
|
|
4301
|
+
const nameAddress = C._ts_query_capture_name_for_id(
|
|
4302
|
+
address,
|
|
4303
|
+
i2,
|
|
4304
|
+
TRANSFER_BUFFER
|
|
4305
|
+
);
|
|
4306
|
+
const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4307
|
+
captureNames[i2] = C.UTF8ToString(nameAddress, nameLength);
|
|
4308
|
+
}
|
|
4309
|
+
for (let i2 = 0; i2 < patternCount; i2++) {
|
|
4310
|
+
const captureQuantifiersArray = new Array(captureCount);
|
|
4311
|
+
for (let j = 0; j < captureCount; j++) {
|
|
4312
|
+
const quantifier = C._ts_query_capture_quantifier_for_id(address, i2, j);
|
|
4313
|
+
captureQuantifiersArray[j] = quantifier;
|
|
4314
|
+
}
|
|
4315
|
+
captureQuantifiers[i2] = captureQuantifiersArray;
|
|
4316
|
+
}
|
|
4317
|
+
for (let i2 = 0; i2 < stringCount; i2++) {
|
|
4318
|
+
const valueAddress = C._ts_query_string_value_for_id(
|
|
4319
|
+
address,
|
|
4320
|
+
i2,
|
|
4321
|
+
TRANSFER_BUFFER
|
|
4322
|
+
);
|
|
4323
|
+
const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4324
|
+
stringValues[i2] = C.UTF8ToString(valueAddress, nameLength);
|
|
4325
|
+
}
|
|
4326
|
+
const setProperties = new Array(patternCount);
|
|
4327
|
+
const assertedProperties = new Array(patternCount);
|
|
4328
|
+
const refutedProperties = new Array(patternCount);
|
|
4329
|
+
const predicates = new Array(patternCount);
|
|
4330
|
+
const textPredicates = new Array(patternCount);
|
|
4331
|
+
for (let i2 = 0; i2 < patternCount; i2++) {
|
|
4332
|
+
const predicatesAddress = C._ts_query_predicates_for_pattern(address, i2, TRANSFER_BUFFER);
|
|
4333
|
+
const stepCount = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4334
|
+
predicates[i2] = [];
|
|
4335
|
+
textPredicates[i2] = [];
|
|
4336
|
+
const steps = new Array();
|
|
4337
|
+
let stepAddress = predicatesAddress;
|
|
4338
|
+
for (let j = 0; j < stepCount; j++) {
|
|
4339
|
+
const stepType = C.getValue(stepAddress, "i32");
|
|
4340
|
+
stepAddress += SIZE_OF_INT;
|
|
4341
|
+
const stepValueId = C.getValue(stepAddress, "i32");
|
|
4342
|
+
stepAddress += SIZE_OF_INT;
|
|
4343
|
+
parsePattern(
|
|
4344
|
+
i2,
|
|
4345
|
+
stepType,
|
|
4346
|
+
stepValueId,
|
|
4347
|
+
captureNames,
|
|
4348
|
+
stringValues,
|
|
4349
|
+
steps,
|
|
4350
|
+
textPredicates,
|
|
4351
|
+
predicates,
|
|
4352
|
+
setProperties,
|
|
4353
|
+
assertedProperties,
|
|
4354
|
+
refutedProperties
|
|
4355
|
+
);
|
|
4356
|
+
}
|
|
4357
|
+
Object.freeze(textPredicates[i2]);
|
|
4358
|
+
Object.freeze(predicates[i2]);
|
|
4359
|
+
Object.freeze(setProperties[i2]);
|
|
4360
|
+
Object.freeze(assertedProperties[i2]);
|
|
4361
|
+
Object.freeze(refutedProperties[i2]);
|
|
4362
|
+
}
|
|
4363
|
+
C._free(sourceAddress);
|
|
4364
|
+
this[0] = address;
|
|
4365
|
+
this.captureNames = captureNames;
|
|
4366
|
+
this.captureQuantifiers = captureQuantifiers;
|
|
4367
|
+
this.textPredicates = textPredicates;
|
|
4368
|
+
this.predicates = predicates;
|
|
4369
|
+
this.setProperties = setProperties;
|
|
4370
|
+
this.assertedProperties = assertedProperties;
|
|
4371
|
+
this.refutedProperties = refutedProperties;
|
|
4372
|
+
this.exceededMatchLimit = false;
|
|
4373
|
+
}
|
|
4374
|
+
/** Delete the query, freeing its resources. */
|
|
4375
|
+
delete() {
|
|
4376
|
+
C._ts_query_delete(this[0]);
|
|
4377
|
+
this[0] = 0;
|
|
4378
|
+
}
|
|
4379
|
+
/**
|
|
4380
|
+
* Iterate over all of the matches in the order that they were found.
|
|
4381
|
+
*
|
|
4382
|
+
* Each match contains the index of the pattern that matched, and a list of
|
|
4383
|
+
* captures. Because multiple patterns can match the same set of nodes,
|
|
4384
|
+
* one match may contain captures that appear *before* some of the
|
|
4385
|
+
* captures from a previous match.
|
|
4386
|
+
*
|
|
4387
|
+
* @param {Node} node - The node to execute the query on.
|
|
4388
|
+
*
|
|
4389
|
+
* @param {QueryOptions} options - Options for query execution.
|
|
4390
|
+
*/
|
|
4391
|
+
matches(node, options = {}) {
|
|
4392
|
+
const startPosition = options.startPosition ?? ZERO_POINT;
|
|
4393
|
+
const endPosition = options.endPosition ?? ZERO_POINT;
|
|
4394
|
+
const startIndex = options.startIndex ?? 0;
|
|
4395
|
+
const endIndex = options.endIndex ?? 0;
|
|
4396
|
+
const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
|
|
4397
|
+
const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
|
|
4398
|
+
const startContainingIndex = options.startContainingIndex ?? 0;
|
|
4399
|
+
const endContainingIndex = options.endContainingIndex ?? 0;
|
|
4400
|
+
const matchLimit = options.matchLimit ?? 4294967295;
|
|
4401
|
+
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
4402
|
+
const progressCallback = options.progressCallback;
|
|
4403
|
+
if (typeof matchLimit !== "number") {
|
|
4404
|
+
throw new Error("Arguments must be numbers");
|
|
4405
|
+
}
|
|
4406
|
+
this.matchLimit = matchLimit;
|
|
4407
|
+
if (endIndex !== 0 && startIndex > endIndex) {
|
|
4408
|
+
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
4409
|
+
}
|
|
4410
|
+
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
4411
|
+
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
4412
|
+
}
|
|
4413
|
+
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
4414
|
+
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
4415
|
+
}
|
|
4416
|
+
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
4417
|
+
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
4418
|
+
}
|
|
4419
|
+
if (progressCallback) {
|
|
4420
|
+
C.currentQueryProgressCallback = progressCallback;
|
|
4421
|
+
}
|
|
4422
|
+
marshalNode(node);
|
|
4423
|
+
C._ts_query_matches_wasm(
|
|
4424
|
+
this[0],
|
|
4425
|
+
node.tree[0],
|
|
4426
|
+
startPosition.row,
|
|
4427
|
+
startPosition.column,
|
|
4428
|
+
endPosition.row,
|
|
4429
|
+
endPosition.column,
|
|
4430
|
+
startIndex,
|
|
4431
|
+
endIndex,
|
|
4432
|
+
startContainingPosition.row,
|
|
4433
|
+
startContainingPosition.column,
|
|
4434
|
+
endContainingPosition.row,
|
|
4435
|
+
endContainingPosition.column,
|
|
4436
|
+
startContainingIndex,
|
|
4437
|
+
endContainingIndex,
|
|
4438
|
+
matchLimit,
|
|
4439
|
+
maxStartDepth
|
|
4440
|
+
);
|
|
4441
|
+
const rawCount = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4442
|
+
const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
4443
|
+
const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
4444
|
+
const result = new Array(rawCount);
|
|
4445
|
+
this.exceededMatchLimit = Boolean(didExceedMatchLimit);
|
|
4446
|
+
let filteredCount = 0;
|
|
4447
|
+
let address = startAddress;
|
|
4448
|
+
for (let i2 = 0; i2 < rawCount; i2++) {
|
|
4449
|
+
const patternIndex = C.getValue(address, "i32");
|
|
4450
|
+
address += SIZE_OF_INT;
|
|
4451
|
+
const captureCount = C.getValue(address, "i32");
|
|
4452
|
+
address += SIZE_OF_INT;
|
|
4453
|
+
const captures = new Array(captureCount);
|
|
4454
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
4455
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
4456
|
+
result[filteredCount] = { patternIndex, captures };
|
|
4457
|
+
const setProperties = this.setProperties[patternIndex];
|
|
4458
|
+
result[filteredCount].setProperties = setProperties;
|
|
4459
|
+
const assertedProperties = this.assertedProperties[patternIndex];
|
|
4460
|
+
result[filteredCount].assertedProperties = assertedProperties;
|
|
4461
|
+
const refutedProperties = this.refutedProperties[patternIndex];
|
|
4462
|
+
result[filteredCount].refutedProperties = refutedProperties;
|
|
4463
|
+
filteredCount++;
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
result.length = filteredCount;
|
|
4467
|
+
C._free(startAddress);
|
|
4468
|
+
C.currentQueryProgressCallback = null;
|
|
4469
|
+
return result;
|
|
4470
|
+
}
|
|
4471
|
+
/**
|
|
4472
|
+
* Iterate over all of the individual captures in the order that they
|
|
4473
|
+
* appear.
|
|
4474
|
+
*
|
|
4475
|
+
* This is useful if you don't care about which pattern matched, and just
|
|
4476
|
+
* want a single, ordered sequence of captures.
|
|
4477
|
+
*
|
|
4478
|
+
* @param {Node} node - The node to execute the query on.
|
|
4479
|
+
*
|
|
4480
|
+
* @param {QueryOptions} options - Options for query execution.
|
|
4481
|
+
*/
|
|
4482
|
+
captures(node, options = {}) {
|
|
4483
|
+
const startPosition = options.startPosition ?? ZERO_POINT;
|
|
4484
|
+
const endPosition = options.endPosition ?? ZERO_POINT;
|
|
4485
|
+
const startIndex = options.startIndex ?? 0;
|
|
4486
|
+
const endIndex = options.endIndex ?? 0;
|
|
4487
|
+
const startContainingPosition = options.startContainingPosition ?? ZERO_POINT;
|
|
4488
|
+
const endContainingPosition = options.endContainingPosition ?? ZERO_POINT;
|
|
4489
|
+
const startContainingIndex = options.startContainingIndex ?? 0;
|
|
4490
|
+
const endContainingIndex = options.endContainingIndex ?? 0;
|
|
4491
|
+
const matchLimit = options.matchLimit ?? 4294967295;
|
|
4492
|
+
const maxStartDepth = options.maxStartDepth ?? 4294967295;
|
|
4493
|
+
const progressCallback = options.progressCallback;
|
|
4494
|
+
if (typeof matchLimit !== "number") {
|
|
4495
|
+
throw new Error("Arguments must be numbers");
|
|
4496
|
+
}
|
|
4497
|
+
this.matchLimit = matchLimit;
|
|
4498
|
+
if (endIndex !== 0 && startIndex > endIndex) {
|
|
4499
|
+
throw new Error("`startIndex` cannot be greater than `endIndex`");
|
|
4500
|
+
}
|
|
4501
|
+
if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
|
|
4502
|
+
throw new Error("`startPosition` cannot be greater than `endPosition`");
|
|
4503
|
+
}
|
|
4504
|
+
if (endContainingIndex !== 0 && startContainingIndex > endContainingIndex) {
|
|
4505
|
+
throw new Error("`startContainingIndex` cannot be greater than `endContainingIndex`");
|
|
4506
|
+
}
|
|
4507
|
+
if (endContainingPosition !== ZERO_POINT && (startContainingPosition.row > endContainingPosition.row || startContainingPosition.row === endContainingPosition.row && startContainingPosition.column > endContainingPosition.column)) {
|
|
4508
|
+
throw new Error("`startContainingPosition` cannot be greater than `endContainingPosition`");
|
|
4509
|
+
}
|
|
4510
|
+
if (progressCallback) {
|
|
4511
|
+
C.currentQueryProgressCallback = progressCallback;
|
|
4512
|
+
}
|
|
4513
|
+
marshalNode(node);
|
|
4514
|
+
C._ts_query_captures_wasm(
|
|
4515
|
+
this[0],
|
|
4516
|
+
node.tree[0],
|
|
4517
|
+
startPosition.row,
|
|
4518
|
+
startPosition.column,
|
|
4519
|
+
endPosition.row,
|
|
4520
|
+
endPosition.column,
|
|
4521
|
+
startIndex,
|
|
4522
|
+
endIndex,
|
|
4523
|
+
startContainingPosition.row,
|
|
4524
|
+
startContainingPosition.column,
|
|
4525
|
+
endContainingPosition.row,
|
|
4526
|
+
endContainingPosition.column,
|
|
4527
|
+
startContainingIndex,
|
|
4528
|
+
endContainingIndex,
|
|
4529
|
+
matchLimit,
|
|
4530
|
+
maxStartDepth
|
|
4531
|
+
);
|
|
4532
|
+
const count = C.getValue(TRANSFER_BUFFER, "i32");
|
|
4533
|
+
const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
4534
|
+
const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
4535
|
+
const result = new Array();
|
|
4536
|
+
this.exceededMatchLimit = Boolean(didExceedMatchLimit);
|
|
4537
|
+
const captures = new Array();
|
|
4538
|
+
let address = startAddress;
|
|
4539
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
4540
|
+
const patternIndex = C.getValue(address, "i32");
|
|
4541
|
+
address += SIZE_OF_INT;
|
|
4542
|
+
const captureCount = C.getValue(address, "i32");
|
|
4543
|
+
address += SIZE_OF_INT;
|
|
4544
|
+
const captureIndex = C.getValue(address, "i32");
|
|
4545
|
+
address += SIZE_OF_INT;
|
|
4546
|
+
captures.length = captureCount;
|
|
4547
|
+
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
4548
|
+
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
4549
|
+
const capture = captures[captureIndex];
|
|
4550
|
+
const setProperties = this.setProperties[patternIndex];
|
|
4551
|
+
capture.setProperties = setProperties;
|
|
4552
|
+
const assertedProperties = this.assertedProperties[patternIndex];
|
|
4553
|
+
capture.assertedProperties = assertedProperties;
|
|
4554
|
+
const refutedProperties = this.refutedProperties[patternIndex];
|
|
4555
|
+
capture.refutedProperties = refutedProperties;
|
|
4556
|
+
result.push(capture);
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
C._free(startAddress);
|
|
4560
|
+
C.currentQueryProgressCallback = null;
|
|
4561
|
+
return result;
|
|
4562
|
+
}
|
|
4563
|
+
/** Get the predicates for a given pattern. */
|
|
4564
|
+
predicatesForPattern(patternIndex) {
|
|
4565
|
+
return this.predicates[patternIndex];
|
|
4566
|
+
}
|
|
4567
|
+
/**
|
|
4568
|
+
* Disable a certain capture within a query.
|
|
4569
|
+
*
|
|
4570
|
+
* This prevents the capture from being returned in matches, and also
|
|
4571
|
+
* avoids any resource usage associated with recording the capture.
|
|
4572
|
+
*/
|
|
4573
|
+
disableCapture(captureName) {
|
|
4574
|
+
const captureNameLength = C.lengthBytesUTF8(captureName);
|
|
4575
|
+
const captureNameAddress = C._malloc(captureNameLength + 1);
|
|
4576
|
+
C.stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);
|
|
4577
|
+
C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);
|
|
4578
|
+
C._free(captureNameAddress);
|
|
4579
|
+
}
|
|
4580
|
+
/**
|
|
4581
|
+
* Disable a certain pattern within a query.
|
|
4582
|
+
*
|
|
4583
|
+
* This prevents the pattern from matching, and also avoids any resource
|
|
4584
|
+
* usage associated with the pattern. This throws an error if the pattern
|
|
4585
|
+
* index is out of bounds.
|
|
4586
|
+
*/
|
|
4587
|
+
disablePattern(patternIndex) {
|
|
4588
|
+
if (patternIndex >= this.predicates.length) {
|
|
4589
|
+
throw new Error(
|
|
4590
|
+
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4591
|
+
);
|
|
4592
|
+
}
|
|
4593
|
+
C._ts_query_disable_pattern(this[0], patternIndex);
|
|
4594
|
+
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Check if, on its last execution, this cursor exceeded its maximum number
|
|
4597
|
+
* of in-progress matches.
|
|
4598
|
+
*/
|
|
4599
|
+
didExceedMatchLimit() {
|
|
4600
|
+
return this.exceededMatchLimit;
|
|
4601
|
+
}
|
|
4602
|
+
/** Get the byte offset where the given pattern starts in the query's source. */
|
|
4603
|
+
startIndexForPattern(patternIndex) {
|
|
4604
|
+
if (patternIndex >= this.predicates.length) {
|
|
4605
|
+
throw new Error(
|
|
4606
|
+
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4607
|
+
);
|
|
4608
|
+
}
|
|
4609
|
+
return C._ts_query_start_byte_for_pattern(this[0], patternIndex);
|
|
4610
|
+
}
|
|
4611
|
+
/** Get the byte offset where the given pattern ends in the query's source. */
|
|
4612
|
+
endIndexForPattern(patternIndex) {
|
|
4613
|
+
if (patternIndex >= this.predicates.length) {
|
|
4614
|
+
throw new Error(
|
|
4615
|
+
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4616
|
+
);
|
|
4617
|
+
}
|
|
4618
|
+
return C._ts_query_end_byte_for_pattern(this[0], patternIndex);
|
|
4619
|
+
}
|
|
4620
|
+
/** Get the number of patterns in the query. */
|
|
4621
|
+
patternCount() {
|
|
4622
|
+
return C._ts_query_pattern_count(this[0]);
|
|
4623
|
+
}
|
|
4624
|
+
/** Get the index for a given capture name. */
|
|
4625
|
+
captureIndexForName(captureName) {
|
|
4626
|
+
return this.captureNames.indexOf(captureName);
|
|
4627
|
+
}
|
|
4628
|
+
/** Check if a given pattern within a query has a single root node. */
|
|
4629
|
+
isPatternRooted(patternIndex) {
|
|
4630
|
+
return C._ts_query_is_pattern_rooted(this[0], patternIndex) === 1;
|
|
4631
|
+
}
|
|
4632
|
+
/** Check if a given pattern within a query has a single root node. */
|
|
4633
|
+
isPatternNonLocal(patternIndex) {
|
|
4634
|
+
return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
|
|
4635
|
+
}
|
|
4636
|
+
/**
|
|
4637
|
+
* Check if a given step in a query is 'definite'.
|
|
4638
|
+
*
|
|
4639
|
+
* A query step is 'definite' if its parent pattern will be guaranteed to
|
|
4640
|
+
* match successfully once it reaches the step.
|
|
4641
|
+
*/
|
|
4642
|
+
isPatternGuaranteedAtStep(byteIndex) {
|
|
4643
|
+
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
|
|
4644
|
+
}
|
|
4645
|
+
};
|
|
4646
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
4647
|
+
0 && (module.exports = {
|
|
4648
|
+
CaptureQuantifier,
|
|
4649
|
+
Edit,
|
|
4650
|
+
LANGUAGE_VERSION,
|
|
4651
|
+
Language,
|
|
4652
|
+
LookaheadIterator,
|
|
4653
|
+
MIN_COMPATIBLE_VERSION,
|
|
4654
|
+
Node,
|
|
4655
|
+
Parser,
|
|
4656
|
+
Query,
|
|
4657
|
+
Tree,
|
|
4658
|
+
TreeCursor
|
|
4659
|
+
});
|
|
4660
|
+
module.exports.default = module.exports;
|
|
4661
|
+
//# sourceMappingURL=web-tree-sitter.cjs.map
|