Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Added a Boa runtime #2743

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 48 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"boa_macros_tests",
"boa_parser",
"boa_profiler",
"boa_runtime",
"boa_tester",
"boa_unicode",
"boa_wasm",
Expand All @@ -26,15 +27,16 @@ license = "Unlicense/MIT"
description = "Boa is a Javascript lexer, parser and compiler written in Rust. Currently, it has support for some of the language."

[workspace.dependencies]
boa_ast = { version = "0.16.0", path = "boa_ast" }
boa_engine = { version = "0.16.0", path = "boa_engine" }
boa_interner = { version = "0.16.0", path = "boa_interner" }
boa_gc = { version = "0.16.0", path = "boa_gc" }
boa_profiler = { version = "0.16.0", path = "boa_profiler" }
boa_unicode = { version = "0.16.0", path = "boa_unicode" }
boa_icu_provider = { version = "0.16.0", path = "boa_icu_provider" }
boa_interner = { version = "0.16.0", path = "boa_interner" }
boa_macros = { version = "0.16.0", path = "boa_macros" }
boa_ast = { version = "0.16.0", path = "boa_ast" }
boa_parser = { version = "0.16.0", path = "boa_parser" }
boa_icu_provider = { version = "0.16.0", path = "boa_icu_provider" }
boa_profiler = { version = "0.16.0", path = "boa_profiler" }
boa_runtime = { version = "0.16.0", path = "boa_runtime" }
boa_unicode = { version = "0.16.0", path = "boa_unicode" }
Razican marked this conversation as resolved.
Show resolved Hide resolved

[workspace.metadata.workspaces]
allow_branch = "main"
Expand Down
2 changes: 1 addition & 1 deletion boa_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ arbitrary = ["dep:arbitrary", "boa_interner/arbitrary", "num-bigint/arbitrary"]
boa_interner.workspace = true
boa_macros.workspace = true
rustc-hash = "1.1.0"
bitflags = "2.2.0"
bitflags = "2.1.0"
num-bigint = "0.4.3"
serde = { version = "1.0.160", features = ["derive"], optional = true }
arbitrary = { version = "1", features = ["derive"], optional = true }
3 changes: 2 additions & 1 deletion boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ repository.workspace = true
rust-version.workspace = true

[dependencies]
boa_engine = { workspace = true, features = ["deser", "flowgraph", "trace", "console"] }
boa_engine = { workspace = true, features = ["deser", "flowgraph", "trace"] }
boa_ast = { workspace = true, features = ["serde"] }
boa_parser.workspace = true
boa_gc.workspace = true
boa_interner.workspace = true
boa_runtime.workspace = true
rustyline = { version = "11.0.0", features = ["derive"]}
clap = { version = "4.2.4", features = ["derive"] }
serde_json = "1.0.96"
Expand Down
13 changes: 13 additions & 0 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ use boa_engine::{
context::ContextBuilder,
job::{FutureJob, JobQueue, NativeJob},
optimizer::OptimizerOptions,
property::Attribute,
vm::flowgraph::{Direction, Graph},
Context, JsResult, Source,
};
use boa_runtime::Console;
use clap::{Parser, ValueEnum, ValueHint};
use colored::{Color, Colorize};
use debug::init_boa_debug_object;
Expand Down Expand Up @@ -311,6 +313,9 @@ fn main() -> Result<(), io::Error> {
// Strict mode
context.strict(args.strict);

// Add `console`.
add_runtime(&mut context);

// Trace Output
context.set_trace(args.trace);

Expand Down Expand Up @@ -404,6 +409,14 @@ fn main() -> Result<(), io::Error> {
Ok(())
}

/// Adds the CLI runtime to the context.
fn add_runtime(context: &mut Context<'_>) {
let console = Console::init(context);
context
.register_global_property(Console::NAME, console, Attribute::all())
.expect("the console object shouldn't exist");
}

#[derive(Default)]
struct Jobs(RefCell<VecDeque<NativeJob>>);

Expand Down
5 changes: 1 addition & 4 deletions boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ flowgraph = []
# Enable Boa's VM instruction tracing.
trace = []

# Enable Boa's WHATWG console object implementation.
console = []

# Enable Boa's additional ECMAScript features for web browsers.
annex-b = ["boa_parser/annex-b"]

Expand All @@ -64,7 +61,7 @@ regress = "0.5.0"
rustc-hash = "1.1.0"
num-bigint = { version = "0.4.3", features = ["serde"] }
num-integer = "0.1.45"
bitflags = "2.2.0"
bitflags = "2.1.0"
indexmap = "1.9.3"
ryu-js = "0.2.2"
chrono = { version = "0.4.24", default-features = false, features = ["clock", "std"] }
Expand Down
3 changes: 1 addition & 2 deletions boa_engine/src/builtins/function/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use indoc::indoc;

use crate::{
builtins::error::ErrorKind,
error::JsNativeError,
Expand All @@ -9,6 +7,7 @@ use crate::{
property::{Attribute, PropertyDescriptor},
run_test_actions, JsValue, TestAction,
};
use indoc::indoc;

#[allow(clippy::float_cmp)]
#[test]
Expand Down
Loading