docs: change WASM/wasm to Wasm
That is the official capitalisation.
This commit is contained in:
parent
7bc8f76667
commit
88e0b4cea4
36 changed files with 122 additions and 122 deletions
|
|
@ -14,7 +14,7 @@ Tree-sitter is a parser generator tool and an incremental parsing library. It ca
|
|||
## Links
|
||||
- [Documentation](https://tree-sitter.github.io)
|
||||
- [Rust binding](lib/binding_rust/README.md)
|
||||
- [WASM binding](lib/binding_web/README.md)
|
||||
- [Wasm binding](lib/binding_web/README.md)
|
||||
- [Command-line interface](crates/cli/README.md)
|
||||
|
||||
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ struct Generate {
|
|||
#[derive(Args)]
|
||||
#[command(alias = "b")]
|
||||
struct Build {
|
||||
/// Build a WASM module instead of a dynamic library
|
||||
/// Build a Wasm module instead of a dynamic library
|
||||
#[arg(short, long)]
|
||||
pub wasm: bool,
|
||||
/// No longer used.
|
||||
|
|
@ -205,7 +205,7 @@ struct Parse {
|
|||
/// Produce the log.html file with debug graphs
|
||||
#[arg(long, short = 'D')]
|
||||
pub debug_graph: bool,
|
||||
/// Compile parsers to wasm instead of native dynamic libraries
|
||||
/// Compile parsers to Wasm instead of native dynamic libraries
|
||||
#[arg(long)]
|
||||
pub wasm: bool,
|
||||
/// Output the parse data with graphviz dot
|
||||
|
|
@ -302,7 +302,7 @@ struct Test {
|
|||
/// Produce the log.html file with debug graphs
|
||||
#[arg(long, short = 'D')]
|
||||
pub debug_graph: bool,
|
||||
/// Compile parsers to wasm instead of native dynamic libraries
|
||||
/// Compile parsers to Wasm instead of native dynamic libraries
|
||||
#[arg(long)]
|
||||
pub wasm: bool,
|
||||
/// Open `log.html` in the default browser, if `--debug-graph` is supplied
|
||||
|
|
@ -520,7 +520,7 @@ struct Playground {
|
|||
/// Don't open in default browser
|
||||
#[arg(long, short)]
|
||||
pub quiet: bool,
|
||||
/// Path to the directory containing the grammar and wasm files
|
||||
/// Path to the directory containing the grammar and Wasm files
|
||||
#[arg(long)]
|
||||
pub grammar_path: Option<PathBuf>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ fn test_load_multiple_wasm_languages() {
|
|||
let mut query_cursor = QueryCursor::new();
|
||||
|
||||
// First, parse with the store that originally loaded the languages.
|
||||
// Then parse with a new parser and wasm store, so that the languages
|
||||
// Then parse with a new parser and Wasm store, so that the languages
|
||||
// are added one-by-one, in between parses.
|
||||
for mut parser in [parser, parser2] {
|
||||
for _ in 0..2 {
|
||||
|
|
@ -226,7 +226,7 @@ fn test_load_wasm_errors() {
|
|||
store.load_language("rust", bad_wasm).unwrap_err(),
|
||||
WasmError {
|
||||
kind: WasmErrorKind::Parse,
|
||||
message: "failed to parse dylink section of wasm module".into(),
|
||||
message: "failed to parse dylink section of Wasm module".into(),
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use wasmparser::Parser;
|
|||
|
||||
pub fn load_language_wasm_file(language_dir: &Path) -> Result<(String, Vec<u8>)> {
|
||||
let grammar_name = get_grammar_name(language_dir)
|
||||
.with_context(|| "Failed to get wasm filename")
|
||||
.with_context(|| "Failed to get Wasm filename")
|
||||
.unwrap();
|
||||
let wasm_filename = format!("tree-sitter-{grammar_name}.wasm");
|
||||
let contents = fs::read(language_dir.join(&wasm_filename)).with_context(|| {
|
||||
|
|
@ -61,7 +61,7 @@ pub fn compile_language_to_wasm(
|
|||
)?;
|
||||
|
||||
// Exit with an error if the external scanner uses symbols from the
|
||||
// C or C++ standard libraries that aren't available to wasm parsers.
|
||||
// C or C++ standard libraries that aren't available to Wasm parsers.
|
||||
let stdlib_symbols = wasm_stdlib_symbols().collect::<Vec<_>>();
|
||||
let dylink_symbols = [
|
||||
"__indirect_function_table",
|
||||
|
|
@ -100,7 +100,7 @@ pub fn compile_language_to_wasm(
|
|||
if !missing_symbols.is_empty() {
|
||||
Err(anyhow!(
|
||||
concat!(
|
||||
"This external scanner uses a symbol that isn't available to wasm parsers.\n",
|
||||
"This external scanner uses a symbol that isn't available to Wasm parsers.\n",
|
||||
"\n",
|
||||
"Missing symbols:\n",
|
||||
" {}\n",
|
||||
|
|
|
|||
|
|
@ -1068,7 +1068,7 @@ impl Loader {
|
|||
}
|
||||
|
||||
fs::rename(src_path.join(output_name), output_path)
|
||||
.context("failed to rename wasm output file")?;
|
||||
.context("failed to rename Wasm output file")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ pub fn run_wasm(args: &BuildWasm) -> Result<()> {
|
|||
fn build_wasm(cmd: &mut Command) -> Result<()> {
|
||||
bail_on_err(
|
||||
&cmd.spawn()?.wait_with_output()?,
|
||||
"Failed to compile the Tree-sitter WASM library",
|
||||
"Failed to compile the Tree-sitter Wasm library",
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
|
|
@ -239,7 +239,7 @@ pub fn run_wasm_stdlib() -> Result<()> {
|
|||
.arg("lib/src/wasm/stdlib.c")
|
||||
.output()?;
|
||||
|
||||
bail_on_err(&output, "Failed to compile the Tree-sitter WASM stdlib")?;
|
||||
bail_on_err(&output, "Failed to compile the Tree-sitter Wasm stdlib")?;
|
||||
|
||||
let xxd = Command::new("xxd")
|
||||
.args(["-C", "-i", "stdlib.wasm"])
|
||||
|
|
@ -247,7 +247,7 @@ pub fn run_wasm_stdlib() -> Result<()> {
|
|||
|
||||
bail_on_err(
|
||||
&xxd,
|
||||
"Failed to run xxd on the compiled Tree-sitter WASM stdlib",
|
||||
"Failed to run xxd on the compiled Tree-sitter Wasm stdlib",
|
||||
)?;
|
||||
|
||||
fs::write("lib/src/wasm/wasm-stdlib.h", xxd.stdout)?;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ const EXCLUDES: [&str; 27] = [
|
|||
"ts_node_eq",
|
||||
"ts_tree_cursor_current_field_name",
|
||||
"ts_lookahead_iterator_current_symbol_name",
|
||||
// Not used in wasm
|
||||
// Not used in Wasm
|
||||
"ts_init",
|
||||
"ts_set_allocator",
|
||||
"ts_parser_set_cancellation_flag",
|
||||
|
|
@ -126,7 +126,7 @@ fn check_wasm_exports() -> Result<()> {
|
|||
|
||||
if !missing.is_empty() {
|
||||
Err(anyhow!(format!(
|
||||
"Unmatched wasm exports:\n{}",
|
||||
"Unmatched Wasm exports:\n{}",
|
||||
missing.join("\n")
|
||||
)))?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub fn run_fixtures(args: &GenerateFixtures) -> Result<()> {
|
|||
|
||||
println!(
|
||||
"Regenerating {grammar_name} parser{}",
|
||||
if args.wasm { " to wasm" } else { "" }
|
||||
if args.wasm { " to Wasm" } else { "" }
|
||||
);
|
||||
|
||||
if args.wasm {
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ use semver::Version;
|
|||
enum Commands {
|
||||
/// Runs `cargo benchmark` with some optional environment variables set.
|
||||
Benchmark(Benchmark),
|
||||
/// Compile the Tree-sitter WASM library. This will create two files in the
|
||||
/// Compile the Tree-sitter Wasm library. This will create two files in the
|
||||
/// `lib/binding_web` directory: `web-tree-sitter.js` and `web-tree-sitter.wasm`.
|
||||
BuildWasm(BuildWasm),
|
||||
/// Compile the Tree-sitter WASM standard library.
|
||||
/// Compile the Tree-sitter Wasm standard library.
|
||||
BuildWasmStdlib,
|
||||
/// Bumps the version of the workspace.
|
||||
BumpVersion(BumpVersion),
|
||||
/// Checks that WASM exports are synced.
|
||||
/// Checks that Wasm exports are synced.
|
||||
CheckWasmExports(CheckWasmExports),
|
||||
/// Runs `cargo clippy`.
|
||||
Clippy(Clippy),
|
||||
|
|
@ -41,11 +41,11 @@ enum Commands {
|
|||
GenerateBindings,
|
||||
/// Generates the fixtures for testing tree-sitter.
|
||||
GenerateFixtures(GenerateFixtures),
|
||||
/// Generate the list of exports from Tree-sitter WASM files.
|
||||
/// Generate the list of exports from Tree-sitter Wasm files.
|
||||
GenerateWasmExports,
|
||||
/// Run the test suite
|
||||
Test(Test),
|
||||
/// Run the WASM test suite
|
||||
/// Run the Wasm test suite
|
||||
TestWasm,
|
||||
/// Upgrade the wasmtime dependency.
|
||||
UpgradeWasmtime(UpgradeWasmtime),
|
||||
|
|
@ -120,7 +120,7 @@ struct Clippy {
|
|||
|
||||
#[derive(Args)]
|
||||
struct GenerateFixtures {
|
||||
/// Generates the parser to WASM
|
||||
/// Generates the parser to Wasm
|
||||
#[arg(long, short)]
|
||||
wasm: bool,
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ struct Test {
|
|||
/// Don't capture the output
|
||||
#[arg(long)]
|
||||
nocapture: bool,
|
||||
/// Enable the wasm tests.
|
||||
/// Enable the Wasm tests.
|
||||
#[arg(long, short)]
|
||||
wasm: bool,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ To make changes to Tree-sitter, you should have:
|
|||
2. A [Rust toolchain][rust], for compiling the Rust bindings, the highlighting library, and the CLI.
|
||||
3. Node.js and NPM, for generating parsers from `grammar.js` files.
|
||||
4. Either [Emscripten][emscripten], [Docker][docker], or [podman][podman] for
|
||||
compiling the library to WASM.
|
||||
compiling the library to Wasm.
|
||||
|
||||
### Building
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ git clone https://github.com/tree-sitter/tree-sitter
|
|||
cd tree-sitter
|
||||
```
|
||||
|
||||
Optionally, build the WASM library. If you skip this step, then the `tree-sitter playground` command will require an internet
|
||||
Optionally, build the Wasm library. If you skip this step, then the `tree-sitter playground` command will require an internet
|
||||
connection. If you have Emscripten installed, this will use your `emcc` compiler. Otherwise, it will use Docker or Podman:
|
||||
|
||||
```sh
|
||||
|
|
@ -76,7 +76,7 @@ Then you can run the tests:
|
|||
cargo xtask test
|
||||
```
|
||||
|
||||
Similarly, to test the WASM binding, you need to compile these parsers to WASM:
|
||||
Similarly, to test the Wasm binding, you need to compile these parsers to Wasm:
|
||||
|
||||
```sh
|
||||
cargo xtask generate-fixtures --wasm
|
||||
|
|
@ -119,7 +119,7 @@ several packages that are published to package registries for different language
|
|||
* [`tree-sitter-cli`][cli crate] — The command-line tool
|
||||
|
||||
* JavaScript modules on [npmjs.com][npmjs]:
|
||||
* [`web-tree-sitter`][web-ts] — A WASM-based JavaScript binding to the core library
|
||||
* [`web-tree-sitter`][web-ts] — A Wasm-based JavaScript binding to the core library
|
||||
* [`tree-sitter-cli`][cli package] — The command-line tool
|
||||
|
||||
There are also several other dependent repositories that contain other published packages:
|
||||
|
|
@ -179,7 +179,7 @@ a short delay. Once you've made a change that you're happy with, you can submit
|
|||
The playground page is a little more complicated, but if you know some basic JavaScript and CSS you should be able to make
|
||||
changes. The playground code can be found in [`docs/src/assets/js/playground.js`][playground], and its corresponding css
|
||||
at [`docs/src/assets/css/playground.css`][playground css]. The editor of choice we use for the playground is [CodeMirror][codemirror],
|
||||
and the tree-sitter module is fetched from [here][js url]. This, along with the wasm module and wasm parsers, live in the
|
||||
and the tree-sitter module is fetched from [here][js url]. This, along with the Wasm module and Wasm parsers, live in the
|
||||
[.github.io repo][gh.io repo].
|
||||
|
||||
[admonish]: https://github.com/tommilligan/mdbook-admonish
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# `tree-sitter build`
|
||||
|
||||
The `build` command compiles your parser into a dynamically-loadable library,
|
||||
either as a shared object (`.so`, `.dylib`, or `.dll`) or as a WASM module.
|
||||
either as a shared object (`.so`, `.dylib`, or `.dll`) or as a Wasm module.
|
||||
|
||||
```bash
|
||||
tree-sitter build [OPTIONS] [PATH] # Aliases: b
|
||||
|
|
@ -18,11 +18,11 @@ will attempt to build the parser in the current working directory.
|
|||
|
||||
### `-w/--wasm`
|
||||
|
||||
Compile the parser as a WASM module.
|
||||
Compile the parser as a Wasm module.
|
||||
|
||||
### `-o/--output`
|
||||
|
||||
Specify where to output the shared object file (native or WASM). This flag accepts either an absolute path or a relative
|
||||
Specify where to output the shared object file (native or Wasm). This flag accepts either an absolute path or a relative
|
||||
path. If you don't supply this flag, the CLI will attempt to figure out what the language name is based on the parent
|
||||
directory name to use for the output file. If the CLI can't figure it out, it will default to `parser`, thus generating
|
||||
`parser.so` or `parser.wasm` in the current working directory.
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ The graphs are constructed with [graphviz dot][dot], and the output is written t
|
|||
|
||||
### `--wasm`
|
||||
|
||||
Compile and run the parser as a WASM module.
|
||||
Compile and run the parser as a Wasm module.
|
||||
|
||||
### `--dot`
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ tree-sitter playground [OPTIONS] # Aliases: play, pg, web-ui
|
|||
```
|
||||
|
||||
```admonish note
|
||||
For this to work, you must have already built the parser as a WASM module. This can be done with the [`build`](./build.md) subcommand
|
||||
For this to work, you must have already built the parser as a Wasm module. This can be done with the [`build`](./build.md) subcommand
|
||||
(`tree-sitter build --wasm`).
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ The graphs are constructed with [graphviz dot][dot], and the output is written t
|
|||
|
||||
### `--wasm`
|
||||
|
||||
Compile and run the parser as a WASM module.
|
||||
Compile and run the parser as a Wasm module.
|
||||
|
||||
### `--open-log`
|
||||
|
||||
|
|
|
|||
|
|
@ -98,11 +98,11 @@ assert_eq!(
|
|||
);
|
||||
```
|
||||
|
||||
## Using WASM Grammar Files
|
||||
## Using Wasm Grammar Files
|
||||
|
||||
> Requires the feature **wasm** to be enabled.
|
||||
|
||||
First, create a parser with a WASM store:
|
||||
First, create a parser with a Wasm store:
|
||||
|
||||
```rust
|
||||
use tree_sitter::{wasmtime::Engine, Parser, WasmStore};
|
||||
|
|
@ -114,7 +114,7 @@ let mut parser = Parser::new();
|
|||
parser.set_wasm_store(store).unwrap();
|
||||
```
|
||||
|
||||
Then, load the language from a WASM file:
|
||||
Then, load the language from a Wasm file:
|
||||
|
||||
```rust
|
||||
const JAVASCRIPT_GRAMMAR: &[u8] = include_bytes!("path/to/tree-sitter-javascript.wasm");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* automatically generated by rust-bindgen 0.71.1 */
|
||||
/* automatically generated by rust-bindgen 0.72.0 */
|
||||
|
||||
pub const TREE_SITTER_LANGUAGE_VERSION: u32 = 15;
|
||||
pub const TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION: u32 = 13;
|
||||
|
|
@ -928,7 +928,7 @@ extern "C" {
|
|||
) -> *const TSLanguage;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the number of languages instantiated in the given wasm store."]
|
||||
#[doc = " Get the number of languages instantiated in the given Wasm store."]
|
||||
pub fn ts_wasm_store_language_count(arg1: *const TSWasmStore) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ pub struct QueryCapture<'tree> {
|
|||
|
||||
/// An error that occurred when trying to assign an incompatible [`Language`] to
|
||||
/// a [`Parser`]. If the `wasm` feature is enabled, this can also indicate a failure
|
||||
/// to load the wasm store.
|
||||
/// to load the Wasm store.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum LanguageError {
|
||||
Version(usize),
|
||||
|
|
@ -3737,7 +3737,7 @@ impl fmt::Display for LanguageError {
|
|||
}
|
||||
#[cfg(feature = "wasm")]
|
||||
Self::Wasm => {
|
||||
write!(f, "Failed to load the wasm store.")
|
||||
write!(f, "Failed to load the Wasm store.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,9 +135,9 @@ impl Drop for WasmStore {
|
|||
impl fmt::Display for WasmError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let kind = match self.kind {
|
||||
WasmErrorKind::Parse => "Failed to parse wasm",
|
||||
WasmErrorKind::Compile => "Failed to compile wasm",
|
||||
WasmErrorKind::Instantiate => "Failed to instantiate wasm module",
|
||||
WasmErrorKind::Parse => "Failed to parse Wasm",
|
||||
WasmErrorKind::Compile => "Failed to compile Wasm",
|
||||
WasmErrorKind::Instantiate => "Failed to instantiate Wasm module",
|
||||
WasmErrorKind::Other => "Unknown error",
|
||||
};
|
||||
write!(f, "{kind}: {}", self.message)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ To make changes to Web-tree-sitter, you should have:
|
|||
1. A [Rust toolchain][rust], for running the xtasks necessary to build the library.
|
||||
2. Node.js and NPM (or an equivalent package manager).
|
||||
3. Either [Emscripten][emscripten], [Docker][docker], or [podman][podman] for
|
||||
compiling the library to WASM.
|
||||
compiling the library to Wasm.
|
||||
|
||||
### Building
|
||||
|
||||
|
|
@ -51,19 +51,19 @@ by visiting the [Rust website][rust] and following the instructions there.
|
|||
|
||||
#### The C side
|
||||
|
||||
There are several components that come together to build the final JS and WASM files. First, we use `emscripten` in our
|
||||
xtask located at `xtask/src/build_wasm.rs` from the root directory to compile the WASM files. This WASM module is output into the
|
||||
local `lib` folder, and is used only in [`src/bindings.ts`][bindings.ts] to handle loading the WASM module. The C code that
|
||||
is compiled into the WASM module is located in at [`lib/tree-sitter.c`][tree-sitter.c], and contains all the necessary
|
||||
There are several components that come together to build the final JS and Wasm files. First, we use `emscripten` in our
|
||||
xtask located at `xtask/src/build_wasm.rs` from the root directory to compile the Wasm files. This Wasm module is output into the
|
||||
local `lib` folder, and is used only in [`src/bindings.ts`][bindings.ts] to handle loading the Wasm module. The C code that
|
||||
is compiled into the Wasm module is located in at [`lib/tree-sitter.c`][tree-sitter.c], and contains all the necessary
|
||||
glue code to interact with the JS environment. If you need to update the imported functions from the tree-sitter library,
|
||||
or anywhere else, you must update [`lib/exports.txt`][exports.txt]. Lastly, the type information for the WASM module is
|
||||
or anywhere else, you must update [`lib/exports.txt`][exports.txt]. Lastly, the type information for the Wasm module is
|
||||
located at [`lib/tree-sitter.d.ts`][tree-sitter.d.ts], and can be updated by running `cargo xtask build-wasm --emit-tsd`
|
||||
from the root directory.
|
||||
|
||||
#### The TypeScript side
|
||||
|
||||
The TypeScript library is a higher level abstraction over the WASM module, and is located in `src`. This is where the
|
||||
public API is defined, and where the WASM module is loaded and initialized. The TypeScript library is built into a single
|
||||
The TypeScript library is a higher level abstraction over the Wasm module, and is located in `src`. This is where the
|
||||
public API is defined, and where the Wasm module is loaded and initialized. The TypeScript library is built into a single
|
||||
ES6 (or CommonJS) module, and is output into the same directory as `package.json`. If you need to update the public API,
|
||||
you can do so by editing the files in `src`.
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ to the TypeScript source code.
|
|||
|
||||
This TypeScript code is then compiled into a single JavaScript file with `esbuild`. The build configuration for this can
|
||||
be found in [`script/build.js`][build.js], but this shouldn't need to be updated. This step is responsible for emitting
|
||||
the final JS and WASM files that are shipped with the library, as well as their sourcemaps.
|
||||
the final JS and Wasm files that are shipped with the library, as well as their sourcemaps.
|
||||
|
||||
### Testing
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ Optionally, to update the generated parser.c files:
|
|||
cargo xtask generate-fixtures
|
||||
```
|
||||
|
||||
Then you can build the WASM modules:
|
||||
Then you can build the Wasm modules:
|
||||
|
||||
```sh
|
||||
cargo xtask generate-fixtures --wasm
|
||||
|
|
|
|||
|
|
@ -217,10 +217,10 @@ const Parser = require('web-tree-sitter');
|
|||
|
||||
`web-tree-sitter` needs to load the `tree-sitter.wasm` file. By default, it assumes that this file is available in the
|
||||
same path as the JavaScript code. Therefore, if the code is being served from `http://localhost:3000/bundle.js`, then
|
||||
the wasm file should be at `http://localhost:3000/tree-sitter.wasm`.
|
||||
the Wasm file should be at `http://localhost:3000/tree-sitter.wasm`.
|
||||
|
||||
For server side frameworks like NextJS, this can be tricky as pages are often served from a path such as
|
||||
`http://localhost:3000/_next/static/chunks/pages/index.js`. The loader will therefore look for the wasm file at
|
||||
`http://localhost:3000/_next/static/chunks/pages/index.js`. The loader will therefore look for the Wasm file at
|
||||
`http://localhost:3000/_next/static/chunks/pages/tree-sitter.wasm`. The solution is to pass a `locateFile` function in
|
||||
the `moduleOptions` argument to `Parser.init()`:
|
||||
|
||||
|
|
@ -232,8 +232,8 @@ await Parser.init({
|
|||
});
|
||||
```
|
||||
|
||||
`locateFile` takes in two parameters, `scriptName`, i.e. the wasm file name, and `scriptDirectory`, i.e. the directory
|
||||
where the loader expects the script to be. It returns the path where the loader will look for the wasm file. In the NextJS
|
||||
`locateFile` takes in two parameters, `scriptName`, i.e. the Wasm file name, and `scriptDirectory`, i.e. the directory
|
||||
where the loader expects the script to be. It returns the path where the loader will look for the Wasm file. In the NextJS
|
||||
case, we want to return just the `scriptName` so that the loader will look at `http://localhost:3000/tree-sitter.wasm`
|
||||
and not `http://localhost:3000/_next/static/chunks/pages/tree-sitter.wasm`.
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const format = process.env.CJS ? 'cjs' : 'esm';
|
|||
const debug = process.argv.includes('--debug');
|
||||
const outfile = `${debug ? 'debug/' : ''}web-tree-sitter.${format === 'esm' ? 'js' : 'cjs'}`;
|
||||
|
||||
// Copy source files to lib directory - we'll map the wasm's sourecmap to these files.
|
||||
// Copy source files to lib directory - we'll map the Wasm's sourcemap to these files.
|
||||
async function copySourceFiles() {
|
||||
const sourceDir = '../src';
|
||||
const files = await fs.readdir(sourceDir);
|
||||
|
|
@ -58,7 +58,7 @@ async function build() {
|
|||
resolveExtensions: ['.ts', '.js', format === 'esm' ? '.mjs' : '.cjs'],
|
||||
});
|
||||
|
||||
// Copy the WASM files to the appropriate spot, as esbuild doesn't "bundle" WASM files
|
||||
// Copy the Wasm files to the appropriate spot, as esbuild doesn't "bundle" Wasm files
|
||||
const outputWasmName = `${debug ? 'debug/' : ''}web-tree-sitter.wasm`;
|
||||
await fs.copyFile('lib/web-tree-sitter.wasm', outputWasmName);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export let Module: MainModule | null = null;
|
|||
/**
|
||||
* @internal
|
||||
*
|
||||
* Initialize the Tree-sitter WASM module. This should only be called by the {@link Parser} class via {@link Parser.init}.
|
||||
* Initialize the Tree-sitter Wasm module. This should only be called by the {@link Parser} class via {@link Parser.init}.
|
||||
*/
|
||||
export async function initializeBinding(moduleOptions?: Partial<EmscriptenModule>): Promise<MainModule> {
|
||||
if (!Module) {
|
||||
|
|
@ -19,7 +19,7 @@ export async function initializeBinding(moduleOptions?: Partial<EmscriptenModule
|
|||
/**
|
||||
* @internal
|
||||
*
|
||||
* Checks if the Tree-sitter WASM module has been initialized.
|
||||
* Checks if the Tree-sitter Wasm module has been initialized.
|
||||
*/
|
||||
export function checkModule(): boolean {
|
||||
return !!Module;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ export function isPoint(point?: Point): point is Point {
|
|||
/**
|
||||
* @internal
|
||||
*
|
||||
* Sets the Tree-sitter WASM module. This should only be called by the {@link Parser} class via {@link Parser.init}.
|
||||
* Sets the Tree-sitter Wasm module. This should only be called by the {@link Parser} class via {@link Parser.init}.
|
||||
*/
|
||||
export function setModule(module: MainModule) {
|
||||
C = module;
|
||||
|
|
@ -127,7 +127,7 @@ export function setModule(module: MainModule) {
|
|||
/**
|
||||
* @internal
|
||||
*
|
||||
* `C` is a convenient shorthand for the Tree-sitter WASM module,
|
||||
* `C` is a convenient shorthand for the Tree-sitter Wasm module,
|
||||
* which allows us to call all of the exported functions.
|
||||
*/
|
||||
export let C: MainModule;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export class LanguageMetadata {
|
|||
*/
|
||||
export class Language {
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
private [0] = 0; // Internal handle for Wasm
|
||||
|
||||
/**
|
||||
* A list of all node types in the language. The index of each type in this
|
||||
|
|
@ -282,8 +282,8 @@ export class Language {
|
|||
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) &&
|
||||
!key.includes('external_scanner_'));
|
||||
if (!functionName) {
|
||||
console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(symbolNames, null, 2)}`);
|
||||
throw new Error('Language.load failed: no language function found in WASM file');
|
||||
console.log(`Couldn't find language function in Wasm file. Symbols:\n${JSON.stringify(symbolNames, null, 2)}`);
|
||||
throw new Error('Language.load failed: no language function found in Wasm file');
|
||||
}
|
||||
const languageAddress = mod[functionName]();
|
||||
return new Language(INTERNAL, languageAddress);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Language } from './language';
|
|||
|
||||
export class LookaheadIterator implements Iterable<string> {
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
private [0] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private language: Language;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { TRANSFER_BUFFER } from './parser';
|
|||
/** A single node within a syntax {@link Tree}. */
|
||||
export class Node {
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
private [0] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private _children?: Node[];
|
||||
|
|
@ -427,7 +427,7 @@ export class Node {
|
|||
}
|
||||
}
|
||||
|
||||
// Copy the array of symbols to the WASM heap
|
||||
// Copy the array of symbols to the Wasm heap
|
||||
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
||||
for (let i = 0, n = symbols.length; i < n; i++) {
|
||||
C.setValue(symbolsAddress + i * SIZE_OF_INT, symbols[i], 'i32');
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ export let MIN_COMPATIBLE_VERSION: number;
|
|||
*/
|
||||
export class Parser {
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
private [0] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private [1] = 0; // Internal handle for WASM
|
||||
private [1] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private logCallback: LogCallback | null = null;
|
||||
|
|
@ -102,7 +102,7 @@ export class Parser {
|
|||
/**
|
||||
* This must always be called before creating a Parser.
|
||||
*
|
||||
* You can optionally pass in options to configure the WASM module, the most common
|
||||
* You can optionally pass in options to configure the Wasm module, the most common
|
||||
* one being `locateFile` to help the module find the `.wasm` file.
|
||||
*/
|
||||
static async init(moduleOptions?: Partial<EmscriptenModule>) {
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ function parsePattern(
|
|||
|
||||
export class Query {
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
private [0] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private exceededMatchLimit: boolean;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export function getText(tree: Tree, startIndex: number, endIndex: number, startP
|
|||
/** A tree that represents the syntactic structure of a source code file. */
|
||||
export class Tree {
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
private [0] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
textCallback: ParseCallback;
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ import { getText, Tree } from './tree';
|
|||
/** A stateful object for walking a syntax {@link Tree} efficiently. */
|
||||
export class TreeCursor {
|
||||
/** @internal */
|
||||
private [0] = 0; // Internal handle for WASM
|
||||
private [0] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private [1] = 0; // Internal handle for WASM
|
||||
private [1] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private [2] = 0; // Internal handle for WASM
|
||||
private [2] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private [3] = 0; // Internal handle for WASM
|
||||
private [3] = 0; // Internal handle for Wasm
|
||||
|
||||
/** @internal */
|
||||
private tree: Tree;
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ describe('Parser', () => {
|
|||
// The callback is called at the end of parsing, however, what we're asserting here is that
|
||||
// parsing ends immediately as the error is detected. This is verified by checking the offset
|
||||
// of the last byte processed is the length of the erroneous code we inserted, aka, 1002, or
|
||||
// 1000 + the length of the erroneous code. Note that in this WASM test, we multiply the offset
|
||||
// 1000 + the length of the erroneous code. Note that in this Wasm test, we multiply the offset
|
||||
// by 2 because JavaScript strings are UTF-16 encoded.
|
||||
expect(offset).toBe((1000 + erroneousCode.length) * 2);
|
||||
expect(tree).toBeNull();
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ declare module 'web-tree-sitter' {
|
|||
/**
|
||||
* This must always be called before creating a Parser.
|
||||
*
|
||||
* You can optionally pass in options to configure the WASM module, the most common
|
||||
* You can optionally pass in options to configure the Wasm module, the most common
|
||||
* one being `locateFile` to help the module find the `.wasm` file.
|
||||
*/
|
||||
static init(moduleOptions?: EmscriptenModule): Promise<void>;
|
||||
|
|
|
|||
2
lib/binding_web/web-tree-sitter.d.ts
vendored
2
lib/binding_web/web-tree-sitter.d.ts
vendored
|
|
@ -130,7 +130,7 @@ declare module 'web-tree-sitter' {
|
|||
/**
|
||||
* This must always be called before creating a Parser.
|
||||
*
|
||||
* You can optionally pass in options to configure the WASM module, the most common
|
||||
* You can optionally pass in options to configure the Wasm module, the most common
|
||||
* one being `locateFile` to help the module find the `.wasm` file.
|
||||
*/
|
||||
static init(moduleOptions?: EmscriptenModule): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -1416,7 +1416,7 @@ const TSLanguage *ts_wasm_store_load_language(
|
|||
);
|
||||
|
||||
/**
|
||||
* Get the number of languages instantiated in the given wasm store.
|
||||
* Get the number of languages instantiated in the given Wasm store.
|
||||
*/
|
||||
size_t ts_wasm_store_language_count(const TSWasmStore *);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// This file implements a very simple allocator for external scanners running
|
||||
// in WASM. Allocation is just bumping a static pointer and growing the heap
|
||||
// in Wasm. Allocation is just bumping a static pointer and growing the heap
|
||||
// as needed, and freeing is mostly a noop. But in the special case of freeing
|
||||
// the last-allocated pointer, we'll reuse that pointer again.
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const char *STDLIB_SYMBOLS[] = {
|
|||
#include "./stdlib-symbols.txt"
|
||||
};
|
||||
|
||||
// The contents of the `dylink.0` custom section of a wasm module,
|
||||
// The contents of the `dylink.0` custom section of a Wasm module,
|
||||
// as specified by the current WebAssembly dynamic linking ABI proposal.
|
||||
typedef struct {
|
||||
uint32_t memory_size;
|
||||
|
|
@ -43,15 +43,15 @@ typedef struct {
|
|||
|
||||
// WasmLanguageId - A pointer used to identify a language. This language id is
|
||||
// reference-counted, so that its ownership can be shared between the language
|
||||
// itself and the instances of the language that are held in wasm stores.
|
||||
// itself and the instances of the language that are held in Wasm stores.
|
||||
typedef struct {
|
||||
volatile uint32_t ref_count;
|
||||
volatile uint32_t is_language_deleted;
|
||||
} WasmLanguageId;
|
||||
|
||||
// LanguageWasmModule - Additional data associated with a wasm-backed
|
||||
// LanguageWasmModule - Additional data associated with a Wasm-backed
|
||||
// `TSLanguage`. This data is read-only and does not reference a particular
|
||||
// wasm store, so it can be shared by all users of a `TSLanguage`. A pointer to
|
||||
// Wasm store, so it can be shared by all users of a `TSLanguage`. A pointer to
|
||||
// this is stored on the language itself.
|
||||
typedef struct {
|
||||
volatile uint32_t ref_count;
|
||||
|
|
@ -64,7 +64,7 @@ typedef struct {
|
|||
} LanguageWasmModule;
|
||||
|
||||
// LanguageWasmInstance - Additional data associated with an instantiation of
|
||||
// a `TSLanguage` in a particular wasm store. The wasm store holds one of
|
||||
// a `TSLanguage` in a particular Wasm store. The Wasm store holds one of
|
||||
// these structs for each language that it has instantiated.
|
||||
typedef struct {
|
||||
WasmLanguageId *language_id;
|
||||
|
|
@ -91,7 +91,7 @@ typedef struct {
|
|||
uint32_t args_sizes_get;
|
||||
} BuiltinFunctionIndices;
|
||||
|
||||
// TSWasmStore - A struct that allows a given `Parser` to use wasm-backed
|
||||
// TSWasmStore - A struct that allows a given `Parser` to use Wasm-backed
|
||||
// languages. This struct is mutable, and can only be used by one parser at a
|
||||
// time.
|
||||
struct TSWasmStore {
|
||||
|
|
@ -115,7 +115,7 @@ struct TSWasmStore {
|
|||
typedef Array(char) StringData;
|
||||
|
||||
// LanguageInWasmMemory - The memory layout of a `TSLanguage` when compiled to
|
||||
// wasm32. This is used to copy static language data out of the wasm memory.
|
||||
// wasm32. This is used to copy static language data out of the Wasm memory.
|
||||
typedef struct {
|
||||
uint32_t abi_version;
|
||||
uint32_t symbol_count;
|
||||
|
|
@ -164,7 +164,7 @@ typedef struct {
|
|||
} LanguageInWasmMemory;
|
||||
|
||||
// LexerInWasmMemory - The memory layout of a `TSLexer` when compiled to wasm32.
|
||||
// This is used to copy mutable lexing state in and out of the wasm memory.
|
||||
// This is used to copy mutable lexing state in and out of the Wasm memory.
|
||||
typedef struct {
|
||||
int32_t lookahead;
|
||||
TSSymbol result_symbol;
|
||||
|
|
@ -252,7 +252,7 @@ static bool wasm_dylink_info__parse(
|
|||
}
|
||||
|
||||
/*******************************************
|
||||
* Native callbacks exposed to wasm modules
|
||||
* Native callbacks exposed to Wasm modules
|
||||
*******************************************/
|
||||
|
||||
static wasm_trap_t *callback__abort(
|
||||
|
|
@ -261,7 +261,7 @@ static bool wasm_dylink_info__parse(
|
|||
wasmtime_val_raw_t *args_and_results,
|
||||
size_t args_and_results_len
|
||||
) {
|
||||
return wasmtime_trap_new("wasm module called abort", 24);
|
||||
return wasmtime_trap_new("Wasm module called abort", 24);
|
||||
}
|
||||
|
||||
static wasm_trap_t *callback__debug_message(
|
||||
|
|
@ -654,7 +654,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
},
|
||||
};
|
||||
|
||||
// Create all of the wasm functions.
|
||||
// Create all of the Wasm functions.
|
||||
unsigned builtin_definitions_len = array_len(builtin_definitions);
|
||||
unsigned lexer_definitions_len = array_len(lexer_definitions);
|
||||
for (unsigned i = 0; i < builtin_definitions_len; i++) {
|
||||
|
|
@ -679,7 +679,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindCompile;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"failed to compile wasm stdlib: %.*s",
|
||||
"failed to compile Wasm stdlib: %.*s",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -702,7 +702,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindCompile;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"wasm stdlib is missing the 'memory' import"
|
||||
"Wasm stdlib is missing the 'memory' import"
|
||||
);
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -718,7 +718,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindAllocate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"failed to allocate wasm memory: %.*s",
|
||||
"failed to allocate Wasm memory: %.*s",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -737,7 +737,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindAllocate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"failed to allocate wasm table: %.*s",
|
||||
"failed to allocate Wasm table: %.*s",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -779,7 +779,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindInstantiate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"unexpected import in wasm stdlib: %.*s\n",
|
||||
"unexpected import in Wasm stdlib: %.*s\n",
|
||||
(int)import_name->size, import_name->data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -796,7 +796,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindInstantiate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"failed to instantiate wasm stdlib module: %.*s",
|
||||
"failed to instantiate Wasm stdlib module: %.*s",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -806,7 +806,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindInstantiate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"trapped when instantiating wasm stdlib module: %.*s",
|
||||
"trapped when instantiating Wasm stdlib module: %.*s",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -867,7 +867,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindInstantiate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"missing malloc reset function in wasm stdlib"
|
||||
"missing malloc reset function in Wasm stdlib"
|
||||
);
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -877,7 +877,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindInstantiate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"missing exported symbol in wasm stdlib: %s",
|
||||
"missing exported symbol in Wasm stdlib: %s",
|
||||
STDLIB_SYMBOLS[i]
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -896,7 +896,7 @@ TSWasmStore *ts_wasm_store_new(TSWasmEngine *engine, TSWasmError *wasm_error) {
|
|||
wasm_error->kind = TSWasmErrorKindAllocate;
|
||||
format(
|
||||
&wasm_error->message,
|
||||
"failed to grow wasm table to initial size: %.*s",
|
||||
"failed to grow Wasm table to initial size: %.*s",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -1063,7 +1063,7 @@ static bool ts_wasm_store__instantiate(
|
|||
wasmtime_error_message(error, &message);
|
||||
format(
|
||||
error_message,
|
||||
"error instantiating wasm module: %.*s\n",
|
||||
"error instantiating Wasm module: %.*s\n",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -1072,7 +1072,7 @@ static bool ts_wasm_store__instantiate(
|
|||
wasm_trap_message(trap, &message);
|
||||
format(
|
||||
error_message,
|
||||
"trap when instantiating wasm module: %.*s\n",
|
||||
"trap when instantiating Wasm module: %.*s\n",
|
||||
(int)message.size, message.data
|
||||
);
|
||||
goto error;
|
||||
|
|
@ -1182,17 +1182,17 @@ const TSLanguage *ts_wasm_store_load_language(
|
|||
|
||||
if (!wasm_dylink_info__parse((const unsigned char *)wasm, wasm_len, &dylink_info)) {
|
||||
wasm_error->kind = TSWasmErrorKindParse;
|
||||
format(&wasm_error->message, "failed to parse dylink section of wasm module");
|
||||
format(&wasm_error->message, "failed to parse dylink section of Wasm module");
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Compile the wasm code.
|
||||
// Compile the Wasm code.
|
||||
error = wasmtime_module_new(self->engine, (const uint8_t *)wasm, wasm_len, &module);
|
||||
if (error) {
|
||||
wasm_message_t message;
|
||||
wasmtime_error_message(error, &message);
|
||||
wasm_error->kind = TSWasmErrorKindCompile;
|
||||
format(&wasm_error->message, "error compiling wasm module: %.*s", (int)message.size, message.data);
|
||||
format(&wasm_error->message, "error compiling Wasm module: %.*s", (int)message.size, message.data);
|
||||
wasm_byte_vec_delete(&message);
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -1213,7 +1213,7 @@ const TSLanguage *ts_wasm_store_load_language(
|
|||
goto error;
|
||||
}
|
||||
|
||||
// Copy all of the static data out of the language object in wasm memory,
|
||||
// Copy all of the static data out of the language object in Wasm memory,
|
||||
// constructing a native language object.
|
||||
LanguageInWasmMemory wasm_language;
|
||||
wasmtime_context_t *context = wasmtime_store_context(self->store);
|
||||
|
|
@ -1442,9 +1442,9 @@ const TSLanguage *ts_wasm_store_load_language(
|
|||
.ref_count = 1,
|
||||
};
|
||||
|
||||
// The lex functions are not used for wasm languages. Use those two fields
|
||||
// to mark this language as WASM-based and to store the language's
|
||||
// WASM-specific data.
|
||||
// The lex functions are not used for Wasm languages. Use those two fields
|
||||
// to mark this language as Wasm-based and to store the language's
|
||||
// Wasm-specific data.
|
||||
language->lex_fn = ts_wasm_store__sentinel_lex_fn;
|
||||
language->keyword_lex_fn = (bool (*)(TSLexer *, TSStateId))language_module;
|
||||
|
||||
|
|
@ -1595,7 +1595,7 @@ static void ts_wasm_store__call(
|
|||
// wasmtime_error_message(error, &message);
|
||||
// fprintf(
|
||||
// stderr,
|
||||
// "error in wasm module: %.*s\n",
|
||||
// "error in Wasm module: %.*s\n",
|
||||
// (int)message.size, message.data
|
||||
// );
|
||||
wasmtime_error_delete(error);
|
||||
|
|
@ -1605,7 +1605,7 @@ static void ts_wasm_store__call(
|
|||
// wasm_trap_message(trap, &message);
|
||||
// fprintf(
|
||||
// stderr,
|
||||
// "trap in wasm module: %.*s\n",
|
||||
// "trap in Wasm module: %.*s\n",
|
||||
// (int)message.size, message.data
|
||||
// );
|
||||
wasm_trap_delete(trap);
|
||||
|
|
@ -1616,7 +1616,7 @@ static void ts_wasm_store__call(
|
|||
// The data fields of TSLexer, without the function pointers.
|
||||
//
|
||||
// This portion of the struct needs to be copied in and out
|
||||
// of wasm memory before and after calling a scan function.
|
||||
// of Wasm memory before and after calling a scan function.
|
||||
typedef struct {
|
||||
int32_t lookahead;
|
||||
TSSymbol result_symbol;
|
||||
|
|
@ -1790,8 +1790,8 @@ void ts_wasm_language_release(const TSLanguage *self) {
|
|||
LanguageWasmModule *module = ts_language__wasm_module(self);
|
||||
ts_assert(module->ref_count > 0);
|
||||
if (atomic_dec(&module->ref_count) == 0) {
|
||||
// Update the language id to reflect that the language is deleted. This allows any wasm stores
|
||||
// that hold wasm instances for this language to delete those instances.
|
||||
// Update the language id to reflect that the language is deleted. This allows any Wasm stores
|
||||
// that hold Wasm instances for this language to delete those instances.
|
||||
atomic_inc(&module->language_id->is_language_deleted);
|
||||
language_id_delete(module->language_id);
|
||||
|
||||
|
|
@ -1833,8 +1833,8 @@ void ts_wasm_language_release(const TSLanguage *self) {
|
|||
|
||||
#else
|
||||
|
||||
// If the WASM feature is not enabled, define dummy versions of all of the
|
||||
// wasm-related functions.
|
||||
// If the Wasm feature is not enabled, define dummy versions of all of the
|
||||
// Wasm-related functions.
|
||||
|
||||
void ts_wasm_store_delete(TSWasmStore *self) {
|
||||
(void)self;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue