Skip to content

Commit

Permalink
Align parse_script and parse_module arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad committed Sep 22, 2024
1 parent 85eb328 commit accfd60
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ where
} else {
let scope = context.realm().scope().clone();
let mut script = parser
.parse_script(context.interner_mut(), &scope)
.parse_script(&scope, context.interner_mut())
.map_err(|e| format!("Uncaught SyntaxError: {e}"))?;

if args.optimize {
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/builtins/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Json {
// 10. Assert: unfiltered is either a String, Number, Boolean, Null, or an Object that is defined by either an ArrayLiteral or an ObjectLiteral.
let mut parser = Parser::new(Source::from_bytes(&script_string));
parser.set_json_parse();
let script = parser.parse_script(context.interner_mut(), &Scope::new_global())?;
let script = parser.parse_script(&Scope::new_global(), context.interner_mut())?;
let code_block = {
let in_with = context.vm.environments.has_object_environment();
let mut compiler = ByteCompiler::new(
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Script {
parser.set_strict();
}
let scope = context.realm().scope().clone();
let mut code = parser.parse_script(context.interner_mut(), &scope)?;
let mut code = parser.parse_script(&scope, context.interner_mut())?;
if !context.optimizer_options().is_empty() {
context.optimize_statement_list(code.statements_mut());
}
Expand Down
6 changes: 3 additions & 3 deletions core/parser/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ impl<'a, R: ReadChar> Parser<'a, R> {
/// [spec]: https://tc39.es/ecma262/#prod-Script
pub fn parse_script(
&mut self,
interner: &mut Interner,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<boa_ast::Script> {
self.cursor.set_goal(InputElement::HashbangOrRegExp);
let mut ast = ScriptParser::new(false).parse(&mut self.cursor, interner)?;
Expand All @@ -166,15 +166,15 @@ impl<'a, R: ReadChar> Parser<'a, R> {
/// [spec]: https://tc39.es/ecma262/#prod-Module
pub fn parse_module(
&mut self,
global_scope: &Scope,
scope: &Scope,
interner: &mut Interner,
) -> ParseResult<boa_ast::Module>
where
R: ReadChar,
{
self.cursor.set_goal(InputElement::HashbangOrRegExp);
let mut module = ModuleParser.parse(&mut self.cursor, interner)?;
if !module.analyze_scope(global_scope, interner) {
if !module.analyze_scope(scope, interner) {
return Err(Error::general(
"invalid scope analysis",
Position::new(1, 1),
Expand Down
2 changes: 1 addition & 1 deletion core/parser/src/parser/tests/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn test_formatting(source: &'static str) {
let source = Source::from_bytes(source);
let interner = &mut Interner::default();
let result = Parser::new(source)
.parse_script(interner, &Scope::new_global())
.parse_script(&Scope::new_global(), interner)
.expect("parsing failed")
.to_interned_string(interner);
if scenario != result {
Expand Down
4 changes: 2 additions & 2 deletions core/parser/src/parser/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
script.analyze_scope(&scope, interner);
assert_eq!(
Parser::new(Source::from_bytes(js))
.parse_script(interner, &Scope::new_global())
.parse_script(&Scope::new_global(), interner)
.expect("failed to parse"),
script,
);
Expand All @@ -50,7 +50,7 @@ where
#[track_caller]
pub(super) fn check_invalid_script(js: &str) {
assert!(Parser::new(Source::from_bytes(js))
.parse_script(&mut Interner::default(), &Scope::new_global())
.parse_script(&Scope::new_global(), &mut Interner::default())
.is_err());
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/commuter_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn main() {
let mut ctx = Context::default();

let scope = ctx.realm().scope().clone();
let mut script = parser.parse_script(ctx.interner_mut(), &scope).unwrap();
let mut script = parser.parse_script(&scope, ctx.interner_mut()).unwrap();

let mut visitor = CommutorVisitor::default();

Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/symbol_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
let mut ctx = Context::default();

let scope = ctx.realm().scope().clone();
let script = parser.parse_script(ctx.interner_mut(), &scope).unwrap();
let script = parser.parse_script(&scope, ctx.interner_mut()).unwrap();

let mut visitor = SymbolVisitor::default();

Expand Down

0 comments on commit accfd60

Please sign in to comment.