From fe39f08f942035e5932a09a55be55547aee317a2 Mon Sep 17 00:00:00 2001 From: Iban Eguia Moraza Date: Sun, 27 Nov 2022 12:18:55 +0100 Subject: [PATCH] Fixed compile errors --- boa_cli/src/main.rs | 4 +-- boa_engine/src/bytecompiler/mod.rs | 26 +++++++------------ boa_engine/src/context/mod.rs | 17 ------------ .../parser/statement/declaration/export.rs | 6 ++--- .../declaration/hoistable/class_decl/mod.rs | 8 +++--- boa_tester/src/exec/mod.rs | 3 +-- boa_tester/src/main.rs | 4 +-- 7 files changed, 21 insertions(+), 47 deletions(-) diff --git a/boa_cli/src/main.rs b/boa_cli/src/main.rs index 60ac3df5e97..53c3b1e5a28 100644 --- a/boa_cli/src/main.rs +++ b/boa_cli/src/main.rs @@ -231,8 +231,8 @@ fn generate_flowgraph( format: FlowgraphFormat, direction: Option, ) -> JsResult { - let ast = context.parse(src)?; - let code = context.compile(&ast)?; + let ast = context.parse_script(src)?; + let code = context.compile_script(&ast)?; let direction = match direction { Some(FlowgraphDirection::TopToBottom) | None => Direction::TopToBottom, diff --git a/boa_engine/src/bytecompiler/mod.rs b/boa_engine/src/bytecompiler/mod.rs index c5ec3a7a1c7..8daa833e9fb 100644 --- a/boa_engine/src/bytecompiler/mod.rs +++ b/boa_engine/src/bytecompiler/mod.rs @@ -871,10 +871,7 @@ impl<'b> ByteCompiler<'b> { Ok(()) } -<<<<<<< HEAD - /// Compile a [`StatementList`]. -======= - /// Compiles a module item list. + /// Compiles a [`ModuleItemList`]. #[inline] pub fn compile_module_item_list( &mut self, @@ -887,8 +884,7 @@ impl<'b> ByteCompiler<'b> { Ok(()) } - /// Compiles a statement list. ->>>>>>> d6d956a26f (Started with the module system) + /// Compile a [`StatementList`]. #[inline] pub fn compile_statement_list( &mut self, @@ -1853,11 +1849,9 @@ impl<'b> ByteCompiler<'b> { Ok(()) } -<<<<<<< HEAD - /// Compile a [`StatementListItem`]. -======= - /// Compiles a single module item. + /// Compiles a [`ModuleItem`]. #[inline] + #[allow(unused_variables, clippy::missing_panics_doc)] // Unimplemented pub fn compile_module_item( &mut self, item: &ModuleItem, @@ -1872,8 +1866,7 @@ impl<'b> ByteCompiler<'b> { } } - /// Compiles a single statement list item. ->>>>>>> d6d956a26f (Started with the module system) + /// Compile a [`StatementListItem`]. #[inline] fn compile_stmt_list_item( &mut self, @@ -3101,7 +3094,7 @@ impl<'b> ByteCompiler<'b> { configurable_globals: bool, ) { for node in stmt_list.items() { - self.create_decls_from_module_list_item(node, configurable_globals); + self.create_decls_from_module_item(node, configurable_globals); } } @@ -3271,9 +3264,10 @@ impl<'b> ByteCompiler<'b> { } } - /// Creates the declarations from a module list item. + /// Creates the declarations from a [`ModuleItem`]. #[inline] - pub(crate) fn create_decls_from_module_list_item( + #[allow(unused_variables)] // Unimplemented + pub(crate) fn create_decls_from_module_item( &mut self, item: &ModuleItem, configurable_globals: bool, @@ -3287,7 +3281,7 @@ impl<'b> ByteCompiler<'b> { } } - /// Creates the declarations from a statement list item. + /// Creates the declarations from a [`StatementListItem`]. #[inline] pub(crate) fn create_decls_from_stmt_list_item( &mut self, diff --git a/boa_engine/src/context/mod.rs b/boa_engine/src/context/mod.rs index b5650cff2d2..a5df3fe3602 100644 --- a/boa_engine/src/context/mod.rs +++ b/boa_engine/src/context/mod.rs @@ -179,23 +179,6 @@ impl Context { parser.parse_script(&mut self.interner) } - /// Parse the given source text with eval specific handling. - pub(crate) fn parse_eval( - &mut self, - src: S, - direct: bool, - strict: bool, - ) -> Result - where - S: AsRef<[u8]>, - { - let mut parser = Parser::new(src.as_ref()); - if strict { - parser.set_strict(); - } - parser.parse_eval(direct, &mut self.interner) - } - /// `Call ( F, V [ , argumentsList ] )` /// /// The abstract operation `Call` takes arguments `F` (an ECMAScript language value) and `V` diff --git a/boa_parser/src/parser/statement/declaration/export.rs b/boa_parser/src/parser/statement/declaration/export.rs index 935ecfe1c27..07ef6a05cdc 100644 --- a/boa_parser/src/parser/statement/declaration/export.rs +++ b/boa_parser/src/parser/statement/declaration/export.rs @@ -117,9 +117,9 @@ where match tok.kind() { TokenKind::Keyword((Keyword::Class, _)) => { - let class_declaration = - ClassDeclaration::new(false, true, true).parse(cursor, interner)?; - todo!("Class") + ClassDeclaration::new(false, true, true) + .parse(cursor, interner) + .map(boa_ast::declaration::ExportDeclaration::DefaultClassDeclaration)? } _ => todo!("default export parsing"), } diff --git a/boa_parser/src/parser/statement/declaration/hoistable/class_decl/mod.rs b/boa_parser/src/parser/statement/declaration/hoistable/class_decl/mod.rs index 8f65cf961f7..8c0fc8b6fc8 100644 --- a/boa_parser/src/parser/statement/declaration/hoistable/class_decl/mod.rs +++ b/boa_parser/src/parser/statement/declaration/hoistable/class_decl/mod.rs @@ -21,7 +21,7 @@ use boa_ast::{ function::{self, Class, FormalParameterList, Function}, operations::{contains, contains_arguments, has_direct_super, ContainsSymbol}, property::{ClassElementName, MethodDefinition}, - Declaration, Expression, Keyword, Punctuator, + Expression, Keyword, Punctuator, }; use boa_interner::{Interner, Sym}; use rustc_hash::{FxHashMap, FxHashSet}; @@ -62,7 +62,7 @@ impl TokenParser for ClassDeclaration where R: Read, { - type Output = Declaration; + type Output = Class; fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { cursor.expect((Keyword::Class, false), "class declaration", interner)?; @@ -87,9 +87,7 @@ where }; cursor.set_strict_mode(strict); - Ok(Declaration::Class( - ClassTail::new(name, self.allow_yield, self.allow_await).parse(cursor, interner)?, - )) + ClassTail::new(name, self.allow_yield, self.allow_await).parse(cursor, interner) } } diff --git a/boa_tester/src/exec/mod.rs b/boa_tester/src/exec/mod.rs index e02124747c8..63d61915659 100644 --- a/boa_tester/src/exec/mod.rs +++ b/boa_tester/src/exec/mod.rs @@ -2,11 +2,10 @@ mod js262; -use super::{ +use crate::{ read::ErrorType, Harness, Outcome, Phase, SuiteResult, Test, TestFlags, TestOutcomeResult, TestResult, TestSuite, }; -use crate::read::ErrorType; use boa_engine::{ builtins::JsArgs, object::FunctionBuilder, property::Attribute, Context, JsNativeErrorKind, JsResult, JsValue, diff --git a/boa_tester/src/main.rs b/boa_tester/src/main.rs index 6e08d2fa392..7a93c669cf3 100644 --- a/boa_tester/src/main.rs +++ b/boa_tester/src/main.rs @@ -408,9 +408,9 @@ impl Test { self.ignored = true; } - /// checks if this is a module test. + /// Checks if this is a module test. #[inline] - fn is_module(&self) -> bool { + const fn is_module(&self) -> bool { self.flags.contains(TestFlags::MODULE) } }