diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d5f45527e62..9397dd89f44 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -13,15 +13,23 @@ updates: schedule: interval: daily - package-ecosystem: cargo - directory: /boa/ + directory: /boa_cli/ schedule: interval: daily - package-ecosystem: cargo - directory: /boa_cli/ + directory: /boa_engine/ schedule: interval: daily - package-ecosystem: cargo - directory: /boa_wasm/ + directory: /boa_gc/ + schedule: + interval: daily + - package-ecosystem: cargo + directory: /boa_interner/ + schedule: + interval: daily + - package-ecosystem: cargo + directory: /boa_profiler/ schedule: interval: daily - package-ecosystem: cargo @@ -29,10 +37,14 @@ updates: schedule: interval: daily - package-ecosystem: cargo - directory: /boa_interner/ + directory: /boa_unicode/ + schedule: + interval: daily + - package-ecosystem: cargo + directory: /boa_wasm/ schedule: interval: daily - package-ecosystem: gitsubmodule - directory: /test262/ + directory: / schedule: interval: weekly diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml index d9970ad54df..4ccf5f7ab45 100644 --- a/.github/workflows/bors.yml +++ b/.github/workflows/bors.yml @@ -43,7 +43,10 @@ jobs: - name: Cache cargo uses: actions/cache@v2.1.7 with: - path: target + path: | + target + ~/.cargo/git + ~/.cargo/registry key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - uses: actions-rs/cargo@v1 with: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7fb22a5138d..7cce9425f7f 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -25,4 +25,4 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} branchName: ${{ github.base_ref }} - cwd: ./boa + cwd: ./boa_engine diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a802068206..4488de418e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,8 @@ jobs: node_modules target boa_wasm/pkg + ~/.cargo/git + ~/.cargo/registry key: ${{ runner.os }}-yarn-build-target-${{ hashFiles('**/yarn.lock') }} - uses: Borales/actions-yarn@v2.3.0 with: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 46089d39456..757c38c2459 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -47,7 +47,10 @@ jobs: - name: Cache cargo uses: actions/cache@v2.1.7 with: - path: target + path: | + target + ~/.cargo/git + ~/.cargo/registry key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} - uses: actions-rs/cargo@v1 with: diff --git a/.github/workflows/test262.yml b/.github/workflows/test262.yml index 63044d0f266..fdc3000f652 100644 --- a/.github/workflows/test262.yml +++ b/.github/workflows/test262.yml @@ -29,7 +29,7 @@ jobs: uses: actions/cache@v2.1.7 with: path: | - ./boa/target + target ~/.cargo/git ~/.cargo/registry key: ${{ runner.os }}-cargo-test262-${{ hashFiles('**/Cargo.lock') }} diff --git a/.github/workflows/webassembly.yml b/.github/workflows/webassembly.yml index d0bda195f8c..a3f2ff95926 100644 --- a/.github/workflows/webassembly.yml +++ b/.github/workflows/webassembly.yml @@ -38,6 +38,8 @@ jobs: path: | node_modules target + ~/.cargo/git + ~/.cargo/registry boa_wasm/pkg key: ${{ runner.os }}-yarn-build-target-${{ hashFiles('**/yarn.lock') }} - uses: Borales/actions-yarn@v2.3.0 diff --git a/.prettierignore b/.prettierignore index 981ec730007..ce0118b9925 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,8 +2,8 @@ *.rs target node_modules -boa/benches/bench_scripts/mini_js.js -boa/benches/bench_scripts/clean_js.js +boa_engine/benches/bench_scripts/mini_js.js +boa_engine/benches/bench_scripts/clean_js.js boa_wasm/pkg dist test262 diff --git a/Cargo.lock b/Cargo.lock index 7124c1e53cb..01d21a9d16a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,35 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "Boa" -version = "0.13.0" -dependencies = [ - "bitflags", - "boa_interner", - "boa_unicode", - "chrono", - "criterion", - "dyn-clone", - "fast-float", - "float-cmp", - "gc", - "indexmap", - "jemallocator", - "measureme", - "num-bigint", - "num-integer", - "num-traits", - "once_cell", - "rand", - "regress", - "rustc-hash", - "ryu-js", - "serde", - "serde_json", - "unicode-normalization", -] - [[package]] name = "ahash" version = "0.7.6" @@ -96,7 +67,8 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" name = "boa_cli" version = "0.13.0" dependencies = [ - "Boa", + "boa_engine", + "boa_interner", "colored", "jemallocator", "phf", @@ -107,6 +79,44 @@ dependencies = [ "structopt", ] +[[package]] +name = "boa_engine" +version = "0.13.0" +dependencies = [ + "bitflags", + "boa_gc", + "boa_interner", + "boa_profiler", + "boa_unicode", + "chrono", + "criterion", + "dyn-clone", + "fast-float", + "float-cmp", + "gc", + "indexmap", + "jemallocator", + "num-bigint", + "num-integer", + "num-traits", + "once_cell", + "rand", + "regress", + "rustc-hash", + "ryu-js", + "serde", + "serde_json", + "unicode-normalization", +] + +[[package]] +name = "boa_gc" +version = "0.13.0" +dependencies = [ + "gc", + "measureme", +] + [[package]] name = "boa_interner" version = "0.13.0" @@ -116,12 +126,21 @@ dependencies = [ "string-interner", ] +[[package]] +name = "boa_profiler" +version = "0.13.0" +dependencies = [ + "measureme", + "once_cell", +] + [[package]] name = "boa_tester" version = "0.13.0" dependencies = [ - "Boa", "bitflags", + "boa_engine", + "boa_interner", "colored", "fxhash", "gc", @@ -148,7 +167,7 @@ dependencies = [ name = "boa_wasm" version = "0.13.0" dependencies = [ - "Boa", + "boa_engine", "getrandom", "wasm-bindgen", ] @@ -669,9 +688,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.118" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "libgit2-sys" diff --git a/Cargo.toml b/Cargo.toml index 57dc631369c..2a92388ffc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,13 @@ [workspace] members = [ - "boa", "boa_cli", - "boa_wasm", + "boa_engine", + "boa_gc", + "boa_interner", + "boa_profiler", "boa_tester", "boa_unicode", - "boa_interner", + "boa_wasm", ] # The release profile, used for `cargo build --release`. diff --git a/boa/src/gc.rs b/boa/src/gc.rs deleted file mode 100644 index 5fbd0255f71..00000000000 --- a/boa/src/gc.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! This module represents the main way to interact with the garbage collector. - -// This is because `rust-gc` unsafe_empty_trace has a `unsafe_` -// when it should be `empty_trace`. -#![allow(clippy::unsafe_removed_from_name)] - -pub use gc::{ - custom_trace, force_collect, unsafe_empty_trace as empty_trace, Finalize, Gc, GcCell as Cell, - GcCellRef as Ref, GcCellRefMut as RefMut, Trace, -}; diff --git a/boa_cli/Cargo.toml b/boa_cli/Cargo.toml index e3b01cab3cb..8da2a2d1e38 100644 --- a/boa_cli/Cargo.toml +++ b/boa_cli/Cargo.toml @@ -1,19 +1,37 @@ [package] name = "boa_cli" version = "0.13.0" +edition = "2021" +rust-version = "1.58" authors = ["boa-dev"] description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." repository = "https://github.com/boa-dev/boa" keywords = ["javascript", "compiler", "lexer", "parser", "js", "cli"] categories = ["command-line-utilities"] license = "Unlicense/MIT" -exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] -edition = "2021" -rust-version = "1.58" default-run = "boa" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] [dependencies] -Boa = { path = "../boa", features = ["deser", "console"] } +boa_engine = { path = "../boa_engine", features = ["deser", "console"] } +boa_interner = { path = "../boa_interner" } rustyline = "9.1.2" rustyline-derive = "0.6.0" structopt = "0.3.26" diff --git a/boa_cli/src/main.rs b/boa_cli/src/main.rs index 3524647766b..87bfb70c804 100644 --- a/boa_cli/src/main.rs +++ b/boa_cli/src/main.rs @@ -59,7 +59,8 @@ rustdoc::missing_doc_code_examples )] -use boa::{syntax::ast::node::StatementList, Context, Interner}; +use boa_engine::{syntax::ast::node::StatementList, Context}; +use boa_interner::Interner; use colored::{Color, Colorize}; use rustyline::{config::Config, error::ReadlineError, EditMode, Editor}; use std::{fs::read, io, path::PathBuf}; @@ -146,7 +147,7 @@ fn parse_tokens(src: S, interner: &mut Interner) -> Result, { - use boa::syntax::parser::Parser; + use boa_engine::syntax::parser::Parser; let src_bytes = src.as_ref(); Parser::new(src_bytes, false) diff --git a/boa/Cargo.toml b/boa_engine/Cargo.toml similarity index 63% rename from boa/Cargo.toml rename to boa_engine/Cargo.toml index 2f759503894..5acfcf8da92 100644 --- a/boa/Cargo.toml +++ b/boa_engine/Cargo.toml @@ -1,18 +1,35 @@ [package] -name = "Boa" +name = "boa_engine" version = "0.13.0" +edition = "2021" +rust-version = "1.58" authors = ["boa-dev"] description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." repository = "https://github.com/boa-dev/boa" -keywords = ["javascript", "compiler", "lexer", "parser", "js"] -categories = ["parser-implementations", "wasm"] +keywords = ["javascript", "js", "compiler", "lexer", "parser"] +categories = ["parser-implementations", "compilers"] license = "Unlicense/MIT" -exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] -edition = "2021" -rust-version = "1.58" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] [features] -profiler = ["measureme"] +profiler = ["boa_profiler/profiler"] deser = ["boa_interner/serde"] # Enable Boa's WHATWG console object implementation. @@ -21,7 +38,9 @@ console = [] [dependencies] boa_unicode = { path = "../boa_unicode", version = "0.13.0" } boa_interner = { path = "../boa_interner", version = "0.13.0" } -gc = { version = "0.4.1", features = ["derive"] } +boa_gc = { path = "../boa_gc", version = "0.13.0" } +gc = { version = "0.4.1" } +boa_profiler = { path = "../boa_profiler", version = "0.13.0" } serde = { version = "1.0.136", features = ["derive", "rc"] } serde_json = "1.0.79" rand = "0.8.5" @@ -39,9 +58,6 @@ unicode-normalization = "0.1.19" dyn-clone = "1.0.4" once_cell = "1.9.0" -# Optional Dependencies -measureme = { version = "10.0.0", optional = true } - [dev-dependencies] criterion = "0.3.5" float-cmp = "0.9.0" @@ -51,7 +67,7 @@ jemallocator = "0.3.2" [lib] crate-type = ["cdylib", "lib"] -name = "boa" +name = "boa_engine" bench = false [[bench]] diff --git a/boa/benches/README.md b/boa_engine/benches/README.md similarity index 100% rename from boa/benches/README.md rename to boa_engine/benches/README.md diff --git a/boa/benches/bench_scripts/arithmetic_operations.js b/boa_engine/benches/bench_scripts/arithmetic_operations.js similarity index 100% rename from boa/benches/bench_scripts/arithmetic_operations.js rename to boa_engine/benches/bench_scripts/arithmetic_operations.js diff --git a/boa/benches/bench_scripts/array_access.js b/boa_engine/benches/bench_scripts/array_access.js similarity index 100% rename from boa/benches/bench_scripts/array_access.js rename to boa_engine/benches/bench_scripts/array_access.js diff --git a/boa/benches/bench_scripts/array_create.js b/boa_engine/benches/bench_scripts/array_create.js similarity index 100% rename from boa/benches/bench_scripts/array_create.js rename to boa_engine/benches/bench_scripts/array_create.js diff --git a/boa/benches/bench_scripts/array_pop.js b/boa_engine/benches/bench_scripts/array_pop.js similarity index 100% rename from boa/benches/bench_scripts/array_pop.js rename to boa_engine/benches/bench_scripts/array_pop.js diff --git a/boa/benches/bench_scripts/boolean_object_access.js b/boa_engine/benches/bench_scripts/boolean_object_access.js similarity index 100% rename from boa/benches/bench_scripts/boolean_object_access.js rename to boa_engine/benches/bench_scripts/boolean_object_access.js diff --git a/boa/benches/bench_scripts/clean_js.js b/boa_engine/benches/bench_scripts/clean_js.js similarity index 100% rename from boa/benches/bench_scripts/clean_js.js rename to boa_engine/benches/bench_scripts/clean_js.js diff --git a/boa/benches/bench_scripts/fibonacci.js b/boa_engine/benches/bench_scripts/fibonacci.js similarity index 100% rename from boa/benches/bench_scripts/fibonacci.js rename to boa_engine/benches/bench_scripts/fibonacci.js diff --git a/boa/benches/bench_scripts/for_loop.js b/boa_engine/benches/bench_scripts/for_loop.js similarity index 100% rename from boa/benches/bench_scripts/for_loop.js rename to boa_engine/benches/bench_scripts/for_loop.js diff --git a/boa/benches/bench_scripts/mini_js.js b/boa_engine/benches/bench_scripts/mini_js.js similarity index 100% rename from boa/benches/bench_scripts/mini_js.js rename to boa_engine/benches/bench_scripts/mini_js.js diff --git a/boa/benches/bench_scripts/number_object_access.js b/boa_engine/benches/bench_scripts/number_object_access.js similarity index 100% rename from boa/benches/bench_scripts/number_object_access.js rename to boa_engine/benches/bench_scripts/number_object_access.js diff --git a/boa/benches/bench_scripts/object_creation.js b/boa_engine/benches/bench_scripts/object_creation.js similarity index 100% rename from boa/benches/bench_scripts/object_creation.js rename to boa_engine/benches/bench_scripts/object_creation.js diff --git a/boa/benches/bench_scripts/object_prop_access_const.js b/boa_engine/benches/bench_scripts/object_prop_access_const.js similarity index 100% rename from boa/benches/bench_scripts/object_prop_access_const.js rename to boa_engine/benches/bench_scripts/object_prop_access_const.js diff --git a/boa/benches/bench_scripts/object_prop_access_dyn.js b/boa_engine/benches/bench_scripts/object_prop_access_dyn.js similarity index 100% rename from boa/benches/bench_scripts/object_prop_access_dyn.js rename to boa_engine/benches/bench_scripts/object_prop_access_dyn.js diff --git a/boa/benches/bench_scripts/regexp.js b/boa_engine/benches/bench_scripts/regexp.js similarity index 100% rename from boa/benches/bench_scripts/regexp.js rename to boa_engine/benches/bench_scripts/regexp.js diff --git a/boa/benches/bench_scripts/regexp_creation.js b/boa_engine/benches/bench_scripts/regexp_creation.js similarity index 100% rename from boa/benches/bench_scripts/regexp_creation.js rename to boa_engine/benches/bench_scripts/regexp_creation.js diff --git a/boa/benches/bench_scripts/regexp_literal.js b/boa_engine/benches/bench_scripts/regexp_literal.js similarity index 100% rename from boa/benches/bench_scripts/regexp_literal.js rename to boa_engine/benches/bench_scripts/regexp_literal.js diff --git a/boa/benches/bench_scripts/regexp_literal_creation.js b/boa_engine/benches/bench_scripts/regexp_literal_creation.js similarity index 100% rename from boa/benches/bench_scripts/regexp_literal_creation.js rename to boa_engine/benches/bench_scripts/regexp_literal_creation.js diff --git a/boa/benches/bench_scripts/string_compare.js b/boa_engine/benches/bench_scripts/string_compare.js similarity index 100% rename from boa/benches/bench_scripts/string_compare.js rename to boa_engine/benches/bench_scripts/string_compare.js diff --git a/boa/benches/bench_scripts/string_concat.js b/boa_engine/benches/bench_scripts/string_concat.js similarity index 100% rename from boa/benches/bench_scripts/string_concat.js rename to boa_engine/benches/bench_scripts/string_concat.js diff --git a/boa/benches/bench_scripts/string_copy.js b/boa_engine/benches/bench_scripts/string_copy.js similarity index 100% rename from boa/benches/bench_scripts/string_copy.js rename to boa_engine/benches/bench_scripts/string_copy.js diff --git a/boa/benches/bench_scripts/string_object_access.js b/boa_engine/benches/bench_scripts/string_object_access.js similarity index 100% rename from boa/benches/bench_scripts/string_object_access.js rename to boa_engine/benches/bench_scripts/string_object_access.js diff --git a/boa/benches/bench_scripts/symbol_creation.js b/boa_engine/benches/bench_scripts/symbol_creation.js similarity index 100% rename from boa/benches/bench_scripts/symbol_creation.js rename to boa_engine/benches/bench_scripts/symbol_creation.js diff --git a/boa/benches/full.rs b/boa_engine/benches/full.rs similarity index 98% rename from boa/benches/full.rs rename to boa_engine/benches/full.rs index e0eedc3ef51..ec90998fd06 100644 --- a/boa/benches/full.rs +++ b/boa_engine/benches/full.rs @@ -1,6 +1,6 @@ //! Benchmarks of the whole execution engine in Boa. -use boa::{realm::Realm, Context}; +use boa_engine::{realm::Realm, Context}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; #[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))] diff --git a/boa/examples/classes.rs b/boa_engine/examples/classes.rs similarity index 99% rename from boa/examples/classes.rs rename to boa_engine/examples/classes.rs index 4cbab44b8c6..55ea749f264 100644 --- a/boa/examples/classes.rs +++ b/boa_engine/examples/classes.rs @@ -1,11 +1,11 @@ // NOTE: this example requires the `console` feature to run correctly. -use boa::{ +use boa_engine::{ class::{Class, ClassBuilder}, - gc::{Finalize, Trace}, property::Attribute, Context, JsResult, JsValue, }; +use boa_gc::{Finalize, Trace}; // We create a new struct that is going to represent a person. // diff --git a/boa/examples/closures.rs b/boa_engine/examples/closures.rs similarity index 98% rename from boa/examples/closures.rs rename to boa_engine/examples/closures.rs index 38b4170218e..9eae78b4b8d 100644 --- a/boa/examples/closures.rs +++ b/boa_engine/examples/closures.rs @@ -1,12 +1,12 @@ // This example goes into the details on how to pass closures as functions // inside Rust and call them from Javascript. -use boa::{ - gc::{Finalize, Trace}, +use boa_engine::{ object::{FunctionBuilder, JsObject}, property::{Attribute, PropertyDescriptor}, Context, JsString, JsValue, }; +use boa_gc::{Finalize, Trace}; fn main() -> Result<(), JsValue> { // We create a new `Context` to create a new Javascript executor. diff --git a/boa/examples/jsarray.rs b/boa_engine/examples/jsarray.rs similarity index 99% rename from boa/examples/jsarray.rs rename to boa_engine/examples/jsarray.rs index 4567af97d2c..86c5bda1836 100644 --- a/boa/examples/jsarray.rs +++ b/boa_engine/examples/jsarray.rs @@ -1,4 +1,4 @@ -use boa::{ +use boa_engine::{ object::{FunctionBuilder, JsArray}, Context, JsValue, }; diff --git a/boa/src/bigint.rs b/boa_engine/src/bigint.rs similarity index 98% rename from boa/src/bigint.rs rename to boa_engine/src/bigint.rs index 9fc60021326..f13546d8eb9 100644 --- a/boa/src/bigint.rs +++ b/boa_engine/src/bigint.rs @@ -1,22 +1,16 @@ //! This module implements the JavaScript bigint primitive rust type. -use crate::{ - builtins::Number, - gc::{empty_trace, Finalize, Trace}, - Context, JsValue, -}; - +use crate::{builtins::Number, Context, JsValue}; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; +use num_integer::Integer; +use num_traits::pow::Pow; +use num_traits::{FromPrimitive, One, ToPrimitive, Zero}; use std::{ - convert::TryFrom, fmt::{self, Display}, ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub}, rc::Rc, }; -use num_integer::Integer; -use num_traits::pow::Pow; -use num_traits::{FromPrimitive, One, ToPrimitive, Zero}; - /// The raw bigint type. pub type RawBigInt = num_bigint::BigInt; @@ -33,7 +27,7 @@ pub struct JsBigInt { // Safety: BigInt does not contain any objects which needs to be traced, // so this is safe. unsafe impl Trace for JsBigInt { - empty_trace!(); + unsafe_empty_trace!(); } impl JsBigInt { diff --git a/boa/src/builtins/array/array_iterator.rs b/boa_engine/src/builtins/array/array_iterator.rs similarity index 96% rename from boa/src/builtins/array/array_iterator.rs rename to boa_engine/src/builtins/array/array_iterator.rs index 45a52fd71ca..e8621c22a27 100644 --- a/boa/src/builtins/array/array_iterator.rs +++ b/boa_engine/src/builtins/array/array_iterator.rs @@ -1,11 +1,12 @@ use crate::{ builtins::{function::make_builtin_fn, iterable::create_iter_result_object, Array, JsValue}, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::{PropertyDescriptor, PropertyNameKind}, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, + Context, JsResult, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; /// The Array Iterator object represents an iteration over an array. It implements the iterator protocol. /// @@ -121,7 +122,7 @@ impl ArrayIterator { iterator_prototype: JsObject, context: &mut Context, ) -> JsObject { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); // Create prototype let array_iterator = diff --git a/boa/src/builtins/array/mod.rs b/boa_engine/src/builtins/array/mod.rs similarity index 99% rename from boa/src/builtins/array/mod.rs rename to boa_engine/src/builtins/array/mod.rs index 2bd45eefd91..f4c9cc4a9e6 100644 --- a/boa/src/builtins/array/mod.rs +++ b/boa_engine/src/builtins/array/mod.rs @@ -13,6 +13,9 @@ pub mod array_iterator; #[cfg(test)] mod tests; +use boa_profiler::Profiler; + +use super::JsArgs; use crate::{ builtins::array::array_iterator::ArrayIterator, builtins::BuiltIn, @@ -25,12 +28,10 @@ use crate::{ property::{Attribute, PropertyDescriptor, PropertyNameKind}, symbol::WellKnownSymbols, value::{IntegerOrInfinity, JsValue}, - BoaProfiler, Context, JsResult, JsString, + Context, JsResult, JsString, }; use std::cmp::{max, min, Ordering}; -use super::JsArgs; - /// JavaScript `Array` built-in implementation. #[derive(Debug, Clone, Copy)] pub(crate) struct Array; @@ -43,7 +44,7 @@ impl BuiltIn for Array { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let symbol_iterator = WellKnownSymbols::iterator(); diff --git a/boa/src/builtins/array/tests.rs b/boa_engine/src/builtins/array/tests.rs similarity index 100% rename from boa/src/builtins/array/tests.rs rename to boa_engine/src/builtins/array/tests.rs diff --git a/boa/src/builtins/array_buffer/mod.rs b/boa_engine/src/builtins/array_buffer/mod.rs similarity index 99% rename from boa/src/builtins/array_buffer/mod.rs rename to boa_engine/src/builtins/array_buffer/mod.rs index dd89ef508c2..9bc118f6b9c 100644 --- a/boa/src/builtins/array_buffer/mod.rs +++ b/boa_engine/src/builtins/array_buffer/mod.rs @@ -4,19 +4,18 @@ mod tests; use crate::{ builtins::{typed_array::TypedArrayName, BuiltIn, JsArgs}, context::StandardObjects, - gc::{Finalize, Trace}, object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, FunctionBuilder, JsObject, ObjectData, }, - profiler::BoaProfiler, property::Attribute, symbol::WellKnownSymbols, value::{IntegerOrInfinity, Numeric}, Context, JsResult, JsValue, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; use num_traits::{Signed, ToPrimitive}; -use std::convert::TryInto; #[derive(Debug, Clone, Trace, Finalize)] pub struct ArrayBuffer { @@ -39,7 +38,7 @@ impl BuiltIn for ArrayBuffer { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let get_species = FunctionBuilder::native(context, Self::get_species) .name("get [Symbol.species]") diff --git a/boa/src/builtins/array_buffer/tests.rs b/boa_engine/src/builtins/array_buffer/tests.rs similarity index 100% rename from boa/src/builtins/array_buffer/tests.rs rename to boa_engine/src/builtins/array_buffer/tests.rs diff --git a/boa/src/builtins/bigint/mod.rs b/boa_engine/src/builtins/bigint/mod.rs similarity index 98% rename from boa/src/builtins/bigint/mod.rs rename to boa_engine/src/builtins/bigint/mod.rs index 619b07c40a7..86a074b86fd 100644 --- a/boa/src/builtins/bigint/mod.rs +++ b/boa_engine/src/builtins/bigint/mod.rs @@ -18,8 +18,9 @@ use crate::{ property::Attribute, symbol::WellKnownSymbols, value::{IntegerOrInfinity, PreferredType}, - BoaProfiler, Context, JsBigInt, JsResult, JsValue, + Context, JsBigInt, JsResult, JsValue, }; +use boa_profiler::Profiler; use num_bigint::ToBigInt; #[cfg(test)] @@ -37,7 +38,7 @@ impl BuiltIn for BigInt { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let to_string_tag = WellKnownSymbols::to_string_tag(); diff --git a/boa/src/builtins/bigint/tests.rs b/boa_engine/src/builtins/bigint/tests.rs similarity index 100% rename from boa/src/builtins/bigint/tests.rs rename to boa_engine/src/builtins/bigint/tests.rs diff --git a/boa/src/builtins/boolean/mod.rs b/boa_engine/src/builtins/boolean/mod.rs similarity index 96% rename from boa/src/builtins/boolean/mod.rs rename to boa_engine/src/builtins/boolean/mod.rs index 2fd7300107b..b14d46d4223 100644 --- a/boa/src/builtins/boolean/mod.rs +++ b/boa_engine/src/builtins/boolean/mod.rs @@ -19,8 +19,9 @@ use crate::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, property::Attribute, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; +use boa_profiler::Profiler; /// Boolean implementation. #[derive(Debug, Clone, Copy)] @@ -35,7 +36,7 @@ impl BuiltIn for Boolean { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let boolean_object = ConstructorBuilder::with_standard_object( context, diff --git a/boa/src/builtins/boolean/tests.rs b/boa_engine/src/builtins/boolean/tests.rs similarity index 100% rename from boa/src/builtins/boolean/tests.rs rename to boa_engine/src/builtins/boolean/tests.rs diff --git a/boa/src/builtins/console/mod.rs b/boa_engine/src/builtins/console/mod.rs similarity index 99% rename from boa/src/builtins/console/mod.rs rename to boa_engine/src/builtins/console/mod.rs index e1053f50935..c06476af2be 100644 --- a/boa/src/builtins/console/mod.rs +++ b/boa_engine/src/builtins/console/mod.rs @@ -21,8 +21,9 @@ use crate::{ object::ObjectInitializer, property::Attribute, value::{display::display_obj, JsValue}, - BoaProfiler, Context, JsResult, JsString, + Context, JsResult, JsString, }; +use boa_profiler::Profiler; use rustc_hash::FxHashMap; use std::time::SystemTime; @@ -142,7 +143,7 @@ impl BuiltIn for Console { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let console = ObjectInitializer::new(context) .function(Self::assert, "assert", 0) .function(Self::clear, "clear", 0) diff --git a/boa/src/builtins/console/tests.rs b/boa_engine/src/builtins/console/tests.rs similarity index 100% rename from boa/src/builtins/console/tests.rs rename to boa_engine/src/builtins/console/tests.rs diff --git a/boa/src/builtins/dataview/mod.rs b/boa_engine/src/builtins/dataview/mod.rs similarity index 99% rename from boa/src/builtins/dataview/mod.rs rename to boa_engine/src/builtins/dataview/mod.rs index 8fab899dd4b..4b8c256c8e3 100644 --- a/boa/src/builtins/dataview/mod.rs +++ b/boa_engine/src/builtins/dataview/mod.rs @@ -1,7 +1,6 @@ use crate::{ builtins::{array_buffer::SharedMemoryOrder, typed_array::TypedArrayName, BuiltIn, JsArgs}, context::StandardObjects, - gc::{Finalize, Trace}, object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, FunctionBuilder, JsObject, ObjectData, @@ -11,6 +10,7 @@ use crate::{ value::JsValue, Context, JsResult, }; +use boa_gc::{Finalize, Trace}; #[derive(Debug, Clone, Trace, Finalize)] pub struct DataView { diff --git a/boa/src/builtins/date/mod.rs b/boa_engine/src/builtins/date/mod.rs similarity index 99% rename from boa/src/builtins/date/mod.rs rename to boa_engine/src/builtins/date/mod.rs index 674ccafdf98..590a3d33200 100644 --- a/boa/src/builtins/date/mod.rs +++ b/boa_engine/src/builtins/date/mod.rs @@ -1,23 +1,23 @@ #[cfg(test)] mod tests; +use super::JsArgs; use crate::{ builtins::BuiltIn, context::StandardObjects, - gc::{empty_trace, Finalize, Trace}, object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, property::Attribute, symbol::WellKnownSymbols, value::{JsValue, PreferredType}, - BoaProfiler, Context, JsResult, JsString, + Context, JsResult, JsString, }; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; +use boa_profiler::Profiler; use chrono::{prelude::*, Duration, LocalResult}; use std::fmt::Display; -use super::JsArgs; - /// The number of nanoseconds in a millisecond. const NANOS_PER_MS: i64 = 1_000_000; /// The number of milliseconds in an hour. @@ -76,7 +76,7 @@ impl Display for Date { unsafe impl Trace for Date { // Date is a stack value, it doesn't require tracing. // only safe if `chrono` never implements `Trace` for `NaiveDateTime` - empty_trace!(); + unsafe_empty_trace!(); } impl Default for Date { @@ -93,7 +93,7 @@ impl BuiltIn for Date { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let date_object = ConstructorBuilder::new(context, Self::constructor) .name(Self::NAME) diff --git a/boa/src/builtins/date/tests.rs b/boa_engine/src/builtins/date/tests.rs similarity index 100% rename from boa/src/builtins/date/tests.rs rename to boa_engine/src/builtins/date/tests.rs diff --git a/boa/src/builtins/error/eval.rs b/boa_engine/src/builtins/error/eval.rs similarity index 89% rename from boa/src/builtins/error/eval.rs rename to boa_engine/src/builtins/error/eval.rs index 2c86ca61f29..fabd901de4e 100644 --- a/boa/src/builtins/error/eval.rs +++ b/boa_engine/src/builtins/error/eval.rs @@ -11,17 +11,16 @@ //! [spec]: https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-evalerror //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError -use crate::context::StandardObjects; -use crate::object::internal_methods::get_prototype_from_constructor; -use crate::object::JsObject; - use crate::{ builtins::BuiltIn, - object::{ConstructorBuilder, ObjectData}, - profiler::BoaProfiler, + context::StandardObjects, + object::{ + internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, + }, property::Attribute, Context, JsResult, JsValue, }; +use boa_profiler::Profiler; /// JavaScript `EvalError` impleentation. #[derive(Debug, Clone, Copy)] @@ -35,7 +34,7 @@ impl BuiltIn for EvalError { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; diff --git a/boa/src/builtins/error/mod.rs b/boa_engine/src/builtins/error/mod.rs similarity index 97% rename from boa/src/builtins/error/mod.rs rename to boa_engine/src/builtins/error/mod.rs index 1319b70061b..42291a379ea 100644 --- a/boa/src/builtins/error/mod.rs +++ b/boa_engine/src/builtins/error/mod.rs @@ -16,10 +16,10 @@ use crate::{ object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, - profiler::BoaProfiler, property::Attribute, Context, JsResult, JsValue, }; +use boa_profiler::Profiler; pub(crate) mod eval; pub(crate) mod range; @@ -50,7 +50,7 @@ impl BuiltIn for Error { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; let error_object = ConstructorBuilder::with_standard_object( diff --git a/boa/src/builtins/error/range.rs b/boa_engine/src/builtins/error/range.rs similarity index 95% rename from boa/src/builtins/error/range.rs rename to boa_engine/src/builtins/error/range.rs index 090c8f7f4c7..9611d503734 100644 --- a/boa/src/builtins/error/range.rs +++ b/boa_engine/src/builtins/error/range.rs @@ -15,10 +15,10 @@ use crate::{ object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, - profiler::BoaProfiler, property::Attribute, Context, JsResult, JsValue, }; +use boa_profiler::Profiler; /// JavaScript `RangeError` implementation. #[derive(Debug, Clone, Copy)] @@ -32,7 +32,7 @@ impl BuiltIn for RangeError { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; diff --git a/boa/src/builtins/error/reference.rs b/boa_engine/src/builtins/error/reference.rs similarity index 95% rename from boa/src/builtins/error/reference.rs rename to boa_engine/src/builtins/error/reference.rs index e0afa38d36b..bacb9ab58ac 100644 --- a/boa/src/builtins/error/reference.rs +++ b/boa_engine/src/builtins/error/reference.rs @@ -15,10 +15,10 @@ use crate::{ object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, - profiler::BoaProfiler, property::Attribute, Context, JsResult, JsValue, }; +use boa_profiler::Profiler; #[derive(Debug, Clone, Copy)] pub(crate) struct ReferenceError; @@ -31,7 +31,7 @@ impl BuiltIn for ReferenceError { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; diff --git a/boa/src/builtins/error/syntax.rs b/boa_engine/src/builtins/error/syntax.rs similarity index 96% rename from boa/src/builtins/error/syntax.rs rename to boa_engine/src/builtins/error/syntax.rs index 850cad58696..bc4a1824b9c 100644 --- a/boa/src/builtins/error/syntax.rs +++ b/boa_engine/src/builtins/error/syntax.rs @@ -17,10 +17,10 @@ use crate::{ object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, - profiler::BoaProfiler, property::Attribute, Context, JsResult, JsValue, }; +use boa_profiler::Profiler; /// JavaScript `SyntaxError` impleentation. #[derive(Debug, Clone, Copy)] @@ -34,7 +34,7 @@ impl BuiltIn for SyntaxError { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; diff --git a/boa/src/builtins/error/tests.rs b/boa_engine/src/builtins/error/tests.rs similarity index 100% rename from boa/src/builtins/error/tests.rs rename to boa_engine/src/builtins/error/tests.rs diff --git a/boa/src/builtins/error/type.rs b/boa_engine/src/builtins/error/type.rs similarity index 95% rename from boa/src/builtins/error/type.rs rename to boa_engine/src/builtins/error/type.rs index ddc47fd3691..4064aa384bf 100644 --- a/boa/src/builtins/error/type.rs +++ b/boa_engine/src/builtins/error/type.rs @@ -22,8 +22,9 @@ use crate::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, property::Attribute, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; +use boa_profiler::Profiler; /// JavaScript `TypeError` implementation. #[derive(Debug, Clone, Copy)] @@ -37,7 +38,7 @@ impl BuiltIn for TypeError { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; diff --git a/boa/src/builtins/error/uri.rs b/boa_engine/src/builtins/error/uri.rs similarity index 95% rename from boa/src/builtins/error/uri.rs rename to boa_engine/src/builtins/error/uri.rs index 07e600712e0..e16628f9d7f 100644 --- a/boa/src/builtins/error/uri.rs +++ b/boa_engine/src/builtins/error/uri.rs @@ -16,10 +16,10 @@ use crate::{ object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsObject, ObjectData, }, - profiler::BoaProfiler, property::Attribute, Context, JsResult, JsValue, }; +use boa_profiler::Profiler; /// JavaScript `URIError` impleentation. #[derive(Debug, Clone, Copy)] @@ -33,7 +33,7 @@ impl BuiltIn for UriError { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let error_prototype = context.standard_objects().error_object().prototype(); let attribute = Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; diff --git a/boa/src/builtins/function/arguments.rs b/boa_engine/src/builtins/function/arguments.rs similarity index 99% rename from boa/src/builtins/function/arguments.rs rename to boa_engine/src/builtins/function/arguments.rs index 4de082a9a5d..81b9d3a3ec6 100644 --- a/boa/src/builtins/function/arguments.rs +++ b/boa_engine/src/builtins/function/arguments.rs @@ -1,14 +1,13 @@ use crate::{ builtins::Array, environments::DeclarativeEnvironment, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::PropertyDescriptor, symbol::{self, WellKnownSymbols}, syntax::ast::node::FormalParameter, Context, JsValue, }; -use gc::Gc; +use boa_gc::{Finalize, Gc, Trace}; use rustc_hash::FxHashMap; /// `ParameterMap` represents the `[[ParameterMap]]` internal slot on a Arguments exotic object. diff --git a/boa/src/builtins/function/mod.rs b/boa_engine/src/builtins/function/mod.rs similarity index 97% rename from boa/src/builtins/function/mod.rs rename to boa_engine/src/builtins/function/mod.rs index 23d05617b79..be7ef7028ec 100644 --- a/boa/src/builtins/function/mod.rs +++ b/boa_engine/src/builtins/function/mod.rs @@ -15,7 +15,6 @@ use crate::{ builtins::{BuiltIn, JsArgs}, context::StandardObjects, environments::DeclarativeEnvironmentStack, - gc::{self, Finalize, Gc, Trace}, object::{ internal_methods::get_prototype_from_constructor, JsObject, NativeObject, Object, ObjectData, @@ -24,8 +23,10 @@ use crate::{ property::{Attribute, PropertyDescriptor, PropertyKey}, symbol::WellKnownSymbols, value::IntegerOrInfinity, - BoaProfiler, Context, JsResult, JsString, JsValue, + Context, JsResult, JsString, JsValue, }; +use boa_gc::{self, Finalize, Gc, Trace}; +use boa_profiler::Profiler; use dyn_clone::DynClone; use std::{ any::Any, @@ -125,7 +126,7 @@ impl ConstructorKind { /// with `Any::downcast_ref` and `Any::downcast_mut` to recover the original /// type. #[derive(Clone, Debug, Trace, Finalize)] -pub struct Captures(Gc>>); +pub struct Captures(Gc>>); impl Captures { /// Creates a new capture context. @@ -133,7 +134,7 @@ impl Captures { where T: NativeObject, { - Self(Gc::new(gc::Cell::new(Box::new(captures)))) + Self(Gc::new(boa_gc::Cell::new(Box::new(captures)))) } /// Casts `Captures` to `Any` @@ -141,7 +142,7 @@ impl Captures { /// # Panics /// /// Panics if it's already borrowed as `&mut Any` - pub fn as_any(&self) -> gc::Ref<'_, dyn Any> { + pub fn as_any(&self) -> boa_gc::Ref<'_, dyn Any> { Ref::map(self.0.borrow(), |data| data.deref().as_any()) } @@ -150,7 +151,7 @@ impl Captures { /// # Panics /// /// Panics if it's already borrowed as `&mut Any` - pub fn as_mut_any(&self) -> gc::RefMut<'_, Box, dyn Any> { + pub fn as_mut_any(&self) -> boa_gc::RefMut<'_, Box, dyn Any> { RefMut::map(self.0.borrow_mut(), |data| data.deref_mut().as_mut_any()) } } @@ -225,7 +226,7 @@ pub(crate) fn make_builtin_fn( N: Into, { let name = name.into(); - let _timer = BoaProfiler::global().start_event(&format!("make_builtin_fn: {name}"), "init"); + let _timer = Profiler::global().start_event(&format!("make_builtin_fn: {name}"), "init"); let function = JsObject::from_proto_and_data( interpreter.standard_objects().function_object().prototype(), @@ -488,7 +489,7 @@ impl BuiltIn for BuiltInFunctionObject { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event("function", "init"); + let _timer = Profiler::global().start_event("function", "init"); let function_prototype = context.standard_objects().function_object().prototype(); FunctionBuilder::native(context, Self::prototype) diff --git a/boa/src/builtins/function/tests.rs b/boa_engine/src/builtins/function/tests.rs similarity index 100% rename from boa/src/builtins/function/tests.rs rename to boa_engine/src/builtins/function/tests.rs diff --git a/boa/src/builtins/global_this/mod.rs b/boa_engine/src/builtins/global_this/mod.rs similarity index 82% rename from boa/src/builtins/global_this/mod.rs rename to boa_engine/src/builtins/global_this/mod.rs index b483158f538..451b5fa09a8 100644 --- a/boa/src/builtins/global_this/mod.rs +++ b/boa_engine/src/builtins/global_this/mod.rs @@ -10,7 +10,8 @@ //! [spec]: https://tc39.es/ecma262/#sec-globalthis //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis -use crate::{builtins::BuiltIn, property::Attribute, BoaProfiler, Context, JsValue}; +use crate::{builtins::BuiltIn, property::Attribute, Context, JsValue}; +use boa_profiler::Profiler; #[cfg(test)] mod tests; @@ -26,7 +27,7 @@ impl BuiltIn for GlobalThis { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); context.global_object().clone().into() } diff --git a/boa/src/builtins/global_this/tests.rs b/boa_engine/src/builtins/global_this/tests.rs similarity index 100% rename from boa/src/builtins/global_this/tests.rs rename to boa_engine/src/builtins/global_this/tests.rs diff --git a/boa/src/builtins/infinity/mod.rs b/boa_engine/src/builtins/infinity/mod.rs similarity index 83% rename from boa/src/builtins/infinity/mod.rs rename to boa_engine/src/builtins/infinity/mod.rs index 37140d35acf..96748a252fb 100644 --- a/boa/src/builtins/infinity/mod.rs +++ b/boa_engine/src/builtins/infinity/mod.rs @@ -12,7 +12,8 @@ #[cfg(test)] mod tests; -use crate::{builtins::BuiltIn, property::Attribute, BoaProfiler, Context, JsValue}; +use crate::{builtins::BuiltIn, property::Attribute, Context, JsValue}; +use boa_profiler::Profiler; /// JavaScript global `Infinity` property. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -26,7 +27,7 @@ impl BuiltIn for Infinity { .union(Attribute::PERMANENT); fn init(_: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); f64::INFINITY.into() } diff --git a/boa/src/builtins/infinity/tests.rs b/boa_engine/src/builtins/infinity/tests.rs similarity index 100% rename from boa/src/builtins/infinity/tests.rs rename to boa_engine/src/builtins/infinity/tests.rs diff --git a/boa/src/builtins/intl/mod.rs b/boa_engine/src/builtins/intl/mod.rs similarity index 97% rename from boa/src/builtins/intl/mod.rs rename to boa_engine/src/builtins/intl/mod.rs index e4f3e0362dd..dcd3c2bb481 100644 --- a/boa/src/builtins/intl/mod.rs +++ b/boa_engine/src/builtins/intl/mod.rs @@ -7,15 +7,15 @@ //! //! [spec]: https://tc39.es/ecma402/#intl-object -use indexmap::IndexSet; - use crate::{ builtins::{Array, BuiltIn, JsArgs}, object::ObjectInitializer, property::Attribute, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsString, JsValue, + Context, JsResult, JsString, JsValue, }; +use boa_profiler::Profiler; +use indexmap::IndexSet; /// JavaScript `Intl` object. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -29,7 +29,7 @@ impl BuiltIn for Intl { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let string_tag = WellKnownSymbols::to_string_tag(); let object = ObjectInitializer::new(context) diff --git a/boa/src/builtins/intrinsics.rs b/boa_engine/src/builtins/intrinsics.rs similarity index 100% rename from boa/src/builtins/intrinsics.rs rename to boa_engine/src/builtins/intrinsics.rs diff --git a/boa/src/builtins/iterable/mod.rs b/boa_engine/src/builtins/iterable/mod.rs similarity index 98% rename from boa/src/builtins/iterable/mod.rs rename to boa_engine/src/builtins/iterable/mod.rs index fbf2dc47ba5..cf2317daeef 100644 --- a/boa/src/builtins/iterable/mod.rs +++ b/boa_engine/src/builtins/iterable/mod.rs @@ -6,8 +6,9 @@ use crate::{ }, object::{JsObject, ObjectInitializer}, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; +use boa_profiler::Profiler; #[derive(Debug, Default)] pub struct IteratorPrototypes { @@ -168,7 +169,7 @@ impl JsValue { /// /// [spec]: https://tc39.es/ecma262/#sec-%iteratorprototype%-object fn create_iterator_prototype(context: &mut Context) -> JsObject { - let _timer = BoaProfiler::global().start_event("Iterator Prototype", "init"); + let _timer = Profiler::global().start_event("Iterator Prototype", "init"); let symbol_iterator = WellKnownSymbols::iterator(); let iterator_prototype = ObjectInitializer::new(context) diff --git a/boa/src/builtins/json/mod.rs b/boa_engine/src/builtins/json/mod.rs similarity index 99% rename from boa/src/builtins/json/mod.rs rename to boa_engine/src/builtins/json/mod.rs index 98cc4868210..c443082aff1 100644 --- a/boa/src/builtins/json/mod.rs +++ b/boa_engine/src/builtins/json/mod.rs @@ -13,6 +13,7 @@ //! [json]: https://www.json.org/json-en.html //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON +use super::JsArgs; use crate::{ builtins::{ string::{is_leading_surrogate, is_trailing_surrogate}, @@ -22,12 +23,11 @@ use crate::{ property::{Attribute, PropertyNameKind}, symbol::WellKnownSymbols, value::IntegerOrInfinity, - BoaProfiler, Context, JsResult, JsString, JsValue, + Context, JsResult, JsString, JsValue, }; +use boa_profiler::Profiler; use serde_json::{self, Value as JSONValue}; -use super::JsArgs; - #[cfg(test)] mod tests; @@ -43,7 +43,7 @@ impl BuiltIn for Json { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let to_string_tag = WellKnownSymbols::to_string_tag(); let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; diff --git a/boa/src/builtins/json/tests.rs b/boa_engine/src/builtins/json/tests.rs similarity index 100% rename from boa/src/builtins/json/tests.rs rename to boa_engine/src/builtins/json/tests.rs diff --git a/boa/src/builtins/map/map_iterator.rs b/boa_engine/src/builtins/map/map_iterator.rs similarity index 97% rename from boa/src/builtins/map/map_iterator.rs rename to boa_engine/src/builtins/map/map_iterator.rs index 92a2e756311..f84e565c4cc 100644 --- a/boa/src/builtins/map/map_iterator.rs +++ b/boa_engine/src/builtins/map/map_iterator.rs @@ -1,12 +1,13 @@ use super::ordered_map::MapLock; use crate::{ builtins::{function::make_builtin_fn, iterable::create_iter_result_object, Array, JsValue}, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::{PropertyDescriptor, PropertyNameKind}, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, + Context, JsResult, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; /// The Map Iterator object represents an iteration over a map. It implements the iterator protocol. /// @@ -120,7 +121,7 @@ impl MapIterator { iterator_prototype: JsObject, context: &mut Context, ) -> JsObject { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); // Create prototype let map_iterator = diff --git a/boa/src/builtins/map/mod.rs b/boa_engine/src/builtins/map/mod.rs similarity index 99% rename from boa/src/builtins/map/mod.rs rename to boa_engine/src/builtins/map/mod.rs index 73be927231b..47dc6c5c821 100644 --- a/boa/src/builtins/map/mod.rs +++ b/boa_engine/src/builtins/map/mod.rs @@ -12,6 +12,8 @@ #![allow(clippy::mutable_key_type)] +use self::{map_iterator::MapIterator, ordered_map::OrderedMap}; +use super::JsArgs; use crate::{ builtins::{iterable::IteratorResult, BuiltIn}, context::StandardObjects, @@ -21,16 +23,12 @@ use crate::{ }, property::{Attribute, PropertyNameKind}, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; -use ordered_map::OrderedMap; - -pub mod map_iterator; -use map_iterator::MapIterator; - -use super::JsArgs; +use boa_profiler::Profiler; use num_traits::Zero; +pub mod map_iterator; pub mod ordered_map; #[cfg(test)] mod tests; @@ -46,7 +44,7 @@ impl BuiltIn for Map { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let get_species = FunctionBuilder::native(context, Self::get_species) .name("get [Symbol.species]") diff --git a/boa/src/builtins/map/ordered_map.rs b/boa_engine/src/builtins/map/ordered_map.rs similarity index 98% rename from boa/src/builtins/map/ordered_map.rs rename to boa_engine/src/builtins/map/ordered_map.rs index 4ea5cd426ab..7b5e60d6d98 100644 --- a/boa/src/builtins/map/ordered_map.rs +++ b/boa_engine/src/builtins/map/ordered_map.rs @@ -1,8 +1,5 @@ -use crate::{ - gc::{custom_trace, Finalize, Trace}, - object::JsObject, - JsValue, -}; +use crate::{object::JsObject, JsValue}; +use boa_gc::{custom_trace, Finalize, Trace}; use indexmap::{Equivalent, IndexMap}; use std::{ collections::hash_map::RandomState, diff --git a/boa/src/builtins/map/tests.rs b/boa_engine/src/builtins/map/tests.rs similarity index 100% rename from boa/src/builtins/map/tests.rs rename to boa_engine/src/builtins/map/tests.rs diff --git a/boa/src/builtins/math/mod.rs b/boa_engine/src/builtins/math/mod.rs similarity index 99% rename from boa/src/builtins/math/mod.rs rename to boa_engine/src/builtins/math/mod.rs index c46ac3f7da6..aa516c3f917 100644 --- a/boa/src/builtins/math/mod.rs +++ b/boa_engine/src/builtins/math/mod.rs @@ -11,12 +11,12 @@ //! [spec]: https://tc39.es/ecma262/#sec-math-object //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math +use super::JsArgs; use crate::{ builtins::BuiltIn, object::ObjectInitializer, property::Attribute, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; - -use super::JsArgs; +use boa_profiler::Profiler; #[cfg(test)] mod tests; @@ -33,7 +33,7 @@ impl BuiltIn for Math { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT; let string_tag = WellKnownSymbols::to_string_tag(); diff --git a/boa/src/builtins/math/tests.rs b/boa_engine/src/builtins/math/tests.rs similarity index 100% rename from boa/src/builtins/math/tests.rs rename to boa_engine/src/builtins/math/tests.rs diff --git a/boa/src/builtins/mod.rs b/boa_engine/src/builtins/mod.rs similarity index 100% rename from boa/src/builtins/mod.rs rename to boa_engine/src/builtins/mod.rs diff --git a/boa/src/builtins/nan/mod.rs b/boa_engine/src/builtins/nan/mod.rs similarity index 83% rename from boa/src/builtins/nan/mod.rs rename to boa_engine/src/builtins/nan/mod.rs index c1bbb40bf3e..6d05a3c5046 100644 --- a/boa/src/builtins/nan/mod.rs +++ b/boa_engine/src/builtins/nan/mod.rs @@ -13,7 +13,8 @@ #[cfg(test)] mod tests; -use crate::{builtins::BuiltIn, property::Attribute, BoaProfiler, Context, JsValue}; +use crate::{builtins::BuiltIn, property::Attribute, Context, JsValue}; +use boa_profiler::Profiler; /// JavaScript global `NaN` property. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -27,7 +28,7 @@ impl BuiltIn for NaN { .union(Attribute::PERMANENT); fn init(_: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); f64::NAN.into() } diff --git a/boa/src/builtins/nan/tests.rs b/boa_engine/src/builtins/nan/tests.rs similarity index 100% rename from boa/src/builtins/nan/tests.rs rename to boa_engine/src/builtins/nan/tests.rs diff --git a/boa/src/builtins/number/conversions.rs b/boa_engine/src/builtins/number/conversions.rs similarity index 100% rename from boa/src/builtins/number/conversions.rs rename to boa_engine/src/builtins/number/conversions.rs diff --git a/boa/src/builtins/number/mod.rs b/boa_engine/src/builtins/number/mod.rs similarity index 99% rename from boa/src/builtins/number/mod.rs rename to boa_engine/src/builtins/number/mod.rs index 0cf5e300713..1de0ad88bc1 100644 --- a/boa/src/builtins/number/mod.rs +++ b/boa_engine/src/builtins/number/mod.rs @@ -21,8 +21,9 @@ use crate::{ }, property::Attribute, value::{AbstractRelation, IntegerOrInfinity, JsValue}, - BoaProfiler, Context, JsResult, + Context, JsResult, }; +use boa_profiler::Profiler; use num_traits::{float::FloatCore, Num}; mod conversions; @@ -46,7 +47,7 @@ impl BuiltIn for Number { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT; let number_object = ConstructorBuilder::with_standard_object( diff --git a/boa/src/builtins/number/tests.rs b/boa_engine/src/builtins/number/tests.rs similarity index 100% rename from boa/src/builtins/number/tests.rs rename to boa_engine/src/builtins/number/tests.rs diff --git a/boa/src/builtins/object/for_in_iterator.rs b/boa_engine/src/builtins/object/for_in_iterator.rs similarity index 96% rename from boa/src/builtins/object/for_in_iterator.rs rename to boa_engine/src/builtins/object/for_in_iterator.rs index ea5082e8045..13a5a5f2ae2 100644 --- a/boa/src/builtins/object/for_in_iterator.rs +++ b/boa_engine/src/builtins/object/for_in_iterator.rs @@ -1,12 +1,13 @@ use crate::{ builtins::{function::make_builtin_fn, iterable::create_iter_result_object}, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::PropertyDescriptor, property::PropertyKey, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsString, JsValue, + Context, JsResult, JsString, JsValue, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; use rustc_hash::FxHashSet; use std::collections::VecDeque; @@ -128,7 +129,7 @@ impl ForInIterator { iterator_prototype: JsObject, context: &mut Context, ) -> JsObject { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); // Create prototype let for_in_iterator = diff --git a/boa/src/builtins/object/mod.rs b/boa_engine/src/builtins/object/mod.rs similarity index 99% rename from boa/src/builtins/object/mod.rs rename to boa_engine/src/builtins/object/mod.rs index b56d52a7323..efdca08993b 100644 --- a/boa/src/builtins/object/mod.rs +++ b/boa_engine/src/builtins/object/mod.rs @@ -13,6 +13,7 @@ //! [spec]: https://tc39.es/ecma262/#sec-objects //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object +use super::Array; use crate::{ builtins::{map, BuiltIn, JsArgs}, context::StandardObjects, @@ -23,10 +24,9 @@ use crate::{ property::{Attribute, PropertyDescriptor, PropertyKey, PropertyNameKind}, symbol::WellKnownSymbols, value::JsValue, - BoaProfiler, Context, JsResult, JsString, + Context, JsResult, JsString, }; - -use super::Array; +use boa_profiler::Profiler; pub mod for_in_iterator; #[cfg(test)] @@ -44,7 +44,7 @@ impl BuiltIn for Object { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let object = ConstructorBuilder::with_standard_object( context, diff --git a/boa/src/builtins/object/tests.rs b/boa_engine/src/builtins/object/tests.rs similarity index 100% rename from boa/src/builtins/object/tests.rs rename to boa_engine/src/builtins/object/tests.rs diff --git a/boa/src/builtins/proxy/mod.rs b/boa_engine/src/builtins/proxy/mod.rs similarity index 97% rename from boa/src/builtins/proxy/mod.rs rename to boa_engine/src/builtins/proxy/mod.rs index 7ee80b11505..233e1a34de3 100644 --- a/boa/src/builtins/proxy/mod.rs +++ b/boa_engine/src/builtins/proxy/mod.rs @@ -12,11 +12,12 @@ use crate::{ builtins::{BuiltIn, JsArgs}, - gc::{Finalize, Trace}, object::{ConstructorBuilder, FunctionBuilder, JsObject, ObjectData}, property::Attribute, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; /// Javascript `Proxy` object. #[derive(Debug, Clone, Trace, Finalize)] @@ -33,7 +34,7 @@ impl BuiltIn for Proxy { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); ConstructorBuilder::with_standard_object( context, diff --git a/boa/src/builtins/reflect/mod.rs b/boa_engine/src/builtins/reflect/mod.rs similarity index 99% rename from boa/src/builtins/reflect/mod.rs rename to boa_engine/src/builtins/reflect/mod.rs index d2640506fac..87cd25d043d 100644 --- a/boa/src/builtins/reflect/mod.rs +++ b/boa_engine/src/builtins/reflect/mod.rs @@ -10,15 +10,15 @@ //! [spec]: https://tc39.es/ecma262/#sec-reflect-object //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect +use super::{Array, JsArgs}; use crate::{ builtins::{self, BuiltIn}, object::{JsObject, ObjectInitializer}, property::Attribute, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; - -use super::{Array, JsArgs}; +use boa_profiler::Profiler; #[cfg(test)] mod tests; @@ -35,7 +35,7 @@ impl BuiltIn for Reflect { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let to_string_tag = WellKnownSymbols::to_string_tag(); diff --git a/boa/src/builtins/reflect/tests.rs b/boa_engine/src/builtins/reflect/tests.rs similarity index 100% rename from boa/src/builtins/reflect/tests.rs rename to boa_engine/src/builtins/reflect/tests.rs diff --git a/boa/src/builtins/regexp/mod.rs b/boa_engine/src/builtins/regexp/mod.rs similarity index 99% rename from boa/src/builtins/regexp/mod.rs rename to boa_engine/src/builtins/regexp/mod.rs index 0a24bc97c6a..915fdbe8bb6 100644 --- a/boa/src/builtins/regexp/mod.rs +++ b/boa_engine/src/builtins/regexp/mod.rs @@ -11,12 +11,11 @@ pub mod regexp_string_iterator; -use std::str::FromStr; - +use self::regexp_string_iterator::RegExpStringIterator; +use super::JsArgs; use crate::{ builtins::{array::Array, string, BuiltIn}, context::StandardObjects, - gc::{empty_trace, Finalize, Trace}, object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, FunctionBuilder, JsObject, ObjectData, @@ -25,12 +24,12 @@ use crate::{ symbol::WellKnownSymbols, syntax::lexer::regex::RegExpFlags, value::{IntegerOrInfinity, JsValue}, - BoaProfiler, Context, JsResult, JsString, + Context, JsResult, JsString, }; -use regexp_string_iterator::RegExpStringIterator; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; +use boa_profiler::Profiler; use regress::Regex; - -use super::JsArgs; +use std::str::FromStr; #[cfg(test)] mod tests; @@ -47,7 +46,7 @@ pub struct RegExp { // Only safe while regress::Regex doesn't implement Trace itself. unsafe impl Trace for RegExp { - empty_trace!(); + unsafe_empty_trace!(); } impl BuiltIn for RegExp { @@ -58,7 +57,7 @@ impl BuiltIn for RegExp { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let get_species = FunctionBuilder::native(context, Self::get_species) .name("get [Symbol.species]") diff --git a/boa/src/builtins/regexp/regexp_string_iterator.rs b/boa_engine/src/builtins/regexp/regexp_string_iterator.rs similarity index 96% rename from boa/src/builtins/regexp/regexp_string_iterator.rs rename to boa_engine/src/builtins/regexp/regexp_string_iterator.rs index ee8a372e39e..993d685d5af 100644 --- a/boa/src/builtins/regexp/regexp_string_iterator.rs +++ b/boa_engine/src/builtins/regexp/regexp_string_iterator.rs @@ -10,16 +10,16 @@ //! //! [spec]: https://tc39.es/ecma262/#sec-regexp-string-iterator-objects -use regexp::{advance_string_index, RegExp}; - use crate::{ builtins::{function::make_builtin_fn, iterable::create_iter_result_object, regexp}, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::PropertyDescriptor, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsString, JsValue, + Context, JsResult, JsString, JsValue, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; +use regexp::{advance_string_index, RegExp}; // TODO: See todos in create_regexp_string_iterator and next. #[derive(Debug, Clone, Finalize, Trace)] @@ -148,7 +148,7 @@ impl RegExpStringIterator { iterator_prototype: JsObject, context: &mut Context, ) -> JsObject { - let _timer = BoaProfiler::global().start_event("RegExp String Iterator", "init"); + let _timer = Profiler::global().start_event("RegExp String Iterator", "init"); // Create prototype let result = JsObject::from_proto_and_data(iterator_prototype, ObjectData::ordinary()); diff --git a/boa/src/builtins/regexp/tests.rs b/boa_engine/src/builtins/regexp/tests.rs similarity index 100% rename from boa/src/builtins/regexp/tests.rs rename to boa_engine/src/builtins/regexp/tests.rs diff --git a/boa/src/builtins/set/mod.rs b/boa_engine/src/builtins/set/mod.rs similarity index 98% rename from boa/src/builtins/set/mod.rs rename to boa_engine/src/builtins/set/mod.rs index c82d9c16b0f..1d33efec2fe 100644 --- a/boa/src/builtins/set/mod.rs +++ b/boa_engine/src/builtins/set/mod.rs @@ -10,6 +10,8 @@ //! [spec]: https://tc39.es/ecma262/#sec-set-objects //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set +use self::{ordered_set::OrderedSet, set_iterator::SetIterator}; +use super::JsArgs; use crate::{ builtins::BuiltIn, context::StandardObjects, @@ -19,16 +21,12 @@ use crate::{ }, property::{Attribute, PropertyNameKind}, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; -use ordered_set::OrderedSet; - -pub mod set_iterator; -use set_iterator::SetIterator; - -use super::JsArgs; +use boa_profiler::Profiler; pub mod ordered_set; +pub mod set_iterator; #[cfg(test)] mod tests; @@ -43,7 +41,7 @@ impl BuiltIn for Set { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let get_species = FunctionBuilder::native(context, Self::get_species) .name("get [Symbol.species]") diff --git a/boa/src/builtins/set/ordered_set.rs b/boa_engine/src/builtins/set/ordered_set.rs similarity index 98% rename from boa/src/builtins/set/ordered_set.rs rename to boa_engine/src/builtins/set/ordered_set.rs index f084b69eaae..758bb9c503e 100644 --- a/boa/src/builtins/set/ordered_set.rs +++ b/boa_engine/src/builtins/set/ordered_set.rs @@ -1,4 +1,4 @@ -use crate::gc::{custom_trace, Finalize, Trace}; +use boa_gc::{custom_trace, Finalize, Trace}; use indexmap::{ set::{IntoIter, Iter}, IndexSet, diff --git a/boa/src/builtins/set/set_iterator.rs b/boa_engine/src/builtins/set/set_iterator.rs similarity index 97% rename from boa/src/builtins/set/set_iterator.rs rename to boa_engine/src/builtins/set/set_iterator.rs index f6c84c0dbf1..2a38e69a253 100644 --- a/boa/src/builtins/set/set_iterator.rs +++ b/boa_engine/src/builtins/set/set_iterator.rs @@ -1,11 +1,12 @@ use crate::{ builtins::{function::make_builtin_fn, iterable::create_iter_result_object, Array, JsValue}, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::{PropertyDescriptor, PropertyNameKind}, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, + Context, JsResult, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; /// The Set Iterator object represents an iteration over a set. It implements the iterator protocol. /// @@ -129,7 +130,7 @@ impl SetIterator { iterator_prototype: JsObject, context: &mut Context, ) -> JsObject { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); // Create prototype let set_iterator = diff --git a/boa/src/builtins/set/tests.rs b/boa_engine/src/builtins/set/tests.rs similarity index 100% rename from boa/src/builtins/set/tests.rs rename to boa_engine/src/builtins/set/tests.rs diff --git a/boa/src/builtins/string/mod.rs b/boa_engine/src/builtins/string/mod.rs similarity index 99% rename from boa/src/builtins/string/mod.rs rename to boa_engine/src/builtins/string/mod.rs index 437203ac511..5a369054cc1 100644 --- a/boa/src/builtins/string/mod.rs +++ b/boa_engine/src/builtins/string/mod.rs @@ -22,8 +22,9 @@ use crate::{ }, property::{Attribute, PropertyDescriptor}, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsString, JsValue, + Context, JsResult, JsString, JsValue, }; +use boa_profiler::Profiler; use std::{char::from_u32, cmp::max, string::String as StdString}; use unicode_normalization::UnicodeNormalization; @@ -90,7 +91,7 @@ impl BuiltIn for String { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let symbol_iterator = WellKnownSymbols::iterator(); diff --git a/boa/src/builtins/string/string_iterator.rs b/boa_engine/src/builtins/string/string_iterator.rs similarity index 95% rename from boa/src/builtins/string/string_iterator.rs rename to boa_engine/src/builtins/string/string_iterator.rs index 60df8b77a20..48e2c8cc93c 100644 --- a/boa/src/builtins/string/string_iterator.rs +++ b/boa_engine/src/builtins/string/string_iterator.rs @@ -2,12 +2,13 @@ use crate::{ builtins::{ function::make_builtin_fn, iterable::create_iter_result_object, string::code_point_at, }, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::PropertyDescriptor, symbol::WellKnownSymbols, - BoaProfiler, Context, JsResult, JsValue, + Context, JsResult, JsValue, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; #[derive(Debug, Clone, Finalize, Trace)] pub struct StringIterator { @@ -77,7 +78,7 @@ impl StringIterator { iterator_prototype: JsObject, context: &mut Context, ) -> JsObject { - let _timer = BoaProfiler::global().start_event("String Iterator", "init"); + let _timer = Profiler::global().start_event("String Iterator", "init"); // Create prototype let array_iterator = diff --git a/boa/src/builtins/string/tests.rs b/boa_engine/src/builtins/string/tests.rs similarity index 100% rename from boa/src/builtins/string/tests.rs rename to boa_engine/src/builtins/string/tests.rs diff --git a/boa/src/builtins/symbol/mod.rs b/boa_engine/src/builtins/symbol/mod.rs similarity index 98% rename from boa/src/builtins/symbol/mod.rs rename to boa_engine/src/builtins/symbol/mod.rs index 89f94f02bc2..1089bc9182e 100644 --- a/boa/src/builtins/symbol/mod.rs +++ b/boa_engine/src/builtins/symbol/mod.rs @@ -18,20 +18,18 @@ #[cfg(test)] mod tests; +use super::JsArgs; use crate::{ builtins::BuiltIn, object::{ConstructorBuilder, FunctionBuilder}, property::Attribute, symbol::{JsSymbol, WellKnownSymbols}, value::JsValue, - BoaProfiler, Context, JsResult, JsString, + Context, JsResult, JsString, }; - -use std::cell::RefCell; - +use boa_profiler::Profiler; use rustc_hash::FxHashMap; - -use super::JsArgs; +use std::cell::RefCell; thread_local! { static GLOBAL_SYMBOL_REGISTRY: RefCell = RefCell::new(GlobalSymbolRegistry::new()); @@ -81,7 +79,7 @@ impl BuiltIn for Symbol { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let symbol_async_iterator = WellKnownSymbols::async_iterator(); let symbol_has_instance = WellKnownSymbols::has_instance(); diff --git a/boa/src/builtins/symbol/tests.rs b/boa_engine/src/builtins/symbol/tests.rs similarity index 100% rename from boa/src/builtins/symbol/tests.rs rename to boa_engine/src/builtins/symbol/tests.rs diff --git a/boa/src/builtins/typed_array/integer_indexed_object.rs b/boa_engine/src/builtins/typed_array/integer_indexed_object.rs similarity index 98% rename from boa/src/builtins/typed_array/integer_indexed_object.rs rename to boa_engine/src/builtins/typed_array/integer_indexed_object.rs index e9eb71ff0ec..f9297eb0cff 100644 --- a/boa/src/builtins/typed_array/integer_indexed_object.rs +++ b/boa_engine/src/builtins/typed_array/integer_indexed_object.rs @@ -10,10 +10,10 @@ use crate::{ builtins::typed_array::TypedArrayName, - gc::{empty_trace, Finalize, Trace}, object::{JsObject, ObjectData}, Context, }; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; /// Type of the array content. #[derive(Debug, Clone, Copy, Finalize, PartialEq)] @@ -24,7 +24,7 @@ pub(crate) enum ContentType { unsafe impl Trace for ContentType { // safe because `ContentType` is `Copy` - empty_trace!(); + unsafe_empty_trace!(); } /// diff --git a/boa/src/builtins/typed_array/mod.rs b/boa_engine/src/builtins/typed_array/mod.rs similarity index 99% rename from boa/src/builtins/typed_array/mod.rs rename to boa_engine/src/builtins/typed_array/mod.rs index 42063d7b531..8fab604ffbc 100644 --- a/boa/src/builtins/typed_array/mod.rs +++ b/boa_engine/src/builtins/typed_array/mod.rs @@ -20,7 +20,6 @@ use crate::{ Array, ArrayIterator, BuiltIn, JsArgs, }, context::{StandardConstructor, StandardObjects}, - gc::{empty_trace, Finalize, Trace}, object::{ internal_methods::get_prototype_from_constructor, ConstructorBuilder, FunctionBuilder, JsObject, ObjectData, @@ -28,8 +27,10 @@ use crate::{ property::{Attribute, PropertyNameKind}, symbol::WellKnownSymbols, value::{IntegerOrInfinity, JsValue}, - BoaProfiler, Context, JsResult, JsString, + Context, JsResult, JsString, }; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; +use boa_profiler::Profiler; use num_traits::{Signed, Zero}; use std::cmp::Ordering; @@ -49,7 +50,7 @@ macro_rules! typed_array { .union(Attribute::CONFIGURABLE); fn init(context: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); let typed_array_constructor = context.typed_array_constructor().constructor(); let typed_array_constructor_proto = context.typed_array_constructor().prototype(); @@ -3302,7 +3303,7 @@ pub(crate) enum TypedArrayName { unsafe impl Trace for TypedArrayName { // Safe because `TypedArrayName` is `Copy` - empty_trace!(); + unsafe_empty_trace!(); } impl TypedArrayName { diff --git a/boa/src/builtins/undefined/mod.rs b/boa_engine/src/builtins/undefined/mod.rs similarity index 83% rename from boa/src/builtins/undefined/mod.rs rename to boa_engine/src/builtins/undefined/mod.rs index 55cb0b45eef..0f9affc6a4d 100644 --- a/boa/src/builtins/undefined/mod.rs +++ b/boa_engine/src/builtins/undefined/mod.rs @@ -9,7 +9,8 @@ //! [spec]: https://tc39.es/ecma262/#sec-undefined //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined -use crate::{builtins::BuiltIn, property::Attribute, BoaProfiler, Context, JsValue}; +use crate::{builtins::BuiltIn, property::Attribute, Context, JsValue}; +use boa_profiler::Profiler; #[cfg(test)] mod tests; @@ -26,7 +27,7 @@ impl BuiltIn for Undefined { .union(Attribute::PERMANENT); fn init(_: &mut Context) -> JsValue { - let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); + let _timer = Profiler::global().start_event(Self::NAME, "init"); JsValue::undefined() } diff --git a/boa/src/builtins/undefined/tests.rs b/boa_engine/src/builtins/undefined/tests.rs similarity index 100% rename from boa/src/builtins/undefined/tests.rs rename to boa_engine/src/builtins/undefined/tests.rs diff --git a/boa/src/bytecompiler.rs b/boa_engine/src/bytecompiler.rs similarity index 99% rename from boa/src/bytecompiler.rs rename to boa_engine/src/bytecompiler.rs index 7d4ad25d787..57e0d7f6599 100644 --- a/boa/src/bytecompiler.rs +++ b/boa_engine/src/bytecompiler.rs @@ -1,7 +1,6 @@ use crate::{ builtins::function::ThisMode, environments::BindingLocator, - gc::Gc, syntax::ast::{ node::{ declaration::{BindingPatternTypeArray, BindingPatternTypeObject, DeclarationPattern}, @@ -16,6 +15,7 @@ use crate::{ vm::{BindingOpcode, CodeBlock, Opcode}, Context, JsBigInt, JsResult, JsString, JsValue, }; +use boa_gc::Gc; use boa_interner::{Interner, Sym}; use rustc_hash::FxHashMap; use std::mem::size_of; diff --git a/boa/src/class.rs b/boa_engine/src/class.rs similarity index 99% rename from boa/src/class.rs rename to boa_engine/src/class.rs index e0abacaf76c..e61123d615c 100644 --- a/boa/src/class.rs +++ b/boa_engine/src/class.rs @@ -2,13 +2,13 @@ //! //! Native classes are implemented through the [`Class`][class-trait] trait. //! ``` -//!# use boa::{ +//!# use boa_engine::{ //!# property::Attribute, //!# class::{Class, ClassBuilder}, -//!# gc::{Finalize, Trace}, //!# Context, JsResult, JsValue, //!# builtins::JsArgs, //!# }; +//!# use boa_gc::{Finalize, Trace}; //!# //! // This does not have to be an enum it can also be a struct. //! #[derive(Debug, Trace, Finalize)] diff --git a/boa/src/context.rs b/boa_engine/src/context.rs similarity index 96% rename from boa/src/context.rs rename to boa_engine/src/context.rs index a105e400440..a29bfb3a4a5 100644 --- a/boa/src/context.rs +++ b/boa_engine/src/context.rs @@ -7,15 +7,16 @@ use crate::{ }, bytecompiler::ByteCompiler, class::{Class, ClassBuilder}, - gc::Gc, object::{FunctionBuilder, GlobalPropertyMap, JsObject, ObjectData}, property::{Attribute, PropertyDescriptor, PropertyKey}, realm::Realm, syntax::{ast::node::StatementList, parser::ParseError, Parser}, vm::{CallFrame, CodeBlock, FinallyReturn, Vm}, - BoaProfiler, Interner, JsResult, JsValue, + JsResult, JsValue, }; -use boa_interner::Sym; +use boa_gc::Gc; +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; #[cfg(feature = "console")] use crate::builtins::console::Console; @@ -327,7 +328,11 @@ impl StandardObjects { /// ## Execute Function of Script File /// /// ```rust -/// use boa::{Context, object::ObjectInitializer, property::{Attribute, PropertyDescriptor}}; +/// use boa_engine::{ +/// Context, +/// object::ObjectInitializer, +/// property::{Attribute, PropertyDescriptor} +/// }; /// /// let script = r#" /// function test(arg1) { @@ -476,7 +481,7 @@ impl Context { /// Sets up the default global objects within Global #[inline] fn create_intrinsics(&mut self) { - let _timer = BoaProfiler::global().start_event("create_intrinsics", "interpreter"); + let _timer = Profiler::global().start_event("create_intrinsics", "interpreter"); // Create intrinsics, add global objects here builtins::init(self); } @@ -722,8 +727,10 @@ impl Context { /// # Note /// /// If you want to make a function only `constructable`, or wish to bind it differently - /// to the global object, you can create the function object with [`FunctionBuilder`](crate::object::FunctionBuilder::native). - /// And bind it to the global object with [`Context::register_global_property`](Context::register_global_property) method. + /// to the global object, you can create the function object with + /// [`FunctionBuilder`](crate::object::FunctionBuilder::native). And bind it to the global + /// object with [`Context::register_global_property`](Context::register_global_property) + /// method. #[inline] pub fn register_global_function( &mut self, @@ -795,8 +802,10 @@ impl Context { /// # Note #1 /// /// If you want to make a function only `constructable`, or wish to bind it differently - /// to the global object, you can create the function object with [`FunctionBuilder`](crate::object::FunctionBuilder::closure). - /// And bind it to the global object with [`Context::register_global_property`](Context::register_global_property) method. + /// to the global object, you can create the function object with + /// [`FunctionBuilder`](crate::object::FunctionBuilder::closure). And bind it to the global + /// object with [`Context::register_global_property`](Context::register_global_property) + /// method. /// /// # Note #2 /// @@ -876,7 +885,11 @@ impl Context { /// /// # Example /// ``` - /// use boa::{Context, property::{Attribute, PropertyDescriptor}, object::ObjectInitializer}; + /// use boa_engine::{ + /// Context, + /// property::{Attribute, PropertyDescriptor}, + /// object::ObjectInitializer + /// }; /// /// let mut context = Context::default(); /// @@ -925,7 +938,7 @@ impl Context { /// /// # Examples /// ``` - ///# use boa::Context; + ///# use boa_engine::Context; /// let mut context = Context::default(); /// /// let value = context.eval("1 + 3").unwrap(); @@ -938,7 +951,7 @@ impl Context { where S: AsRef<[u8]>, { - let main_timer = BoaProfiler::global().start_event("Evaluation", "Main"); + let main_timer = Profiler::global().start_event("Evaluation", "Main"); let parsing_result = Parser::new(src.as_ref(), false) .parse_all(&mut self.interner) @@ -952,9 +965,9 @@ impl Context { let code_block = self.compile(&statement_list)?; let result = self.execute(code_block); - // The main_timer needs to be dropped before the BoaProfiler is. + // The main_timer needs to be dropped before the Profiler is. drop(main_timer); - BoaProfiler::global().drop(); + Profiler::global().drop(); result } @@ -962,7 +975,7 @@ impl Context { /// Compile the AST into a `CodeBlock` ready to be executed by the VM. #[inline] pub fn compile(&mut self, statement_list: &StatementList) -> JsResult> { - let _timer = BoaProfiler::global().start_event("Compilation", "Main"); + let _timer = Profiler::global().start_event("Compilation", "Main"); let mut compiler = ByteCompiler::new(Sym::MAIN, statement_list.strict(), self); for node in statement_list.items() { compiler.create_declarations(node)?; @@ -979,7 +992,7 @@ impl Context { /// `Gc` returned by the [`Self::compile()`] function. #[inline] pub fn execute(&mut self, code_block: Gc) -> JsResult { - let _timer = BoaProfiler::global().start_event("Execution", "Main"); + let _timer = Profiler::global().start_event("Execution", "Main"); let global_object = self.global_object().clone().into(); self.vm.push_frame(CallFrame { diff --git a/boa/src/environments/compile.rs b/boa_engine/src/environments/compile.rs similarity index 100% rename from boa/src/environments/compile.rs rename to boa_engine/src/environments/compile.rs diff --git a/boa/src/environments/mod.rs b/boa_engine/src/environments/mod.rs similarity index 100% rename from boa/src/environments/mod.rs rename to boa_engine/src/environments/mod.rs diff --git a/boa/src/environments/runtime.rs b/boa_engine/src/environments/runtime.rs similarity index 96% rename from boa/src/environments/runtime.rs rename to boa_engine/src/environments/runtime.rs index 42884b25702..1e2c3dd7e73 100644 --- a/boa/src/environments/runtime.rs +++ b/boa_engine/src/environments/runtime.rs @@ -1,9 +1,6 @@ -use crate::{ - gc::{Finalize, Gc, Trace}, - Context, JsResult, JsValue, -}; +use crate::{Context, JsResult, JsValue}; +use boa_gc::{Cell, Finalize, Gc, Trace}; use boa_interner::Sym; -use gc::GcCell; /// A declarative environment holds the bindings values at runtime. /// @@ -14,7 +11,7 @@ use gc::GcCell; /// The `this` value is present only if the environment is a function environment. #[derive(Debug, Trace, Finalize)] pub(crate) struct DeclarativeEnvironment { - bindings: GcCell>>, + bindings: Cell>>, this: Option, } @@ -65,7 +62,7 @@ impl DeclarativeEnvironmentStack { pub(crate) fn new() -> Self { Self { stack: vec![Gc::new(DeclarativeEnvironment { - bindings: GcCell::new(Vec::new()), + bindings: Cell::new(Vec::new()), this: None, })], } @@ -103,7 +100,7 @@ impl DeclarativeEnvironmentStack { #[inline] pub(crate) fn push_declarative(&mut self, num_bindings: usize) { self.stack.push(Gc::new(DeclarativeEnvironment { - bindings: GcCell::new(vec![None; num_bindings]), + bindings: Cell::new(vec![None; num_bindings]), this: None, })); } @@ -112,7 +109,7 @@ impl DeclarativeEnvironmentStack { #[inline] pub(crate) fn push_function(&mut self, num_bindings: usize, this: JsValue) { self.stack.push(Gc::new(DeclarativeEnvironment { - bindings: GcCell::new(vec![None; num_bindings]), + bindings: Cell::new(vec![None; num_bindings]), this: Some(this), })); } diff --git a/boa/src/environments/tests.rs b/boa_engine/src/environments/tests.rs similarity index 100% rename from boa/src/environments/tests.rs rename to boa_engine/src/environments/tests.rs diff --git a/boa/src/lib.rs b/boa_engine/src/lib.rs similarity index 95% rename from boa/src/lib.rs rename to boa_engine/src/lib.rs index c227ef2b3f3..9db8165bf50 100644 --- a/boa/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -73,9 +73,7 @@ pub mod bytecompiler; pub mod class; pub mod context; pub mod environments; -pub mod gc; pub mod object; -pub mod profiler; pub mod property; pub mod realm; pub mod string; @@ -92,8 +90,6 @@ pub mod prelude { pub use crate::{object::JsObject, Context, JsBigInt, JsResult, JsString, JsValue}; } -pub(crate) use crate::profiler::BoaProfiler; -pub use boa_interner::{Interner, Sym}; use std::result::Result as StdResult; // Export things to root level @@ -127,14 +123,16 @@ where #[allow(clippy::unit_arg, clippy::drop_copy)] #[cfg(test)] pub(crate) fn forward_val>(context: &mut Context, src: T) -> JsResult { - let main_timer = BoaProfiler::global().start_event("Main", "Main"); + use boa_profiler::Profiler; + + let main_timer = Profiler::global().start_event("Main", "Main"); let src_bytes: &[u8] = src.as_ref(); let result = context.eval(src_bytes); - // The main_timer needs to be dropped before the BoaProfiler is. + // The main_timer needs to be dropped before the Profiler is. drop(main_timer); - BoaProfiler::global().drop(); + Profiler::global().drop(); result } diff --git a/boa/src/object/internal_methods/arguments.rs b/boa_engine/src/object/internal_methods/arguments.rs similarity index 100% rename from boa/src/object/internal_methods/arguments.rs rename to boa_engine/src/object/internal_methods/arguments.rs diff --git a/boa/src/object/internal_methods/array.rs b/boa_engine/src/object/internal_methods/array.rs similarity index 100% rename from boa/src/object/internal_methods/array.rs rename to boa_engine/src/object/internal_methods/array.rs diff --git a/boa/src/object/internal_methods/bound_function.rs b/boa_engine/src/object/internal_methods/bound_function.rs similarity index 100% rename from boa/src/object/internal_methods/bound_function.rs rename to boa_engine/src/object/internal_methods/bound_function.rs diff --git a/boa/src/object/internal_methods/function.rs b/boa_engine/src/object/internal_methods/function.rs similarity index 100% rename from boa/src/object/internal_methods/function.rs rename to boa_engine/src/object/internal_methods/function.rs diff --git a/boa/src/object/internal_methods/global.rs b/boa_engine/src/object/internal_methods/global.rs similarity index 96% rename from boa/src/object/internal_methods/global.rs rename to boa_engine/src/object/internal_methods/global.rs index e53b2fa8d6c..69d07b44e57 100644 --- a/boa/src/object/internal_methods/global.rs +++ b/boa_engine/src/object/internal_methods/global.rs @@ -2,8 +2,9 @@ use crate::{ object::{InternalObjectMethods, JsObject, ORDINARY_INTERNAL_METHODS}, property::{DescriptorKind, PropertyDescriptor, PropertyKey}, value::JsValue, - BoaProfiler, Context, JsResult, + Context, JsResult, }; +use boa_profiler::Profiler; /// Definitions of the internal object methods for global object. /// @@ -36,7 +37,7 @@ pub(crate) fn global_get_own_property( key: &PropertyKey, context: &mut Context, ) -> JsResult> { - let _timer = BoaProfiler::global().start_event("Object::global_get_own_property", "object"); + let _timer = Profiler::global().start_event("Object::global_get_own_property", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. If O does not have an own property with key P, return undefined. // 3. Let D be a newly created Property Descriptor with no fields. @@ -97,7 +98,7 @@ pub(crate) fn global_define_own_property( desc: PropertyDescriptor, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::global_define_own_property", "object"); + let _timer = Profiler::global().start_event("Object::global_define_own_property", "object"); // 1. Let current be ? O.[[GetOwnProperty]](P). let current = global_get_own_property(obj, &key, context)?; @@ -123,7 +124,7 @@ pub(crate) fn global_has_property( key: &PropertyKey, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::global_has_property", "object"); + let _timer = Profiler::global().start_event("Object::global_has_property", "object"); Ok(context.realm.global_property_map.contains_key(key)) } @@ -141,7 +142,7 @@ pub(crate) fn global_get( receiver: JsValue, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::global_get", "object"); + let _timer = Profiler::global().start_event("Object::global_get", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. Let desc be ? O.[[GetOwnProperty]](P). match global_get_own_property(obj, key, context)? { @@ -191,7 +192,7 @@ pub(crate) fn global_set_no_receiver( value: JsValue, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::global_set", "object"); + let _timer = Profiler::global().start_event("Object::global_set", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. Let ownDesc be ? O.[[GetOwnProperty]](P). @@ -290,7 +291,7 @@ pub(crate) fn global_delete( key: &PropertyKey, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::global_delete", "object"); + let _timer = Profiler::global().start_event("Object::global_delete", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. Let desc be ? O.[[GetOwnProperty]](P). match context.realm.global_property_map.get(key) { @@ -322,7 +323,7 @@ pub(crate) fn validate_and_apply_property_descriptor( current: Option, context: &mut Context, ) -> bool { - let _timer = BoaProfiler::global().start_event( + let _timer = Profiler::global().start_event( "Object::global_validate_and_apply_property_descriptor", "object", ); diff --git a/boa/src/object/internal_methods/integer_indexed.rs b/boa_engine/src/object/internal_methods/integer_indexed.rs similarity index 100% rename from boa/src/object/internal_methods/integer_indexed.rs rename to boa_engine/src/object/internal_methods/integer_indexed.rs diff --git a/boa/src/object/internal_methods/mod.rs b/boa_engine/src/object/internal_methods/mod.rs similarity index 93% rename from boa/src/object/internal_methods/mod.rs rename to boa_engine/src/object/internal_methods/mod.rs index 775a85d28ca..ead2912ad2d 100644 --- a/boa/src/object/internal_methods/mod.rs +++ b/boa_engine/src/object/internal_methods/mod.rs @@ -5,15 +5,15 @@ //! //! [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots +use super::{JsPrototype, PROTOTYPE}; use crate::{ context::{StandardConstructor, StandardObjects}, object::JsObject, property::{DescriptorKind, PropertyDescriptor, PropertyKey}, value::JsValue, - BoaProfiler, Context, JsResult, + Context, JsResult, }; - -use super::{JsPrototype, PROTOTYPE}; +use boa_profiler::Profiler; pub(super) mod arguments; pub(super) mod array; @@ -36,7 +36,7 @@ impl JsObject { #[inline] #[track_caller] pub(crate) fn __get_prototype_of__(&self, context: &mut Context) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__get_prototype_of__", "object"); + let _timer = Profiler::global().start_event("Object::__get_prototype_of__", "object"); let func = self.borrow().data.internal_methods.__get_prototype_of__; func(self, context) } @@ -55,7 +55,7 @@ impl JsObject { val: JsPrototype, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__set_prototype_of__", "object"); + let _timer = Profiler::global().start_event("Object::__set_prototype_of__", "object"); let func = self.borrow().data.internal_methods.__set_prototype_of__; func(self, val, context) } @@ -70,7 +70,7 @@ impl JsObject { /// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-isextensible #[inline] pub(crate) fn __is_extensible__(&self, context: &mut Context) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__is_extensible__", "object"); + let _timer = Profiler::global().start_event("Object::__is_extensible__", "object"); let func = self.borrow().data.internal_methods.__is_extensible__; func(self, context) } @@ -85,7 +85,7 @@ impl JsObject { /// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-preventextensions #[inline] pub(crate) fn __prevent_extensions__(&self, context: &mut Context) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__prevent_extensions__", "object"); + let _timer = Profiler::global().start_event("Object::__prevent_extensions__", "object"); let func = self.borrow().data.internal_methods.__prevent_extensions__; func(self, context) } @@ -104,7 +104,7 @@ impl JsObject { key: &PropertyKey, context: &mut Context, ) -> JsResult> { - let _timer = BoaProfiler::global().start_event("Object::__get_own_property__", "object"); + let _timer = Profiler::global().start_event("Object::__get_own_property__", "object"); let func = self.borrow().data.internal_methods.__get_own_property__; func(self, key, context) } @@ -124,7 +124,7 @@ impl JsObject { desc: PropertyDescriptor, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__define_own_property__", "object"); + let _timer = Profiler::global().start_event("Object::__define_own_property__", "object"); let func = self.borrow().data.internal_methods.__define_own_property__; func(self, key, desc, context) } @@ -143,7 +143,7 @@ impl JsObject { key: &PropertyKey, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__has_property__", "object"); + let _timer = Profiler::global().start_event("Object::__has_property__", "object"); let func = self.borrow().data.internal_methods.__has_property__; func(self, key, context) } @@ -163,7 +163,7 @@ impl JsObject { receiver: JsValue, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__get__", "object"); + let _timer = Profiler::global().start_event("Object::__get__", "object"); let func = self.borrow().data.internal_methods.__get__; func(self, key, receiver, context) } @@ -184,7 +184,7 @@ impl JsObject { receiver: JsValue, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__set__", "object"); + let _timer = Profiler::global().start_event("Object::__set__", "object"); let func = self.borrow().data.internal_methods.__set__; func(self, key, value, receiver, context) } @@ -199,7 +199,7 @@ impl JsObject { /// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-delete-p #[inline] pub(crate) fn __delete__(&self, key: &PropertyKey, context: &mut Context) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__delete__", "object"); + let _timer = Profiler::global().start_event("Object::__delete__", "object"); let func = self.borrow().data.internal_methods.__delete__; func(self, key, context) } @@ -218,7 +218,7 @@ impl JsObject { &self, context: &mut Context, ) -> JsResult> { - let _timer = BoaProfiler::global().start_event("Object::__own_property_keys__", "object"); + let _timer = Profiler::global().start_event("Object::__own_property_keys__", "object"); let func = self.borrow().data.internal_methods.__own_property_keys__; func(self, context) } @@ -239,7 +239,7 @@ impl JsObject { args: &[JsValue], context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__call__", "object"); + let _timer = Profiler::global().start_event("Object::__call__", "object"); let func = self.borrow().data.internal_methods.__call__; func.expect("called `[[Call]]` for object without a `[[Call]]` internal method")( self, this, args, context, @@ -262,7 +262,7 @@ impl JsObject { new_target: &JsValue, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::__construct__", "object"); + let _timer = Profiler::global().start_event("Object::__construct__", "object"); let func = self.borrow().data.internal_methods.__construct__; func.expect("called `[[Construct]]` for object without a `[[Construct]]` internal method")( self, args, new_target, context, @@ -339,7 +339,7 @@ pub(crate) fn ordinary_get_prototype_of( obj: &JsObject, _context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::ordinary_get_prototype_of", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_get_prototype_of", "object"); // 1. Return O.[[Prototype]]. Ok(obj.prototype().as_ref().cloned()) @@ -450,7 +450,7 @@ pub(crate) fn ordinary_get_own_property( key: &PropertyKey, _context: &mut Context, ) -> JsResult> { - let _timer = BoaProfiler::global().start_event("Object::ordinary_get_own_property", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_get_own_property", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. If O does not have an own property with key P, return undefined. // 3. Let D be a newly created Property Descriptor with no fields. @@ -481,8 +481,7 @@ pub(crate) fn ordinary_define_own_property( desc: PropertyDescriptor, context: &mut Context, ) -> JsResult { - let _timer = - BoaProfiler::global().start_event("Object::ordinary_define_own_property", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_define_own_property", "object"); // 1. Let current be ? O.[[GetOwnProperty]](P). let current = obj.__get_own_property__(&key, context)?; @@ -510,7 +509,7 @@ pub(crate) fn ordinary_has_property( key: &PropertyKey, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::ordinary_has_property", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_has_property", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. Let hasOwn be ? O.[[GetOwnProperty]](P). // 3. If hasOwn is not undefined, return true. @@ -541,7 +540,7 @@ pub(crate) fn ordinary_get( receiver: JsValue, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::ordinary_get", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_get", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. Let desc be ? O.[[GetOwnProperty]](P). match obj.__get_own_property__(key, context)? { @@ -588,7 +587,7 @@ pub(crate) fn ordinary_set( receiver: JsValue, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::ordinary_set", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_set", "object"); // 1. Assert: IsPropertyKey(P) is true. // 2. Let ownDesc be ? O.[[GetOwnProperty]](P). @@ -689,7 +688,7 @@ pub(crate) fn ordinary_delete( key: &PropertyKey, context: &mut Context, ) -> JsResult { - let _timer = BoaProfiler::global().start_event("Object::ordinary_delete", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_delete", "object"); // 1. Assert: IsPropertyKey(P) is true. Ok( // 2. Let desc be ? O.[[GetOwnProperty]](P). @@ -721,7 +720,7 @@ pub(crate) fn ordinary_own_property_keys( obj: &JsObject, _context: &mut Context, ) -> JsResult> { - let _timer = BoaProfiler::global().start_event("Object::ordinary_own_property_keys", "object"); + let _timer = Profiler::global().start_event("Object::ordinary_own_property_keys", "object"); // 1. Let keys be a new empty List. let mut keys = Vec::new(); @@ -777,7 +776,7 @@ pub(crate) fn is_compatible_property_descriptor( current: Option, ) -> bool { let _timer = - BoaProfiler::global().start_event("Object::is_compatible_property_descriptor", "object"); + Profiler::global().start_event("Object::is_compatible_property_descriptor", "object"); // 1. Return ValidateAndApplyPropertyDescriptor(undefined, undefined, Extensible, Desc, Current). validate_and_apply_property_descriptor(None, extensible, desc, current) @@ -796,8 +795,8 @@ pub(crate) fn validate_and_apply_property_descriptor( desc: PropertyDescriptor, current: Option, ) -> bool { - let _timer = BoaProfiler::global() - .start_event("Object::validate_and_apply_property_descriptor", "object"); + let _timer = + Profiler::global().start_event("Object::validate_and_apply_property_descriptor", "object"); // 1. Assert: If O is not undefined, then IsPropertyKey(P) is true. let mut current = if let Some(own) = current { @@ -954,8 +953,7 @@ pub(crate) fn get_prototype_from_constructor( where F: FnOnce(&StandardObjects) -> &StandardConstructor, { - let _timer = - BoaProfiler::global().start_event("Object::get_prototype_from_constructor", "object"); + let _timer = Profiler::global().start_event("Object::get_prototype_from_constructor", "object"); // 1. Assert: intrinsicDefaultProto is this specification's name of an intrinsic // object. // The corresponding object must be an intrinsic that is intended to be used diff --git a/boa/src/object/internal_methods/proxy.rs b/boa_engine/src/object/internal_methods/proxy.rs similarity index 100% rename from boa/src/object/internal_methods/proxy.rs rename to boa_engine/src/object/internal_methods/proxy.rs diff --git a/boa/src/object/internal_methods/string.rs b/boa_engine/src/object/internal_methods/string.rs similarity index 100% rename from boa/src/object/internal_methods/string.rs rename to boa_engine/src/object/internal_methods/string.rs diff --git a/boa/src/object/jsarray.rs b/boa_engine/src/object/jsarray.rs similarity index 99% rename from boa/src/object/jsarray.rs rename to boa_engine/src/object/jsarray.rs index 41af6cdd0d8..17ddabf88af 100644 --- a/boa/src/object/jsarray.rs +++ b/boa_engine/src/object/jsarray.rs @@ -1,11 +1,10 @@ -use std::ops::Deref; - use crate::{ builtins::Array, - gc::{Finalize, Trace}, object::{JsObject, JsObjectType}, Context, JsResult, JsString, JsValue, }; +use boa_gc::{Finalize, Trace}; +use std::ops::Deref; /// JavaScript `Array` rust object. #[derive(Debug, Clone, Trace, Finalize)] diff --git a/boa/src/object/jsobject.rs b/boa_engine/src/object/jsobject.rs similarity index 98% rename from boa/src/object/jsobject.rs rename to boa_engine/src/object/jsobject.rs index 7451617a987..c4f66e62b88 100644 --- a/boa/src/object/jsobject.rs +++ b/boa_engine/src/object/jsobject.rs @@ -4,12 +4,12 @@ use super::{JsPrototype, NativeObject, Object, PropertyMap}; use crate::{ - gc::{self, Finalize, Gc, Trace}, object::{ObjectData, ObjectKind}, property::{PropertyDescriptor, PropertyKey}, value::PreferredType, Context, JsResult, JsValue, }; +use boa_gc::{self, Finalize, Gc, Trace}; use std::{ cell::RefCell, collections::HashMap, @@ -19,20 +19,20 @@ use std::{ }; /// A wrapper type for an immutably borrowed type T. -pub type Ref<'a, T> = gc::Ref<'a, T>; +pub type Ref<'a, T> = boa_gc::Ref<'a, T>; /// A wrapper type for a mutably borrowed type T. -pub type RefMut<'a, T, U> = gc::RefMut<'a, T, U>; +pub type RefMut<'a, T, U> = boa_gc::RefMut<'a, T, U>; /// Garbage collected `Object`. #[derive(Trace, Finalize, Clone, Default)] -pub struct JsObject(Gc>); +pub struct JsObject(Gc>); impl JsObject { /// Create a new `JsObject` from an internal `Object`. #[inline] fn from_object(object: Object) -> Self { - Self(Gc::new(gc::Cell::new(object))) + Self(Gc::new(boa_gc::Cell::new(object))) } /// Create a new empty `JsObject`, with `prototype` set to `JsValue::Null` @@ -655,9 +655,9 @@ Cannot both specify accessors and a value or writable attribute", } } -impl AsRef> for JsObject { +impl AsRef> for JsObject { #[inline] - fn as_ref(&self) -> &gc::Cell { + fn as_ref(&self) -> &boa_gc::Cell { &*self.0 } } diff --git a/boa/src/object/mod.rs b/boa_engine/src/object/mod.rs similarity index 99% rename from boa/src/object/mod.rs rename to boa_engine/src/object/mod.rs index 4f1e429f49d..c05fa4350ff 100644 --- a/boa/src/object/mod.rs +++ b/boa_engine/src/object/mod.rs @@ -1,11 +1,33 @@ //! This module implements the Rust representation of a JavaScript object. +pub use jsobject::{JsObject, RecursionLimiter, Ref, RefMut}; +pub use operations::IntegrityLevel; +pub use property_map::*; + +use self::internal_methods::{ + arguments::ARGUMENTS_EXOTIC_INTERNAL_METHODS, + array::ARRAY_EXOTIC_INTERNAL_METHODS, + bound_function::{ + BOUND_CONSTRUCTOR_EXOTIC_INTERNAL_METHODS, BOUND_FUNCTION_EXOTIC_INTERNAL_METHODS, + }, + function::{CONSTRUCTOR_INTERNAL_METHODS, FUNCTION_INTERNAL_METHODS}, + global::GLOBAL_INTERNAL_METHODS, + integer_indexed::INTEGER_INDEXED_EXOTIC_INTERNAL_METHODS, + proxy::{ + PROXY_EXOTIC_INTERNAL_METHODS_ALL, PROXY_EXOTIC_INTERNAL_METHODS_BASIC, + PROXY_EXOTIC_INTERNAL_METHODS_WITH_CALL, + }, + string::STRING_EXOTIC_INTERNAL_METHODS, + InternalObjectMethods, ORDINARY_INTERNAL_METHODS, +}; use crate::{ builtins::{ array::array_iterator::ArrayIterator, array_buffer::ArrayBuffer, - function::arguments::{Arguments, ParameterMap}, - function::{BoundFunction, Captures, Function, NativeFunctionSignature}, + function::arguments::Arguments, + function::{ + arguments::ParameterMap, BoundFunction, Captures, Function, NativeFunctionSignature, + }, map::map_iterator::MapIterator, map::ordered_map::OrderedMap, object::for_in_iterator::ForInIterator, @@ -18,37 +40,16 @@ use crate::{ DataView, Date, RegExp, }, context::StandardConstructor, - gc::{Finalize, Trace}, property::{Attribute, PropertyDescriptor, PropertyKey}, Context, JsBigInt, JsResult, JsString, JsSymbol, JsValue, }; +use boa_gc::{Finalize, Trace}; use std::{ any::Any, fmt::{self, Debug, Display}, ops::{Deref, DerefMut}, }; -pub use jsobject::{JsObject, RecursionLimiter, Ref, RefMut}; -pub use operations::IntegrityLevel; -pub use property_map::*; - -use self::internal_methods::{ - arguments::ARGUMENTS_EXOTIC_INTERNAL_METHODS, - array::ARRAY_EXOTIC_INTERNAL_METHODS, - bound_function::{ - BOUND_CONSTRUCTOR_EXOTIC_INTERNAL_METHODS, BOUND_FUNCTION_EXOTIC_INTERNAL_METHODS, - }, - function::{CONSTRUCTOR_INTERNAL_METHODS, FUNCTION_INTERNAL_METHODS}, - global::GLOBAL_INTERNAL_METHODS, - integer_indexed::INTEGER_INDEXED_EXOTIC_INTERNAL_METHODS, - proxy::{ - PROXY_EXOTIC_INTERNAL_METHODS_ALL, PROXY_EXOTIC_INTERNAL_METHODS_BASIC, - PROXY_EXOTIC_INTERNAL_METHODS_WITH_CALL, - }, - string::STRING_EXOTIC_INTERNAL_METHODS, - InternalObjectMethods, ORDINARY_INTERNAL_METHODS, -}; - #[cfg(test)] mod tests; @@ -1415,7 +1416,7 @@ impl<'context> FunctionBuilder<'context> { /// # Examples /// /// ``` -/// # use boa::{Context, JsValue, object::ObjectInitializer, property::Attribute}; +/// # use boa_engine::{Context, JsValue, object::ObjectInitializer, property::Attribute}; /// let mut context = Context::default(); /// let object = ObjectInitializer::new(&mut context) /// .property( diff --git a/boa/src/object/operations.rs b/boa_engine/src/object/operations.rs similarity index 100% rename from boa/src/object/operations.rs rename to boa_engine/src/object/operations.rs diff --git a/boa/src/object/property_map.rs b/boa_engine/src/object/property_map.rs similarity index 99% rename from boa/src/object/property_map.rs rename to boa_engine/src/object/property_map.rs index aa32776b82e..f661820ca96 100644 --- a/boa/src/object/property_map.rs +++ b/boa_engine/src/object/property_map.rs @@ -1,8 +1,6 @@ use super::{PropertyDescriptor, PropertyKey}; -use crate::{ - gc::{custom_trace, Finalize, Trace}, - JsString, JsSymbol, -}; +use crate::{JsString, JsSymbol}; +use boa_gc::{custom_trace, Finalize, Trace}; use indexmap::IndexMap; use rustc_hash::{FxHashMap, FxHasher}; use std::{collections::hash_map, hash::BuildHasherDefault, iter::FusedIterator}; diff --git a/boa/src/object/tests.rs b/boa_engine/src/object/tests.rs similarity index 100% rename from boa/src/object/tests.rs rename to boa_engine/src/object/tests.rs diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/tests.rs b/boa_engine/src/profiler.rs similarity index 100% rename from boa/src/syntax/parser/statement/declaration/hoistable/tests.rs rename to boa_engine/src/profiler.rs diff --git a/boa/src/property/attribute/mod.rs b/boa_engine/src/property/attribute/mod.rs similarity index 97% rename from boa/src/property/attribute/mod.rs rename to boa_engine/src/property/attribute/mod.rs index 29b826b1052..f855fc700f6 100644 --- a/boa/src/property/attribute/mod.rs +++ b/boa_engine/src/property/attribute/mod.rs @@ -1,7 +1,7 @@ //! This module implements the `Attribute` struct which contains the attibutes for property descriptors. -use crate::gc::{empty_trace, Finalize, Trace}; use bitflags::bitflags; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; #[cfg(test)] mod tests; @@ -44,7 +44,7 @@ bitflags! { // SAFETY: The `Attribute` struct only contains an `u8` // and therefore it should be safe to implement an empty trace. unsafe impl Trace for Attribute { - empty_trace!(); + unsafe_empty_trace!(); } impl Attribute { diff --git a/boa/src/property/attribute/tests.rs b/boa_engine/src/property/attribute/tests.rs similarity index 100% rename from boa/src/property/attribute/tests.rs rename to boa_engine/src/property/attribute/tests.rs diff --git a/boa/src/property/mod.rs b/boa_engine/src/property/mod.rs similarity index 99% rename from boa/src/property/mod.rs rename to boa_engine/src/property/mod.rs index 1333d9e24d3..079f985d786 100644 --- a/boa/src/property/mod.rs +++ b/boa_engine/src/property/mod.rs @@ -15,11 +15,9 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty //! [section]: https://tc39.es/ecma262/#sec-property-attributes -use crate::{ - gc::{empty_trace, Finalize, Trace}, - JsString, JsSymbol, JsValue, -}; -use std::{convert::TryFrom, fmt}; +use crate::{JsString, JsSymbol, JsValue}; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; +use std::fmt; mod attribute; pub use attribute::Attribute; @@ -672,5 +670,5 @@ pub(crate) enum PropertyNameKind { } unsafe impl Trace for PropertyNameKind { - empty_trace!(); + unsafe_empty_trace!(); } diff --git a/boa/src/realm.rs b/boa_engine/src/realm.rs similarity index 95% rename from boa/src/realm.rs rename to boa_engine/src/realm.rs index f78d9367e82..97b6ef6977e 100644 --- a/boa/src/realm.rs +++ b/boa_engine/src/realm.rs @@ -7,8 +7,8 @@ use crate::{ environments::{CompileTimeEnvironmentStack, DeclarativeEnvironmentStack}, object::{GlobalPropertyMap, JsObject, ObjectData, PropertyMap}, - BoaProfiler, }; +use boa_profiler::Profiler; /// Representation of a Realm. /// @@ -25,7 +25,7 @@ pub struct Realm { impl Realm { #[inline] pub fn create() -> Self { - let _timer = BoaProfiler::global().start_event("Realm::create", "realm"); + let _timer = Profiler::global().start_event("Realm::create", "realm"); // Create brand new global object // Global has no prototype to pass None to new_obj // Allow identification of the global object easily diff --git a/boa/src/string.rs b/boa_engine/src/string.rs similarity index 99% rename from boa/src/string.rs rename to boa_engine/src/string.rs index 4faa2da695a..03a34f6f66a 100644 --- a/boa/src/string.rs +++ b/boa_engine/src/string.rs @@ -1,7 +1,5 @@ -use crate::{ - builtins::string::is_trimmable_whitespace, - gc::{empty_trace, Finalize, Trace}, -}; +use crate::builtins::string::is_trimmable_whitespace; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; use rustc_hash::FxHashSet; use std::{ alloc::{alloc, dealloc, handle_alloc_error, Layout}, @@ -499,7 +497,7 @@ impl JsString { // Safety: [`JsString`] does not contain any objects which recquire trace, // so this is safe. unsafe impl Trace for JsString { - empty_trace!(); + unsafe_empty_trace!(); } impl Clone for JsString { diff --git a/boa/src/symbol.rs b/boa_engine/src/symbol.rs similarity index 98% rename from boa/src/symbol.rs rename to boa_engine/src/symbol.rs index 0164e35f23f..b35e18a2bc0 100644 --- a/boa/src/symbol.rs +++ b/boa_engine/src/symbol.rs @@ -15,10 +15,8 @@ //! [spec]: https://tc39.es/ecma262/#sec-symbol-value //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol -use crate::{ - gc::{empty_trace, Finalize, Trace}, - JsString, -}; +use crate::JsString; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; use std::{ cell::Cell, fmt::{self, Display}, @@ -30,7 +28,7 @@ use std::{ /// /// # Examples /// ``` -///# use boa::symbol::WellKnownSymbols; +///# use boa_engine::symbol::WellKnownSymbols; /// /// let iterator = WellKnownSymbols::iterator(); /// assert_eq!(iterator.description().as_deref(), Some("Symbol.iterator")); @@ -298,7 +296,7 @@ impl Finalize for JsSymbol {} // Safety: `JsSymbol` does not contain any object that require trace, // so this is safe. unsafe impl Trace for JsSymbol { - empty_trace!(); + unsafe_empty_trace!(); } impl Display for JsSymbol { diff --git a/boa/src/syntax/ast/constant.rs b/boa_engine/src/syntax/ast/constant.rs similarity index 99% rename from boa/src/syntax/ast/constant.rs rename to boa_engine/src/syntax/ast/constant.rs index b657b854a2b..b1672492e7c 100644 --- a/boa/src/syntax/ast/constant.rs +++ b/boa_engine/src/syntax/ast/constant.rs @@ -7,10 +7,8 @@ //! [spec]: https://tc39.es/ecma262/#sec-primary-expression-literals //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Literals -use crate::{ - gc::{Finalize, Trace}, - JsBigInt, -}; +use crate::JsBigInt; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/keyword.rs b/boa_engine/src/syntax/ast/keyword.rs similarity index 100% rename from boa/src/syntax/ast/keyword.rs rename to boa_engine/src/syntax/ast/keyword.rs diff --git a/boa/src/syntax/ast/mod.rs b/boa_engine/src/syntax/ast/mod.rs similarity index 100% rename from boa/src/syntax/ast/mod.rs rename to boa_engine/src/syntax/ast/mod.rs diff --git a/boa/src/syntax/ast/node/array/mod.rs b/boa_engine/src/syntax/ast/node/array/mod.rs similarity index 97% rename from boa/src/syntax/ast/node/array/mod.rs rename to boa_engine/src/syntax/ast/node/array/mod.rs index 1745e3fd267..232ee973399 100644 --- a/boa/src/syntax/ast/node/array/mod.rs +++ b/boa_engine/src/syntax/ast/node/array/mod.rs @@ -1,7 +1,7 @@ //! Array declaration node. use super::{join_nodes, Node}; -use crate::gc::{Finalize, Trace}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/array/tests.rs b/boa_engine/src/syntax/ast/node/array/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/array/tests.rs rename to boa_engine/src/syntax/ast/node/array/tests.rs diff --git a/boa/src/syntax/ast/node/await_expr/mod.rs b/boa_engine/src/syntax/ast/node/await_expr/mod.rs similarity index 97% rename from boa/src/syntax/ast/node/await_expr/mod.rs rename to boa_engine/src/syntax/ast/node/await_expr/mod.rs index 0527ec0d407..f5a97030945 100644 --- a/boa/src/syntax/ast/node/await_expr/mod.rs +++ b/boa_engine/src/syntax/ast/node/await_expr/mod.rs @@ -1,7 +1,7 @@ //! Await expression node. use super::Node; -use crate::gc::{Finalize, Trace}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/await_expr/tests.rs b/boa_engine/src/syntax/ast/node/await_expr/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/await_expr/tests.rs rename to boa_engine/src/syntax/ast/node/await_expr/tests.rs diff --git a/boa/src/syntax/ast/node/block/mod.rs b/boa_engine/src/syntax/ast/node/block/mod.rs similarity index 98% rename from boa/src/syntax/ast/node/block/mod.rs rename to boa_engine/src/syntax/ast/node/block/mod.rs index 498a0e13cd8..5f8d4118096 100644 --- a/boa/src/syntax/ast/node/block/mod.rs +++ b/boa_engine/src/syntax/ast/node/block/mod.rs @@ -1,7 +1,7 @@ //! Block AST node. use super::{Node, StatementList}; -use crate::gc::{Finalize, Trace}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; use rustc_hash::FxHashSet; diff --git a/boa/src/syntax/ast/node/block/tests.rs b/boa_engine/src/syntax/ast/node/block/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/block/tests.rs rename to boa_engine/src/syntax/ast/node/block/tests.rs diff --git a/boa/src/syntax/ast/node/call/mod.rs b/boa_engine/src/syntax/ast/node/call/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/call/mod.rs rename to boa_engine/src/syntax/ast/node/call/mod.rs index 914648688a5..72b8580cf1b 100644 --- a/boa/src/syntax/ast/node/call/mod.rs +++ b/boa_engine/src/syntax/ast/node/call/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, Node}, -}; +use crate::syntax::ast::node::{join_nodes, Node}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/call/tests.rs b/boa_engine/src/syntax/ast/node/call/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/call/tests.rs rename to boa_engine/src/syntax/ast/node/call/tests.rs diff --git a/boa/src/syntax/ast/node/conditional/conditional_op/mod.rs b/boa_engine/src/syntax/ast/node/conditional/conditional_op/mod.rs similarity index 96% rename from boa/src/syntax/ast/node/conditional/conditional_op/mod.rs rename to boa_engine/src/syntax/ast/node/conditional/conditional_op/mod.rs index a9bc9b24dcd..16766e842a8 100644 --- a/boa/src/syntax/ast/node/conditional/conditional_op/mod.rs +++ b/boa_engine/src/syntax/ast/node/conditional/conditional_op/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/conditional/if_node/mod.rs b/boa_engine/src/syntax/ast/node/conditional/if_node/mod.rs similarity index 97% rename from boa/src/syntax/ast/node/conditional/if_node/mod.rs rename to boa_engine/src/syntax/ast/node/conditional/if_node/mod.rs index 0981f037f65..a41ed183a09 100644 --- a/boa/src/syntax/ast/node/conditional/if_node/mod.rs +++ b/boa_engine/src/syntax/ast/node/conditional/if_node/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/conditional/mod.rs b/boa_engine/src/syntax/ast/node/conditional/mod.rs similarity index 100% rename from boa/src/syntax/ast/node/conditional/mod.rs rename to boa_engine/src/syntax/ast/node/conditional/mod.rs diff --git a/boa/src/syntax/ast/node/conditional/tests.rs b/boa_engine/src/syntax/ast/node/conditional/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/conditional/tests.rs rename to boa_engine/src/syntax/ast/node/conditional/tests.rs diff --git a/boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs b/boa_engine/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs index 85e6a5d7db0..674b109ba4c 100644 --- a/boa/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/async_function_decl/mod.rs b/boa_engine/src/syntax/ast/node/declaration/async_function_decl/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/async_function_decl/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/async_function_decl/mod.rs index 681f08b6b9d..fe628733449 100644 --- a/boa/src/syntax/ast/node/declaration/async_function_decl/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/async_function_decl/mod.rs @@ -1,9 +1,7 @@ //! Async Function Declaration. -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/async_function_expr/mod.rs b/boa_engine/src/syntax/ast/node/declaration/async_function_expr/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/async_function_expr/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/async_function_expr/mod.rs index a74b9552d36..d508778ea6b 100644 --- a/boa/src/syntax/ast/node/declaration/async_function_expr/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/async_function_expr/mod.rs @@ -1,9 +1,7 @@ //! Async Function Expression. -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/async_generator_decl/mod.rs b/boa_engine/src/syntax/ast/node/declaration/async_generator_decl/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/async_generator_decl/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/async_generator_decl/mod.rs index 6ab7f9ab918..279e31fa2f7 100644 --- a/boa/src/syntax/ast/node/declaration/async_generator_decl/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/async_generator_decl/mod.rs @@ -1,9 +1,7 @@ //! Async Generator Declaration -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/async_generator_expr/mod.rs b/boa_engine/src/syntax/ast/node/declaration/async_generator_expr/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/async_generator_expr/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/async_generator_expr/mod.rs index c2812218076..fee25b76f1e 100644 --- a/boa/src/syntax/ast/node/declaration/async_generator_expr/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/async_generator_expr/mod.rs @@ -1,9 +1,7 @@ //! Async Generator Expression -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/function_decl/mod.rs b/boa_engine/src/syntax/ast/node/declaration/function_decl/mod.rs similarity index 96% rename from boa/src/syntax/ast/node/declaration/function_decl/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/function_decl/mod.rs index be55fe5937c..b97eb285047 100644 --- a/boa/src/syntax/ast/node/declaration/function_decl/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/function_decl/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/function_expr/mod.rs b/boa_engine/src/syntax/ast/node/declaration/function_expr/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/function_expr/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/function_expr/mod.rs index 2a9e3fc01a3..2905f906068 100644 --- a/boa/src/syntax/ast/node/declaration/function_expr/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/function_expr/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/generator_decl/mod.rs b/boa_engine/src/syntax/ast/node/declaration/generator_decl/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/generator_decl/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/generator_decl/mod.rs index 0b69f6ada44..d1ca3d2d83c 100644 --- a/boa/src/syntax/ast/node/declaration/generator_decl/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/generator_decl/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/generator_expr/mod.rs b/boa_engine/src/syntax/ast/node/declaration/generator_expr/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/declaration/generator_expr/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/generator_expr/mod.rs index 42a2b0224dd..05fbac78e34 100644 --- a/boa/src/syntax/ast/node/declaration/generator_expr/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/generator_expr/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}, -}; +use crate::syntax::ast::node::{join_nodes, FormalParameter, Node, StatementList}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/mod.rs b/boa_engine/src/syntax/ast/node/declaration/mod.rs similarity index 99% rename from boa/src/syntax/ast/node/declaration/mod.rs rename to boa_engine/src/syntax/ast/node/declaration/mod.rs index 0c8587c4d91..ebb3eaaf8ae 100644 --- a/boa/src/syntax/ast/node/declaration/mod.rs +++ b/boa_engine/src/syntax/ast/node/declaration/mod.rs @@ -1,8 +1,6 @@ //! Declaration nodes -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{join_nodes, Identifier, Node}, -}; +use crate::syntax::ast::node::{join_nodes, Identifier, Node}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/declaration/tests.rs b/boa_engine/src/syntax/ast/node/declaration/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/declaration/tests.rs rename to boa_engine/src/syntax/ast/node/declaration/tests.rs diff --git a/boa/src/syntax/ast/node/field/get_const_field/mod.rs b/boa_engine/src/syntax/ast/node/field/get_const_field/mod.rs similarity index 97% rename from boa/src/syntax/ast/node/field/get_const_field/mod.rs rename to boa_engine/src/syntax/ast/node/field/get_const_field/mod.rs index c33bc32665c..00f7a75c5be 100644 --- a/boa/src/syntax/ast/node/field/get_const_field/mod.rs +++ b/boa_engine/src/syntax/ast/node/field/get_const_field/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/field/get_field/mod.rs b/boa_engine/src/syntax/ast/node/field/get_field/mod.rs similarity index 96% rename from boa/src/syntax/ast/node/field/get_field/mod.rs rename to boa_engine/src/syntax/ast/node/field/get_field/mod.rs index 79207490fe3..744a40c00be 100644 --- a/boa/src/syntax/ast/node/field/get_field/mod.rs +++ b/boa_engine/src/syntax/ast/node/field/get_field/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/field/mod.rs b/boa_engine/src/syntax/ast/node/field/mod.rs similarity index 100% rename from boa/src/syntax/ast/node/field/mod.rs rename to boa_engine/src/syntax/ast/node/field/mod.rs diff --git a/boa/src/syntax/ast/node/field/tests.rs b/boa_engine/src/syntax/ast/node/field/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/field/tests.rs rename to boa_engine/src/syntax/ast/node/field/tests.rs diff --git a/boa/src/syntax/ast/node/identifier/mod.rs b/boa_engine/src/syntax/ast/node/identifier/mod.rs similarity index 93% rename from boa/src/syntax/ast/node/identifier/mod.rs rename to boa_engine/src/syntax/ast/node/identifier/mod.rs index 0d9e2b7b212..7bec5fc53c8 100644 --- a/boa/src/syntax/ast/node/identifier/mod.rs +++ b/boa_engine/src/syntax/ast/node/identifier/mod.rs @@ -1,9 +1,7 @@ //! Local identifier node. -use crate::{ - gc::{empty_trace, Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] @@ -50,7 +48,7 @@ impl ToInternedString for Identifier { } unsafe impl Trace for Identifier { - empty_trace!(); + unsafe_empty_trace!(); } impl From for Identifier { diff --git a/boa/src/syntax/ast/node/iteration/break_node/mod.rs b/boa_engine/src/syntax/ast/node/iteration/break_node/mod.rs similarity index 94% rename from boa/src/syntax/ast/node/iteration/break_node/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/break_node/mod.rs index ba185d489d8..aa6afc331eb 100644 --- a/boa/src/syntax/ast/node/iteration/break_node/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/break_node/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{empty_trace, Finalize, Trace}, - syntax::ast::Node, -}; +use crate::syntax::ast::Node; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] @@ -48,7 +46,7 @@ impl Break { } unsafe impl Trace for Break { - empty_trace!(); + unsafe_empty_trace!(); } impl ToInternedString for Break { diff --git a/boa/src/syntax/ast/node/iteration/break_node/tests.rs b/boa_engine/src/syntax/ast/node/iteration/break_node/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/iteration/break_node/tests.rs rename to boa_engine/src/syntax/ast/node/iteration/break_node/tests.rs diff --git a/boa/src/syntax/ast/node/iteration/continue_node/mod.rs b/boa_engine/src/syntax/ast/node/iteration/continue_node/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/iteration/continue_node/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/continue_node/mod.rs index 13e73e160f4..7933a0bebcc 100644 --- a/boa/src/syntax/ast/node/iteration/continue_node/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/continue_node/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/iteration/do_while_loop/mod.rs b/boa_engine/src/syntax/ast/node/iteration/do_while_loop/mod.rs similarity index 97% rename from boa/src/syntax/ast/node/iteration/do_while_loop/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/do_while_loop/mod.rs index de20c10d6e1..6750d946e27 100644 --- a/boa/src/syntax/ast/node/iteration/do_while_loop/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/do_while_loop/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/iteration/for_in_loop/mod.rs b/boa_engine/src/syntax/ast/node/iteration/for_in_loop/mod.rs similarity index 94% rename from boa/src/syntax/ast/node/iteration/for_in_loop/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/for_in_loop/mod.rs index d5eec396c2d..9d8b3a242df 100644 --- a/boa/src/syntax/ast/node/iteration/for_in_loop/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/for_in_loop/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{iteration::IterableLoopInitializer, Node}, -}; +use crate::syntax::ast::node::{iteration::IterableLoopInitializer, Node}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/iteration/for_loop/mod.rs b/boa_engine/src/syntax/ast/node/iteration/for_loop/mod.rs similarity index 98% rename from boa/src/syntax/ast/node/iteration/for_loop/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/for_loop/mod.rs index 8faf7058e84..e18cb709713 100644 --- a/boa/src/syntax/ast/node/iteration/for_loop/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/for_loop/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/iteration/for_of_loop/mod.rs b/boa_engine/src/syntax/ast/node/iteration/for_of_loop/mod.rs similarity index 94% rename from boa/src/syntax/ast/node/iteration/for_of_loop/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/for_of_loop/mod.rs index 29626d7dd58..2542baf1d79 100644 --- a/boa/src/syntax/ast/node/iteration/for_of_loop/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/for_of_loop/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{iteration::IterableLoopInitializer, Node}, -}; +use crate::syntax::ast::node::{iteration::IterableLoopInitializer, Node}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/iteration/mod.rs b/boa_engine/src/syntax/ast/node/iteration/mod.rs similarity index 92% rename from boa/src/syntax/ast/node/iteration/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/mod.rs index b2bb3d26899..29a663cf758 100644 --- a/boa/src/syntax/ast/node/iteration/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/mod.rs @@ -4,10 +4,8 @@ pub use self::{ break_node::Break, continue_node::Continue, do_while_loop::DoWhileLoop, for_in_loop::ForInLoop, for_loop::ForLoop, for_of_loop::ForOfLoop, while_loop::WhileLoop, }; -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{declaration::Declaration, identifier::Identifier}, -}; +use crate::syntax::ast::node::{declaration::Declaration, identifier::Identifier}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/iteration/tests.rs b/boa_engine/src/syntax/ast/node/iteration/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/iteration/tests.rs rename to boa_engine/src/syntax/ast/node/iteration/tests.rs diff --git a/boa/src/syntax/ast/node/iteration/while_loop/mod.rs b/boa_engine/src/syntax/ast/node/iteration/while_loop/mod.rs similarity index 96% rename from boa/src/syntax/ast/node/iteration/while_loop/mod.rs rename to boa_engine/src/syntax/ast/node/iteration/while_loop/mod.rs index eba779c4f26..eec09515cd1 100644 --- a/boa/src/syntax/ast/node/iteration/while_loop/mod.rs +++ b/boa_engine/src/syntax/ast/node/iteration/while_loop/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/mod.rs b/boa_engine/src/syntax/ast/node/mod.rs similarity index 99% rename from boa/src/syntax/ast/node/mod.rs rename to boa_engine/src/syntax/ast/node/mod.rs index 0a3ed13d809..d1e0049ad9f 100644 --- a/boa/src/syntax/ast/node/mod.rs +++ b/boa_engine/src/syntax/ast/node/mod.rs @@ -49,7 +49,7 @@ pub use self::{ try_node::{Catch, Finally, Try}, }; use super::Const; -use crate::gc::{empty_trace, Finalize, Trace}; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; use std::cmp::Ordering; @@ -605,7 +605,7 @@ pub enum MethodDefinitionKind { } unsafe impl Trace for MethodDefinitionKind { - empty_trace!(); + unsafe_empty_trace!(); } /// `PropertyName` can be either a literal or computed. @@ -655,7 +655,7 @@ impl From for PropertyName { } unsafe impl Trace for PropertyName { - empty_trace!(); + unsafe_empty_trace!(); } /// This parses the given source code, and then makes sure that diff --git a/boa/src/syntax/ast/node/new/mod.rs b/boa_engine/src/syntax/ast/node/new/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/new/mod.rs rename to boa_engine/src/syntax/ast/node/new/mod.rs index 1a523dd967a..028e939f3db 100644 --- a/boa/src/syntax/ast/node/new/mod.rs +++ b/boa_engine/src/syntax/ast/node/new/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{Call, Node}, -}; +use crate::syntax::ast::node::{Call, Node}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/new/tests.rs b/boa_engine/src/syntax/ast/node/new/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/new/tests.rs rename to boa_engine/src/syntax/ast/node/new/tests.rs diff --git a/boa/src/syntax/ast/node/object/mod.rs b/boa_engine/src/syntax/ast/node/object/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/object/mod.rs rename to boa_engine/src/syntax/ast/node/object/mod.rs index 982c45715d7..4fc64660be2 100644 --- a/boa/src/syntax/ast/node/object/mod.rs +++ b/boa_engine/src/syntax/ast/node/object/mod.rs @@ -1,11 +1,9 @@ //! Object node. -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{ - declaration::block_to_string, join_nodes, MethodDefinitionKind, Node, PropertyDefinition, - }, +use crate::syntax::ast::node::{ + declaration::block_to_string, join_nodes, MethodDefinitionKind, Node, PropertyDefinition, }; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/object/tests.rs b/boa_engine/src/syntax/ast/node/object/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/object/tests.rs rename to boa_engine/src/syntax/ast/node/object/tests.rs diff --git a/boa/src/syntax/ast/node/operator/assign/mod.rs b/boa_engine/src/syntax/ast/node/operator/assign/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/operator/assign/mod.rs rename to boa_engine/src/syntax/ast/node/operator/assign/mod.rs index 5ead4b8ac68..03e2e4c2754 100644 --- a/boa/src/syntax/ast/node/operator/assign/mod.rs +++ b/boa_engine/src/syntax/ast/node/operator/assign/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/operator/bin_op/mod.rs b/boa_engine/src/syntax/ast/node/operator/bin_op/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/operator/bin_op/mod.rs rename to boa_engine/src/syntax/ast/node/operator/bin_op/mod.rs index 489587800b8..40cdb16339d 100644 --- a/boa/src/syntax/ast/node/operator/bin_op/mod.rs +++ b/boa_engine/src/syntax/ast/node/operator/bin_op/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::{node::Node, op}, -}; +use crate::syntax::ast::{node::Node, op}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/operator/mod.rs b/boa_engine/src/syntax/ast/node/operator/mod.rs similarity index 100% rename from boa/src/syntax/ast/node/operator/mod.rs rename to boa_engine/src/syntax/ast/node/operator/mod.rs diff --git a/boa/src/syntax/ast/node/operator/tests.rs b/boa_engine/src/syntax/ast/node/operator/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/operator/tests.rs rename to boa_engine/src/syntax/ast/node/operator/tests.rs diff --git a/boa/src/syntax/ast/node/operator/unary_op/mod.rs b/boa_engine/src/syntax/ast/node/operator/unary_op/mod.rs similarity index 94% rename from boa/src/syntax/ast/node/operator/unary_op/mod.rs rename to boa_engine/src/syntax/ast/node/operator/unary_op/mod.rs index 5759d73ea58..42a9a99e055 100644 --- a/boa/src/syntax/ast/node/operator/unary_op/mod.rs +++ b/boa_engine/src/syntax/ast/node/operator/unary_op/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::{node::Node, op}, -}; +use crate::syntax::ast::{node::Node, op}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/return_smt/mod.rs b/boa_engine/src/syntax/ast/node/return_smt/mod.rs similarity index 96% rename from boa/src/syntax/ast/node/return_smt/mod.rs rename to boa_engine/src/syntax/ast/node/return_smt/mod.rs index fc6b010aa59..1e34cf7dc9b 100644 --- a/boa/src/syntax/ast/node/return_smt/mod.rs +++ b/boa_engine/src/syntax/ast/node/return_smt/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/return_smt/tests.rs b/boa_engine/src/syntax/ast/node/return_smt/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/return_smt/tests.rs rename to boa_engine/src/syntax/ast/node/return_smt/tests.rs diff --git a/boa/src/syntax/ast/node/spread/mod.rs b/boa_engine/src/syntax/ast/node/spread/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/spread/mod.rs rename to boa_engine/src/syntax/ast/node/spread/mod.rs index 1e59bbb46f0..cb645e4de61 100644 --- a/boa/src/syntax/ast/node/spread/mod.rs +++ b/boa_engine/src/syntax/ast/node/spread/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/spread/tests.rs b/boa_engine/src/syntax/ast/node/spread/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/spread/tests.rs rename to boa_engine/src/syntax/ast/node/spread/tests.rs diff --git a/boa/src/syntax/ast/node/statement_list/mod.rs b/boa_engine/src/syntax/ast/node/statement_list/mod.rs similarity index 97% rename from boa/src/syntax/ast/node/statement_list/mod.rs rename to boa_engine/src/syntax/ast/node/statement_list/mod.rs index 4da5345f874..0239b4548c4 100644 --- a/boa/src/syntax/ast/node/statement_list/mod.rs +++ b/boa_engine/src/syntax/ast/node/statement_list/mod.rs @@ -1,9 +1,7 @@ //! Statement list node. -use crate::{ - gc::{empty_trace, Finalize, Trace}, - syntax::ast::node::{Declaration, Node}, -}; +use crate::syntax::ast::node::{Declaration, Node}; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; use std::{ops::Deref, rc::Rc}; @@ -172,5 +170,5 @@ impl From for RcStatementList { // SAFETY: This is safe for types not containing any `Trace` types. unsafe impl Trace for RcStatementList { - empty_trace!(); + unsafe_empty_trace!(); } diff --git a/boa/src/syntax/ast/node/statement_list/tests.rs b/boa_engine/src/syntax/ast/node/statement_list/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/statement_list/tests.rs rename to boa_engine/src/syntax/ast/node/statement_list/tests.rs diff --git a/boa/src/syntax/ast/node/switch/mod.rs b/boa_engine/src/syntax/ast/node/switch/mod.rs similarity index 98% rename from boa/src/syntax/ast/node/switch/mod.rs rename to boa_engine/src/syntax/ast/node/switch/mod.rs index 2c49c660e8a..1ae2d40a5cb 100644 --- a/boa/src/syntax/ast/node/switch/mod.rs +++ b/boa_engine/src/syntax/ast/node/switch/mod.rs @@ -1,9 +1,7 @@ //! Switch node. //! -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; use crate::syntax::ast::node::StatementList; diff --git a/boa/src/syntax/ast/node/switch/tests.rs b/boa_engine/src/syntax/ast/node/switch/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/switch/tests.rs rename to boa_engine/src/syntax/ast/node/switch/tests.rs diff --git a/boa/src/syntax/ast/node/template/mod.rs b/boa_engine/src/syntax/ast/node/template/mod.rs similarity index 98% rename from boa/src/syntax/ast/node/template/mod.rs rename to boa_engine/src/syntax/ast/node/template/mod.rs index 199fa7a9804..41f88ccce6d 100644 --- a/boa/src/syntax/ast/node/template/mod.rs +++ b/boa_engine/src/syntax/ast/node/template/mod.rs @@ -1,7 +1,7 @@ //! Template literal node. use super::Node; -use crate::gc::{Finalize, Trace}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/template/tests.rs b/boa_engine/src/syntax/ast/node/template/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/template/tests.rs rename to boa_engine/src/syntax/ast/node/template/tests.rs diff --git a/boa/src/syntax/ast/node/throw/mod.rs b/boa_engine/src/syntax/ast/node/throw/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/throw/mod.rs rename to boa_engine/src/syntax/ast/node/throw/mod.rs index 73676c6a785..607a2ab093a 100644 --- a/boa/src/syntax/ast/node/throw/mod.rs +++ b/boa_engine/src/syntax/ast/node/throw/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/throw/tests.rs b/boa_engine/src/syntax/ast/node/throw/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/throw/tests.rs rename to boa_engine/src/syntax/ast/node/throw/tests.rs diff --git a/boa/src/syntax/ast/node/try_node/mod.rs b/boa_engine/src/syntax/ast/node/try_node/mod.rs similarity index 98% rename from boa/src/syntax/ast/node/try_node/mod.rs rename to boa_engine/src/syntax/ast/node/try_node/mod.rs index 9171ea5ec10..7fd0f57f416 100644 --- a/boa/src/syntax/ast/node/try_node/mod.rs +++ b/boa_engine/src/syntax/ast/node/try_node/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::{Block, Declaration, Node}, -}; +use crate::syntax::ast::node::{Block, Declaration, Node}; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/node/try_node/tests.rs b/boa_engine/src/syntax/ast/node/try_node/tests.rs similarity index 100% rename from boa/src/syntax/ast/node/try_node/tests.rs rename to boa_engine/src/syntax/ast/node/try_node/tests.rs diff --git a/boa/src/syntax/ast/node/yield/mod.rs b/boa_engine/src/syntax/ast/node/yield/mod.rs similarity index 95% rename from boa/src/syntax/ast/node/yield/mod.rs rename to boa_engine/src/syntax/ast/node/yield/mod.rs index 7ec4324906a..0e9e602ff92 100644 --- a/boa/src/syntax/ast/node/yield/mod.rs +++ b/boa_engine/src/syntax/ast/node/yield/mod.rs @@ -1,7 +1,5 @@ -use crate::{ - gc::{Finalize, Trace}, - syntax::ast::node::Node, -}; +use crate::syntax::ast::node::Node; +use boa_gc::{Finalize, Trace}; use boa_interner::{Interner, ToInternedString}; #[cfg(feature = "deser")] diff --git a/boa/src/syntax/ast/op.rs b/boa_engine/src/syntax/ast/op.rs similarity index 99% rename from boa/src/syntax/ast/op.rs rename to boa_engine/src/syntax/ast/op.rs index 5bbfdcf7a2c..859fb7b0274 100644 --- a/boa/src/syntax/ast/op.rs +++ b/boa_engine/src/syntax/ast/op.rs @@ -1,6 +1,6 @@ //! This module implements various structure for logic handling. -use crate::gc::{empty_trace, Finalize, Trace}; +use boa_gc::{unsafe_empty_trace, Finalize, Trace}; use std::fmt::{Display, Formatter, Result}; #[cfg(feature = "deser")] @@ -116,7 +116,7 @@ impl Display for NumOp { } unsafe impl Trace for NumOp { - empty_trace!(); + unsafe_empty_trace!(); } /// A unary operator is one that takes a single operand/argument and performs an operation. @@ -335,7 +335,7 @@ impl Display for UnaryOp { } unsafe impl Trace for UnaryOp { - empty_trace!(); + unsafe_empty_trace!(); } /// A bitwise operator is an operator used to perform bitwise operations @@ -453,7 +453,7 @@ impl Display for BitOp { } unsafe impl Trace for BitOp { - empty_trace!(); + unsafe_empty_trace!(); } /// A comparison operator compares its operands and returns a logical value based on whether the comparison is true. @@ -653,7 +653,7 @@ impl Display for CompOp { } unsafe impl Trace for CompOp { - empty_trace!(); + unsafe_empty_trace!(); } /// Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value. @@ -728,7 +728,7 @@ impl Display for LogOp { } unsafe impl Trace for LogOp { - empty_trace!(); + unsafe_empty_trace!(); } /// This represents a binary operation between two values. @@ -815,7 +815,7 @@ impl Display for BinOp { } unsafe impl Trace for BinOp { - empty_trace!(); + unsafe_empty_trace!(); } /// An assignment operator assigns a value to its left operand based on the value of its right operand. @@ -1021,7 +1021,7 @@ pub enum AssignOp { } unsafe impl Trace for AssignOp { - empty_trace!(); + unsafe_empty_trace!(); } impl AssignOp { diff --git a/boa/src/syntax/ast/position.rs b/boa_engine/src/syntax/ast/position.rs similarity index 100% rename from boa/src/syntax/ast/position.rs rename to boa_engine/src/syntax/ast/position.rs diff --git a/boa/src/syntax/ast/punctuator.rs b/boa_engine/src/syntax/ast/punctuator.rs similarity index 100% rename from boa/src/syntax/ast/punctuator.rs rename to boa_engine/src/syntax/ast/punctuator.rs diff --git a/boa/src/syntax/lexer/comment.rs b/boa_engine/src/syntax/lexer/comment.rs similarity index 89% rename from boa/src/syntax/lexer/comment.rs rename to boa_engine/src/syntax/lexer/comment.rs index 8eaf0d2d7c3..1e5ecdf367e 100644 --- a/boa/src/syntax/lexer/comment.rs +++ b/boa_engine/src/syntax/lexer/comment.rs @@ -1,15 +1,12 @@ //! This module implements lexing for comments used in the JavaScript programing language. use super::{Cursor, Error, Tokenizer}; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{Position, Span}, - lexer::{Token, TokenKind}, - }, - Interner, +use crate::syntax::{ + ast::{Position, Span}, + lexer::{Token, TokenKind}, }; -use core::convert::TryFrom; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Lexes a single line comment. @@ -34,7 +31,7 @@ impl Tokenizer for SingleLineComment { where R: Read, { - let _timer = BoaProfiler::global().start_event("SingleLineComment", "Lexing"); + let _timer = Profiler::global().start_event("SingleLineComment", "Lexing"); // Skip either to the end of the line or to the end of the input while let Some(ch) = cursor.peek()? { @@ -73,7 +70,7 @@ impl Tokenizer for MultiLineComment { where R: Read, { - let _timer = BoaProfiler::global().start_event("MultiLineComment", "Lexing"); + let _timer = Profiler::global().start_event("MultiLineComment", "Lexing"); let mut new_line = false; while let Some(ch) = cursor.next_char()? { @@ -122,7 +119,7 @@ impl Tokenizer for HashbangComment { where R: Read, { - let _timer = BoaProfiler::global().start_event("Hashbang", "Lexing"); + let _timer = Profiler::global().start_event("Hashbang", "Lexing"); while let Some(ch) = cursor.next_char()? { let tried_ch = char::try_from(ch); diff --git a/boa/src/syntax/lexer/cursor.rs b/boa_engine/src/syntax/lexer/cursor.rs similarity index 93% rename from boa/src/syntax/lexer/cursor.rs rename to boa_engine/src/syntax/lexer/cursor.rs index 3c3d04d799f..5784d112522 100644 --- a/boa/src/syntax/lexer/cursor.rs +++ b/boa_engine/src/syntax/lexer/cursor.rs @@ -1,5 +1,6 @@ //! Module implementing the lexer cursor. This is used for managing the input byte stream. -use crate::{profiler::BoaProfiler, syntax::ast::Position}; +use crate::syntax::ast::Position; +use boa_profiler::Profiler; use std::io::{self, Bytes, Error, ErrorKind, Read}; /// Cursor over the source code. @@ -69,7 +70,7 @@ where /// Peeks the next byte. #[inline] pub(super) fn peek(&mut self) -> Result, Error> { - let _timer = BoaProfiler::global().start_event("cursor::peek()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::peek()", "Lexing"); self.iter.peek_byte() } @@ -77,7 +78,7 @@ where /// Peeks the next n bytes, the maximum number of peeked bytes is 4 (n <= 4). #[inline] pub(super) fn peek_n(&mut self, n: u8) -> Result { - let _timer = BoaProfiler::global().start_event("cursor::peek_n()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::peek_n()", "Lexing"); self.iter.peek_n_bytes(n) } @@ -85,7 +86,7 @@ where /// Peeks the next UTF-8 character in u32 code point. #[inline] pub(super) fn peek_char(&mut self) -> Result, Error> { - let _timer = BoaProfiler::global().start_event("cursor::peek_char()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::peek_char()", "Lexing"); self.iter.peek_char() } @@ -93,7 +94,7 @@ where /// Compares the byte passed in to the next byte, if they match true is returned and the buffer is incremented #[inline] pub(super) fn next_is(&mut self, byte: u8) -> io::Result { - let _timer = BoaProfiler::global().start_event("cursor::next_is()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::next_is()", "Lexing"); Ok(match self.peek()? { Some(next) if next == byte => { @@ -114,7 +115,7 @@ where where F: Fn(char) -> bool, { - let _timer = BoaProfiler::global().start_event("cursor::next_is_ascii_pred()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::next_is_ascii_pred()", "Lexing"); Ok(match self.peek()? { Some(byte) => match byte { @@ -136,7 +137,7 @@ where where F: Fn(u32) -> bool, { - let _timer = BoaProfiler::global().start_event("cursor::next_is_char_pred()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::next_is_char_pred()", "Lexing"); Ok(if let Some(peek) = self.peek_char()? { pred(peek) @@ -150,7 +151,7 @@ where /// /// Note that all bytes up until the stop byte are added to the buffer, including the byte right before. pub(super) fn take_until(&mut self, stop: u8, buf: &mut Vec) -> io::Result<()> { - let _timer = BoaProfiler::global().start_event("cursor::take_until()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::take_until()", "Lexing"); loop { if self.next_is(stop)? { @@ -174,7 +175,7 @@ where where F: Fn(char) -> bool, { - let _timer = BoaProfiler::global().start_event("cursor::take_while_ascii_pred()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::take_while_ascii_pred()", "Lexing"); loop { if !self.next_is_ascii_pred(pred)? { @@ -197,7 +198,7 @@ where where F: Fn(u32) -> bool, { - let _timer = BoaProfiler::global().start_event("cursor::take_while_char_pred()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::take_while_char_pred()", "Lexing"); loop { if !self.next_is_char_pred(pred)? { @@ -222,7 +223,7 @@ where /// `UnexpectedEof` I/O error. #[inline] pub(super) fn fill_bytes(&mut self, buf: &mut [u8]) -> io::Result<()> { - let _timer = BoaProfiler::global().start_event("cursor::fill_bytes()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::fill_bytes()", "Lexing"); self.iter.fill_bytes(buf) } @@ -230,7 +231,7 @@ where /// Retrieves the next byte. #[inline] pub(crate) fn next_byte(&mut self) -> Result, Error> { - let _timer = BoaProfiler::global().start_event("cursor::next_byte()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::next_byte()", "Lexing"); let byte = self.iter.next_byte()?; @@ -264,7 +265,7 @@ where /// Retrieves the next UTF-8 character. #[inline] pub(crate) fn next_char(&mut self) -> Result, Error> { - let _timer = BoaProfiler::global().start_event("cursor::next_char()", "Lexing"); + let _timer = Profiler::global().start_event("cursor::next_char()", "Lexing"); let ch = self.iter.next_char()?; diff --git a/boa/src/syntax/lexer/error.rs b/boa_engine/src/syntax/lexer/error.rs similarity index 100% rename from boa/src/syntax/lexer/error.rs rename to boa_engine/src/syntax/lexer/error.rs diff --git a/boa/src/syntax/lexer/identifier.rs b/boa_engine/src/syntax/lexer/identifier.rs similarity index 93% rename from boa/src/syntax/lexer/identifier.rs rename to boa_engine/src/syntax/lexer/identifier.rs index 38a54c26cbb..6e0210d1b63 100644 --- a/boa/src/syntax/lexer/identifier.rs +++ b/boa_engine/src/syntax/lexer/identifier.rs @@ -1,18 +1,14 @@ //! This module implements lexing for identifiers (foo, myvar, etc.) used in the JavaScript programing language. use super::{Cursor, Error, Tokenizer}; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{Keyword, Position, Span}, - lexer::{StringLiteral, Token, TokenKind}, - }, - Interner, +use crate::syntax::{ + ast::{Keyword, Position, Span}, + lexer::{StringLiteral, Token, TokenKind}, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use boa_unicode::UnicodeProperties; -use core::convert::TryFrom; -use std::io::Read; -use std::str; +use std::{io::Read, str}; const STRICT_FORBIDDEN_IDENTIFIERS: [&str; 11] = [ "eval", @@ -90,7 +86,7 @@ impl Tokenizer for Identifier { where R: Read, { - let _timer = BoaProfiler::global().start_event("Identifier", "Lexing"); + let _timer = Profiler::global().start_event("Identifier", "Lexing"); let (identifier_name, contains_escaped_chars) = Self::take_identifier_name(cursor, start_pos, self.init)?; @@ -145,8 +141,7 @@ impl Identifier { where R: Read, { - let _timer = - BoaProfiler::global().start_event("Identifier::take_identifier_name", "Lexing"); + let _timer = Profiler::global().start_event("Identifier::take_identifier_name", "Lexing"); let mut contains_escaped_chars = false; let mut identifier_name = if init == '\\' && cursor.next_is(b'u')? { diff --git a/boa/src/syntax/lexer/mod.rs b/boa_engine/src/syntax/lexer/mod.rs similarity index 96% rename from boa/src/syntax/lexer/mod.rs rename to boa_engine/src/syntax/lexer/mod.rs index 305abcc77e6..d804b2d5260 100644 --- a/boa/src/syntax/lexer/mod.rs +++ b/boa_engine/src/syntax/lexer/mod.rs @@ -40,15 +40,15 @@ use self::{ string::StringLiteral, template::TemplateLiteral, }; -pub use crate::{profiler::BoaProfiler, syntax::ast::Position}; -use crate::{ - syntax::ast::{Punctuator, Span}, - Interner, -}; -use core::convert::TryFrom; -pub use error::Error; +use crate::syntax::ast::{Position, Punctuator, Span}; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; -pub use token::{Token, TokenKind}; + +pub use self::{ + error::Error, + token::{Token, TokenKind}, +}; trait Tokenizer { /// Lexes the next token. @@ -136,7 +136,7 @@ impl Lexer { where R: Read, { - let _timer = BoaProfiler::global().start_event("lex_slash_token", "Lexing"); + let _timer = Profiler::global().start_event("lex_slash_token", "Lexing"); if let Some(c) = self.cursor.peek()? { match c { @@ -189,7 +189,7 @@ impl Lexer { where R: Read, { - let _timer = BoaProfiler::global().start_event("next()", "Lexing"); + let _timer = Profiler::global().start_event("next()", "Lexing"); let (start, next_ch) = loop { let start = self.cursor.pos(); diff --git a/boa/src/syntax/lexer/number.rs b/boa_engine/src/syntax/lexer/number.rs similarity index 98% rename from boa/src/syntax/lexer/number.rs rename to boa_engine/src/syntax/lexer/number.rs index 006f7034df7..ff4171abb4e 100644 --- a/boa/src/syntax/lexer/number.rs +++ b/boa_engine/src/syntax/lexer/number.rs @@ -1,16 +1,15 @@ //! This module implements lexing for number literals (123, 787) used in the JavaScript programing language. -use super::{Cursor, Error, TokenKind, Tokenizer}; use crate::{ - profiler::BoaProfiler, syntax::{ ast::{Position, Span}, - lexer::{token::Numeric, Token}, + lexer::{token::Numeric, Cursor, Error, Token, TokenKind, Tokenizer}, }, - Interner, JsBigInt, + JsBigInt, }; -use std::io::Read; -use std::str; +use boa_interner::Interner; +use boa_profiler::Profiler; +use std::{io::Read, str}; /// Number literal lexing. /// @@ -186,7 +185,7 @@ impl Tokenizer for NumberLiteral { where R: Read, { - let _timer = BoaProfiler::global().start_event("NumberLiteral", "Lexing"); + let _timer = Profiler::global().start_event("NumberLiteral", "Lexing"); let mut buf = vec![self.init]; diff --git a/boa/src/syntax/lexer/operator.rs b/boa_engine/src/syntax/lexer/operator.rs similarity index 95% rename from boa/src/syntax/lexer/operator.rs rename to boa_engine/src/syntax/lexer/operator.rs index 10eddc64626..122152354fb 100644 --- a/boa/src/syntax/lexer/operator.rs +++ b/boa_engine/src/syntax/lexer/operator.rs @@ -1,15 +1,11 @@ //! This module implements lexing for operators (+, - etc.) used in the JavaScript programing language. -use super::{Cursor, Error, Tokenizer}; -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{Position, Punctuator, Span}, - lexer::Token, - }, +use crate::syntax::{ + ast::{Position, Punctuator, Span}, + lexer::{Cursor, Error, Token, TokenKind, Tokenizer}, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// `vop` tests the next token to see if we're on an assign operation of just a plain binary operation. @@ -104,7 +100,7 @@ impl Tokenizer for Operator { where R: Read, { - let _timer = BoaProfiler::global().start_event("Operator", "Lexing"); + let _timer = Profiler::global().start_event("Operator", "Lexing"); match self.init { b'*' => op!(cursor, start_pos, Ok(Punctuator::AssignMul), Ok(Punctuator::Mul), { diff --git a/boa/src/syntax/lexer/regex.rs b/boa_engine/src/syntax/lexer/regex.rs similarity index 97% rename from boa/src/syntax/lexer/regex.rs rename to boa_engine/src/syntax/lexer/regex.rs index daf1ff1106b..06d945c89fe 100644 --- a/boa/src/syntax/lexer/regex.rs +++ b/boa_engine/src/syntax/lexer/regex.rs @@ -1,15 +1,13 @@ //! This module implements lexing for regex literals used in the JavaScript programing language. use super::{Cursor, Error, Span, Tokenizer}; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::Position, - lexer::{Token, TokenKind}, - }, +use crate::syntax::{ + ast::Position, + lexer::{Token, TokenKind}, }; use bitflags::bitflags; use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::{ io::{self, ErrorKind, Read}, str::{self, FromStr}, @@ -40,7 +38,7 @@ impl Tokenizer for RegexLiteral { where R: Read, { - let _timer = BoaProfiler::global().start_event("RegexLiteral", "Lexing"); + let _timer = Profiler::global().start_event("RegexLiteral", "Lexing"); let mut body = Vec::new(); diff --git a/boa/src/syntax/lexer/spread.rs b/boa_engine/src/syntax/lexer/spread.rs similarity index 87% rename from boa/src/syntax/lexer/spread.rs rename to boa_engine/src/syntax/lexer/spread.rs index a4db4696a48..fac7c2d963b 100644 --- a/boa/src/syntax/lexer/spread.rs +++ b/boa_engine/src/syntax/lexer/spread.rs @@ -1,14 +1,12 @@ //! This module implements lexing for spread (...) literals used in the JavaScript programing language. use super::{Cursor, Error, Tokenizer}; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{Position, Punctuator, Span}, - lexer::Token, - }, - Interner, +use crate::syntax::{ + ast::{Position, Punctuator, Span}, + lexer::Token, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Spread literal lexing. @@ -41,7 +39,7 @@ impl Tokenizer for SpreadLiteral { where R: Read, { - let _timer = BoaProfiler::global().start_event("SpreadLiteral", "Lexing"); + let _timer = Profiler::global().start_event("SpreadLiteral", "Lexing"); // . or ... if cursor.next_is(b'.')? { diff --git a/boa/src/syntax/lexer/string.rs b/boa_engine/src/syntax/lexer/string.rs similarity index 96% rename from boa/src/syntax/lexer/string.rs rename to boa_engine/src/syntax/lexer/string.rs index aec844135d6..c38e10f4267 100644 --- a/boa/src/syntax/lexer/string.rs +++ b/boa_engine/src/syntax/lexer/string.rs @@ -1,14 +1,12 @@ //! This module implements lexing for string literals used in the JavaScript programing language. use super::{Cursor, Error, Tokenizer}; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{Position, Span}, - lexer::{Token, TokenKind}, - }, - Interner, +use crate::syntax::{ + ast::{Position, Span}, + lexer::{Token, TokenKind}, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::{ io::{self, ErrorKind, Read}, str, @@ -87,7 +85,7 @@ impl Tokenizer for StringLiteral { where R: Read, { - let _timer = BoaProfiler::global().start_event("StringLiteral", "Lexing"); + let _timer = Profiler::global().start_event("StringLiteral", "Lexing"); let (lit, span) = Self::take_string_characters(cursor, start_pos, self.terminator, cursor.strict_mode())?; @@ -133,8 +131,8 @@ impl StringLiteral { Some(0x0027 /* ' */) if terminator == StringTerminator::SingleQuote => break, Some(0x0022 /* " */) if terminator == StringTerminator::DoubleQuote => break, Some(0x005C /* \ */) => { - let _timer = BoaProfiler::global() - .start_event("StringLiteral - escape sequence", "Lexing"); + let _timer = + Profiler::global().start_event("StringLiteral - escape sequence", "Lexing"); if let Some(escape_value) = Self::take_escape_sequence_or_line_continuation( cursor, diff --git a/boa/src/syntax/lexer/template.rs b/boa_engine/src/syntax/lexer/template.rs similarity index 97% rename from boa/src/syntax/lexer/template.rs rename to boa_engine/src/syntax/lexer/template.rs index 3613e1a1aea..7825138c119 100644 --- a/boa/src/syntax/lexer/template.rs +++ b/boa_engine/src/syntax/lexer/template.rs @@ -2,14 +2,14 @@ use super::{Cursor, Error, Tokenizer}; use crate::{ - profiler::BoaProfiler, syntax::lexer::string::{StringLiteral, UTF16CodeUnitsBuffer}, syntax::{ ast::{Position, Span}, lexer::{Token, TokenKind}, }, - Interner, Sym, }; +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::{self, ErrorKind, Read}; #[cfg(feature = "deser")] @@ -109,7 +109,7 @@ impl Tokenizer for TemplateLiteral { where R: Read, { - let _timer = BoaProfiler::global().start_event("TemplateLiteral", "Lexing"); + let _timer = Profiler::global().start_event("TemplateLiteral", "Lexing"); let mut buf = Vec::new(); loop { diff --git a/boa/src/syntax/lexer/tests.rs b/boa_engine/src/syntax/lexer/tests.rs similarity index 100% rename from boa/src/syntax/lexer/tests.rs rename to boa_engine/src/syntax/lexer/tests.rs diff --git a/boa/src/syntax/lexer/token.rs b/boa_engine/src/syntax/lexer/token.rs similarity index 99% rename from boa/src/syntax/lexer/token.rs rename to boa_engine/src/syntax/lexer/token.rs index d546276053a..a394dc19d64 100644 --- a/boa/src/syntax/lexer/token.rs +++ b/boa_engine/src/syntax/lexer/token.rs @@ -8,8 +8,9 @@ use crate::{ syntax::ast::{Keyword, Punctuator, Span}, syntax::lexer::template::TemplateString, - Interner, JsBigInt, Sym, + JsBigInt, }; +use boa_interner::{Interner, Sym}; #[cfg(feature = "deser")] use serde::{Deserialize, Serialize}; diff --git a/boa/src/syntax/mod.rs b/boa_engine/src/syntax/mod.rs similarity index 100% rename from boa/src/syntax/mod.rs rename to boa_engine/src/syntax/mod.rs diff --git a/boa/src/syntax/parser/cursor/buffered_lexer/mod.rs b/boa_engine/src/syntax/parser/cursor/buffered_lexer/mod.rs similarity index 95% rename from boa/src/syntax/parser/cursor/buffered_lexer/mod.rs rename to boa_engine/src/syntax/parser/cursor/buffered_lexer/mod.rs index 66a5b51307a..88a7fd89250 100644 --- a/boa/src/syntax/parser/cursor/buffered_lexer/mod.rs +++ b/boa_engine/src/syntax/parser/cursor/buffered_lexer/mod.rs @@ -1,11 +1,10 @@ -use crate::{ - profiler::BoaProfiler, - syntax::{ - lexer::{InputElement, Lexer, Position, Token, TokenKind}, - parser::error::ParseError, - }, - Interner, +use crate::syntax::{ + ast::Position, + lexer::{InputElement, Lexer, Token, TokenKind}, + parser::error::ParseError, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; #[cfg(test)] @@ -74,7 +73,7 @@ where /// Sets the goal symbol for the lexer. #[inline] pub(super) fn set_goal(&mut self, elm: InputElement) { - let _timer = BoaProfiler::global().start_event("cursor::set_goal()", "Parsing"); + let _timer = Profiler::global().start_event("cursor::set_goal()", "Parsing"); self.lexer.set_goal(elm); } @@ -85,7 +84,7 @@ where start: Position, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("cursor::lex_regex()", "Parsing"); + let _timer = Profiler::global().start_event("cursor::lex_regex()", "Parsing"); self.set_goal(InputElement::RegExp); self.lexer .lex_slash_token(start, interner) diff --git a/boa/src/syntax/parser/cursor/buffered_lexer/tests.rs b/boa_engine/src/syntax/parser/cursor/buffered_lexer/tests.rs similarity index 99% rename from boa/src/syntax/parser/cursor/buffered_lexer/tests.rs rename to boa_engine/src/syntax/parser/cursor/buffered_lexer/tests.rs index b2a301736d9..399dd7aded2 100644 --- a/boa/src/syntax/parser/cursor/buffered_lexer/tests.rs +++ b/boa_engine/src/syntax/parser/cursor/buffered_lexer/tests.rs @@ -1,8 +1,6 @@ use super::BufferedLexer; -use crate::{ - syntax::lexer::{Token, TokenKind}, - Interner, -}; +use crate::syntax::lexer::{Token, TokenKind}; +use boa_interner::Interner; #[test] fn peek_skip_accending() { diff --git a/boa/src/syntax/parser/cursor/mod.rs b/boa_engine/src/syntax/parser/cursor/mod.rs similarity index 97% rename from boa/src/syntax/parser/cursor/mod.rs rename to boa_engine/src/syntax/parser/cursor/mod.rs index b0c2f092066..2ec0514cdf5 100644 --- a/boa/src/syntax/parser/cursor/mod.rs +++ b/boa_engine/src/syntax/parser/cursor/mod.rs @@ -2,13 +2,11 @@ mod buffered_lexer; use super::ParseError; -use crate::{ - syntax::{ - ast::Punctuator, - lexer::{InputElement, Lexer, Position, Token, TokenKind}, - }, - Interner, +use crate::syntax::{ + ast::{Position, Punctuator}, + lexer::{InputElement, Lexer, Token, TokenKind}, }; +use boa_interner::Interner; use buffered_lexer::BufferedLexer; use std::io::Read; diff --git a/boa/src/syntax/parser/error.rs b/boa_engine/src/syntax/parser/error.rs similarity index 100% rename from boa/src/syntax/parser/error.rs rename to boa_engine/src/syntax/parser/error.rs diff --git a/boa/src/syntax/parser/expression/assignment/arrow_function.rs b/boa_engine/src/syntax/parser/expression/assignment/arrow_function.rs similarity index 91% rename from boa/src/syntax/parser/expression/assignment/arrow_function.rs rename to boa_engine/src/syntax/parser/expression/assignment/arrow_function.rs index 03966bfc196..a7a66c66061 100644 --- a/boa/src/syntax/parser/expression/assignment/arrow_function.rs +++ b/boa_engine/src/syntax/parser/expression/assignment/arrow_function.rs @@ -7,29 +7,25 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions //! [spec]: https://tc39.es/ecma262/#sec-arrow-function-definitions -use boa_interner::Sym; - use super::AssignmentExpression; -use crate::{ - syntax::{ - ast::{ - node::{ - declaration::Declaration, ArrowFunctionDecl, FormalParameter, Node, Return, - StatementList, - }, - Punctuator, - }, - lexer::{Error as LexError, Position, TokenKind}, - parser::{ - error::{ErrorContext, ParseError, ParseResult}, - function::{FormalParameterList, FormalParameters, FunctionBody}, - statement::BindingIdentifier, - AllowAwait, AllowIn, AllowYield, Cursor, TokenParser, +use crate::syntax::{ + ast::{ + node::{ + declaration::Declaration, ArrowFunctionDecl, FormalParameter, Node, Return, + StatementList, }, + Position, Punctuator, + }, + lexer::{Error as LexError, TokenKind}, + parser::{ + error::{ErrorContext, ParseError, ParseResult}, + function::{FormalParameterList, FormalParameters, FunctionBody}, + statement::BindingIdentifier, + AllowAwait, AllowIn, AllowYield, Cursor, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Arrow function parsing. @@ -82,7 +78,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ArrowFunction", "Parsing"); + let _timer = Profiler::global().start_event("ArrowFunction", "Parsing"); let next_token = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; let (params, params_start_position) = diff --git a/boa/src/syntax/parser/expression/assignment/conditional.rs b/boa_engine/src/syntax/parser/expression/assignment/conditional.rs similarity index 85% rename from boa/src/syntax/parser/expression/assignment/conditional.rs rename to boa_engine/src/syntax/parser/expression/assignment/conditional.rs index ff2447520c0..737a775bfe1 100644 --- a/boa/src/syntax/parser/expression/assignment/conditional.rs +++ b/boa_engine/src/syntax/parser/expression/assignment/conditional.rs @@ -7,19 +7,16 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator //! [spec]: https://tc39.es/ecma262/#sec-conditional-operator -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{node::ConditionalOp, Node, Punctuator}, - parser::{ - expression::{AssignmentExpression, ShortCircuitExpression}, - AllowAwait, AllowIn, AllowYield, Cursor, ParseResult, TokenParser, - }, +use crate::syntax::{ + ast::{node::ConditionalOp, Node, Punctuator}, + lexer::TokenKind, + parser::{ + expression::{AssignmentExpression, ShortCircuitExpression}, + AllowAwait, AllowIn, AllowYield, Cursor, ParseResult, TokenParser, }, - BoaProfiler, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Conditional expression parsing. @@ -64,7 +61,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("ConditionalExpression", "Parsing"); + let _timer = Profiler::global().start_event("ConditionalExpression", "Parsing"); let lhs = ShortCircuitExpression::new(self.allow_in, self.allow_yield, self.allow_await) .parse(cursor, interner)?; diff --git a/boa/src/syntax/parser/expression/assignment/exponentiation.rs b/boa_engine/src/syntax/parser/expression/assignment/exponentiation.rs similarity index 84% rename from boa/src/syntax/parser/expression/assignment/exponentiation.rs rename to boa_engine/src/syntax/parser/expression/assignment/exponentiation.rs index 6bf97a9d575..b233f8336f7 100644 --- a/boa/src/syntax/parser/expression/assignment/exponentiation.rs +++ b/boa_engine/src/syntax/parser/expression/assignment/exponentiation.rs @@ -8,23 +8,20 @@ //! [spec]: https://tc39.es/ecma262/#sec-exp-operator use super::ParseError; -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{ - node::{BinOp, Node}, - op::NumOp, - Keyword, Punctuator, - }, - parser::{ - expression::{unary::UnaryExpression, update::UpdateExpression}, - AllowAwait, AllowYield, Cursor, ParseResult, TokenParser, - }, +use crate::syntax::{ + ast::{ + node::{BinOp, Node}, + op::NumOp, + Keyword, Punctuator, + }, + lexer::TokenKind, + parser::{ + expression::{unary::UnaryExpression, update::UpdateExpression}, + AllowAwait, AllowYield, Cursor, ParseResult, TokenParser, }, - BoaProfiler, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses an exponentiation expression. @@ -83,7 +80,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("ExponentiationExpression", "Parsing"); + let _timer = Profiler::global().start_event("ExponentiationExpression", "Parsing"); if is_unary_expression(cursor, interner)? { return UnaryExpression::new(self.allow_yield, self.allow_await) diff --git a/boa/src/syntax/parser/expression/assignment/mod.rs b/boa_engine/src/syntax/parser/expression/assignment/mod.rs similarity index 94% rename from boa/src/syntax/parser/expression/assignment/mod.rs rename to boa_engine/src/syntax/parser/expression/assignment/mod.rs index b9dcb5bd5dc..e14d1aa755b 100644 --- a/boa/src/syntax/parser/expression/assignment/mod.rs +++ b/boa_engine/src/syntax/parser/expression/assignment/mod.rs @@ -12,25 +12,23 @@ mod conditional; mod exponentiation; mod r#yield; -use self::r#yield::YieldExpression; -use self::{arrow_function::ArrowFunction, conditional::ConditionalExpression}; -use crate::syntax::lexer::{Error as LexError, InputElement, TokenKind}; -use crate::Interner; -use crate::{ - syntax::{ - ast::{ - node::{Assign, BinOp, Node}, - Keyword, Punctuator, - }, - parser::{AllowAwait, AllowIn, AllowYield, Cursor, ParseError, ParseResult, TokenParser}, +use self::{ + arrow_function::ArrowFunction, conditional::ConditionalExpression, r#yield::YieldExpression, +}; +use crate::syntax::{ + ast::{ + node::{Assign, BinOp, Node}, + Keyword, Punctuator, }, - BoaProfiler, + lexer::{Error as LexError, InputElement, TokenKind}, + parser::{AllowAwait, AllowIn, AllowYield, Cursor, ParseError, ParseResult, TokenParser}, }; -use boa_interner::Sym; -pub(super) use exponentiation::ExponentiationExpression; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; +pub(super) use exponentiation::ExponentiationExpression; + /// Assignment expression parsing. /// /// This can be one of the following: @@ -87,7 +85,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("AssignmentExpression", "Parsing"); + let _timer = Profiler::global().start_event("AssignmentExpression", "Parsing"); cursor.set_goal(InputElement::Div); match cursor diff --git a/boa/src/syntax/parser/expression/assignment/yield.rs b/boa_engine/src/syntax/parser/expression/assignment/yield.rs similarity index 87% rename from boa/src/syntax/parser/expression/assignment/yield.rs rename to boa_engine/src/syntax/parser/expression/assignment/yield.rs index 7ba97006ec1..4ddf3f97701 100644 --- a/boa/src/syntax/parser/expression/assignment/yield.rs +++ b/boa_engine/src/syntax/parser/expression/assignment/yield.rs @@ -7,22 +7,19 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield //! [spec]: https://tc39.es/ecma262/#prod-YieldExpression -use crate::{ - syntax::{ - ast::{ - node::{Node, Yield}, - Keyword, Punctuator, - }, - lexer::TokenKind, - parser::{cursor::SemicolonResult, AllowAwait, AllowIn, Cursor, ParseResult, TokenParser}, +use super::AssignmentExpression; +use crate::syntax::{ + ast::{ + node::{Node, Yield}, + Keyword, Punctuator, }, - BoaProfiler, Interner, + lexer::TokenKind, + parser::{cursor::SemicolonResult, AllowAwait, AllowIn, Cursor, ParseResult, TokenParser}, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; -use super::AssignmentExpression; - /// `YieldExpression` parsing. /// /// More information: @@ -58,7 +55,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("YieldExpression", "Parsing"); + let _timer = Profiler::global().start_event("YieldExpression", "Parsing"); cursor.expect( TokenKind::Keyword(Keyword::Yield), diff --git a/boa/src/syntax/parser/expression/await_expr.rs b/boa_engine/src/syntax/parser/expression/await_expr.rs similarity index 89% rename from boa/src/syntax/parser/expression/await_expr.rs rename to boa_engine/src/syntax/parser/expression/await_expr.rs index 6f988a33ed2..7969cfe82fd 100644 --- a/boa/src/syntax/parser/expression/await_expr.rs +++ b/boa_engine/src/syntax/parser/expression/await_expr.rs @@ -8,15 +8,12 @@ //! [spec]: https://tc39.es/ecma262/#prod-AwaitExpression use super::unary::UnaryExpression; - -use crate::{ - syntax::{ - ast::{node::AwaitExpr, Keyword}, - lexer::TokenKind, - parser::{AllowYield, Cursor, ParseError, TokenParser}, - }, - Interner, +use crate::syntax::{ + ast::{node::AwaitExpr, Keyword}, + lexer::TokenKind, + parser::{AllowYield, Cursor, ParseError, TokenParser}, }; +use boa_interner::Interner; use std::io::Read; /// Parses an await expression. diff --git a/boa/src/syntax/parser/expression/left_hand_side/arguments.rs b/boa_engine/src/syntax/parser/expression/left_hand_side/arguments.rs similarity index 89% rename from boa/src/syntax/parser/expression/left_hand_side/arguments.rs rename to boa_engine/src/syntax/parser/expression/left_hand_side/arguments.rs index a646ae2b185..fb68e5e6cec 100644 --- a/boa/src/syntax/parser/expression/left_hand_side/arguments.rs +++ b/boa_engine/src/syntax/parser/expression/left_hand_side/arguments.rs @@ -7,20 +7,15 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Glossary/Argument //! [spec]: https://tc39.es/ecma262/#prod-Arguments -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{node::Spread, Node, Punctuator}, - lexer::InputElement, - parser::{ - expression::AssignmentExpression, AllowAwait, AllowYield, Cursor, ParseError, - TokenParser, - }, +use crate::syntax::{ + ast::{node::Spread, Node, Punctuator}, + lexer::{InputElement, TokenKind}, + parser::{ + expression::AssignmentExpression, AllowAwait, AllowYield, Cursor, ParseError, TokenParser, }, - BoaProfiler, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a list of arguments. @@ -62,7 +57,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("Arguments", "Parsing"); + let _timer = Profiler::global().start_event("Arguments", "Parsing"); cursor.expect(Punctuator::OpenParen, "arguments", interner)?; let mut args = Vec::new(); diff --git a/boa/src/syntax/parser/expression/left_hand_side/call.rs b/boa_engine/src/syntax/parser/expression/left_hand_side/call.rs similarity index 89% rename from boa/src/syntax/parser/expression/left_hand_side/call.rs rename to boa_engine/src/syntax/parser/expression/left_hand_side/call.rs index 0f6d1c9c315..9ca3775ca69 100644 --- a/boa/src/syntax/parser/expression/left_hand_side/call.rs +++ b/boa_engine/src/syntax/parser/expression/left_hand_side/call.rs @@ -8,24 +8,22 @@ //! [spec]: https://tc39.es/ecma262/#prod-CallExpression use super::arguments::Arguments; -use crate::{ - syntax::{ - ast::{ - node::{ - field::{GetConstField, GetField}, - Call, Node, - }, - Punctuator, - }, - lexer::TokenKind, - parser::{ - expression::{left_hand_side::template::TaggedTemplateLiteral, Expression}, - AllowAwait, AllowYield, Cursor, ParseError, ParseResult, TokenParser, +use crate::syntax::{ + ast::{ + node::{ + field::{GetConstField, GetField}, + Call, Node, }, + Punctuator, + }, + lexer::TokenKind, + parser::{ + expression::{left_hand_side::template::TaggedTemplateLiteral, Expression}, + AllowAwait, AllowYield, Cursor, ParseError, ParseResult, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a call expression. @@ -63,7 +61,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("CallExpression", "Parsing"); + let _timer = Profiler::global().start_event("CallExpression", "Parsing"); let token = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; diff --git a/boa/src/syntax/parser/expression/left_hand_side/member.rs b/boa_engine/src/syntax/parser/expression/left_hand_side/member.rs similarity index 87% rename from boa/src/syntax/parser/expression/left_hand_side/member.rs rename to boa_engine/src/syntax/parser/expression/left_hand_side/member.rs index 5e95814aafb..2b863a3b3e0 100644 --- a/boa/src/syntax/parser/expression/left_hand_side/member.rs +++ b/boa_engine/src/syntax/parser/expression/left_hand_side/member.rs @@ -6,27 +6,24 @@ //! [spec]: https://tc39.es/ecma262/#prod-MemberExpression use super::arguments::Arguments; -use crate::{ - syntax::{ - ast::{ - node::{ - field::{GetConstField, GetField}, - Call, New, Node, - }, - Keyword, Punctuator, +use crate::syntax::{ + ast::{ + node::{ + field::{GetConstField, GetField}, + Call, New, Node, }, - lexer::TokenKind, - parser::{ - expression::{ - left_hand_side::template::TaggedTemplateLiteral, primary::PrimaryExpression, - Expression, - }, - AllowAwait, AllowYield, Cursor, ParseError, ParseResult, TokenParser, + Keyword, Punctuator, + }, + lexer::TokenKind, + parser::{ + expression::{ + left_hand_side::template::TaggedTemplateLiteral, primary::PrimaryExpression, Expression, }, + AllowAwait, AllowYield, Cursor, ParseError, ParseResult, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a member expression. @@ -62,7 +59,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("MemberExpression", "Parsing"); + let _timer = Profiler::global().start_event("MemberExpression", "Parsing"); let mut lhs = if cursor .peek(0, interner)? diff --git a/boa/src/syntax/parser/expression/left_hand_side/mod.rs b/boa_engine/src/syntax/parser/expression/left_hand_side/mod.rs similarity index 86% rename from boa/src/syntax/parser/expression/left_hand_side/mod.rs rename to boa_engine/src/syntax/parser/expression/left_hand_side/mod.rs index d40da0d47fb..c9837ae1823 100644 --- a/boa/src/syntax/parser/expression/left_hand_side/mod.rs +++ b/boa_engine/src/syntax/parser/expression/left_hand_side/mod.rs @@ -13,16 +13,13 @@ mod member; mod template; use self::{call::CallExpression, member::MemberExpression}; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{Node, Punctuator}, - lexer::{InputElement, TokenKind}, - parser::{AllowAwait, AllowYield, Cursor, ParseResult, TokenParser}, - }, - Interner, +use crate::syntax::{ + ast::{Node, Punctuator}, + lexer::{InputElement, TokenKind}, + parser::{AllowAwait, AllowYield, Cursor, ParseResult, TokenParser}, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a left hand side expression. @@ -60,7 +57,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("LeftHandSIdeExpression", "Parsing"); + let _timer = Profiler::global().start_event("LeftHandSIdeExpression", "Parsing"); cursor.set_goal(InputElement::TemplateTail); diff --git a/boa/src/syntax/parser/expression/left_hand_side/template.rs b/boa_engine/src/syntax/parser/expression/left_hand_side/template.rs similarity index 85% rename from boa/src/syntax/parser/expression/left_hand_side/template.rs rename to boa_engine/src/syntax/parser/expression/left_hand_side/template.rs index 5691563843c..9e2a98577fe 100644 --- a/boa/src/syntax/parser/expression/left_hand_side/template.rs +++ b/boa_engine/src/syntax/parser/expression/left_hand_side/template.rs @@ -1,16 +1,14 @@ -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::node::TaggedTemplate, - ast::{Node, Position, Punctuator}, - lexer::TokenKind, - parser::{ - cursor::Cursor, expression::Expression, AllowAwait, AllowYield, ParseError, - ParseResult, TokenParser, - }, +use crate::syntax::{ + ast::node::TaggedTemplate, + ast::{Node, Position, Punctuator}, + lexer::TokenKind, + parser::{ + cursor::Cursor, expression::Expression, AllowAwait, AllowYield, ParseError, ParseResult, + TokenParser, }, - Interner, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a tagged template. @@ -50,7 +48,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("TaggedTemplateLiteral", "Parsing"); + let _timer = Profiler::global().start_event("TaggedTemplateLiteral", "Parsing"); let mut raws = Vec::new(); let mut cookeds = Vec::new(); diff --git a/boa/src/syntax/parser/expression/mod.rs b/boa_engine/src/syntax/parser/expression/mod.rs similarity index 97% rename from boa/src/syntax/parser/expression/mod.rs rename to boa_engine/src/syntax/parser/expression/mod.rs index f806292a762..e7b6bacc961 100644 --- a/boa/src/syntax/parser/expression/mod.rs +++ b/boa_engine/src/syntax/parser/expression/mod.rs @@ -15,29 +15,24 @@ mod tests; mod unary; mod update; -pub(in crate::syntax::parser) mod await_expr; - -use boa_interner::Sym; - use self::assignment::ExponentiationExpression; -pub(super) use self::{assignment::AssignmentExpression, primary::Initializer}; use super::{AllowAwait, AllowIn, AllowYield, Cursor, ParseResult, TokenParser}; - -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::op::LogOp, - ast::{ - node::{BinOp, Node}, - Keyword, Punctuator, - }, - lexer::{InputElement, TokenKind}, - parser::ParseError, +use crate::syntax::{ + ast::op::LogOp, + ast::{ + node::{BinOp, Node}, + Keyword, Punctuator, }, - Interner, + lexer::{InputElement, TokenKind}, + parser::ParseError, }; +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; +pub(super) use self::{assignment::AssignmentExpression, primary::Initializer}; +pub(in crate::syntax::parser) mod await_expr; + // For use in the expression! macro to allow for both Punctuator and Keyword parameters. // Always returns false. impl PartialEq for Punctuator { @@ -79,7 +74,7 @@ macro_rules! expression { ($name:ident, $lower:ident, [$( $op:path ),*], [$( $lo type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner)-> ParseResult { - let _timer = BoaProfiler::global().start_event(stringify!($name), "Parsing"); + let _timer = Profiler::global().start_event(stringify!($name), "Parsing"); if $goal.is_some() { cursor.set_goal($goal.unwrap()); @@ -221,7 +216,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("ShortCircuitExpression", "Parsing"); + let _timer = Profiler::global().start_event("ShortCircuitExpression", "Parsing"); let mut current_node = BitwiseORExpression::new(self.allow_in, self.allow_yield, self.allow_await) @@ -487,7 +482,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("Relation Expression", "Parsing"); + let _timer = Profiler::global().start_event("Relation Expression", "Parsing"); let mut lhs = ShiftExpression::new(self.allow_yield, self.allow_await).parse(cursor, interner)?; diff --git a/boa/src/syntax/parser/expression/primary/array_initializer/mod.rs b/boa_engine/src/syntax/parser/expression/primary/array_initializer/mod.rs similarity index 86% rename from boa/src/syntax/parser/expression/primary/array_initializer/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/array_initializer/mod.rs index b06ead775e0..b017f779faa 100644 --- a/boa/src/syntax/parser/expression/primary/array_initializer/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/array_initializer/mod.rs @@ -10,20 +10,17 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{ - node::{ArrayDecl, Node, Spread}, - Const, Punctuator, - }, - parser::{ - expression::AssignmentExpression, AllowAwait, AllowYield, Cursor, ParseError, - TokenParser, - }, +use crate::syntax::{ + ast::{ + node::{ArrayDecl, Node, Spread}, + Const, Punctuator, + }, + parser::{ + expression::AssignmentExpression, AllowAwait, AllowYield, Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses an array literal. @@ -65,7 +62,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ArrayLiteral", "Parsing"); + let _timer = Profiler::global().start_event("ArrayLiteral", "Parsing"); let mut elements = Vec::new(); loop { diff --git a/boa/src/syntax/parser/expression/primary/array_initializer/tests.rs b/boa_engine/src/syntax/parser/expression/primary/array_initializer/tests.rs similarity index 95% rename from boa/src/syntax/parser/expression/primary/array_initializer/tests.rs rename to boa_engine/src/syntax/parser/expression/primary/array_initializer/tests.rs index c36aaa544ed..554cb6e9011 100644 --- a/boa/src/syntax/parser/expression/primary/array_initializer/tests.rs +++ b/boa_engine/src/syntax/parser/expression/primary/array_initializer/tests.rs @@ -1,14 +1,10 @@ // ! Tests for array initializer parsing. -use boa_interner::Sym; - -use crate::{ - syntax::{ - ast::{node::ArrayDecl, Const}, - parser::tests::check_parser, - }, - Interner, +use crate::syntax::{ + ast::{node::ArrayDecl, Const}, + parser::tests::check_parser, }; +use boa_interner::{Interner, Sym}; /// Checks an empty array. #[test] diff --git a/boa/src/syntax/parser/expression/primary/async_function_expression/mod.rs b/boa_engine/src/syntax/parser/expression/primary/async_function_expression/mod.rs similarity index 91% rename from boa/src/syntax/parser/expression/primary/async_function_expression/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/async_function_expression/mod.rs index b1d6f4418ab..047bff9cc4d 100644 --- a/boa/src/syntax/parser/expression/primary/async_function_expression/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/async_function_expression/mod.rs @@ -1,21 +1,17 @@ #[cfg(test)] mod tests; -use boa_interner::Sym; - -use crate::{ - syntax::{ - ast::{node::AsyncFunctionExpr, Keyword, Punctuator}, - lexer::{Error as LexError, Position, TokenKind}, - parser::{ - function::{FormalParameters, FunctionBody}, - statement::BindingIdentifier, - AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::AsyncFunctionExpr, Keyword, Position, Punctuator}, + lexer::{Error as LexError, TokenKind}, + parser::{ + function::{FormalParameters, FunctionBody}, + statement::BindingIdentifier, + AllowYield, Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Async Function expression parsing. @@ -54,7 +50,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("AsyncFunctionExpression", "Parsing"); + let _timer = Profiler::global().start_event("AsyncFunctionExpression", "Parsing"); cursor.peek_expect_no_lineterminator(0, "async function expression", interner)?; cursor.expect(Keyword::Function, "async function expression", interner)?; diff --git a/boa/src/syntax/parser/expression/primary/async_function_expression/tests.rs b/boa_engine/src/syntax/parser/expression/primary/async_function_expression/tests.rs similarity index 91% rename from boa/src/syntax/parser/expression/primary/async_function_expression/tests.rs rename to boa_engine/src/syntax/parser/expression/primary/async_function_expression/tests.rs index 7bcfb50ed42..fdfd3cf0b54 100644 --- a/boa/src/syntax/parser/expression/primary/async_function_expression/tests.rs +++ b/boa_engine/src/syntax/parser/expression/primary/async_function_expression/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{AsyncFunctionExpr, Declaration, DeclarationList, Return, StatementList}, - Const, - }, - parser::tests::check_parser, +use crate::syntax::{ + ast::{ + node::{AsyncFunctionExpr, Declaration, DeclarationList, Return, StatementList}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; /// Checks async expression parsing. #[test] diff --git a/boa/src/syntax/parser/expression/primary/async_generator_expression/mod.rs b/boa_engine/src/syntax/parser/expression/primary/async_generator_expression/mod.rs similarity index 91% rename from boa/src/syntax/parser/expression/primary/async_generator_expression/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/async_generator_expression/mod.rs index 991390e6cd8..efb43cdafe6 100644 --- a/boa/src/syntax/parser/expression/primary/async_generator_expression/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/async_generator_expression/mod.rs @@ -10,21 +10,17 @@ #[cfg(test)] mod tests; -use boa_interner::Sym; - -use crate::{ - syntax::{ - ast::{node::AsyncGeneratorExpr, Keyword, Punctuator}, - lexer::{Error as LexError, Position, TokenKind}, - parser::{ - function::{FormalParameters, FunctionBody}, - statement::BindingIdentifier, - Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::AsyncGeneratorExpr, Keyword, Position, Punctuator}, + lexer::{Error as LexError, TokenKind}, + parser::{ + function::{FormalParameters, FunctionBody}, + statement::BindingIdentifier, + Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Async Generator Expression Parsing @@ -48,7 +44,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("AsyncGeneratorExpression", "Parsing"); + let _timer = Profiler::global().start_event("AsyncGeneratorExpression", "Parsing"); cursor.peek_expect_no_lineterminator(0, "async generator expression", interner)?; cursor.expect(Keyword::Function, "async generator expression", interner)?; diff --git a/boa/src/syntax/parser/expression/primary/async_generator_expression/tests.rs b/boa_engine/src/syntax/parser/expression/primary/async_generator_expression/tests.rs similarity index 91% rename from boa/src/syntax/parser/expression/primary/async_generator_expression/tests.rs rename to boa_engine/src/syntax/parser/expression/primary/async_generator_expression/tests.rs index 3ee20f92c5b..67091d90b29 100644 --- a/boa/src/syntax/parser/expression/primary/async_generator_expression/tests.rs +++ b/boa_engine/src/syntax/parser/expression/primary/async_generator_expression/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{AsyncGeneratorExpr, Declaration, DeclarationList, Return, StatementList}, - Const, - }, - parser::tests::check_parser, +use crate::syntax::{ + ast::{ + node::{AsyncGeneratorExpr, Declaration, DeclarationList, Return, StatementList}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; ///checks async generator expression parsing diff --git a/boa/src/syntax/parser/expression/primary/function_expression/mod.rs b/boa_engine/src/syntax/parser/expression/primary/function_expression/mod.rs similarity index 91% rename from boa/src/syntax/parser/expression/primary/function_expression/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/function_expression/mod.rs index 2cfe0dd6f72..027fe790176 100644 --- a/boa/src/syntax/parser/expression/primary/function_expression/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/function_expression/mod.rs @@ -10,21 +10,17 @@ #[cfg(test)] mod tests; -use boa_interner::Sym; - -use crate::{ - syntax::{ - ast::{node::FunctionExpr, Keyword, Punctuator}, - lexer::{Error as LexError, Position, TokenKind}, - parser::{ - function::{FormalParameters, FunctionBody}, - statement::BindingIdentifier, - Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::FunctionExpr, Keyword, Position, Punctuator}, + lexer::{Error as LexError, TokenKind}, + parser::{ + function::{FormalParameters, FunctionBody}, + statement::BindingIdentifier, + Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Function expression parsing. @@ -49,7 +45,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("FunctionExpression", "Parsing"); + let _timer = Profiler::global().start_event("FunctionExpression", "Parsing"); let name = if let Some(token) = cursor.peek(0, interner)? { match token.kind() { diff --git a/boa/src/syntax/parser/expression/primary/function_expression/tests.rs b/boa_engine/src/syntax/parser/expression/primary/function_expression/tests.rs similarity index 91% rename from boa/src/syntax/parser/expression/primary/function_expression/tests.rs rename to boa_engine/src/syntax/parser/expression/primary/function_expression/tests.rs index bf20ec78983..e60f4ee108e 100644 --- a/boa/src/syntax/parser/expression/primary/function_expression/tests.rs +++ b/boa_engine/src/syntax/parser/expression/primary/function_expression/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{Declaration, DeclarationList, FunctionExpr, Return, StatementList}, - Const, - }, - parser::tests::check_parser, +use crate::syntax::{ + ast::{ + node::{Declaration, DeclarationList, FunctionExpr, Return, StatementList}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; /// Checks async expression parsing. #[test] diff --git a/boa/src/syntax/parser/expression/primary/generator_expression/mod.rs b/boa_engine/src/syntax/parser/expression/primary/generator_expression/mod.rs similarity index 91% rename from boa/src/syntax/parser/expression/primary/generator_expression/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/generator_expression/mod.rs index 8981dda16a8..ffb7d32ff2c 100644 --- a/boa/src/syntax/parser/expression/primary/generator_expression/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/generator_expression/mod.rs @@ -10,21 +10,17 @@ #[cfg(test)] mod tests; -use boa_interner::Sym; - -use crate::{ - syntax::{ - ast::{node::GeneratorExpr, Punctuator}, - lexer::{Error as LexError, Position, TokenKind}, - parser::{ - function::{FormalParameters, FunctionBody}, - statement::BindingIdentifier, - Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::GeneratorExpr, Position, Punctuator}, + lexer::{Error as LexError, TokenKind}, + parser::{ + function::{FormalParameters, FunctionBody}, + statement::BindingIdentifier, + Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Generator expression parsing. @@ -49,7 +45,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("GeneratorExpression", "Parsing"); + let _timer = Profiler::global().start_event("GeneratorExpression", "Parsing"); cursor.expect( TokenKind::Punctuator(Punctuator::Mul), diff --git a/boa/src/syntax/parser/expression/primary/generator_expression/tests.rs b/boa_engine/src/syntax/parser/expression/primary/generator_expression/tests.rs similarity index 87% rename from boa/src/syntax/parser/expression/primary/generator_expression/tests.rs rename to boa_engine/src/syntax/parser/expression/primary/generator_expression/tests.rs index 968d003e0e2..c688991d752 100644 --- a/boa/src/syntax/parser/expression/primary/generator_expression/tests.rs +++ b/boa_engine/src/syntax/parser/expression/primary/generator_expression/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{Declaration, DeclarationList, GeneratorExpr, StatementList, Yield}, - Const, - }, - parser::tests::check_parser, +use crate::syntax::{ + ast::{ + node::{Declaration, DeclarationList, GeneratorExpr, StatementList, Yield}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; #[test] fn check_generator_function_expression() { diff --git a/boa/src/syntax/parser/expression/primary/mod.rs b/boa_engine/src/syntax/parser/expression/primary/mod.rs similarity index 93% rename from boa/src/syntax/parser/expression/primary/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/mod.rs index ef353b0241e..50053f9c310 100644 --- a/boa/src/syntax/parser/expression/primary/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/mod.rs @@ -23,26 +23,23 @@ use self::{ generator_expression::GeneratorExpression, object_initializer::ObjectLiteral, }; use super::Expression; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{ - node::{Call, Identifier, New, Node}, - Const, Keyword, Punctuator, - }, - lexer::{token::Numeric, InputElement, TokenKind}, - parser::{ - expression::primary::template::TemplateLiteral, AllowAwait, AllowYield, Cursor, - ParseError, ParseResult, TokenParser, - }, +use crate::syntax::{ + ast::{ + node::{Call, Identifier, New, Node}, + Const, Keyword, Punctuator, + }, + lexer::{token::Numeric, InputElement, TokenKind}, + parser::{ + expression::primary::template::TemplateLiteral, AllowAwait, AllowYield, Cursor, ParseError, + ParseResult, TokenParser, }, - Interner, }; -use boa_interner::Sym; -pub(in crate::syntax::parser) use object_initializer::Initializer; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; +pub(in crate::syntax::parser) use object_initializer::Initializer; + /// Parses a primary expression. /// /// More information: @@ -78,7 +75,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("PrimaryExpression", "Parsing"); + let _timer = Profiler::global().start_event("PrimaryExpression", "Parsing"); // TODO: tok currently consumes the token instead of peeking, so the token // isn't passed and consumed by parsers according to spec (EX: GeneratorExpression) diff --git a/boa/src/syntax/parser/expression/primary/object_initializer/mod.rs b/boa_engine/src/syntax/parser/expression/primary/object_initializer/mod.rs similarity index 96% rename from boa/src/syntax/parser/expression/primary/object_initializer/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/object_initializer/mod.rs index 01d6b1a7a05..890794a7843 100644 --- a/boa/src/syntax/parser/expression/primary/object_initializer/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/object_initializer/mod.rs @@ -9,22 +9,21 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{ - node::{self, FunctionExpr, Identifier, MethodDefinitionKind, Node, Object}, - Keyword, Punctuator, - }, - lexer::{Error as LexError, Position, TokenKind}, - parser::{ - expression::AssignmentExpression, - function::{FormalParameters, FunctionBody}, - AllowAwait, AllowIn, AllowYield, Cursor, ParseError, ParseResult, TokenParser, - }, + +use crate::syntax::{ + ast::{ + node::{self, FunctionExpr, Identifier, MethodDefinitionKind, Node, Object}, + Keyword, Position, Punctuator, + }, + lexer::{Error as LexError, TokenKind}, + parser::{ + expression::AssignmentExpression, + function::{FormalParameters, FunctionBody}, + AllowAwait, AllowIn, AllowYield, Cursor, ParseError, ParseResult, TokenParser, }, - BoaProfiler, Interner, }; -use boa_interner::Sym; +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Parses an object literal. @@ -66,7 +65,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ObjectLiteral", "Parsing"); + let _timer = Profiler::global().start_event("ObjectLiteral", "Parsing"); let mut elements = Vec::new(); loop { @@ -135,7 +134,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("PropertyDefinition", "Parsing"); + let _timer = Profiler::global().start_event("PropertyDefinition", "Parsing"); // IdentifierReference[?Yield, ?Await] if let Some(next_token) = cursor.peek(1, interner)? { @@ -634,7 +633,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("PropertyName", "Parsing"); + let _timer = Profiler::global().start_event("PropertyName", "Parsing"); // ComputedPropertyName[?Yield, ?Await] -> [ AssignmentExpression[+In, ?Yield, ?Await] ] if cursor.next_if(Punctuator::OpenBracket, interner)?.is_some() { @@ -697,7 +696,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("Initializer", "Parsing"); + let _timer = Profiler::global().start_event("Initializer", "Parsing"); cursor.expect(Punctuator::Assign, "initializer", interner)?; AssignmentExpression::new(self.name, self.allow_in, self.allow_yield, self.allow_await) diff --git a/boa/src/syntax/parser/expression/primary/object_initializer/tests.rs b/boa_engine/src/syntax/parser/expression/primary/object_initializer/tests.rs similarity index 97% rename from boa/src/syntax/parser/expression/primary/object_initializer/tests.rs rename to boa_engine/src/syntax/parser/expression/primary/object_initializer/tests.rs index bdfbe9c0514..60681cfb774 100644 --- a/boa/src/syntax/parser/expression/primary/object_initializer/tests.rs +++ b/boa_engine/src/syntax/parser/expression/primary/object_initializer/tests.rs @@ -1,16 +1,14 @@ -use crate::{ - syntax::{ - ast::{ - node::{ - Declaration, DeclarationList, FormalParameter, FunctionExpr, Identifier, - MethodDefinitionKind, Object, PropertyDefinition, - }, - Const, +use crate::syntax::{ + ast::{ + node::{ + Declaration, DeclarationList, FormalParameter, FunctionExpr, Identifier, + MethodDefinitionKind, Object, PropertyDefinition, }, - parser::tests::{check_invalid, check_parser}, + Const, }, - Interner, + parser::tests::{check_invalid, check_parser}, }; +use boa_interner::Interner; /// Checks object literal parsing. #[test] diff --git a/boa/src/syntax/parser/expression/primary/template/mod.rs b/boa_engine/src/syntax/parser/expression/primary/template/mod.rs similarity index 89% rename from boa/src/syntax/parser/expression/primary/template/mod.rs rename to boa_engine/src/syntax/parser/expression/primary/template/mod.rs index e5ca389030e..e1760d62c6f 100644 --- a/boa/src/syntax/parser/expression/primary/template/mod.rs +++ b/boa_engine/src/syntax/parser/expression/primary/template/mod.rs @@ -7,18 +7,16 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals //! [spec]: https://tc39.es/ecma262/#sec-template-literals -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{ - node::template::{TemplateElement, TemplateLit}, - Position, Punctuator, - }, - lexer::TokenKind, - parser::{expression::Expression, AllowAwait, AllowYield, Cursor, ParseError, TokenParser}, +use crate::syntax::{ + ast::{ + node::template::{TemplateElement, TemplateLit}, + Position, Punctuator, }, + lexer::TokenKind, + parser::{expression::Expression, AllowAwait, AllowYield, Cursor, ParseError, TokenParser}, }; use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Parses a template literal. @@ -64,7 +62,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("TemplateLiteral", "Parsing"); + let _timer = Profiler::global().start_event("TemplateLiteral", "Parsing"); let mut elements = vec![ TemplateElement::String(self.first), diff --git a/boa/src/syntax/parser/expression/primary/tests.rs b/boa_engine/src/syntax/parser/expression/primary/tests.rs similarity index 80% rename from boa/src/syntax/parser/expression/primary/tests.rs rename to boa_engine/src/syntax/parser/expression/primary/tests.rs index 691b29d2c54..cbbda4fd169 100644 --- a/boa/src/syntax/parser/expression/primary/tests.rs +++ b/boa_engine/src/syntax/parser/expression/primary/tests.rs @@ -1,9 +1,5 @@ -use boa_interner::Sym; - -use crate::{ - syntax::{ast::Const, parser::tests::check_parser}, - Interner, -}; +use crate::syntax::{ast::Const, parser::tests::check_parser}; +use boa_interner::{Interner, Sym}; #[test] fn check_string() { diff --git a/boa/src/syntax/parser/expression/tests.rs b/boa_engine/src/syntax/parser/expression/tests.rs similarity index 98% rename from boa/src/syntax/parser/expression/tests.rs rename to boa_engine/src/syntax/parser/expression/tests.rs index 836a093888c..bddc26a8ec5 100644 --- a/boa/src/syntax/parser/expression/tests.rs +++ b/boa_engine/src/syntax/parser/expression/tests.rs @@ -1,14 +1,12 @@ -use crate::{ - syntax::{ - ast::op::{AssignOp, BitOp, CompOp, LogOp, NumOp}, - ast::{ - node::{BinOp, Identifier}, - Const, - }, - parser::tests::{check_invalid, check_parser}, +use crate::syntax::{ + ast::op::{AssignOp, BitOp, CompOp, LogOp, NumOp}, + ast::{ + node::{BinOp, Identifier}, + Const, }, - Interner, + parser::tests::{check_invalid, check_parser}, }; +use boa_interner::Interner; /// Checks numeric operations #[test] diff --git a/boa/src/syntax/parser/expression/unary.rs b/boa_engine/src/syntax/parser/expression/unary.rs similarity index 88% rename from boa/src/syntax/parser/expression/unary.rs rename to boa_engine/src/syntax/parser/expression/unary.rs index 4255e620721..b4cdb370456 100644 --- a/boa/src/syntax/parser/expression/unary.rs +++ b/boa_engine/src/syntax/parser/expression/unary.rs @@ -7,22 +7,20 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Unary //! [spec]: https://tc39.es/ecma262/#sec-unary-operators -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{ - node::{self, Node}, - op::UnaryOp, - Keyword, Punctuator, - }, - lexer::{Error as LexError, TokenKind}, - parser::{ - expression::update::UpdateExpression, AllowAwait, AllowYield, Cursor, ParseError, - ParseResult, TokenParser, - }, +use crate::syntax::{ + ast::{ + node::{self, Node}, + op::UnaryOp, + Keyword, Punctuator, + }, + lexer::{Error as LexError, TokenKind}, + parser::{ + expression::update::UpdateExpression, AllowAwait, AllowYield, Cursor, ParseError, + ParseResult, TokenParser, }, - Interner, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a unary expression. @@ -60,7 +58,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("UnaryExpression", "Parsing"); + let _timer = Profiler::global().start_event("UnaryExpression", "Parsing"); let tok = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; let token_start = tok.span().start(); diff --git a/boa/src/syntax/parser/expression/update.rs b/boa_engine/src/syntax/parser/expression/update.rs similarity index 91% rename from boa/src/syntax/parser/expression/update.rs rename to boa_engine/src/syntax/parser/expression/update.rs index a8dc2855561..76ef9fe8543 100644 --- a/boa/src/syntax/parser/expression/update.rs +++ b/boa_engine/src/syntax/parser/expression/update.rs @@ -5,22 +5,17 @@ //! //! [spec]: https://tc39.es/ecma262/#sec-update-expressions -use boa_interner::Sym; - use super::left_hand_side::LeftHandSideExpression; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{node, op::UnaryOp, Node, Punctuator}, - lexer::{Error as LexError, TokenKind}, - parser::{ - expression::unary::UnaryExpression, AllowAwait, AllowYield, Cursor, ParseError, - ParseResult, TokenParser, - }, +use crate::syntax::{ + ast::{node, op::UnaryOp, Node, Punctuator}, + lexer::{Error as LexError, TokenKind}, + parser::{ + expression::unary::UnaryExpression, AllowAwait, AllowYield, Cursor, ParseError, + ParseResult, TokenParser, }, - Interner, }; - +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Parses an update expression. @@ -56,7 +51,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("UpdateExpression", "Parsing"); + let _timer = Profiler::global().start_event("UpdateExpression", "Parsing"); let tok = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; match tok.kind() { diff --git a/boa/src/syntax/parser/function/mod.rs b/boa_engine/src/syntax/parser/function/mod.rs similarity index 94% rename from boa/src/syntax/parser/function/mod.rs rename to boa_engine/src/syntax/parser/function/mod.rs index 22a34b96734..ba84c874195 100644 --- a/boa/src/syntax/parser/function/mod.rs +++ b/boa_engine/src/syntax/parser/function/mod.rs @@ -10,21 +10,17 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{node, node::declaration::Declaration, Punctuator}, - lexer::{Error as LexError, InputElement, TokenKind}, - parser::{ - expression::Initializer, - statement::{ - ArrayBindingPattern, BindingIdentifier, ObjectBindingPattern, StatementList, - }, - AllowAwait, AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node, node::declaration::Declaration, Punctuator}, + lexer::{Error as LexError, InputElement, TokenKind}, + parser::{ + expression::Initializer, + statement::{ArrayBindingPattern, BindingIdentifier, ObjectBindingPattern, StatementList}, + AllowAwait, AllowYield, Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; -use boa_interner::Sym; +use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use rustc_hash::FxHashSet; use std::io::Read; @@ -74,7 +70,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("FormalParameters", "Parsing"); + let _timer = Profiler::global().start_event("FormalParameters", "Parsing"); cursor.set_goal(InputElement::RegExp); let mut params = Vec::new(); @@ -214,7 +210,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("BindingRestElement", "Parsing"); + let _timer = Profiler::global().start_event("BindingRestElement", "Parsing"); cursor.expect(Punctuator::Spread, "rest parameter", interner)?; if let Some(t) = cursor.peek(0, interner)? { @@ -314,7 +310,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("FormalParameter", "Parsing"); + let _timer = Profiler::global().start_event("FormalParameter", "Parsing"); if let Some(t) = cursor.peek(0, interner)? { let declaration = match *t.kind() { @@ -423,7 +419,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("FunctionStatementList", "Parsing"); + let _timer = Profiler::global().start_event("FunctionStatementList", "Parsing"); let global_strict_mode = cursor.strict_mode(); let mut strict = false; diff --git a/boa/src/syntax/parser/function/tests.rs b/boa_engine/src/syntax/parser/function/tests.rs similarity index 98% rename from boa/src/syntax/parser/function/tests.rs rename to boa_engine/src/syntax/parser/function/tests.rs index 155dbd56a09..b58d5fa0c31 100644 --- a/boa/src/syntax/parser/function/tests.rs +++ b/boa_engine/src/syntax/parser/function/tests.rs @@ -1,14 +1,12 @@ -use crate::{ - syntax::{ - ast::node::{ - ArrowFunctionDecl, BinOp, Declaration, DeclarationList, FormalParameter, FunctionDecl, - Identifier, Node, Return, - }, - ast::op::NumOp, - parser::{tests::check_parser, Parser}, +use crate::syntax::{ + ast::node::{ + ArrowFunctionDecl, BinOp, Declaration, DeclarationList, FormalParameter, FunctionDecl, + Identifier, Node, Return, }, - Interner, + ast::op::NumOp, + parser::{tests::check_parser, Parser}, }; +use boa_interner::Interner; /// Checks basic function declaration parsing. #[test] diff --git a/boa/src/syntax/parser/mod.rs b/boa_engine/src/syntax/parser/mod.rs similarity index 97% rename from boa/src/syntax/parser/mod.rs rename to boa_engine/src/syntax/parser/mod.rs index a451b035664..7674f9d2e5c 100644 --- a/boa/src/syntax/parser/mod.rs +++ b/boa_engine/src/syntax/parser/mod.rs @@ -9,13 +9,10 @@ mod statement; mod tests; pub use self::error::{ParseError, ParseResult}; -use crate::{ - syntax::{ast::node::StatementList, lexer::TokenKind}, - Interner, -}; - -use cursor::Cursor; +use self::cursor::Cursor; +use crate::syntax::{ast::node::StatementList, lexer::TokenKind}; +use boa_interner::Interner; use std::io::Read; /// Trait implemented by parsers. diff --git a/boa/src/syntax/parser/statement/block/mod.rs b/boa_engine/src/syntax/parser/statement/block/mod.rs similarity index 89% rename from boa/src/syntax/parser/statement/block/mod.rs rename to boa_engine/src/syntax/parser/statement/block/mod.rs index f3452a18779..4ef128d20e2 100644 --- a/boa/src/syntax/parser/statement/block/mod.rs +++ b/boa_engine/src/syntax/parser/statement/block/mod.rs @@ -11,16 +11,13 @@ mod tests; use super::StatementList; -use crate::{ - profiler::BoaProfiler, - syntax::{ - ast::{node, Punctuator}, - lexer::TokenKind, - parser::{AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser}, - }, - Interner, +use crate::syntax::{ + ast::{node, Punctuator}, + lexer::TokenKind, + parser::{AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser}, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// The possible `TokenKind` which indicate the end of a block statement. @@ -76,7 +73,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("Block", "Parsing"); + let _timer = Profiler::global().start_event("Block", "Parsing"); cursor.expect(Punctuator::OpenBlock, "block", interner)?; if let Some(tk) = cursor.peek(0, interner)? { if tk.kind() == &TokenKind::Punctuator(Punctuator::CloseBlock) { diff --git a/boa/src/syntax/parser/statement/block/tests.rs b/boa_engine/src/syntax/parser/statement/block/tests.rs similarity index 92% rename from boa/src/syntax/parser/statement/block/tests.rs rename to boa_engine/src/syntax/parser/statement/block/tests.rs index 30d95a8bfe5..a499a9e12c2 100644 --- a/boa/src/syntax/parser/statement/block/tests.rs +++ b/boa_engine/src/syntax/parser/statement/block/tests.rs @@ -1,18 +1,16 @@ //! Block statement parsing tests. -use crate::{ - syntax::{ - ast::{ - node::{ - Assign, Block, Call, Declaration, DeclarationList, FunctionDecl, Identifier, Node, - Return, UnaryOp, - }, - op, Const, +use crate::syntax::{ + ast::{ + node::{ + Assign, Block, Call, Declaration, DeclarationList, FunctionDecl, Identifier, Node, + Return, UnaryOp, }, - parser::tests::check_parser, + op, Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; /// Helper function to check a block. // TODO: #[track_caller]: https://github.com/rust-lang/rust/issues/47809 diff --git a/boa/src/syntax/parser/statement/break_stm/mod.rs b/boa_engine/src/syntax/parser/statement/break_stm/mod.rs similarity index 84% rename from boa/src/syntax/parser/statement/break_stm/mod.rs rename to boa_engine/src/syntax/parser/statement/break_stm/mod.rs index c842fb24f5b..efdb435404c 100644 --- a/boa/src/syntax/parser/statement/break_stm/mod.rs +++ b/boa_engine/src/syntax/parser/statement/break_stm/mod.rs @@ -11,20 +11,16 @@ mod tests; use super::LabelIdentifier; - -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{node::Break, Keyword, Punctuator}, - parser::{ - cursor::{Cursor, SemicolonResult}, - AllowAwait, AllowYield, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::Break, Keyword, Punctuator}, + lexer::TokenKind, + parser::{ + cursor::{Cursor, SemicolonResult}, + AllowAwait, AllowYield, ParseError, TokenParser, }, - BoaProfiler, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Break statement parsing @@ -66,7 +62,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("BreakStatement", "Parsing"); + let _timer = Profiler::global().start_event("BreakStatement", "Parsing"); cursor.expect(Keyword::Break, "break statement", interner)?; let label = if let SemicolonResult::Found(tok) = cursor.peek_semicolon(interner)? { diff --git a/boa/src/syntax/parser/statement/break_stm/tests.rs b/boa_engine/src/syntax/parser/statement/break_stm/tests.rs similarity index 95% rename from boa/src/syntax/parser/statement/break_stm/tests.rs rename to boa_engine/src/syntax/parser/statement/break_stm/tests.rs index a6eb3786767..b0c630cdcce 100644 --- a/boa/src/syntax/parser/statement/break_stm/tests.rs +++ b/boa_engine/src/syntax/parser/statement/break_stm/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{Block, Break, Node, WhileLoop}, - Const, - }, - parser::tests::check_parser, +use crate::syntax::{ + ast::{ + node::{Block, Break, Node, WhileLoop}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; #[test] fn inline() { diff --git a/boa/src/syntax/parser/statement/continue_stm/mod.rs b/boa_engine/src/syntax/parser/statement/continue_stm/mod.rs similarity index 82% rename from boa/src/syntax/parser/statement/continue_stm/mod.rs rename to boa_engine/src/syntax/parser/statement/continue_stm/mod.rs index 379ba78c92e..5a8fecee721 100644 --- a/boa/src/syntax/parser/statement/continue_stm/mod.rs +++ b/boa_engine/src/syntax/parser/statement/continue_stm/mod.rs @@ -10,20 +10,17 @@ #[cfg(test)] mod tests; -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{node::Continue, Keyword, Punctuator}, - parser::{ - cursor::{Cursor, SemicolonResult}, - statement::LabelIdentifier, - AllowAwait, AllowYield, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::Continue, Keyword, Punctuator}, + lexer::TokenKind, + parser::{ + cursor::{Cursor, SemicolonResult}, + statement::LabelIdentifier, + AllowAwait, AllowYield, ParseError, TokenParser, }, - BoaProfiler, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// For statement parsing @@ -65,7 +62,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ContinueStatement", "Parsing"); + let _timer = Profiler::global().start_event("ContinueStatement", "Parsing"); cursor.expect(Keyword::Continue, "continue statement", interner)?; let label = if let SemicolonResult::Found(tok) = cursor.peek_semicolon(interner)? { diff --git a/boa/src/syntax/parser/statement/continue_stm/tests.rs b/boa_engine/src/syntax/parser/statement/continue_stm/tests.rs similarity index 95% rename from boa/src/syntax/parser/statement/continue_stm/tests.rs rename to boa_engine/src/syntax/parser/statement/continue_stm/tests.rs index b56c9ef0992..5c5f6a07a69 100644 --- a/boa/src/syntax/parser/statement/continue_stm/tests.rs +++ b/boa_engine/src/syntax/parser/statement/continue_stm/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{Block, Continue, WhileLoop}, - Const, - }, - parser::tests::check_parser, +use crate::syntax::{ + ast::{ + node::{Block, Continue, WhileLoop}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; #[test] fn inline() { diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs similarity index 88% rename from boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs index e3cbe35c069..a068bae3f6c 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/mod.rs @@ -1,16 +1,14 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{node::AsyncFunctionDecl, Keyword}, - parser::{ - statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, - AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::AsyncFunctionDecl, Keyword}, + parser::{ + statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, + AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, }, - Interner, }; +use boa_interner::Interner; use std::io::Read; /// Async Function declaration parsing. diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/tests.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/tests.rs similarity index 89% rename from boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/tests.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/tests.rs index a4ba0014d76..2446bcd0b51 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/async_function_decl/tests.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_function_decl/tests.rs @@ -1,7 +1,5 @@ -use crate::{ - syntax::{ast::node::AsyncFunctionDecl, parser::tests::check_parser}, - Interner, -}; +use crate::syntax::{ast::node::AsyncFunctionDecl, parser::tests::check_parser}; +use boa_interner::Interner; /// Async function declaration parsing. #[test] diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs similarity index 88% rename from boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs index 5bd39f25570..276e33d0b42 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/mod.rs @@ -5,16 +5,15 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{node::AsyncGeneratorDecl, Keyword, Punctuator}, - parser::{ - statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, - AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, - }, + +use crate::syntax::{ + ast::{node::AsyncGeneratorDecl, Keyword, Punctuator}, + parser::{ + statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, + AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, }, - Interner, }; +use boa_interner::Interner; use std::io::Read; /// Async Generator Declaration Parser diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/tests.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/tests.rs similarity index 72% rename from boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/tests.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/tests.rs index 2918edc3b13..23864263ec2 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/tests.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/async_generator_decl/tests.rs @@ -1,7 +1,5 @@ -use crate::{ - syntax::{ast::node::AsyncGeneratorDecl, parser::tests::check_parser}, - Interner, -}; +use crate::syntax::{ast::node::AsyncGeneratorDecl, parser::tests::check_parser}; +use boa_interner::Interner; #[test] fn async_generator_function_declaration() { diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs similarity index 87% rename from boa/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs index 1793900c668..14d526164e1 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/function_decl/mod.rs @@ -1,16 +1,14 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{node::FunctionDecl, Keyword}, - parser::{ - statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, - AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::FunctionDecl, Keyword}, + parser::{ + statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, + AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, }, - Interner, }; +use boa_interner::Interner; use std::io::Read; /// Function declaration parsing. diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs similarity index 88% rename from boa/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs index fd0e479c4af..1c556b9517a 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/function_decl/tests.rs @@ -1,7 +1,5 @@ -use crate::{ - syntax::{ast::node::FunctionDecl, parser::tests::check_parser}, - Interner, -}; +use crate::syntax::{ast::node::FunctionDecl, parser::tests::check_parser}; +use boa_interner::Interner; /// Function declaration parsing. #[test] diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/generator_decl/mod.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/generator_decl/mod.rs similarity index 86% rename from boa/src/syntax/parser/statement/declaration/hoistable/generator_decl/mod.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/generator_decl/mod.rs index e82979d717c..40c4d1166d8 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/generator_decl/mod.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/generator_decl/mod.rs @@ -1,16 +1,14 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{node::declaration::generator_decl::GeneratorDecl, Keyword, Punctuator}, - parser::{ - statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, - AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::declaration::generator_decl::GeneratorDecl, Keyword, Punctuator}, + parser::{ + statement::declaration::hoistable::{parse_callable_declaration, CallableDeclaration}, + AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, TokenParser, }, - Interner, }; +use boa_interner::Interner; use std::io::Read; /// Generator declaration parsing. diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/generator_decl/tests.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/generator_decl/tests.rs similarity index 71% rename from boa/src/syntax/parser/statement/declaration/hoistable/generator_decl/tests.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/generator_decl/tests.rs index 1825e6dd7b4..01332fbe62d 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/generator_decl/tests.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/generator_decl/tests.rs @@ -1,7 +1,5 @@ -use crate::{ - syntax::{ast::node::GeneratorDecl, parser::tests::check_parser}, - Interner, -}; +use crate::syntax::{ast::node::GeneratorDecl, parser::tests::check_parser}; +use boa_interner::Interner; #[test] fn generator_function_declaration() { diff --git a/boa/src/syntax/parser/statement/declaration/hoistable/mod.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/mod.rs similarity index 92% rename from boa/src/syntax/parser/statement/declaration/hoistable/mod.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/mod.rs index ff409a95de4..febf8ad3863 100644 --- a/boa/src/syntax/parser/statement/declaration/hoistable/mod.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/hoistable/mod.rs @@ -13,27 +13,26 @@ mod async_generator_decl; mod function_decl; mod generator_decl; -use async_function_decl::AsyncFunctionDeclaration; -use async_generator_decl::AsyncGeneratorDeclaration; -pub(in crate::syntax::parser) use function_decl::FunctionDeclaration; -use generator_decl::GeneratorDeclaration; - -use crate::{ - syntax::{ - ast::node::{FormalParameter, StatementList}, - ast::{Keyword, Node, Punctuator}, - lexer::{Position, TokenKind}, - parser::{ - function::{FormalParameters, FunctionBody}, - statement::{BindingIdentifier, LexError}, - AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, ParseResult, TokenParser, - }, +use self::{ + async_function_decl::AsyncFunctionDeclaration, async_generator_decl::AsyncGeneratorDeclaration, + generator_decl::GeneratorDeclaration, +}; +use crate::syntax::{ + ast::node::{FormalParameter, StatementList}, + ast::{Keyword, Node, Position, Punctuator}, + lexer::TokenKind, + parser::{ + function::{FormalParameters, FunctionBody}, + statement::{BindingIdentifier, LexError}, + AllowAwait, AllowDefault, AllowYield, Cursor, ParseError, ParseResult, TokenParser, }, - BoaProfiler, }; use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; +pub(in crate::syntax::parser) use function_decl::FunctionDeclaration; + /// Hoistable declaration parsing. /// /// More information: @@ -70,7 +69,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("HoistableDeclaration", "Parsing"); + let _timer = Profiler::global().start_event("HoistableDeclaration", "Parsing"); let tok = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; match tok.kind() { diff --git a/boa/src/syntax/parser/statement/return_stm/tests.rs b/boa_engine/src/syntax/parser/statement/declaration/hoistable/tests.rs similarity index 100% rename from boa/src/syntax/parser/statement/return_stm/tests.rs rename to boa_engine/src/syntax/parser/statement/declaration/hoistable/tests.rs diff --git a/boa/src/syntax/parser/statement/declaration/lexical.rs b/boa_engine/src/syntax/parser/statement/declaration/lexical.rs similarity index 92% rename from boa/src/syntax/parser/statement/declaration/lexical.rs rename to boa_engine/src/syntax/parser/statement/declaration/lexical.rs index fa8c11c00d2..cccaef84e1f 100644 --- a/boa/src/syntax/parser/statement/declaration/lexical.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/lexical.rs @@ -7,26 +7,24 @@ //! //! [spec]: https://tc39.es/ecma262/#sec-let-and-const-declarations -use crate::{ - syntax::{ - ast::{ - node::{ - declaration::{Declaration, DeclarationList}, - Node, - }, - Keyword, Punctuator, - }, - lexer::TokenKind, - parser::{ - cursor::{Cursor, SemicolonResult}, - expression::Initializer, - statement::{ArrayBindingPattern, BindingIdentifier, ObjectBindingPattern}, - AllowAwait, AllowIn, AllowYield, ParseError, ParseResult, TokenParser, +use crate::syntax::{ + ast::{ + node::{ + declaration::{Declaration, DeclarationList}, + Node, }, + Keyword, Punctuator, + }, + lexer::TokenKind, + parser::{ + cursor::{Cursor, SemicolonResult}, + expression::Initializer, + statement::{ArrayBindingPattern, BindingIdentifier, ObjectBindingPattern}, + AllowAwait, AllowIn, AllowYield, ParseError, ParseResult, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a lexical declaration. @@ -72,7 +70,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("LexicalDeclaration", "Parsing"); + let _timer = Profiler::global().start_event("LexicalDeclaration", "Parsing"); let tok = cursor.next(interner)?.ok_or(ParseError::AbruptEnd)?; match tok.kind() { @@ -146,7 +144,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("BindingList", "Parsing"); + let _timer = Profiler::global().start_event("BindingList", "Parsing"); // Create vectors to store the variable declarations // Const and Let signatures are slightly different, Const needs definitions, Lets don't @@ -256,7 +254,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("LexicalBinding", "Parsing"); + let _timer = Profiler::global().start_event("LexicalBinding", "Parsing"); let peek_token = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; diff --git a/boa/src/syntax/parser/statement/declaration/mod.rs b/boa_engine/src/syntax/parser/statement/declaration/mod.rs similarity index 87% rename from boa/src/syntax/parser/statement/declaration/mod.rs rename to boa_engine/src/syntax/parser/statement/declaration/mod.rs index 7404fd45aed..da85466f68c 100644 --- a/boa/src/syntax/parser/statement/declaration/mod.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/mod.rs @@ -13,17 +13,13 @@ mod lexical; mod tests; use self::{hoistable::HoistableDeclaration, lexical::LexicalDeclaration}; - -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{Keyword, Node}, - parser::{AllowAwait, AllowYield, Cursor, ParseError, TokenParser}, - }, - BoaProfiler, +use crate::syntax::{ + ast::{Keyword, Node}, + lexer::TokenKind, + parser::{AllowAwait, AllowYield, Cursor, ParseError, TokenParser}, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Parses a declaration. @@ -64,7 +60,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("Declaration", "Parsing"); + let _timer = Profiler::global().start_event("Declaration", "Parsing"); let tok = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; match tok.kind() { diff --git a/boa/src/syntax/parser/statement/declaration/tests.rs b/boa_engine/src/syntax/parser/statement/declaration/tests.rs similarity index 97% rename from boa/src/syntax/parser/statement/declaration/tests.rs rename to boa_engine/src/syntax/parser/statement/declaration/tests.rs index b3e26d47db8..379a238e221 100644 --- a/boa/src/syntax/parser/statement/declaration/tests.rs +++ b/boa_engine/src/syntax/parser/statement/declaration/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{Declaration, DeclarationList, Node}, - Const, - }, - parser::tests::{check_invalid, check_parser}, +use crate::syntax::{ + ast::{ + node::{Declaration, DeclarationList, Node}, + Const, }, - Interner, + parser::tests::{check_invalid, check_parser}, }; +use boa_interner::Interner; /// Checks `var` declaration parsing. #[test] diff --git a/boa/src/syntax/parser/statement/expression/mod.rs b/boa_engine/src/syntax/parser/statement/expression/mod.rs similarity index 87% rename from boa/src/syntax/parser/statement/expression/mod.rs rename to boa_engine/src/syntax/parser/statement/expression/mod.rs index a45ef35a796..8d9659a94ca 100644 --- a/boa/src/syntax/parser/statement/expression/mod.rs +++ b/boa_engine/src/syntax/parser/statement/expression/mod.rs @@ -1,12 +1,13 @@ -use super::super::{expression::Expression, ParseResult}; -use crate::{ - syntax::{ - ast::{node::Node, Keyword, Punctuator}, - lexer::TokenKind, - parser::{AllowAwait, AllowYield, Cursor, ParseError, TokenParser}, +use crate::syntax::{ + ast::{node::Node, Keyword, Punctuator}, + lexer::TokenKind, + parser::{ + expression::Expression, AllowAwait, AllowYield, Cursor, ParseError, ParseResult, + TokenParser, }, - BoaProfiler, Interner, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Expression statement parsing. @@ -42,7 +43,7 @@ where type Output = Node; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { - let _timer = BoaProfiler::global().start_event("ExpressionStatement", "Parsing"); + let _timer = Profiler::global().start_event("ExpressionStatement", "Parsing"); let next_token = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; match next_token.kind() { diff --git a/boa/src/syntax/parser/statement/if_stm/mod.rs b/boa_engine/src/syntax/parser/statement/if_stm/mod.rs similarity index 90% rename from boa/src/syntax/parser/statement/if_stm/mod.rs rename to boa_engine/src/syntax/parser/statement/if_stm/mod.rs index a23164bc07c..df658cf37b8 100644 --- a/boa/src/syntax/parser/statement/if_stm/mod.rs +++ b/boa_engine/src/syntax/parser/statement/if_stm/mod.rs @@ -1,18 +1,17 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{node::If, Keyword, Node, Punctuator}, - lexer::TokenKind, - parser::{ - expression::Expression, - statement::{declaration::hoistable::FunctionDeclaration, Statement}, - AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::If, Keyword, Node, Punctuator}, + lexer::TokenKind, + parser::{ + expression::Expression, + statement::{declaration::hoistable::FunctionDeclaration, Statement}, + AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// If statement parsing. @@ -59,7 +58,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("IfStatement", "Parsing"); + let _timer = Profiler::global().start_event("IfStatement", "Parsing"); cursor.expect(Keyword::If, "if statement", interner)?; cursor.expect(Punctuator::OpenParen, "if statement", interner)?; diff --git a/boa/src/syntax/parser/statement/if_stm/tests.rs b/boa_engine/src/syntax/parser/statement/if_stm/tests.rs similarity index 77% rename from boa/src/syntax/parser/statement/if_stm/tests.rs rename to boa_engine/src/syntax/parser/statement/if_stm/tests.rs index 4710fe1d78e..fcb3ea69e69 100644 --- a/boa/src/syntax/parser/statement/if_stm/tests.rs +++ b/boa_engine/src/syntax/parser/statement/if_stm/tests.rs @@ -1,13 +1,11 @@ -use crate::{ - syntax::{ - ast::{ - node::{Block, If, Node}, - Const, - }, - parser::tests::check_parser, +use crate::syntax::{ + ast::{ + node::{Block, If, Node}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; #[test] fn if_without_else_block() { diff --git a/boa/src/syntax/parser/statement/iteration/do_while_statement.rs b/boa_engine/src/syntax/parser/statement/iteration/do_while_statement.rs similarity index 89% rename from boa/src/syntax/parser/statement/iteration/do_while_statement.rs rename to boa_engine/src/syntax/parser/statement/iteration/do_while_statement.rs index 6bf5b673bf0..b8cd8201149 100644 --- a/boa/src/syntax/parser/statement/iteration/do_while_statement.rs +++ b/boa_engine/src/syntax/parser/statement/iteration/do_while_statement.rs @@ -7,17 +7,16 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while //! [spec]: https://tc39.es/ecma262/#sec-do-while-statement -use crate::{ - syntax::{ - ast::{node::DoWhileLoop, Keyword, Node, Punctuator}, - lexer::TokenKind, - parser::{ - expression::Expression, statement::Statement, AllowAwait, AllowReturn, AllowYield, - Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::DoWhileLoop, Keyword, Node, Punctuator}, + lexer::TokenKind, + parser::{ + expression::Expression, statement::Statement, AllowAwait, AllowReturn, AllowYield, Cursor, + ParseError, TokenParser, }, - BoaProfiler, Interner, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Do...while statement parsing @@ -66,7 +65,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("DoWhileStatement", "Parsing"); + let _timer = Profiler::global().start_event("DoWhileStatement", "Parsing"); let position = cursor .expect(Keyword::Do, "do while statement", interner)? diff --git a/boa/src/syntax/parser/statement/iteration/for_statement.rs b/boa_engine/src/syntax/parser/statement/iteration/for_statement.rs similarity index 93% rename from boa/src/syntax/parser/statement/iteration/for_statement.rs rename to boa_engine/src/syntax/parser/statement/iteration/for_statement.rs index 8f90dc817e0..2bd25c803ae 100644 --- a/boa/src/syntax/parser/statement/iteration/for_statement.rs +++ b/boa_engine/src/syntax/parser/statement/iteration/for_statement.rs @@ -7,22 +7,21 @@ //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for //! [spec]: https://tc39.es/ecma262/#sec-for-statement -use crate::{ - syntax::{ - ast::{ - node::{iteration::IterableLoopInitializer, ForInLoop, ForLoop, ForOfLoop, Node}, - Const, Keyword, Punctuator, - }, - lexer::{Error as LexError, Position, TokenKind}, - parser::{ - expression::Expression, - statement::declaration::Declaration, - statement::{variable::VariableDeclarationList, Statement}, - AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{ + node::{iteration::IterableLoopInitializer, ForInLoop, ForLoop, ForOfLoop, Node}, + Const, Keyword, Position, Punctuator, + }, + lexer::{Error as LexError, TokenKind}, + parser::{ + expression::Expression, + statement::declaration::Declaration, + statement::{variable::VariableDeclarationList, Statement}, + AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// For statement parsing @@ -71,7 +70,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ForStatement", "Parsing"); + let _timer = Profiler::global().start_event("ForStatement", "Parsing"); cursor.expect(Keyword::For, "for statement", interner)?; let init_position = cursor .expect(Punctuator::OpenParen, "for statement", interner)? diff --git a/boa/src/syntax/parser/statement/iteration/mod.rs b/boa_engine/src/syntax/parser/statement/iteration/mod.rs similarity index 100% rename from boa/src/syntax/parser/statement/iteration/mod.rs rename to boa_engine/src/syntax/parser/statement/iteration/mod.rs diff --git a/boa/src/syntax/parser/statement/iteration/tests.rs b/boa_engine/src/syntax/parser/statement/iteration/tests.rs similarity index 93% rename from boa/src/syntax/parser/statement/iteration/tests.rs rename to boa_engine/src/syntax/parser/statement/iteration/tests.rs index 9cee454525a..a6ad01c4296 100644 --- a/boa/src/syntax/parser/statement/iteration/tests.rs +++ b/boa_engine/src/syntax/parser/statement/iteration/tests.rs @@ -1,17 +1,15 @@ -use crate::{ - syntax::{ - ast::{ - node::{ - field::GetConstField, BinOp, Block, Break, Call, Declaration, DeclarationList, - DoWhileLoop, Identifier, UnaryOp, WhileLoop, - }, - op::{self, AssignOp, CompOp}, - Const, +use crate::syntax::{ + ast::{ + node::{ + field::GetConstField, BinOp, Block, Break, Call, Declaration, DeclarationList, + DoWhileLoop, Identifier, UnaryOp, WhileLoop, }, - parser::tests::check_parser, + op::{self, AssignOp, CompOp}, + Const, }, - Interner, + parser::tests::check_parser, }; +use boa_interner::Interner; /// Checks do-while statement parsing. #[test] diff --git a/boa/src/syntax/parser/statement/iteration/while_statement.rs b/boa_engine/src/syntax/parser/statement/iteration/while_statement.rs similarity index 84% rename from boa/src/syntax/parser/statement/iteration/while_statement.rs rename to boa_engine/src/syntax/parser/statement/iteration/while_statement.rs index 682ec1c9d3f..479030fa108 100644 --- a/boa/src/syntax/parser/statement/iteration/while_statement.rs +++ b/boa_engine/src/syntax/parser/statement/iteration/while_statement.rs @@ -1,14 +1,12 @@ -use crate::{ - syntax::{ - ast::{node::WhileLoop, Keyword, Node, Punctuator}, - parser::{ - expression::Expression, statement::Statement, AllowAwait, AllowReturn, AllowYield, - Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::WhileLoop, Keyword, Node, Punctuator}, + parser::{ + expression::Expression, statement::Statement, AllowAwait, AllowReturn, AllowYield, Cursor, + ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// While statement parsing @@ -57,7 +55,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("WhileStatement", "Parsing"); + let _timer = Profiler::global().start_event("WhileStatement", "Parsing"); cursor.expect(Keyword::While, "while statement", interner)?; cursor.expect(Punctuator::OpenParen, "while statement", interner)?; diff --git a/boa/src/syntax/parser/statement/labelled_stm/mod.rs b/boa_engine/src/syntax/parser/statement/labelled_stm/mod.rs similarity index 86% rename from boa/src/syntax/parser/statement/labelled_stm/mod.rs rename to boa_engine/src/syntax/parser/statement/labelled_stm/mod.rs index 3f190597c29..96653887611 100644 --- a/boa/src/syntax/parser/statement/labelled_stm/mod.rs +++ b/boa_engine/src/syntax/parser/statement/labelled_stm/mod.rs @@ -1,20 +1,18 @@ -use crate::{ - syntax::{ - ast::{Keyword, Node, Punctuator}, - lexer::TokenKind, - parser::{ - cursor::Cursor, - error::ParseError, - statement::{ - declaration::hoistable::FunctionDeclaration, AllowAwait, AllowReturn, - LabelIdentifier, Statement, - }, - AllowYield, TokenParser, +use crate::syntax::{ + ast::{Keyword, Node, Punctuator}, + lexer::TokenKind, + parser::{ + cursor::Cursor, + error::ParseError, + statement::{ + declaration::hoistable::FunctionDeclaration, AllowAwait, AllowReturn, LabelIdentifier, + Statement, }, + AllowYield, TokenParser, }, - BoaProfiler, }; use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::io::Read; /// Labelled Statement Parsing @@ -58,7 +56,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("Label", "Parsing"); + let _timer = Profiler::global().start_event("Label", "Parsing"); let name = LabelIdentifier::new(self.allow_yield, self.allow_await).parse(cursor, interner)?; diff --git a/boa/src/syntax/parser/statement/mod.rs b/boa_engine/src/syntax/parser/statement/mod.rs similarity index 97% rename from boa/src/syntax/parser/statement/mod.rs rename to boa_engine/src/syntax/parser/statement/mod.rs index 184c23046c6..6f967ffd732 100644 --- a/boa/src/syntax/parser/statement/mod.rs +++ b/boa_engine/src/syntax/parser/statement/mod.rs @@ -37,24 +37,22 @@ use self::{ variable::VariableStatement, }; use super::{AllowAwait, AllowIn, AllowReturn, AllowYield, Cursor, ParseError, TokenParser}; -use crate::{ - syntax::{ - ast::{ - node::{ - self, - declaration::{ - BindingPatternTypeArray, BindingPatternTypeObject, DeclarationPattern, - DeclarationPatternArray, DeclarationPatternObject, - }, +use crate::syntax::{ + ast::{ + node::{ + self, + declaration::{ + BindingPatternTypeArray, BindingPatternTypeObject, DeclarationPattern, + DeclarationPatternArray, DeclarationPatternObject, }, - Keyword, Node, Punctuator, }, - lexer::{Error as LexError, InputElement, Position, TokenKind}, - parser::expression::{await_expr::AwaitExpression, Initializer}, + Keyword, Node, Position, Punctuator, }, - BoaProfiler, + lexer::{Error as LexError, InputElement, TokenKind}, + parser::expression::{await_expr::AwaitExpression, Initializer}, }; use boa_interner::{Interner, Sym}; +use boa_profiler::Profiler; use std::{collections::HashSet, io::Read, vec}; /// Statement parsing. @@ -117,7 +115,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("Statement", "Parsing"); + let _timer = Profiler::global().start_event("Statement", "Parsing"); // TODO: add BreakableStatement and divide Whiles, fors and so on to another place. let tok = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; @@ -285,7 +283,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("StatementList", "Parsing"); + let _timer = Profiler::global().start_event("StatementList", "Parsing"); let mut items = Vec::new(); loop { @@ -462,7 +460,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("StatementListItem", "Parsing"); + let _timer = Profiler::global().start_event("StatementListItem", "Parsing"); let strict_mode = cursor.strict_mode(); let tok = cursor.peek(0, interner)?.ok_or(ParseError::AbruptEnd)?; @@ -533,7 +531,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("BindingIdentifier", "Parsing"); + let _timer = Profiler::global().start_event("BindingIdentifier", "Parsing"); let next_token = cursor.next(interner)?.ok_or(ParseError::AbruptEnd)?; @@ -623,7 +621,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ObjectBindingPattern", "Parsing"); + let _timer = Profiler::global().start_event("ObjectBindingPattern", "Parsing"); cursor.expect( TokenKind::Punctuator(Punctuator::OpenBlock), @@ -911,7 +909,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ArrayBindingPattern", "Parsing"); + let _timer = Profiler::global().start_event("ArrayBindingPattern", "Parsing"); cursor.expect( TokenKind::Punctuator(Punctuator::OpenBracket), diff --git a/boa/src/syntax/parser/statement/return_stm/mod.rs b/boa_engine/src/syntax/parser/statement/return_stm/mod.rs similarity index 79% rename from boa/src/syntax/parser/statement/return_stm/mod.rs rename to boa_engine/src/syntax/parser/statement/return_stm/mod.rs index 55b15a78c65..eb761f2abce 100644 --- a/boa/src/syntax/parser/statement/return_stm/mod.rs +++ b/boa_engine/src/syntax/parser/statement/return_stm/mod.rs @@ -1,20 +1,14 @@ -#[cfg(test)] -mod tests; - -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{node::Return, Keyword, Node, Punctuator}, - parser::{ - cursor::{Cursor, SemicolonResult}, - expression::Expression, - AllowAwait, AllowYield, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node::Return, Keyword, Node, Punctuator}, + lexer::TokenKind, + parser::{ + cursor::{Cursor, SemicolonResult}, + expression::Expression, + AllowAwait, AllowYield, ParseError, TokenParser, }, - BoaProfiler, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Return statement parsing @@ -56,7 +50,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ReturnStatement", "Parsing"); + let _timer = Profiler::global().start_event("ReturnStatement", "Parsing"); cursor.expect(Keyword::Return, "return statement", interner)?; if let SemicolonResult::Found(tok) = cursor.peek_semicolon(interner)? { diff --git a/boa/src/syntax/parser/statement/switch/mod.rs b/boa_engine/src/syntax/parser/statement/switch/mod.rs similarity index 93% rename from boa/src/syntax/parser/statement/switch/mod.rs rename to boa_engine/src/syntax/parser/statement/switch/mod.rs index a9e9b555ff8..709f9f804e7 100644 --- a/boa/src/syntax/parser/statement/switch/mod.rs +++ b/boa_engine/src/syntax/parser/statement/switch/mod.rs @@ -1,18 +1,16 @@ #[cfg(test)] mod tests; -use crate::{ - syntax::{ - ast::{node, node::Switch, Keyword, Punctuator}, - lexer::TokenKind, - parser::{ - expression::Expression, statement::StatementList, AllowAwait, AllowReturn, AllowYield, - Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{node, node::Switch, Keyword, Punctuator}, + lexer::TokenKind, + parser::{ + expression::Expression, statement::StatementList, AllowAwait, AllowReturn, AllowYield, + Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// The possible `TokenKind` which indicate the end of a case statement. @@ -64,7 +62,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("SwitchStatement", "Parsing"); + let _timer = Profiler::global().start_event("SwitchStatement", "Parsing"); cursor.expect(Keyword::Switch, "switch statement", interner)?; cursor.expect(Punctuator::OpenParen, "switch statement", interner)?; diff --git a/boa/src/syntax/parser/statement/switch/tests.rs b/boa_engine/src/syntax/parser/statement/switch/tests.rs similarity index 93% rename from boa/src/syntax/parser/statement/switch/tests.rs rename to boa_engine/src/syntax/parser/statement/switch/tests.rs index 4c12ce79e30..62abc052a2b 100644 --- a/boa/src/syntax/parser/statement/switch/tests.rs +++ b/boa_engine/src/syntax/parser/statement/switch/tests.rs @@ -1,16 +1,14 @@ -use crate::{ - syntax::{ - ast::{ - node::{ - Break, Call, Case, Declaration, DeclarationList, GetConstField, Identifier, Node, - Switch, - }, - Const, +use crate::syntax::{ + ast::{ + node::{ + Break, Call, Case, Declaration, DeclarationList, GetConstField, Identifier, Node, + Switch, }, - parser::tests::{check_invalid, check_parser}, + Const, }, - Interner, + parser::tests::{check_invalid, check_parser}, }; +use boa_interner::Interner; /// Checks parsing malformed switch with no closeblock. #[test] diff --git a/boa/src/syntax/parser/statement/throw/mod.rs b/boa_engine/src/syntax/parser/statement/throw/mod.rs similarity index 81% rename from boa/src/syntax/parser/statement/throw/mod.rs rename to boa_engine/src/syntax/parser/statement/throw/mod.rs index 98aebd6e7de..67b181a8c1f 100644 --- a/boa/src/syntax/parser/statement/throw/mod.rs +++ b/boa_engine/src/syntax/parser/statement/throw/mod.rs @@ -1,16 +1,13 @@ #[cfg(test)] mod tests; -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{node::Throw, Keyword, Punctuator}, - parser::{expression::Expression, AllowAwait, AllowYield, Cursor, ParseError, TokenParser}, - }, - BoaProfiler, +use crate::syntax::{ + ast::{node::Throw, Keyword, Punctuator}, + lexer::TokenKind, + parser::{expression::Expression, AllowAwait, AllowYield, Cursor, ParseError, TokenParser}, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// For statement parsing @@ -52,7 +49,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("ThrowStatement", "Parsing"); + let _timer = Profiler::global().start_event("ThrowStatement", "Parsing"); cursor.expect(Keyword::Throw, "throw statement", interner)?; cursor.peek_expect_no_lineterminator(0, "throw statement", interner)?; diff --git a/boa/src/syntax/parser/statement/throw/tests.rs b/boa_engine/src/syntax/parser/statement/throw/tests.rs similarity index 67% rename from boa/src/syntax/parser/statement/throw/tests.rs rename to boa_engine/src/syntax/parser/statement/throw/tests.rs index 89951f72ecc..df405820b16 100644 --- a/boa/src/syntax/parser/statement/throw/tests.rs +++ b/boa_engine/src/syntax/parser/statement/throw/tests.rs @@ -1,10 +1,8 @@ -use crate::{ - syntax::{ - ast::{node::Throw, Const}, - parser::tests::check_parser, - }, - Interner, +use crate::syntax::{ + ast::{node::Throw, Const}, + parser::tests::check_parser, }; +use boa_interner::Interner; #[test] fn check_throw_parsing() { diff --git a/boa/src/syntax/parser/statement/try_stm/catch.rs b/boa_engine/src/syntax/parser/statement/try_stm/catch.rs similarity index 92% rename from boa/src/syntax/parser/statement/try_stm/catch.rs rename to boa_engine/src/syntax/parser/statement/try_stm/catch.rs index fa5a8505d04..0fd4a2600df 100644 --- a/boa/src/syntax/parser/statement/try_stm/catch.rs +++ b/boa_engine/src/syntax/parser/statement/try_stm/catch.rs @@ -1,20 +1,16 @@ -use crate::{ - syntax::{ - ast::{ - node::{self, Identifier}, - Keyword, Position, Punctuator, - }, - lexer::TokenKind, - parser::{ - statement::{ - block::Block, ArrayBindingPattern, BindingIdentifier, ObjectBindingPattern, - }, - AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{ + node::{self, Identifier}, + Keyword, Position, Punctuator, + }, + lexer::TokenKind, + parser::{ + statement::{block::Block, ArrayBindingPattern, BindingIdentifier, ObjectBindingPattern}, + AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use rustc_hash::FxHashSet; use std::io::Read; @@ -60,7 +56,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("Catch", "Parsing"); + let _timer = Profiler::global().start_event("Catch", "Parsing"); cursor.expect(Keyword::Catch, "try statement", interner)?; let catch_param = if cursor.next_if(Punctuator::OpenParen, interner)?.is_some() { let catch_param = diff --git a/boa/src/syntax/parser/statement/try_stm/finally.rs b/boa_engine/src/syntax/parser/statement/try_stm/finally.rs similarity index 81% rename from boa/src/syntax/parser/statement/try_stm/finally.rs rename to boa_engine/src/syntax/parser/statement/try_stm/finally.rs index b0d090c7dea..d98ce58fe1f 100644 --- a/boa/src/syntax/parser/statement/try_stm/finally.rs +++ b/boa_engine/src/syntax/parser/statement/try_stm/finally.rs @@ -1,14 +1,12 @@ -use crate::{ - syntax::{ - ast::{node, Keyword}, - parser::{ - statement::block::Block, AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, - TokenParser, - }, +use crate::syntax::{ + ast::{node, Keyword}, + parser::{ + statement::block::Block, AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, + TokenParser, }, - BoaProfiler, Interner, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Finally parsing @@ -53,7 +51,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("Finally", "Parsing"); + let _timer = Profiler::global().start_event("Finally", "Parsing"); cursor.expect(Keyword::Finally, "try statement", interner)?; Ok( Block::new(self.allow_yield, self.allow_await, self.allow_return) diff --git a/boa/src/syntax/parser/statement/try_stm/mod.rs b/boa_engine/src/syntax/parser/statement/try_stm/mod.rs similarity index 87% rename from boa/src/syntax/parser/statement/try_stm/mod.rs rename to boa_engine/src/syntax/parser/statement/try_stm/mod.rs index d381b2f43df..f9eceec294b 100644 --- a/boa/src/syntax/parser/statement/try_stm/mod.rs +++ b/boa_engine/src/syntax/parser/statement/try_stm/mod.rs @@ -4,19 +4,15 @@ mod finally; #[cfg(test)] mod tests; -use self::catch::Catch; -use self::finally::Finally; +use self::{catch::Catch, finally::Finally}; use super::block::Block; -use crate::syntax::lexer::TokenKind; -use crate::Interner; -use crate::{ - syntax::{ - ast::{node::Try, Keyword}, - parser::{AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser}, - }, - BoaProfiler, +use crate::syntax::{ + ast::{node::Try, Keyword}, + lexer::TokenKind, + parser::{AllowAwait, AllowReturn, AllowYield, Cursor, ParseError, TokenParser}, }; - +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Try...catch statement parsing @@ -61,7 +57,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("TryStatement", "Parsing"); + let _timer = Profiler::global().start_event("TryStatement", "Parsing"); // TRY cursor.expect(Keyword::Try, "try statement", interner)?; diff --git a/boa/src/syntax/parser/statement/try_stm/tests.rs b/boa_engine/src/syntax/parser/statement/try_stm/tests.rs similarity index 95% rename from boa/src/syntax/parser/statement/try_stm/tests.rs rename to boa_engine/src/syntax/parser/statement/try_stm/tests.rs index 72e2f2e7e67..657bdc8fe83 100644 --- a/boa/src/syntax/parser/statement/try_stm/tests.rs +++ b/boa_engine/src/syntax/parser/statement/try_stm/tests.rs @@ -1,16 +1,14 @@ -use crate::{ - syntax::{ - ast::{ - node::{ - declaration::{BindingPatternTypeArray, BindingPatternTypeObject}, - Block, Catch, Declaration, DeclarationList, Finally, Try, - }, - Const, +use crate::syntax::{ + ast::{ + node::{ + declaration::{BindingPatternTypeArray, BindingPatternTypeObject}, + Block, Catch, Declaration, DeclarationList, Finally, Try, }, - parser::tests::{check_invalid, check_parser}, + Const, }, - Interner, + parser::tests::{check_invalid, check_parser}, }; +use boa_interner::Interner; #[test] fn check_inline_with_empty_try_catch() { diff --git a/boa/src/syntax/parser/statement/variable/mod.rs b/boa_engine/src/syntax/parser/statement/variable/mod.rs similarity index 92% rename from boa/src/syntax/parser/statement/variable/mod.rs rename to boa_engine/src/syntax/parser/statement/variable/mod.rs index 887abe8ace3..802a2e2b8c2 100644 --- a/boa/src/syntax/parser/statement/variable/mod.rs +++ b/boa_engine/src/syntax/parser/statement/variable/mod.rs @@ -1,22 +1,21 @@ //! Variable statement parsing. -use crate::{ - syntax::{ - ast::{ - node::{Declaration, DeclarationList}, - Keyword, Punctuator, - }, - lexer::TokenKind, - parser::statement::{ArrayBindingPattern, ObjectBindingPattern}, - parser::{ - cursor::{Cursor, SemicolonResult}, - expression::Initializer, - statement::BindingIdentifier, - AllowAwait, AllowIn, AllowYield, ParseError, TokenParser, - }, +use crate::syntax::{ + ast::{ + node::{Declaration, DeclarationList}, + Keyword, Punctuator, + }, + lexer::TokenKind, + parser::statement::{ArrayBindingPattern, ObjectBindingPattern}, + parser::{ + cursor::{Cursor, SemicolonResult}, + expression::Initializer, + statement::BindingIdentifier, + AllowAwait, AllowIn, AllowYield, ParseError, TokenParser, }, - BoaProfiler, Interner, }; +use boa_interner::Interner; +use boa_profiler::Profiler; use std::io::Read; /// Variable statement parsing. @@ -60,7 +59,7 @@ where cursor: &mut Cursor, interner: &mut Interner, ) -> Result { - let _timer = BoaProfiler::global().start_event("VariableStatement", "Parsing"); + let _timer = Profiler::global().start_event("VariableStatement", "Parsing"); cursor.expect(Keyword::Var, "variable statement", interner)?; let decl_list = VariableDeclarationList::new(true, self.allow_yield, self.allow_await) diff --git a/boa/src/syntax/parser/tests.rs b/boa_engine/src/syntax/parser/tests.rs similarity index 96% rename from boa/src/syntax/parser/tests.rs rename to boa_engine/src/syntax/parser/tests.rs index 105433444be..f2d264b87fa 100644 --- a/boa/src/syntax/parser/tests.rs +++ b/boa_engine/src/syntax/parser/tests.rs @@ -1,20 +1,16 @@ //! Tests for the parser. -use boa_interner::Sym; - use super::Parser; -use crate::{ - syntax::ast::{ - node::{ - field::GetConstField, ArrowFunctionDecl, Assign, BinOp, Call, Declaration, - DeclarationList, FormalParameter, FunctionDecl, Identifier, If, New, Node, Object, - PropertyDefinition, Return, StatementList, UnaryOp, - }, - op::{self, CompOp, LogOp, NumOp}, - Const, +use crate::syntax::ast::{ + node::{ + field::GetConstField, ArrowFunctionDecl, Assign, BinOp, Call, Declaration, DeclarationList, + FormalParameter, FunctionDecl, Identifier, If, New, Node, Object, PropertyDefinition, + Return, StatementList, UnaryOp, }, - Interner, + op::{self, CompOp, LogOp, NumOp}, + Const, }; +use boa_interner::{Interner, Sym}; /// Checks that the given JavaScript string gives the expected expression. #[allow(clippy::unwrap_used)] diff --git a/boa/src/tests.rs b/boa_engine/src/tests.rs similarity index 100% rename from boa/src/tests.rs rename to boa_engine/src/tests.rs diff --git a/boa/src/value/conversions.rs b/boa_engine/src/value/conversions.rs similarity index 91% rename from boa/src/value/conversions.rs rename to boa_engine/src/value/conversions.rs index fb189060d24..40df84a5afd 100644 --- a/boa/src/value/conversions.rs +++ b/boa_engine/src/value/conversions.rs @@ -1,5 +1,4 @@ -use super::{BoaProfiler, Display, JsBigInt, JsObject, JsString, JsSymbol, JsValue}; -use std::convert::TryFrom; +use super::{Display, JsBigInt, JsObject, JsString, JsSymbol, JsValue, Profiler}; impl From<&Self> for JsValue { #[inline] @@ -14,7 +13,7 @@ where { #[inline] fn from(value: T) -> Self { - let _timer = BoaProfiler::global().start_event("From", "value"); + let _timer = Profiler::global().start_event("From", "value"); Self::String(value.into()) } @@ -123,7 +122,7 @@ impl From for JsValue { impl From for JsValue { #[inline] fn from(object: JsObject) -> Self { - let _timer = BoaProfiler::global().start_event("From", "value"); + let _timer = Profiler::global().start_event("From", "value"); Self::Object(object) } } diff --git a/boa/src/value/display.rs b/boa_engine/src/value/display.rs similarity index 100% rename from boa/src/value/display.rs rename to boa_engine/src/value/display.rs diff --git a/boa/src/value/equality.rs b/boa_engine/src/value/equality.rs similarity index 100% rename from boa/src/value/equality.rs rename to boa_engine/src/value/equality.rs diff --git a/boa/src/value/hash.rs b/boa_engine/src/value/hash.rs similarity index 100% rename from boa/src/value/hash.rs rename to boa_engine/src/value/hash.rs diff --git a/boa/src/value/mod.rs b/boa_engine/src/value/mod.rs similarity index 98% rename from boa/src/value/mod.rs rename to boa_engine/src/value/mod.rs index fc44b3ae288..e91d058c8de 100644 --- a/boa/src/value/mod.rs +++ b/boa_engine/src/value/mod.rs @@ -10,19 +10,19 @@ use crate::{ number::{f64_to_int32, f64_to_uint32}, Number, }, - gc::{Finalize, Trace}, object::{JsObject, ObjectData}, property::{PropertyDescriptor, PropertyKey}, symbol::{JsSymbol, WellKnownSymbols}, - BoaProfiler, Context, JsBigInt, JsResult, JsString, + Context, JsBigInt, JsResult, JsString, }; +use boa_gc::{Finalize, Trace}; +use boa_profiler::Profiler; use num_bigint::BigInt; use num_integer::Integer; use num_traits::Zero; use once_cell::sync::Lazy; use std::{ collections::HashSet, - convert::TryFrom, fmt::{self, Display}, ops::Sub, str::FromStr, @@ -302,7 +302,7 @@ impl JsValue { Key: Into, { let key = key.into(); - let _timer = BoaProfiler::global().start_event("Value::get_property", "value"); + let _timer = Profiler::global().start_event("Value::get_property", "value"); match self { Self::Object(ref object) => { // TODO: had to skip `__get_own_properties__` since we don't have context here @@ -329,7 +329,7 @@ impl JsValue { where K: Into, { - let _timer = BoaProfiler::global().start_event("Value::get_field", "value"); + let _timer = Profiler::global().start_event("Value::get_field", "value"); if let Self::Object(ref obj) = *self { obj.clone() .__get__(&key.into(), obj.clone().into(), context) @@ -366,7 +366,7 @@ impl JsValue { let key = key.into(); let value = value.into(); - let _timer = BoaProfiler::global().start_event("Value::set_field", "value"); + let _timer = Profiler::global().start_event("Value::set_field", "value"); if let Self::Object(ref obj) = *self { // 4. Let success be ? O.[[Set]](P, V, O). let success = obj @@ -496,7 +496,7 @@ impl JsValue { /// # Examples /// /// ``` - /// use boa::JsValue; + /// use boa_engine::JsValue; /// /// let value = JsValue::new(3); /// diff --git a/boa/src/value/operations.rs b/boa_engine/src/value/operations.rs similarity index 99% rename from boa/src/value/operations.rs rename to boa_engine/src/value/operations.rs index 19899e69508..15c9d6bc8b9 100644 --- a/boa/src/value/operations.rs +++ b/boa_engine/src/value/operations.rs @@ -1,5 +1,5 @@ use super::{ - Context, FromStr, JsBigInt, JsResult, JsString, JsValue, Numeric, PreferredType, TryFrom, + Context, FromStr, JsBigInt, JsResult, JsString, JsValue, Numeric, PreferredType, WellKnownSymbols, }; use crate::builtins::number::{f64_to_int32, f64_to_uint32, Number}; diff --git a/boa/src/value/tests.rs b/boa_engine/src/value/tests.rs similarity index 100% rename from boa/src/value/tests.rs rename to boa_engine/src/value/tests.rs diff --git a/boa/src/value/type.rs b/boa_engine/src/value/type.rs similarity index 100% rename from boa/src/value/type.rs rename to boa_engine/src/value/type.rs diff --git a/boa/src/vm/call_frame.rs b/boa_engine/src/vm/call_frame.rs similarity index 98% rename from boa/src/vm/call_frame.rs rename to boa_engine/src/vm/call_frame.rs index e9d7e27aad5..205ea3cdf4c 100644 --- a/boa/src/vm/call_frame.rs +++ b/boa_engine/src/vm/call_frame.rs @@ -3,7 +3,8 @@ //! This module will provides everything needed to implement the `CallFrame` use super::CodeBlock; -use crate::{gc::Gc, JsValue}; +use crate::JsValue; +use boa_gc::Gc; #[derive(Debug)] pub struct CallFrame { diff --git a/boa/src/vm/code_block.rs b/boa_engine/src/vm/code_block.rs similarity index 99% rename from boa/src/vm/code_block.rs rename to boa_engine/src/vm/code_block.rs index a346885a657..cb45df1c3fd 100644 --- a/boa/src/vm/code_block.rs +++ b/boa_engine/src/vm/code_block.rs @@ -9,15 +9,15 @@ use crate::{ }, context::StandardObjects, environments::{BindingLocator, DeclarativeEnvironmentStack}, - gc::{Finalize, Gc, Trace}, object::{internal_methods::get_prototype_from_constructor, JsObject, ObjectData}, - profiler::BoaProfiler, property::PropertyDescriptor, syntax::ast::node::FormalParameter, vm::{call_frame::FinallyReturn, CallFrame, Opcode}, Context, JsResult, JsValue, }; +use boa_gc::{Finalize, Gc, Trace}; use boa_interner::{Interner, Sym, ToInternedString}; +use boa_profiler::Profiler; use std::{convert::TryInto, mem::size_of}; /// This represents whether a value can be read from [`CodeBlock`] code. @@ -398,7 +398,7 @@ pub struct JsVmFunction {} impl JsVmFunction { #[allow(clippy::new_ret_no_self)] pub fn new(code: Gc, context: &mut Context) -> JsObject { - let _timer = BoaProfiler::global().start_event("Identifier", "vm"); + let _timer = Profiler::global().start_event("JsVmFunction::new", "vm"); let function_prototype = context.standard_objects().function_object().prototype(); diff --git a/boa/src/vm/mod.rs b/boa_engine/src/vm/mod.rs similarity index 99% rename from boa/src/vm/mod.rs rename to boa_engine/src/vm/mod.rs index 4bee56fef17..95bf42db83a 100644 --- a/boa/src/vm/mod.rs +++ b/boa_engine/src/vm/mod.rs @@ -7,9 +7,10 @@ use crate::{ property::{DescriptorKind, PropertyDescriptor, PropertyKey}, value::Numeric, vm::{call_frame::CatchAddresses, code_block::Readable}, - BoaProfiler, Context, JsBigInt, JsResult, JsString, JsValue, + Context, JsBigInt, JsResult, JsString, JsValue, }; use boa_interner::ToInternedString; +use boa_profiler::Profiler; use std::{convert::TryInto, mem::size_of, ops::Neg, time::Instant}; mod call_frame; @@ -109,7 +110,7 @@ impl Context { } let opcode: Opcode = { - let _timer = BoaProfiler::global().start_event("Opcode retrieval", "vm"); + let _timer = Profiler::global().start_event("Opcode retrieval", "vm"); let opcode = self.vm.frame().code.code[self.vm.frame().pc] .try_into() .expect("could not convert code at PC to opcode"); @@ -117,8 +118,7 @@ impl Context { opcode }; - let _timer = - BoaProfiler::global().start_event(&format!("INST - {}", opcode.as_str()), "vm"); + let _timer = Profiler::global().start_event(&format!("INST - {}", opcode.as_str()), "vm"); match opcode { Opcode::Nop => {} @@ -1272,7 +1272,7 @@ impl Context { const OPERAND_COLUMN_WIDTH: usize = COLUMN_WIDTH; const NUMBER_OF_COLUMNS: usize = 4; - let _timer = BoaProfiler::global().start_event("run", "vm"); + let _timer = Profiler::global().start_event("run", "vm"); if self.vm.trace { let msg = if self.vm.frame().prev.is_some() { diff --git a/boa/src/vm/opcode.rs b/boa_engine/src/vm/opcode.rs similarity index 99% rename from boa/src/vm/opcode.rs rename to boa_engine/src/vm/opcode.rs index 86b481a03c0..cd96a17aa1a 100644 --- a/boa/src/vm/opcode.rs +++ b/boa_engine/src/vm/opcode.rs @@ -1,5 +1,3 @@ -use std::convert::TryFrom; - /// The opcodes of the vm. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[repr(u8)] diff --git a/boa/src/vm/tests.rs b/boa_engine/src/vm/tests.rs similarity index 100% rename from boa/src/vm/tests.rs rename to boa_engine/src/vm/tests.rs diff --git a/boa_gc/Cargo.toml b/boa_gc/Cargo.toml new file mode 100644 index 00000000000..7cbd5672af4 --- /dev/null +++ b/boa_gc/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "boa_gc" +version = "0.13.0" +edition = "2021" +rust-version = "1.58" +authors = ["boa-dev"] +description = "Garbage collector used in Boa." +repository = "https://github.com/boa-dev/boa" +keywords = ["javascript", "js", "garbage", "memory"] +categories = ["command-line-utilities"] +license = "Unlicense/MIT" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] + +[dependencies] +gc = { version = "0.4.1", features = ["derive"] } + +# Optional Dependencies +measureme = { version = "10.0.0", optional = true } diff --git a/boa_gc/src/lib.rs b/boa_gc/src/lib.rs new file mode 100644 index 00000000000..0ae80e1a5ee --- /dev/null +++ b/boa_gc/src/lib.rs @@ -0,0 +1,6 @@ +//! Garbage collector for the Boa JavaScript engine. + +pub use gc::{ + custom_trace, force_collect, unsafe_empty_trace, Finalize, Gc, GcCell as Cell, + GcCellRef as Ref, GcCellRefMut as RefMut, Trace, +}; diff --git a/boa_interner/Cargo.toml b/boa_interner/Cargo.toml index 8c52017115a..d25da2e06bc 100644 --- a/boa_interner/Cargo.toml +++ b/boa_interner/Cargo.toml @@ -1,13 +1,32 @@ [package] name = "boa_interner" version = "0.13.0" +edition = "2021" +rust-version = "1.58" authors = ["boa-dev"] description = "String interner used in Boa." repository = "https://github.com/boa-dev/boa" +keywords = ["javascript", "js", "string", "interner"] +categories = ["data-structures"] license = "Unlicense/MIT" -exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] -edition = "2021" -rust-version = "1.56" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] [dependencies] string-interner = "0.14.0" diff --git a/boa_profiler/Cargo.toml b/boa_profiler/Cargo.toml new file mode 100644 index 00000000000..ed8c34746aa --- /dev/null +++ b/boa_profiler/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "boa_profiler" +version = "0.13.0" +edition = "2021" +rust-version = "1.58" +authors = ["boa-dev"] +description = "Profiler used in Boa." +repository = "https://github.com/boa-dev/boa" +keywords = ["javascript", "js", "compiler", "profiler"] +categories = ["development-tools::profiling"] +license = "Unlicense/MIT" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] + +[features] +profiler = ["measureme", "once_cell"] + +[dependencies] +measureme = { version = "10.0.0", optional = true } +once_cell = { version = "1.9.0", optional = true } \ No newline at end of file diff --git a/boa/src/profiler.rs b/boa_profiler/src/lib.rs similarity index 78% rename from boa/src/profiler.rs rename to boa_profiler/src/lib.rs index 6b8bc412891..c1a543aa763 100644 --- a/boa/src/profiler.rs +++ b/boa_profiler/src/lib.rs @@ -1,7 +1,7 @@ #![allow(missing_copy_implementations, missing_debug_implementations)] #[cfg(feature = "profiler")] -use measureme::{EventId, Profiler, TimingGuard}; +use measureme::{EventId, Profiler as MeasuremeProfiler, TimingGuard}; #[cfg(feature = "profiler")] use once_cell::sync::OnceCell; use std::fmt::{self, Debug}; @@ -12,17 +12,18 @@ use std::{ }; #[cfg(feature = "profiler")] -pub struct BoaProfiler { - profiler: Profiler, +pub struct Profiler { + profiler: MeasuremeProfiler, } -/// This static instance should never be public, and its only access should be done through the `global()` and `drop()` methods -/// This is because `get_or_init` manages synchronisation and the case of an empty value +/// This static instance must never be public, and its only access must be done through the +/// `global()` and `drop()` methods. This is because `get_or_init` manages synchronization and the +/// case of an empty value. #[cfg(feature = "profiler")] -static mut INSTANCE: OnceCell = OnceCell::new(); +static mut INSTANCE: OnceCell = OnceCell::new(); #[cfg(feature = "profiler")] -impl BoaProfiler { +impl Profiler { pub fn start_event(&self, label: &str, category: &str) -> TimingGuard<'_> { let kind = self.profiler.alloc_string(category); let id = EventId::from_label(self.profiler.alloc_string(label)); @@ -32,7 +33,8 @@ impl BoaProfiler { } pub fn default() -> Self { - let profiler = Profiler::new(Path::new("./my_trace")).expect("must be able to create file"); + let profiler = + MeasuremeProfiler::new(Path::new("./my_trace")).expect("must be able to create file"); Self { profiler } } @@ -61,18 +63,18 @@ impl BoaProfiler { } } -impl Debug for BoaProfiler { +impl Debug for Profiler { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { Debug::fmt("no debug implemented", f) } } #[cfg(not(feature = "profiler"))] -pub struct BoaProfiler; +pub struct Profiler; #[allow(clippy::unused_unit, clippy::unused_self)] #[cfg(not(feature = "profiler"))] -impl BoaProfiler { +impl Profiler { pub fn start_event(&self, _label: &str, _category: &str) -> () {} pub fn drop(&self) {} diff --git a/boa_tester/Cargo.toml b/boa_tester/Cargo.toml index 5e57bcc97e2..787ccfefb2c 100644 --- a/boa_tester/Cargo.toml +++ b/boa_tester/Cargo.toml @@ -1,18 +1,36 @@ [package] name = "boa_tester" version = "0.13.0" +edition = "2021" +rust-version = "1.58" authors = ["boa-dev"] -description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." +description = "Test runner for the Boa JavaScript engine." repository = "https://github.com/boa-dev/boa" -keywords = ["javascript", "compiler", "test262", "tester", "js"] -categories = ["parser-implementations", "wasm"] +keywords = ["javascript", "ECMASCript", "compiler", "test262", "tester"] +categories = ["command-line-utilites"] license = "Unlicense/MIT" -exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] -edition = "2021" -rust-version = "1.58" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] [dependencies] -Boa = { path = "../boa" } +boa_engine = { path = "../boa_engine" } +boa_interner = { path = "../boa_interner" } structopt = "0.3.26" serde = { version = "1.0.136", features = ["derive"] } serde_yaml = "0.8.23" diff --git a/boa_tester/src/exec/js262.rs b/boa_tester/src/exec/js262.rs index 531a481da9f..91bb507ed20 100644 --- a/boa_tester/src/exec/js262.rs +++ b/boa_tester/src/exec/js262.rs @@ -1,4 +1,4 @@ -use boa::{ +use boa_engine::{ builtins::JsArgs, object::{JsObject, ObjectInitializer}, property::Attribute, diff --git a/boa_tester/src/exec/mod.rs b/boa_tester/src/exec/mod.rs index 3e289fb503d..2d7978c4d42 100644 --- a/boa_tester/src/exec/mod.rs +++ b/boa_tester/src/exec/mod.rs @@ -6,7 +6,8 @@ use super::{ Harness, Outcome, Phase, SuiteResult, Test, TestFlags, TestOutcomeResult, TestResult, TestSuite, IGNORED, }; -use boa::{syntax::Parser, Context, Interner, JsValue}; +use boa_engine::{syntax::Parser, Context, JsResult, JsValue}; +use boa_interner::Interner; use colored::Colorize; use rayon::prelude::*; use std::panic; @@ -335,6 +336,6 @@ impl Test { } /// `print()` function required by the test262 suite. -fn test262_print(_this: &JsValue, _: &[JsValue], _context: &mut Context) -> boa::JsResult { +fn test262_print(_this: &JsValue, _: &[JsValue], _context: &mut Context) -> JsResult { todo!("print() function"); } diff --git a/boa_unicode/Cargo.toml b/boa_unicode/Cargo.toml index 1ed02853d41..4127aff7b41 100644 --- a/boa_unicode/Cargo.toml +++ b/boa_unicode/Cargo.toml @@ -1,15 +1,32 @@ [package] name = "boa_unicode" version = "0.13.0" +edition = "2021" +rust-version = "1.58" authors = ["boa-dev"] -description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." +description = "Unicode support for the Boa JavaScript engine." repository = "https://github.com/boa-dev/boa" keywords = ["javascript", "compiler", "lexer", "parser", "unicode"] categories = ["parsing"] license = "Unlicense/MIT" -exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] -edition = "2021" -rust-version = "1.56" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] [dependencies] unicode-general-category = "0.5.1" diff --git a/boa_wasm/Cargo.toml b/boa_wasm/Cargo.toml index e460c5b627b..2c6e7f32255 100644 --- a/boa_wasm/Cargo.toml +++ b/boa_wasm/Cargo.toml @@ -1,18 +1,35 @@ [package] name = "boa_wasm" version = "0.13.0" +edition = "2021" +rust-version = "1.58" authors = ["boa-dev"] -description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." +description = "WASM package for the Boa JavaScript engine." repository = "https://github.com/boa-dev/boa" keywords = ["javascript", "compiler", "lexer", "parser", "js"] -categories = ["wasm"] +categories = ["parser-implementations", "wasm", "compilers"] license = "Unlicense/MIT" -exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] -edition = "2021" -rust-version = "1.56" +exclude = [ + "../.vscode/*", + "../.editorconfig", + "../test262/*", + "../node_modules/*", + "../target/*", + "../dist/*", + "../.github/*", + "../assets/*", + "../docs/*", + "../*.js", + "../test_ignore.txt", + "../yarn.lock", + "../package.json", + "../index.html", + "../tests/*", + "../.github/*", +] [dependencies] -Boa = { path = "../boa", features = ["console"] } +boa_engine = { path = "../boa_engine", features = ["console"] } wasm-bindgen = "=0.2.78" getrandom = { version = "0.2.4", features = ["js"] } diff --git a/boa_wasm/src/lib.rs b/boa_wasm/src/lib.rs index 7ec244637f3..fe37e482953 100644 --- a/boa_wasm/src/lib.rs +++ b/boa_wasm/src/lib.rs @@ -59,7 +59,7 @@ rustdoc::missing_doc_code_examples )] -use boa::Context; +use boa_engine::Context; use wasm_bindgen::prelude::*; #[wasm_bindgen]