From 02ec15a5a8bd6a9d445745e4b5927b746a7ef5a5 Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Tue, 2 Nov 2021 01:20:04 +0100 Subject: [PATCH 1/7] Implement missing vm operations --- boa/src/builtins/iterable/mod.rs | 10 + boa/src/bytecompiler.rs | 646 ++++++++++++++++-- boa/src/context.rs | 4 +- boa/src/object/internal_methods/function.rs | 31 +- boa/src/object/operations.rs | 2 - boa/src/syntax/ast/node/declaration/mod.rs | 22 +- .../ast/node/iteration/for_in_loop/mod.rs | 191 ++---- .../ast/node/iteration/for_of_loop/mod.rs | 191 ++---- boa/src/syntax/ast/node/iteration/mod.rs | 28 + boa/src/syntax/ast/node/new/mod.rs | 6 + boa/src/syntax/ast/node/template/mod.rs | 25 + .../statement/iteration/for_statement.rs | 84 ++- boa/src/vm/call_frame.rs | 4 +- boa/src/vm/code_block.rs | 154 ++++- boa/src/vm/mod.rs | 323 +++++++-- boa/src/vm/opcode.rs | 165 ++++- 16 files changed, 1466 insertions(+), 420 deletions(-) diff --git a/boa/src/builtins/iterable/mod.rs b/boa/src/builtins/iterable/mod.rs index 0c3c5a63c81..0624665e74d 100644 --- a/boa/src/builtins/iterable/mod.rs +++ b/boa/src/builtins/iterable/mod.rs @@ -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: diff --git a/boa/src/bytecompiler.rs b/boa/src/bytecompiler.rs index 0d87d2471e4..ceee75a5de7 100644 --- a/boa/src/bytecompiler.rs +++ b/boa/src/bytecompiler.rs @@ -4,6 +4,9 @@ use crate::{ builtins::function::ThisMode, syntax::ast::{ node::{ + declaration::{BindingPatternTypeArray, BindingPatternTypeObject, DeclarationPattern}, + iteration::IterableLoopInitializer, + template::TemplateElement, Declaration, GetConstField, GetField, MethodDefinitionKind, PropertyDefinition, PropertyName, StatementList, }, @@ -31,10 +34,17 @@ struct Label { struct JumpControlInfo { label: Option>, start_address: u32, - is_loop: bool, + kind: JumpControlInfoKind, breaks: Vec