Skip to content

Commit

Permalink
some renames
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-str committed Jan 10, 2025
1 parent 4b4ae34 commit 782a218
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 53 deletions.
2 changes: 1 addition & 1 deletion core/engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ impl BuiltInFunctionObject {
}

let in_with = context.vm.environments.has_object_environment();
let spanned_source_text = SpannedSourceText::new_pseudo();
let spanned_source_text = SpannedSourceText::new_empty();

let code = FunctionCompiler::new(spanned_source_text)
.name(js_string!("anonymous"))
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 @@ -118,7 +118,7 @@ impl Json {
let code_block = {
let in_with = context.vm.environments.has_object_environment();
// If the source is needed then call `parser.parse_script_with_source` and pass `source_text` here.
let spanned_source_text = SpannedSourceText::new_pseudo();
let spanned_source_text = SpannedSourceText::new_empty();
let mut compiler = ByteCompiler::new(
js_string!("<main>"),
script.strict(),
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/module/synthetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl SyntheticModule {
context.interner_mut(),
false,
// A synthetic module does not contain `SourceText`
SpannedSourceText::new_pseudo(),
SpannedSourceText::new_empty(),
);

// 4. For each String exportName in module.[[ExportNames]], do
Expand Down
7 changes: 3 additions & 4 deletions core/engine/src/spanned_source_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ impl SourceText {
}
}

#[must_use]
pub(crate) fn new_pseudo() -> Self {
fn new_empty() -> Self {
Self { source_text: None }
}

Expand Down Expand Up @@ -59,9 +58,9 @@ impl SpannedSourceText {
}
}

pub(crate) fn new_pseudo() -> Self {
pub(crate) fn new_empty() -> Self {
Self {
source_text: SourceText::new_pseudo(),
source_text: SourceText::new_empty(),
span: None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl CodeBlock {
parameter_length: 0,
handlers: ThinVec::default(),
ic: Box::default(),
source_text_spanned: SpannedSourceText::new_pseudo(),
source_text_spanned: SpannedSourceText::new_empty(),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use boa_interner::Interner;
use boa_macros::utf16;

const PSEUDO_LINEAR_POS: boa_ast::LinearPosition = boa_ast::LinearPosition::new(0);
const PSEUDO_LINEAR_SPAN: boa_ast::LinearSpan =
const EMPTY_LINEAR_SPAN: boa_ast::LinearSpan =
boa_ast::LinearSpan::new(PSEUDO_LINEAR_POS, PSEUDO_LINEAR_POS);

/// Checks async expression parsing.
Expand All @@ -37,7 +37,7 @@ fn check_async_expression() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand Down Expand Up @@ -86,7 +86,7 @@ fn check_nested_async_expression() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand All @@ -99,7 +99,7 @@ fn check_nested_async_expression() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use boa_interner::Interner;
use boa_macros::utf16;

const PSEUDO_LINEAR_POS: boa_ast::LinearPosition = boa_ast::LinearPosition::new(0);
const PSEUDO_LINEAR_SPAN: boa_ast::LinearSpan =
const EMPTY_LINEAR_SPAN: boa_ast::LinearSpan =
boa_ast::LinearSpan::new(PSEUDO_LINEAR_POS, PSEUDO_LINEAR_POS);

///checks async generator expression parsing
Expand Down Expand Up @@ -38,7 +38,7 @@ fn check_async_generator_expr() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand Down Expand Up @@ -86,7 +86,7 @@ fn check_nested_async_generator_expr() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand All @@ -99,7 +99,7 @@ fn check_nested_async_generator_expr() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use boa_interner::Interner;
use boa_macros::utf16;

const PSEUDO_LINEAR_POS: boa_ast::LinearPosition = boa_ast::LinearPosition::new(0);
const PSEUDO_LINEAR_SPAN: boa_ast::LinearSpan =
const EMPTY_LINEAR_SPAN: boa_ast::LinearSpan =
boa_ast::LinearSpan::new(PSEUDO_LINEAR_POS, PSEUDO_LINEAR_POS);

#[test]
Expand All @@ -35,7 +35,7 @@ fn check_generator_function_expression() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand Down Expand Up @@ -72,7 +72,7 @@ fn check_generator_function_delegate_yield_expression() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
false,
)
.into(),
Expand Down
42 changes: 21 additions & 21 deletions core/parser/src/parser/function/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use boa_interner::Interner;
use boa_macros::utf16;

const PSEUDO_LINEAR_POS: boa_ast::LinearPosition = boa_ast::LinearPosition::new(0);
const PSEUDO_LINEAR_SPAN: boa_ast::LinearSpan =
const EMPTY_LINEAR_SPAN: boa_ast::LinearSpan =
boa_ast::LinearSpan::new(PSEUDO_LINEAR_POS, PSEUDO_LINEAR_POS);

/// Checks basic function declaration parsing.
Expand Down Expand Up @@ -44,7 +44,7 @@ fn check_basic() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into()],
interner,
Expand Down Expand Up @@ -84,7 +84,7 @@ fn check_duplicates_strict_off() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into()],
interner,
Expand Down Expand Up @@ -122,7 +122,7 @@ fn check_basic_semicolon_insertion() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into()],
interner,
Expand Down Expand Up @@ -151,7 +151,7 @@ fn check_empty_return() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into()],
interner,
Expand Down Expand Up @@ -180,7 +180,7 @@ fn check_empty_return_semicolon_insertion() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into()],
interner,
Expand Down Expand Up @@ -212,7 +212,7 @@ fn check_rest_operator() {
interner.get_or_intern_static("foo", utf16!("foo")).into(),
params,
FunctionBody::default(),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into()],
interner,
Expand All @@ -238,7 +238,7 @@ fn check_arrow_only_rest() {
None,
params,
FunctionBody::default(),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)))
.into()],
interner,
Expand Down Expand Up @@ -274,7 +274,7 @@ fn check_arrow_rest() {
None,
params,
FunctionBody::default(),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)))
.into()],
interner,
Expand Down Expand Up @@ -316,7 +316,7 @@ fn check_arrow() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)))
.into()],
interner,
Expand Down Expand Up @@ -356,7 +356,7 @@ fn check_arrow_semicolon_insertion() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)))
.into()],
interner,
Expand Down Expand Up @@ -389,7 +389,7 @@ fn check_arrow_epty_return() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)))
.into()],
interner,
Expand Down Expand Up @@ -422,7 +422,7 @@ fn check_arrow_empty_return_semicolon_insertion() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)))
.into()],
interner,
Expand Down Expand Up @@ -459,7 +459,7 @@ fn check_arrow_assignment() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down Expand Up @@ -502,7 +502,7 @@ fn check_arrow_assignment_nobrackets() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down Expand Up @@ -545,7 +545,7 @@ fn check_arrow_assignment_noparenthesis() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down Expand Up @@ -588,7 +588,7 @@ fn check_arrow_assignment_noparenthesis_nobrackets() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down Expand Up @@ -637,7 +637,7 @@ fn check_arrow_assignment_2arg() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down Expand Up @@ -686,7 +686,7 @@ fn check_arrow_assignment_2arg_nobrackets() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down Expand Up @@ -739,7 +739,7 @@ fn check_arrow_assignment_3arg() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down Expand Up @@ -792,7 +792,7 @@ fn check_arrow_assignment_3arg_nobrackets() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
)
.into(),
),
Expand Down
6 changes: 3 additions & 3 deletions core/parser/src/parser/statement/block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use boa_interner::Interner;
use boa_macros::utf16;

const PSEUDO_LINEAR_POS: boa_ast::LinearPosition = boa_ast::LinearPosition::new(0);
const PSEUDO_LINEAR_SPAN: boa_ast::LinearSpan =
const EMPTY_LINEAR_SPAN: boa_ast::LinearSpan =
boa_ast::LinearSpan::new(PSEUDO_LINEAR_POS, PSEUDO_LINEAR_POS);

/// Helper function to check a block.
Expand Down Expand Up @@ -92,7 +92,7 @@ fn non_empty() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into(),
Statement::Var(VarDeclaration(
Expand Down Expand Up @@ -151,7 +151,7 @@ fn hoisting() {
PSEUDO_LINEAR_POS,
false,
),
PSEUDO_LINEAR_SPAN,
EMPTY_LINEAR_SPAN,
))
.into(),
],
Expand Down
Loading

0 comments on commit 782a218

Please sign in to comment.