wasm: Fix logic for finding language functions
This commit is contained in:
parent
70309ad846
commit
9ea3668f75
1 changed files with 3 additions and 1 deletions
|
|
@ -11,6 +11,8 @@ const PREDICATE_STEP_TYPE_DONE = 0;
|
|||
const PREDICATE_STEP_TYPE_CAPTURE = 1;
|
||||
const PREDICATE_STEP_TYPE_STRING = 2;
|
||||
|
||||
const LANGUAGE_FUNCTION_REGEX = /^_?tree_sitter_\w+/;
|
||||
|
||||
var VERSION;
|
||||
var MIN_COMPATIBLE_VERSION;
|
||||
var TRANSFER_BUFFER;
|
||||
|
|
@ -866,7 +868,7 @@ class Language {
|
|||
.then(bytes => loadWebAssemblyModule(bytes, {loadAsync: true}))
|
||||
.then(mod => {
|
||||
const functionName = Object.keys(mod).find(key =>
|
||||
key.includes("tree_sitter_") &&
|
||||
LANGUAGE_FUNCTION_REGEX.test(key) &&
|
||||
!key.includes("external_scanner_")
|
||||
);
|
||||
const languageAddress = mod[functionName]();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue