diff --git a/boa_engine/src/bytecompiler/module.rs b/boa_engine/src/bytecompiler/module.rs index 41ed75320b5..be56f13af67 100644 --- a/boa_engine/src/bytecompiler/module.rs +++ b/boa_engine/src/bytecompiler/module.rs @@ -1,10 +1,20 @@ -use super::ByteCompiler; +use crate::{js_string, vm::Opcode}; + +use super::{ByteCompiler, Literal}; use boa_ast::{ModuleItem, ModuleItemList}; impl ByteCompiler<'_, '_> { /// Compiles a [`ModuleItemList`]. #[inline] + #[allow(unreachable_code, unused_variables)] pub fn compile_module_item_list(&mut self, list: &ModuleItemList, configurable_globals: bool) { + // TODO: Remove after implementing modules. + { + let msg = self + .get_or_insert_literal(Literal::String(js_string!("modules are unimplemented"))); + self.emit(Opcode::ThrowNewTypeError, &[msg]); + return; + } for node in list.items() { self.compile_module_item(node, configurable_globals); } @@ -12,11 +22,11 @@ impl ByteCompiler<'_, '_> { /// Compiles a [`ModuleItem`]. #[inline] - #[allow(unused_variables, clippy::missing_panics_doc)] // Unimplemented + #[allow(clippy::missing_panics_doc)] // Unimplemented pub fn compile_module_item(&mut self, item: &ModuleItem, configurable_globals: bool) { match item { - ModuleItem::ImportDeclaration(import) => todo!("import declaration compilation"), - ModuleItem::ExportDeclaration(export) => todo!("export declaration compilation"), + ModuleItem::ImportDeclaration(_import) => todo!("import declaration compilation"), + ModuleItem::ExportDeclaration(_export) => todo!("export declaration compilation"), ModuleItem::StatementListItem(stmt) => { self.compile_stmt_list_item(stmt, false, configurable_globals); } @@ -24,11 +34,16 @@ impl ByteCompiler<'_, '_> { } /// Creates the declarations for a module. + #[allow(unreachable_code, unused_variables)] pub(crate) fn create_module_decls( &mut self, stmt_list: &ModuleItemList, configurable_globals: bool, ) { + // TODO: Remove after implementing modules. + { + return; + } for node in stmt_list.items() { self.create_decls_from_module_item(node, configurable_globals); } @@ -36,15 +51,14 @@ impl ByteCompiler<'_, '_> { /// Creates the declarations from a [`ModuleItem`]. #[inline] - #[allow(unused_variables)] // Unimplemented pub(crate) fn create_decls_from_module_item( &mut self, item: &ModuleItem, configurable_globals: bool, ) -> bool { match item { - ModuleItem::ImportDeclaration(import) => todo!("import declaration generation"), - ModuleItem::ExportDeclaration(export) => todo!("export declaration generation"), + ModuleItem::ImportDeclaration(_import) => todo!("import declaration generation"), + ModuleItem::ExportDeclaration(_export) => todo!("export declaration generation"), ModuleItem::StatementListItem(stmt) => { self.create_decls_from_stmt_list_item(stmt, configurable_globals) }