Skip to content
Open
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
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"type": "process",
"label": "Run JS file",
"command": "cargo",
"args": ["run", "--bin", "boa", "${file}"],
"args": ["run", "--bin", "boa", "${workspaceFolder}/debug/script.js"],
"group": {
"kind": "build",
"isDefault": true
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## What's Changed

# [0.20.0 (2024-09-11)](https://github.com/boa-dev/boa/compare/v0.19.1...v0.20.0)
# [0.20.0 (2024-12-5)](https://github.com/boa-dev/boa/compare/v0.19.1...v0.20.0)

### Feature Enhancements

Expand Down Expand Up @@ -61,6 +61,7 @@
- Update night build's rename binary step by @nekevss in https://github.com/boa-dev/boa/pull/4032
- Use upload-rust-binary-action for nightly release by @nekevss in https://github.com/boa-dev/boa/pull/4040
- Fix `ref` value in nightly and add target to nightly release by @nekevss in https://github.com/boa-dev/boa/pull/4042
- Reduce environment allocations by @raskad in https://github.com/boa-dev/boa/pull/4002

### Other Changes

Expand Down
34 changes: 17 additions & 17 deletions Cargo.lock

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

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exclude = [

[workspace.package]
edition = "2021"
version = "0.19.0"
version = "0.20.0"
rust-version = "1.82.0"
authors = ["boa-dev"]
repository = "https://github.com/boa-dev/boa"
Expand All @@ -33,17 +33,17 @@ description = "Boa is a Javascript lexer, parser and compiler written in Rust. C
[workspace.dependencies]

# Repo Crates
boa_ast = { version = "~0.19.0", path = "core/ast" }
boa_engine = { version = "~0.19.0", path = "core/engine" }
boa_gc = { version = "~0.19.0", path = "core/gc" }
boa_icu_provider = { version = "~0.19.0", path = "core/icu_provider" }
boa_interner = { version = "~0.19.0", path = "core/interner" }
boa_interop = { version = "~0.19.0", path = "core/interop" }
boa_macros = { version = "~0.19.0", path = "core/macros" }
boa_parser = { version = "~0.19.0", path = "core/parser" }
boa_profiler = { version = "~0.19.0", path = "core/profiler" }
boa_runtime = { version = "~0.19.0", path = "core/runtime" }
boa_string = { version = "~0.19.0", path = "core/string" }
boa_ast = { version = "~0.20.0", path = "core/ast" }
boa_engine = { version = "~0.20.0", path = "core/engine" }
boa_gc = { version = "~0.20.0", path = "core/gc" }
boa_icu_provider = { version = "~0.20.0", path = "core/icu_provider" }
boa_interner = { version = "~0.20.0", path = "core/interner" }
boa_interop = { version = "~0.20.0", path = "core/interop" }
boa_macros = { version = "~0.20.0", path = "core/macros" }
boa_parser = { version = "~0.20.0", path = "core/parser" }
boa_profiler = { version = "~0.20.0", path = "core/profiler" }
boa_runtime = { version = "~0.20.0", path = "core/runtime" }
boa_string = { version = "~0.20.0", path = "core/string" }

# Shared deps
arbitrary = "1"
Expand Down
27 changes: 20 additions & 7 deletions core/engine/src/builtins/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
native_function::{NativeFunctionObject, NativeFunctionPointer},
object::{
shape::{property_table::PropertyTableInner, slot::SlotAttributes},
FunctionBinding, JsFunction, JsPrototype, CONSTRUCTOR, PROTOTYPE,
FunctionBinding, JsFunction, JsPrototype, LazyBuiltIn, CONSTRUCTOR, PROTOTYPE,
},
property::{Attribute, PropertyDescriptor, PropertyKey},
realm::Realm,
Expand Down Expand Up @@ -392,12 +392,25 @@ impl BuiltInConstructorWithPrototype<'_> {
}

let mut object = self.object.borrow_mut();
let function = object
.downcast_mut::<NativeFunctionObject>()
.expect("Builtin must be a function object");
function.f = NativeFunction::from_fn_ptr(self.function);
function.constructor = Some(ConstructorKind::Base);
function.realm = Some(self.realm.clone());
if object.is::<NativeFunctionObject>() {
let function = object
.downcast_mut::<NativeFunctionObject>()
.expect("Builtin must be a function object");
function.f = NativeFunction::from_fn_ptr(self.function);
function.constructor = Some(ConstructorKind::Base);
function.realm = Some(self.realm.clone());
} else if object.is::<LazyBuiltIn>() {
let lazy = object
.downcast_mut::<LazyBuiltIn>()
.expect("Builtin must be a lazy object");
lazy.set_constructor(
NativeFunction::from_fn_ptr(self.function),
self.realm.clone(),
);
} else {
unreachable!("The object must be a function or a lazy object");
}

object
.properties_mut()
.shape
Expand Down
8 changes: 4 additions & 4 deletions core/engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
get_prototype_from_constructor, CallValue, InternalObjectMethods,
ORDINARY_INTERNAL_METHODS,
},
JsData, JsFunction, JsObject, PrivateElement, PrivateName,
JsData, JsFunction, JsObject, LazyBuiltIn, PrivateElement, PrivateName,
},
property::{Attribute, PropertyDescriptor, PropertyKey},
realm::Realm,
Expand Down Expand Up @@ -845,8 +845,7 @@ impl BuiltInFunctionObject {
return Err(JsNativeError::typ().with_message("not a function").into());
};

let object_borrow = object.borrow();
if object_borrow.is::<NativeFunctionObject>() {
if object.is::<NativeFunctionObject>() || object.is::<LazyBuiltIn>() {
let name = {
// Is there a case here where if there is no name field on a value
// name should default to None? Do all functions have names set?
Expand All @@ -860,10 +859,11 @@ impl BuiltInFunctionObject {
return Ok(
js_string!(js_str!("function "), &name, js_str!("() { [native code] }")).into(),
);
} else if object_borrow.is::<Proxy>() || object_borrow.is::<BoundFunction>() {
} else if object.is::<Proxy>() || object.is::<BoundFunction>() {
return Ok(js_string!("function () { [native code] }").into());
}

let object_borrow = object.borrow();
let function = object_borrow
.downcast_ref::<OrdinaryFunction>()
.ok_or_else(|| JsNativeError::typ().with_message("not a function"))?;
Expand Down
1 change: 0 additions & 1 deletion core/engine/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ impl Realm {
ForInIterator::init(self);
Math::init(self);
Json::init(self);
Array::init(self);
ArrayIterator::init(self);
Proxy::init(self);
ArrayBuffer::init(self);
Expand Down
Loading
Loading