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] - Implement missing vm operations #1697

Closed
wants to merge 7 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
10 changes: 10 additions & 0 deletions boa/src/builtins/iterable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ impl IteratorRecord {
}
}

#[cfg(feature = "vm")]
pub(crate) fn iterator_object(&self) -> &JsValue {
&self.iterator_object
}

#[cfg(feature = "vm")]
pub(crate) fn next_function(&self) -> &JsValue {
&self.next_function
}

/// Get the next value in the iterator
///
/// More information:
Expand Down
702 changes: 629 additions & 73 deletions boa/src/bytecompiler.rs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion boa/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,10 @@ impl Context {
this: global_object,
pc: 0,
fp,
exit_on_return: true,
environment,
catch: None,
pop_env_on_return: 0,
finally_no_jump: false,
});
let result = self.run();

Expand Down
31 changes: 23 additions & 8 deletions boa/src/object/internal_methods/function.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
use crate::{
builtins::function::{Captures, ClosureFunctionSignature, Function, NativeFunctionSignature},
object::{
internal_methods::{InternalObjectMethods, ORDINARY_INTERNAL_METHODS},
JsObject,
},
Context, JsResult, JsValue,
};

#[cfg(not(feature = "vm"))]
use crate::{
builtins::function::{
arguments::Arguments, Captures, ClosureFunctionSignature, Function, NativeFunctionSignature,
},
context::StandardObjects,
environment::{
function_environment_record::{BindingStatus, FunctionEnvironmentRecord},
lexical_environment::Environment,
},
exec::{Executable, InterpreterState},
object::{internal_methods::get_prototype_from_constructor, JsObject, ObjectData},
object::{internal_methods::get_prototype_from_constructor, ObjectData},
syntax::ast::node::RcStatementList,
Context, JsResult, JsValue,
};

use super::{InternalObjectMethods, ORDINARY_INTERNAL_METHODS};
use crate::{builtins::function::arguments::Arguments, context::StandardObjects};

/// Definitions of the internal object methods for function objects.
///
/// More information:
Expand Down Expand Up @@ -46,7 +54,10 @@ fn function_call(
args: &[JsValue],
context: &mut Context,
) -> JsResult<JsValue> {
call_construct(obj, this, args, context, false)
#[cfg(not(feature = "vm"))]
return call_construct(obj, this, args, context, false);
#[cfg(feature = "vm")]
return obj.call_internal(this, args, context);
}

/// Construct an instance of this object with the specified arguments.
Expand All @@ -63,7 +74,10 @@ fn function_construct(
new_target: &JsValue,
context: &mut Context,
) -> JsResult<JsValue> {
call_construct(obj, new_target, args, context, true)
#[cfg(not(feature = "vm"))]
return call_construct(obj, new_target, args, context, true);
#[cfg(feature = "vm")]
return obj.construct_internal(args, new_target, context);
}

/// Internal implementation of [`call`](#method.call) and [`construct`](#method.construct).
Expand All @@ -77,6 +91,7 @@ fn function_construct(
/// <https://tc39.es/ecma262/#sec-runtime-semantics-evaluatebody>
/// <https://tc39.es/ecma262/#sec-ordinarycallevaluatebody>
#[track_caller]
#[cfg(not(feature = "vm"))]
pub(super) fn call_construct(
obj: &JsObject,
this_target: &JsValue,
Expand Down
2 changes: 0 additions & 2 deletions boa/src/object/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ impl JsObject {
// <https://tc39.es/ecma262/#sec-ecmascript-function-objects-call-thisargument-argumentslist>
#[track_caller]
#[inline]
#[cfg(not(feature = "vm"))]
pub fn call(
&self,
this: &JsValue,
Expand All @@ -283,7 +282,6 @@ impl JsObject {
// <https://tc39.es/ecma262/#sec-ecmascript-function-objects-construct-argumentslist-newtarget>
#[track_caller]
#[inline]
#[cfg(not(feature = "vm"))]
pub fn construct(
&self,
args: &[JsValue],
Expand Down
22 changes: 18 additions & 4 deletions boa/src/syntax/ast/node/declaration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,17 @@ impl DeclarationPatternObject {

/// Gets the initialization node for the object binding pattern, if any.
#[inline]
pub(in crate::syntax) fn init(&self) -> Option<&Node> {
pub(crate) fn init(&self) -> Option<&Node> {
self.init.as_ref()
}

/// Gets the bindings for the object binding pattern.
#[inline]
#[cfg(feature = "vm")]
pub(crate) fn bindings(&self) -> &Vec<BindingPatternTypeObject> {
&self.bindings
}

/// Initialize the values of an object binding pattern.
///
/// More information:
Expand Down Expand Up @@ -560,7 +567,7 @@ impl DeclarationPatternObject {

/// Gets the list of identifiers declared by the object binding pattern.
#[inline]
pub(in crate::syntax) fn idents(&self) -> Vec<&str> {
pub(crate) fn idents(&self) -> Vec<&str> {
let mut idents = Vec::new();

for binding in &self.bindings {
Expand Down Expand Up @@ -645,10 +652,17 @@ impl DeclarationPatternArray {

/// Gets the initialization node for the array binding pattern, if any.
#[inline]
pub(in crate::syntax) fn init(&self) -> Option<&Node> {
pub(crate) fn init(&self) -> Option<&Node> {
self.init.as_ref()
}

/// Gets the bindings for the array binding pattern.
#[inline]
#[cfg(feature = "vm")]
pub(crate) fn bindings(&self) -> &Vec<BindingPatternTypeArray> {
&self.bindings
}

/// Initialize the values of an array binding pattern.
///
/// More information:
Expand Down Expand Up @@ -847,7 +861,7 @@ impl DeclarationPatternArray {

/// Gets the list of identifiers declared by the array binding pattern.
#[inline]
pub(in crate::syntax) fn idents(&self) -> Vec<&str> {
pub(crate) fn idents(&self) -> Vec<&str> {
let mut idents = Vec::new();

for binding in &self.bindings {
Expand Down
Loading