mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:47:45 +00:00
Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
This commit is contained in:
parent
104be6c8ac
commit
8a48246ed1
168 changed files with 1280 additions and 1280 deletions
|
@ -107,7 +107,7 @@ Completion ScopeNode::evaluate_statements(Interpreter& interpreter) const
|
|||
{
|
||||
auto completion = normal_completion({});
|
||||
for (auto const& node : children()) {
|
||||
completion = node.execute(interpreter).update_empty(completion.value());
|
||||
completion = node->execute(interpreter).update_empty(completion.value());
|
||||
if (completion.is_abrupt())
|
||||
break;
|
||||
}
|
||||
|
@ -958,12 +958,12 @@ struct ForInOfHeadState {
|
|||
VERIFY(expression_lhs);
|
||||
if (is<VariableDeclaration>(*expression_lhs)) {
|
||||
auto& declaration = static_cast<VariableDeclaration const&>(*expression_lhs);
|
||||
VERIFY(declaration.declarations().first().target().has<NonnullRefPtr<Identifier const>>());
|
||||
lhs_reference = TRY(declaration.declarations().first().target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
|
||||
VERIFY(declaration.declarations().first()->target().has<NonnullRefPtr<Identifier const>>());
|
||||
lhs_reference = TRY(declaration.declarations().first()->target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
|
||||
} else if (is<UsingDeclaration>(*expression_lhs)) {
|
||||
auto& declaration = static_cast<UsingDeclaration const&>(*expression_lhs);
|
||||
VERIFY(declaration.declarations().first().target().has<NonnullRefPtr<Identifier const>>());
|
||||
lhs_reference = TRY(declaration.declarations().first().target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
|
||||
VERIFY(declaration.declarations().first()->target().has<NonnullRefPtr<Identifier const>>());
|
||||
lhs_reference = TRY(declaration.declarations().first()->target().get<NonnullRefPtr<Identifier const>>()->to_reference(interpreter));
|
||||
} else {
|
||||
VERIFY(is<Identifier>(*expression_lhs) || is<MemberExpression>(*expression_lhs) || is<CallExpression>(*expression_lhs));
|
||||
auto& expression = static_cast<Expression const&>(*expression_lhs);
|
||||
|
@ -1032,7 +1032,7 @@ struct ForInOfHeadState {
|
|||
}
|
||||
VERIFY(expression_lhs && is<VariableDeclaration>(*expression_lhs));
|
||||
auto& for_declaration = static_cast<VariableDeclaration const&>(*expression_lhs);
|
||||
auto& binding_pattern = for_declaration.declarations().first().target().get<NonnullRefPtr<BindingPattern const>>();
|
||||
auto& binding_pattern = for_declaration.declarations().first()->target().get<NonnullRefPtr<BindingPattern const>>();
|
||||
VERIFY(lhs_kind == VarBinding || iteration_environment);
|
||||
|
||||
// At this point iteration_environment is undefined if lhs_kind == VarBinding which means this does both
|
||||
|
@ -1063,16 +1063,16 @@ static ThrowCompletionOr<ForInOfHeadState> for_in_of_head_execute(Interpreter& i
|
|||
if (is<VariableDeclaration>(ast_ptr->ptr())) {
|
||||
auto& variable_declaration = static_cast<VariableDeclaration const&>(*(*ast_ptr));
|
||||
VERIFY(variable_declaration.declarations().size() == 1);
|
||||
state.destructuring = variable_declaration.declarations().first().target().has<NonnullRefPtr<BindingPattern const>>();
|
||||
state.destructuring = variable_declaration.declarations().first()->target().has<NonnullRefPtr<BindingPattern const>>();
|
||||
if (variable_declaration.declaration_kind() == DeclarationKind::Var) {
|
||||
state.lhs_kind = ForInOfHeadState::VarBinding;
|
||||
auto& variable = variable_declaration.declarations().first();
|
||||
// B.3.5 Initializers in ForIn Statement Heads, https://tc39.es/ecma262/#sec-initializers-in-forin-statement-heads
|
||||
if (variable.init()) {
|
||||
VERIFY(variable.target().has<NonnullRefPtr<Identifier const>>());
|
||||
auto& binding_id = variable.target().get<NonnullRefPtr<Identifier const>>()->string();
|
||||
if (variable->init()) {
|
||||
VERIFY(variable->target().has<NonnullRefPtr<Identifier const>>());
|
||||
auto& binding_id = variable->target().get<NonnullRefPtr<Identifier const>>()->string();
|
||||
auto reference = TRY(interpreter.vm().resolve_binding(binding_id));
|
||||
auto result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*variable.init(), binding_id));
|
||||
auto result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*variable->init(), binding_id));
|
||||
TRY(reference.put_value(vm, result));
|
||||
}
|
||||
} else {
|
||||
|
@ -1950,7 +1950,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
|
|||
auto class_private_environment = new_private_environment(vm, outer_private_environment);
|
||||
|
||||
for (auto const& element : m_elements) {
|
||||
auto opt_private_name = element.private_bound_identifier();
|
||||
auto opt_private_name = element->private_bound_identifier();
|
||||
if (opt_private_name.has_value())
|
||||
class_private_environment->add_private_name({}, opt_private_name.release_value());
|
||||
}
|
||||
|
@ -2026,10 +2026,10 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
|
|||
|
||||
for (auto const& element : m_elements) {
|
||||
// Note: All ClassElementEvaluation start with evaluating the name (or we fake it).
|
||||
auto element_value = TRY(element.class_element_evaluation(interpreter, element.is_static() ? *class_constructor : *prototype));
|
||||
auto element_value = TRY(element->class_element_evaluation(interpreter, element->is_static() ? *class_constructor : *prototype));
|
||||
|
||||
if (element_value.has<PrivateElement>()) {
|
||||
auto& container = element.is_static() ? static_private_methods : instance_private_methods;
|
||||
auto& container = element->is_static() ? static_private_methods : instance_private_methods;
|
||||
|
||||
auto& private_element = element_value.get<PrivateElement>();
|
||||
|
||||
|
@ -2051,11 +2051,11 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e
|
|||
if (!added_to_existing)
|
||||
container.append(move(element_value.get<PrivateElement>()));
|
||||
} else if (auto* class_field_definition_ptr = element_value.get_pointer<ClassFieldDefinition>()) {
|
||||
if (element.is_static())
|
||||
if (element->is_static())
|
||||
static_elements.append(move(*class_field_definition_ptr));
|
||||
else
|
||||
instance_fields.append(move(*class_field_definition_ptr));
|
||||
} else if (element.class_element_kind() == ClassElement::ElementKind::StaticInitializer) {
|
||||
} else if (element->class_element_kind() == ClassElement::ElementKind::StaticInitializer) {
|
||||
// We use Completion to hold the ClassStaticBlockDefinition Record.
|
||||
VERIFY(element_value.has<Completion>() && element_value.get<Completion>().value().has_value());
|
||||
auto& element_object = element_value.get<Completion>().value()->as_object();
|
||||
|
@ -2108,28 +2108,28 @@ void ScopeNode::dump(int indent) const
|
|||
print_indent(indent + 1);
|
||||
outln("(Lexical declarations)");
|
||||
for (auto& declaration : m_lexical_declarations)
|
||||
declaration.dump(indent + 2);
|
||||
declaration->dump(indent + 2);
|
||||
}
|
||||
|
||||
if (!m_var_declarations.is_empty()) {
|
||||
print_indent(indent + 1);
|
||||
outln("(Variable declarations)");
|
||||
for (auto& declaration : m_var_declarations)
|
||||
declaration.dump(indent + 2);
|
||||
declaration->dump(indent + 2);
|
||||
}
|
||||
|
||||
if (!m_functions_hoistable_with_annexB_extension.is_empty()) {
|
||||
print_indent(indent + 1);
|
||||
outln("(Hoisted functions via annexB extension)");
|
||||
for (auto& declaration : m_functions_hoistable_with_annexB_extension)
|
||||
declaration.dump(indent + 2);
|
||||
declaration->dump(indent + 2);
|
||||
}
|
||||
|
||||
if (!m_children.is_empty()) {
|
||||
print_indent(indent + 1);
|
||||
outln("(Children)");
|
||||
for (auto& child : children())
|
||||
child.dump(indent + 2);
|
||||
child->dump(indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2322,7 +2322,7 @@ void ClassExpression::dump(int indent) const
|
|||
print_indent(indent);
|
||||
outln("(Elements)");
|
||||
for (auto& method : m_elements)
|
||||
method.dump(indent + 1);
|
||||
method->dump(indent + 1);
|
||||
}
|
||||
|
||||
void ClassMethod::dump(int indent) const
|
||||
|
@ -3033,8 +3033,8 @@ Completion VariableDeclaration::execute(Interpreter& interpreter) const
|
|||
auto& vm = interpreter.vm();
|
||||
|
||||
for (auto& declarator : m_declarations) {
|
||||
if (auto* init = declarator.init()) {
|
||||
TRY(declarator.target().visit(
|
||||
if (auto* init = declarator->init()) {
|
||||
TRY(declarator->target().visit(
|
||||
[&](NonnullRefPtr<Identifier const> const& id) -> ThrowCompletionOr<void> {
|
||||
auto reference = TRY(id->to_reference(interpreter));
|
||||
auto initializer_result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*init, id->string()));
|
||||
|
@ -3053,8 +3053,8 @@ Completion VariableDeclaration::execute(Interpreter& interpreter) const
|
|||
return vm.binding_initialization(pattern, initializer_result, environment);
|
||||
}));
|
||||
} else if (m_declaration_kind != DeclarationKind::Var) {
|
||||
VERIFY(declarator.target().has<NonnullRefPtr<Identifier const>>());
|
||||
auto& identifier = declarator.target().get<NonnullRefPtr<Identifier const>>();
|
||||
VERIFY(declarator->target().has<NonnullRefPtr<Identifier const>>());
|
||||
auto& identifier = declarator->target().get<NonnullRefPtr<Identifier const>>();
|
||||
auto reference = TRY(identifier->to_reference(interpreter));
|
||||
TRY(reference.initialize_referenced_binding(vm, js_undefined()));
|
||||
}
|
||||
|
@ -3073,7 +3073,7 @@ Completion VariableDeclarator::execute(Interpreter& interpreter) const
|
|||
ThrowCompletionOr<void> VariableDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
|
||||
{
|
||||
for (auto const& entry : declarations()) {
|
||||
TRY(entry.target().visit(
|
||||
TRY(entry->target().visit(
|
||||
[&](NonnullRefPtr<Identifier const> const& id) {
|
||||
return callback(id->string());
|
||||
},
|
||||
|
@ -3107,7 +3107,7 @@ void VariableDeclaration::dump(int indent) const
|
|||
outln("{}", declaration_kind_string);
|
||||
|
||||
for (auto& declarator : m_declarations)
|
||||
declarator.dump(indent + 1);
|
||||
declarator->dump(indent + 1);
|
||||
}
|
||||
|
||||
// 6.2.1.2 Runtime Semantics: Evaluation, https://tc39.es/proposal-explicit-resource-management/#sec-let-and-const-declarations-runtime-semantics-evaluation
|
||||
|
@ -3118,14 +3118,14 @@ Completion UsingDeclaration::execute(Interpreter& interpreter) const
|
|||
auto& vm = interpreter.vm();
|
||||
|
||||
for (auto& declarator : m_declarations) {
|
||||
VERIFY(declarator.target().has<NonnullRefPtr<Identifier const>>());
|
||||
VERIFY(declarator.init());
|
||||
VERIFY(declarator->target().has<NonnullRefPtr<Identifier const>>());
|
||||
VERIFY(declarator->init());
|
||||
|
||||
auto& id = declarator.target().get<NonnullRefPtr<Identifier const>>();
|
||||
auto& id = declarator->target().get<NonnullRefPtr<Identifier const>>();
|
||||
|
||||
// 2. ReturnIfAbrupt(next).
|
||||
auto reference = TRY(id->to_reference(interpreter));
|
||||
auto initializer_result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*declarator.init(), id->string()));
|
||||
auto initializer_result = TRY(interpreter.vm().named_evaluation_if_anonymous_function(*declarator->init(), id->string()));
|
||||
VERIFY(!initializer_result.is_empty());
|
||||
TRY(reference.initialize_referenced_binding(vm, initializer_result, Environment::InitializeBindingHint::SyncDispose));
|
||||
}
|
||||
|
@ -3137,8 +3137,8 @@ Completion UsingDeclaration::execute(Interpreter& interpreter) const
|
|||
ThrowCompletionOr<void> UsingDeclaration::for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
|
||||
{
|
||||
for (auto const& entry : m_declarations) {
|
||||
VERIFY(entry.target().has<NonnullRefPtr<Identifier const>>());
|
||||
TRY(callback(entry.target().get<NonnullRefPtr<Identifier const>>()->string()));
|
||||
VERIFY(entry->target().has<NonnullRefPtr<Identifier const>>());
|
||||
TRY(callback(entry->target().get<NonnullRefPtr<Identifier const>>()->string()));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -3149,7 +3149,7 @@ void UsingDeclaration::dump(int indent) const
|
|||
ASTNode::dump(indent);
|
||||
print_indent(indent + 1);
|
||||
for (auto& declarator : m_declarations)
|
||||
declarator.dump(indent + 1);
|
||||
declarator->dump(indent + 1);
|
||||
}
|
||||
|
||||
void VariableDeclarator::dump(int indent) const
|
||||
|
@ -3178,7 +3178,7 @@ void ObjectExpression::dump(int indent) const
|
|||
{
|
||||
ASTNode::dump(indent);
|
||||
for (auto& property : m_properties) {
|
||||
property.dump(indent + 1);
|
||||
property->dump(indent + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3208,10 +3208,10 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
|
|||
|
||||
// 2. Perform ? PropertyDefinitionEvaluation of PropertyDefinitionList with argument obj.
|
||||
for (auto& property : m_properties) {
|
||||
auto key = TRY(property.key().execute(interpreter)).release_value();
|
||||
auto key = TRY(property->key().execute(interpreter)).release_value();
|
||||
|
||||
// PropertyDefinition : ... AssignmentExpression
|
||||
if (property.type() == ObjectProperty::Type::Spread) {
|
||||
if (property->type() == ObjectProperty::Type::Spread) {
|
||||
// 4. Perform ? CopyDataProperties(object, fromValue, excludedNames).
|
||||
TRY(object->copy_data_properties(vm, key, {}));
|
||||
|
||||
|
@ -3219,10 +3219,10 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
|
|||
continue;
|
||||
}
|
||||
|
||||
auto value = TRY(property.value().execute(interpreter)).release_value();
|
||||
auto value = TRY(property->value().execute(interpreter)).release_value();
|
||||
|
||||
// 8. If isProtoSetter is true, then
|
||||
if (property.type() == ObjectProperty::Type::ProtoSetter) {
|
||||
if (property->type() == ObjectProperty::Type::ProtoSetter) {
|
||||
// a. If Type(propValue) is either Object or Null, then
|
||||
if (value.is_object() || value.is_null()) {
|
||||
// i. Perform ! object.[[SetPrototypeOf]](propValue).
|
||||
|
@ -3234,21 +3234,21 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
|
|||
|
||||
auto property_key = TRY(PropertyKey::from_value(vm, key));
|
||||
|
||||
if (property.is_method()) {
|
||||
if (property->is_method()) {
|
||||
VERIFY(value.is_function());
|
||||
static_cast<ECMAScriptFunctionObject&>(value.as_function()).set_home_object(object);
|
||||
|
||||
auto name = MUST(get_function_property_name(property_key));
|
||||
if (property.type() == ObjectProperty::Type::Getter) {
|
||||
if (property->type() == ObjectProperty::Type::Getter) {
|
||||
name = DeprecatedString::formatted("get {}", name);
|
||||
} else if (property.type() == ObjectProperty::Type::Setter) {
|
||||
} else if (property->type() == ObjectProperty::Type::Setter) {
|
||||
name = DeprecatedString::formatted("set {}", name);
|
||||
}
|
||||
|
||||
update_function_name(value, name);
|
||||
}
|
||||
|
||||
switch (property.type()) {
|
||||
switch (property->type()) {
|
||||
case ObjectProperty::Type::Getter:
|
||||
VERIFY(value.is_function());
|
||||
object->define_direct_accessor(property_key, &value.as_function(), nullptr, Attribute::Configurable | Attribute::Enumerable);
|
||||
|
@ -3741,7 +3741,7 @@ void TemplateLiteral::dump(int indent) const
|
|||
{
|
||||
ASTNode::dump(indent);
|
||||
for (auto& expression : m_expressions)
|
||||
expression.dump(indent + 1);
|
||||
expression->dump(indent + 1);
|
||||
}
|
||||
|
||||
// 13.2.8.5 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-template-literals-runtime-semantics-evaluation
|
||||
|
@ -3757,7 +3757,7 @@ Completion TemplateLiteral::execute(Interpreter& interpreter) const
|
|||
|
||||
// 2. Let subRef be the result of evaluating Expression.
|
||||
// 3. Let sub be ? GetValue(subRef).
|
||||
auto sub = TRY(expression.execute(interpreter)).release_value();
|
||||
auto sub = TRY(expression->execute(interpreter)).release_value();
|
||||
|
||||
// 4. Let middle be ? ToString(sub).
|
||||
auto string = TRY(sub.to_deprecated_string(vm));
|
||||
|
@ -3835,7 +3835,7 @@ Completion TaggedTemplateLiteral::execute(Interpreter& interpreter) const
|
|||
// tag`foo${bar}baz${qux}` -> "foo", bar, "baz", qux, "" -> tag(["foo", "baz", ""], bar, qux)
|
||||
// So we want all the odd expressions
|
||||
for (size_t i = 1; i < expressions.size(); i += 2)
|
||||
arguments.append(TRY(expressions[i].execute(interpreter)).release_value());
|
||||
arguments.append(TRY(expressions[i]->execute(interpreter)).release_value());
|
||||
|
||||
// 5. Return ? EvaluateCall(tagFunc, tagRef, TemplateLiteral, tailCall).
|
||||
return call(vm, tag, tag_this_value, move(arguments));
|
||||
|
@ -3887,7 +3887,7 @@ ThrowCompletionOr<Value> TaggedTemplateLiteral::get_template_object(Interpreter&
|
|||
auto cooked_string_index = i * 2;
|
||||
// a. Let prop be ! ToString(𝔽(index)).
|
||||
// b. Let cookedValue be cookedStrings[index].
|
||||
auto cooked_value = TRY(expressions[cooked_string_index].execute(interpreter)).release_value();
|
||||
auto cooked_value = TRY(expressions[cooked_string_index]->execute(interpreter)).release_value();
|
||||
|
||||
// NOTE: If the string contains invalid escapes we get a null expression here,
|
||||
// which we then convert to the expected `undefined` TV. See
|
||||
|
@ -3900,7 +3900,7 @@ ThrowCompletionOr<Value> TaggedTemplateLiteral::get_template_object(Interpreter&
|
|||
|
||||
// d. Let rawValue be the String value rawStrings[index].
|
||||
// e. Perform ! DefinePropertyOrThrow(rawObj, prop, PropertyDescriptor { [[Value]]: rawValue, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false }).
|
||||
raw_obj->indexed_properties().append(TRY(raw_strings[i].execute(interpreter)).release_value());
|
||||
raw_obj->indexed_properties().append(TRY(raw_strings[i]->execute(interpreter)).release_value());
|
||||
|
||||
// f. Set index to index + 1.
|
||||
}
|
||||
|
@ -4108,11 +4108,11 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
|
|||
// 14.12.3 CaseClauseIsSelected ( C, input ), https://tc39.es/ecma262/#sec-runtime-semantics-caseclauseisselected
|
||||
auto case_clause_is_selected = [&](auto const& case_clause, auto input) -> ThrowCompletionOr<bool> {
|
||||
// 1. Assert: C is an instance of the production CaseClause : case Expression : StatementList[opt] .
|
||||
VERIFY(case_clause.test());
|
||||
VERIFY(case_clause->test());
|
||||
|
||||
// 2. Let exprRef be the result of evaluating the Expression of C.
|
||||
// 3. Let clauseSelector be ? GetValue(exprRef).
|
||||
auto clause_selector = TRY(case_clause.test()->execute(interpreter)).release_value();
|
||||
auto clause_selector = TRY(case_clause->test()->execute(interpreter)).release_value();
|
||||
|
||||
// 4. Return IsStrictlyEqual(input, clauseSelector).
|
||||
return is_strictly_equal(input, clause_selector);
|
||||
|
@ -4126,11 +4126,11 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<SwitchCase const> case_clauses_1;
|
||||
NonnullRefPtrVector<SwitchCase const> case_clauses_2;
|
||||
Vector<NonnullRefPtr<SwitchCase const>> case_clauses_1;
|
||||
Vector<NonnullRefPtr<SwitchCase const>> case_clauses_2;
|
||||
RefPtr<SwitchCase const> default_clause;
|
||||
for (auto const& switch_case : m_cases) {
|
||||
if (!switch_case.test())
|
||||
if (!switch_case->test())
|
||||
default_clause = switch_case;
|
||||
else if (!default_clause)
|
||||
case_clauses_1.append(switch_case);
|
||||
|
@ -4163,7 +4163,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
|
|||
// b. If found is true, then
|
||||
if (found) {
|
||||
// i. Let R be the result of evaluating C.
|
||||
auto result = case_clause.evaluate_statements(interpreter);
|
||||
auto result = case_clause->evaluate_statements(interpreter);
|
||||
|
||||
// ii. If R.[[Value]] is not empty, set V to R.[[Value]].
|
||||
if (result.value().has_value())
|
||||
|
@ -4203,7 +4203,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
|
|||
// b. If found is true, then
|
||||
if (found) {
|
||||
// i. Let R be the result of evaluating C.
|
||||
auto result = case_clause.evaluate_statements(interpreter);
|
||||
auto result = case_clause->evaluate_statements(interpreter);
|
||||
|
||||
// ii. If R.[[Value]] is not empty, set V to R.[[Value]].
|
||||
if (result.value().has_value())
|
||||
|
@ -4237,7 +4237,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
|
|||
// ii. If foundInB is true, then
|
||||
if (found_in_b) {
|
||||
// 1. Let R be the result of evaluating CaseClause C.
|
||||
auto result = case_clause.evaluate_statements(interpreter);
|
||||
auto result = case_clause->evaluate_statements(interpreter);
|
||||
|
||||
// 2. If R.[[Value]] is not empty, set V to R.[[Value]].
|
||||
if (result.value().has_value())
|
||||
|
@ -4269,7 +4269,7 @@ Completion SwitchStatement::execute_impl(Interpreter& interpreter) const
|
|||
// 15. For each CaseClause C of B, do
|
||||
for (auto const& case_clause : case_clauses_2) {
|
||||
// a. Let R be the result of evaluating CaseClause C.
|
||||
result = case_clause.evaluate_statements(interpreter);
|
||||
result = case_clause->evaluate_statements(interpreter);
|
||||
|
||||
// b. If R.[[Value]] is not empty, set V to R.[[Value]].
|
||||
if (result.value().has_value())
|
||||
|
@ -4375,7 +4375,7 @@ void SwitchStatement::dump(int indent) const
|
|||
ASTNode::dump(indent);
|
||||
m_discriminant->dump(indent + 1);
|
||||
for (auto& switch_case : m_cases) {
|
||||
switch_case.dump(indent + 1);
|
||||
switch_case->dump(indent + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4434,7 +4434,7 @@ void SequenceExpression::dump(int indent) const
|
|||
{
|
||||
ASTNode::dump(indent);
|
||||
for (auto& expression : m_expressions)
|
||||
expression.dump(indent + 1);
|
||||
expression->dump(indent + 1);
|
||||
}
|
||||
|
||||
// 13.16.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-comma-operator-runtime-semantics-evaluation
|
||||
|
@ -4449,7 +4449,7 @@ Completion SequenceExpression::execute(Interpreter& interpreter) const
|
|||
// 4. Return ? GetValue(rref).
|
||||
Value last_value;
|
||||
for (auto const& expression : m_expressions)
|
||||
last_value = TRY(expression.execute(interpreter)).release_value();
|
||||
last_value = TRY(expression->execute(interpreter)).release_value();
|
||||
return { move(last_value) };
|
||||
}
|
||||
|
||||
|
@ -4484,7 +4484,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_lexically_scoped_declaration(ThrowCo
|
|||
ThrowCompletionOr<void> ScopeNode::for_each_lexically_declared_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
|
||||
{
|
||||
for (auto const& declaration : m_lexical_declarations) {
|
||||
TRY(declaration.for_each_bound_name([&](auto const& name) {
|
||||
TRY(declaration->for_each_bound_name([&](auto const& name) {
|
||||
return callback(name);
|
||||
}));
|
||||
}
|
||||
|
@ -4494,7 +4494,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_lexically_declared_name(ThrowComplet
|
|||
ThrowCompletionOr<void> ScopeNode::for_each_var_declared_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const
|
||||
{
|
||||
for (auto& declaration : m_var_declarations) {
|
||||
TRY(declaration.for_each_bound_name([&](auto const& name) {
|
||||
TRY(declaration->for_each_bound_name([&](auto const& name) {
|
||||
return callback(name);
|
||||
}));
|
||||
}
|
||||
|
@ -4506,7 +4506,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_var_function_declaration_in_reverse_
|
|||
for (ssize_t i = m_var_declarations.size() - 1; i >= 0; i--) {
|
||||
auto& declaration = m_var_declarations[i];
|
||||
if (is<FunctionDeclaration>(declaration))
|
||||
TRY(callback(static_cast<FunctionDeclaration const&>(declaration)));
|
||||
TRY(callback(static_cast<FunctionDeclaration const&>(*declaration)));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -4516,7 +4516,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_var_scoped_variable_declaration(Thro
|
|||
for (auto& declaration : m_var_declarations) {
|
||||
if (!is<FunctionDeclaration>(declaration)) {
|
||||
VERIFY(is<VariableDeclaration>(declaration));
|
||||
TRY(callback(static_cast<VariableDeclaration const&>(declaration)));
|
||||
TRY(callback(static_cast<VariableDeclaration const&>(*declaration)));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
@ -4526,7 +4526,7 @@ ThrowCompletionOr<void> ScopeNode::for_each_function_hoistable_with_annexB_exten
|
|||
{
|
||||
for (auto& function : m_functions_hoistable_with_annexB_extension) {
|
||||
// We need const_cast here since it might have to set a property on function declaration.
|
||||
TRY(callback(const_cast<FunctionDeclaration&>(function)));
|
||||
TRY(callback(const_cast<FunctionDeclaration&>(*function)));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -272,7 +272,7 @@ public:
|
|||
{
|
||||
auto child = create_ast_node<T>(range, forward<Args>(args)...);
|
||||
m_children.append(move(child));
|
||||
return static_cast<T&>(m_children.last());
|
||||
return static_cast<T&>(*m_children.last());
|
||||
}
|
||||
void append(NonnullRefPtr<Statement const> child)
|
||||
{
|
||||
|
@ -287,7 +287,7 @@ public:
|
|||
m_functions_hoistable_with_annexB_extension.shrink_to_fit();
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<Statement const> const& children() const { return m_children; }
|
||||
Vector<NonnullRefPtr<Statement const>> const& children() const { return m_children; }
|
||||
virtual void dump(int indent) const override;
|
||||
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
|
||||
|
||||
|
@ -324,11 +324,11 @@ protected:
|
|||
private:
|
||||
virtual bool is_scope_node() const final { return true; }
|
||||
|
||||
NonnullRefPtrVector<Statement const> m_children;
|
||||
NonnullRefPtrVector<Declaration const> m_lexical_declarations;
|
||||
NonnullRefPtrVector<Declaration const> m_var_declarations;
|
||||
Vector<NonnullRefPtr<Statement const>> m_children;
|
||||
Vector<NonnullRefPtr<Declaration const>> m_lexical_declarations;
|
||||
Vector<NonnullRefPtr<Declaration const>> m_var_declarations;
|
||||
|
||||
NonnullRefPtrVector<FunctionDeclaration const> m_functions_hoistable_with_annexB_extension;
|
||||
Vector<NonnullRefPtr<FunctionDeclaration const>> m_functions_hoistable_with_annexB_extension;
|
||||
};
|
||||
|
||||
// ImportEntry Record, https://tc39.es/ecma262/#table-importentry-record-fields
|
||||
|
@ -526,11 +526,11 @@ public:
|
|||
append(export_statement);
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<ImportStatement const> const& imports() const { return m_imports; }
|
||||
NonnullRefPtrVector<ExportStatement const> const& exports() const { return m_exports; }
|
||||
Vector<NonnullRefPtr<ImportStatement const>> const& imports() const { return m_imports; }
|
||||
Vector<NonnullRefPtr<ExportStatement const>> const& exports() const { return m_exports; }
|
||||
|
||||
NonnullRefPtrVector<ImportStatement const>& imports() { return m_imports; }
|
||||
NonnullRefPtrVector<ExportStatement const>& exports() { return m_exports; }
|
||||
Vector<NonnullRefPtr<ImportStatement const>>& imports() { return m_imports; }
|
||||
Vector<NonnullRefPtr<ExportStatement const>>& exports() { return m_exports; }
|
||||
|
||||
bool has_top_level_await() const { return m_has_top_level_await; }
|
||||
void set_has_top_level_await() { m_has_top_level_await = true; }
|
||||
|
@ -543,8 +543,8 @@ private:
|
|||
bool m_is_strict_mode { false };
|
||||
Type m_type { Type::Script };
|
||||
|
||||
NonnullRefPtrVector<ImportStatement const> m_imports;
|
||||
NonnullRefPtrVector<ExportStatement const> m_exports;
|
||||
Vector<NonnullRefPtr<ImportStatement const>> m_imports;
|
||||
Vector<NonnullRefPtr<ExportStatement const>> m_exports;
|
||||
bool m_has_top_level_await { false };
|
||||
};
|
||||
|
||||
|
@ -1101,7 +1101,7 @@ private:
|
|||
|
||||
class SequenceExpression final : public Expression {
|
||||
public:
|
||||
SequenceExpression(SourceRange source_range, NonnullRefPtrVector<Expression const> expressions)
|
||||
SequenceExpression(SourceRange source_range, Vector<NonnullRefPtr<Expression const>> expressions)
|
||||
: Expression(source_range)
|
||||
, m_expressions(move(expressions))
|
||||
{
|
||||
|
@ -1113,7 +1113,7 @@ public:
|
|||
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<Expression const> m_expressions;
|
||||
Vector<NonnullRefPtr<Expression const>> m_expressions;
|
||||
};
|
||||
|
||||
class Literal : public Expression {
|
||||
|
@ -1395,7 +1395,7 @@ public:
|
|||
|
||||
class ClassExpression final : public Expression {
|
||||
public:
|
||||
ClassExpression(SourceRange source_range, DeprecatedString name, DeprecatedString source_text, RefPtr<FunctionExpression const> constructor, RefPtr<Expression const> super_class, NonnullRefPtrVector<ClassElement const> elements)
|
||||
ClassExpression(SourceRange source_range, DeprecatedString name, DeprecatedString source_text, RefPtr<FunctionExpression const> constructor, RefPtr<Expression const> super_class, Vector<NonnullRefPtr<ClassElement const>> elements)
|
||||
: Expression(source_range)
|
||||
, m_name(move(name))
|
||||
, m_source_text(move(source_text))
|
||||
|
@ -1424,7 +1424,7 @@ private:
|
|||
DeprecatedString m_source_text;
|
||||
RefPtr<FunctionExpression const> m_constructor;
|
||||
RefPtr<Expression const> m_super_class;
|
||||
NonnullRefPtrVector<ClassElement const> m_elements;
|
||||
Vector<NonnullRefPtr<ClassElement const>> m_elements;
|
||||
};
|
||||
|
||||
class ClassDeclaration final : public Declaration {
|
||||
|
@ -1691,7 +1691,7 @@ private:
|
|||
|
||||
class VariableDeclaration final : public Declaration {
|
||||
public:
|
||||
VariableDeclaration(SourceRange source_range, DeclarationKind declaration_kind, NonnullRefPtrVector<VariableDeclarator const> declarations)
|
||||
VariableDeclaration(SourceRange source_range, DeclarationKind declaration_kind, Vector<NonnullRefPtr<VariableDeclarator const>> declarations)
|
||||
: Declaration(source_range)
|
||||
, m_declaration_kind(declaration_kind)
|
||||
, m_declarations(move(declarations))
|
||||
|
@ -1704,7 +1704,7 @@ public:
|
|||
virtual void dump(int indent) const override;
|
||||
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
|
||||
|
||||
NonnullRefPtrVector<VariableDeclarator const> const& declarations() const { return m_declarations; }
|
||||
Vector<NonnullRefPtr<VariableDeclarator const>> const& declarations() const { return m_declarations; }
|
||||
|
||||
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const override;
|
||||
|
||||
|
@ -1716,12 +1716,12 @@ private:
|
|||
virtual bool is_variable_declaration() const override { return true; }
|
||||
|
||||
DeclarationKind m_declaration_kind;
|
||||
NonnullRefPtrVector<VariableDeclarator const> m_declarations;
|
||||
Vector<NonnullRefPtr<VariableDeclarator const>> m_declarations;
|
||||
};
|
||||
|
||||
class UsingDeclaration final : public Declaration {
|
||||
public:
|
||||
UsingDeclaration(SourceRange source_range, NonnullRefPtrVector<VariableDeclarator const> declarations)
|
||||
UsingDeclaration(SourceRange source_range, Vector<NonnullRefPtr<VariableDeclarator const>> declarations)
|
||||
: Declaration(move(source_range))
|
||||
, m_declarations(move(declarations))
|
||||
{
|
||||
|
@ -1736,10 +1736,10 @@ public:
|
|||
|
||||
virtual bool is_lexical_declaration() const override { return true; }
|
||||
|
||||
NonnullRefPtrVector<VariableDeclarator const> const& declarations() const { return m_declarations; }
|
||||
Vector<NonnullRefPtr<VariableDeclarator const>> const& declarations() const { return m_declarations; }
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<VariableDeclarator const> m_declarations;
|
||||
Vector<NonnullRefPtr<VariableDeclarator const>> m_declarations;
|
||||
};
|
||||
|
||||
class ObjectProperty final : public ASTNode {
|
||||
|
@ -1783,7 +1783,7 @@ private:
|
|||
|
||||
class ObjectExpression final : public Expression {
|
||||
public:
|
||||
explicit ObjectExpression(SourceRange source_range, NonnullRefPtrVector<ObjectProperty> properties = {})
|
||||
explicit ObjectExpression(SourceRange source_range, Vector<NonnullRefPtr<ObjectProperty>> properties = {})
|
||||
: Expression(source_range)
|
||||
, m_properties(move(properties))
|
||||
{
|
||||
|
@ -1796,7 +1796,7 @@ public:
|
|||
private:
|
||||
virtual bool is_object_expression() const override { return true; }
|
||||
|
||||
NonnullRefPtrVector<ObjectProperty> m_properties;
|
||||
Vector<NonnullRefPtr<ObjectProperty>> m_properties;
|
||||
};
|
||||
|
||||
class ArrayExpression final : public Expression {
|
||||
|
@ -1821,13 +1821,13 @@ private:
|
|||
|
||||
class TemplateLiteral final : public Expression {
|
||||
public:
|
||||
TemplateLiteral(SourceRange source_range, NonnullRefPtrVector<Expression const> expressions)
|
||||
TemplateLiteral(SourceRange source_range, Vector<NonnullRefPtr<Expression const>> expressions)
|
||||
: Expression(source_range)
|
||||
, m_expressions(move(expressions))
|
||||
{
|
||||
}
|
||||
|
||||
TemplateLiteral(SourceRange source_range, NonnullRefPtrVector<Expression const> expressions, NonnullRefPtrVector<Expression const> raw_strings)
|
||||
TemplateLiteral(SourceRange source_range, Vector<NonnullRefPtr<Expression const>> expressions, Vector<NonnullRefPtr<Expression const>> raw_strings)
|
||||
: Expression(source_range)
|
||||
, m_expressions(move(expressions))
|
||||
, m_raw_strings(move(raw_strings))
|
||||
|
@ -1838,12 +1838,12 @@ public:
|
|||
virtual void dump(int indent) const override;
|
||||
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
|
||||
|
||||
NonnullRefPtrVector<Expression const> const& expressions() const { return m_expressions; }
|
||||
NonnullRefPtrVector<Expression const> const& raw_strings() const { return m_raw_strings; }
|
||||
Vector<NonnullRefPtr<Expression const>> const& expressions() const { return m_expressions; }
|
||||
Vector<NonnullRefPtr<Expression const>> const& raw_strings() const { return m_raw_strings; }
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<Expression const> const m_expressions;
|
||||
NonnullRefPtrVector<Expression const> const m_raw_strings;
|
||||
Vector<NonnullRefPtr<Expression const>> const m_expressions;
|
||||
Vector<NonnullRefPtr<Expression const>> const m_raw_strings;
|
||||
};
|
||||
|
||||
class TaggedTemplateLiteral final : public Expression {
|
||||
|
@ -2110,7 +2110,7 @@ public:
|
|||
|
||||
private:
|
||||
NonnullRefPtr<Expression const> m_discriminant;
|
||||
NonnullRefPtrVector<SwitchCase const> m_cases;
|
||||
Vector<NonnullRefPtr<SwitchCase const>> m_cases;
|
||||
};
|
||||
|
||||
class BreakStatement final : public Statement {
|
||||
|
|
|
@ -291,7 +291,7 @@ Bytecode::CodeGenerationErrorOr<void> ScopeNode::generate_bytecode(Bytecode::Gen
|
|||
return maybe_error.release_value();
|
||||
|
||||
for (auto& child : children()) {
|
||||
TRY(child.generate_bytecode(generator));
|
||||
TRY(child->generate_bytecode(generator));
|
||||
if (generator.is_current_block_terminated())
|
||||
break;
|
||||
}
|
||||
|
@ -1085,7 +1085,7 @@ Bytecode::CodeGenerationErrorOr<void> ObjectExpression::generate_bytecode(Byteco
|
|||
|
||||
for (auto& property : m_properties) {
|
||||
Bytecode::Op::PropertyKind property_kind;
|
||||
switch (property.type()) {
|
||||
switch (property->type()) {
|
||||
case ObjectProperty::Type::KeyValue:
|
||||
property_kind = Bytecode::Op::PropertyKind::KeyValue;
|
||||
break;
|
||||
|
@ -1103,21 +1103,21 @@ Bytecode::CodeGenerationErrorOr<void> ObjectExpression::generate_bytecode(Byteco
|
|||
break;
|
||||
}
|
||||
|
||||
if (is<StringLiteral>(property.key())) {
|
||||
auto& string_literal = static_cast<StringLiteral const&>(property.key());
|
||||
if (is<StringLiteral>(property->key())) {
|
||||
auto& string_literal = static_cast<StringLiteral const&>(property->key());
|
||||
Bytecode::IdentifierTableIndex key_name = generator.intern_identifier(string_literal.value());
|
||||
|
||||
if (property_kind != Bytecode::Op::PropertyKind::Spread)
|
||||
TRY(property.value().generate_bytecode(generator));
|
||||
TRY(property->value().generate_bytecode(generator));
|
||||
|
||||
generator.emit<Bytecode::Op::PutById>(object_reg, key_name, property_kind);
|
||||
} else {
|
||||
TRY(property.key().generate_bytecode(generator));
|
||||
TRY(property->key().generate_bytecode(generator));
|
||||
auto property_reg = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::Store>(property_reg);
|
||||
|
||||
if (property_kind != Bytecode::Op::PropertyKind::Spread)
|
||||
TRY(property.value().generate_bytecode(generator));
|
||||
TRY(property->value().generate_bytecode(generator));
|
||||
|
||||
generator.emit<Bytecode::Op::PutByValue>(object_reg, property_reg, property_kind);
|
||||
}
|
||||
|
@ -1504,8 +1504,8 @@ static Bytecode::CodeGenerationErrorOr<void> assign_accumulator_to_variable_decl
|
|||
Bytecode::CodeGenerationErrorOr<void> VariableDeclaration::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
for (auto& declarator : m_declarations) {
|
||||
if (declarator.init())
|
||||
TRY(declarator.init()->generate_bytecode(generator));
|
||||
if (declarator->init())
|
||||
TRY(declarator->init()->generate_bytecode(generator));
|
||||
else
|
||||
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
|
||||
TRY(assign_accumulator_to_variable_declarator(generator, declarator, *this));
|
||||
|
@ -2026,7 +2026,7 @@ Bytecode::CodeGenerationErrorOr<void> ConditionalExpression::generate_bytecode(B
|
|||
Bytecode::CodeGenerationErrorOr<void> SequenceExpression::generate_bytecode(Bytecode::Generator& generator) const
|
||||
{
|
||||
for (auto& expression : m_expressions)
|
||||
TRY(expression.generate_bytecode(generator));
|
||||
TRY(expression->generate_bytecode(generator));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -2036,7 +2036,7 @@ Bytecode::CodeGenerationErrorOr<void> TemplateLiteral::generate_bytecode(Bytecod
|
|||
auto string_reg = generator.allocate_register();
|
||||
|
||||
for (size_t i = 0; i < m_expressions.size(); i++) {
|
||||
TRY(m_expressions[i].generate_bytecode(generator));
|
||||
TRY(m_expressions[i]->generate_bytecode(generator));
|
||||
if (i == 0) {
|
||||
generator.emit<Bytecode::Op::Store>(string_reg);
|
||||
} else {
|
||||
|
@ -2069,7 +2069,7 @@ Bytecode::CodeGenerationErrorOr<void> TaggedTemplateLiteral::generate_bytecode(B
|
|||
if (i % 2 != 0)
|
||||
continue;
|
||||
|
||||
TRY(expressions[i].generate_bytecode(generator));
|
||||
TRY(expressions[i]->generate_bytecode(generator));
|
||||
auto string_reg = string_regs[reg_index++];
|
||||
generator.emit<Bytecode::Op::Store>(string_reg);
|
||||
}
|
||||
|
@ -2089,7 +2089,7 @@ Bytecode::CodeGenerationErrorOr<void> TaggedTemplateLiteral::generate_bytecode(B
|
|||
|
||||
for (size_t i = 1; i < expressions.size(); i += 2) {
|
||||
auto string_reg = argument_regs[1 + i / 2];
|
||||
TRY(expressions[i].generate_bytecode(generator));
|
||||
TRY(expressions[i]->generate_bytecode(generator));
|
||||
generator.emit<Bytecode::Op::Store>(string_reg);
|
||||
}
|
||||
|
||||
|
@ -2099,7 +2099,7 @@ Bytecode::CodeGenerationErrorOr<void> TaggedTemplateLiteral::generate_bytecode(B
|
|||
|
||||
reg_index = 0;
|
||||
for (auto& raw_string : m_template_literal->raw_strings()) {
|
||||
TRY(raw_string.generate_bytecode(generator));
|
||||
TRY(raw_string->generate_bytecode(generator));
|
||||
auto raw_string_reg = string_regs[reg_index++];
|
||||
generator.emit<Bytecode::Op::Store>(raw_string_reg);
|
||||
raw_string_regs.append(raw_string_reg);
|
||||
|
@ -2292,9 +2292,9 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
|
|||
|
||||
for (auto& switch_case : m_cases) {
|
||||
auto& case_block = generator.make_block();
|
||||
if (switch_case.test()) {
|
||||
if (switch_case->test()) {
|
||||
generator.switch_to_basic_block(*next_test_block);
|
||||
TRY(switch_case.test()->generate_bytecode(generator));
|
||||
TRY(switch_case->test()->generate_bytecode(generator));
|
||||
generator.emit<Bytecode::Op::StrictlyEquals>(discriminant_reg);
|
||||
next_test_block = &generator.make_block();
|
||||
generator.emit<Bytecode::Op::JumpConditional>().set_targets(Bytecode::Label { case_block }, Bytecode::Label { *next_test_block });
|
||||
|
@ -2318,8 +2318,8 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluat
|
|||
generator.switch_to_basic_block(*current_block);
|
||||
|
||||
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
|
||||
for (auto& statement : switch_case.children()) {
|
||||
TRY(statement.generate_bytecode(generator));
|
||||
for (auto& statement : switch_case->children()) {
|
||||
TRY(statement->generate_bytecode(generator));
|
||||
if (generator.is_current_block_terminated())
|
||||
break;
|
||||
}
|
||||
|
@ -2464,7 +2464,7 @@ static Bytecode::CodeGenerationErrorOr<ForInOfHeadEvaluationResult> for_in_of_he
|
|||
// ForInOfStatement : for ( ForDeclaration of AssignmentExpression ) Statement
|
||||
|
||||
auto& variable_declaration = static_cast<VariableDeclaration const&>(**ast_ptr);
|
||||
result.is_destructuring = variable_declaration.declarations().first().target().has<NonnullRefPtr<BindingPattern const>>();
|
||||
result.is_destructuring = variable_declaration.declarations().first()->target().has<NonnullRefPtr<BindingPattern const>>();
|
||||
result.lhs_kind = variable_declaration.is_lexical_declaration() ? LHSKind::LexicalBinding : LHSKind::VarBinding;
|
||||
|
||||
// 1. Let oldEnv be the running execution context's LexicalEnvironment.
|
||||
|
@ -2660,7 +2660,7 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
|
|||
if (!destructuring) {
|
||||
// 1. Assert: lhs binds a single name.
|
||||
// 2. Let lhsName be the sole element of BoundNames of lhs.
|
||||
auto lhs_name = variable_declaration.declarations().first().target().get<NonnullRefPtr<Identifier const>>()->string();
|
||||
auto lhs_name = variable_declaration.declarations().first()->target().get<NonnullRefPtr<Identifier const>>()->string();
|
||||
// 3. Let lhsRef be ! ResolveBinding(lhsName).
|
||||
// NOTE: We're skipping all the completion stuff that the spec does, as the unwinding mechanism will take case of doing that.
|
||||
auto identifier = generator.intern_identifier(lhs_name);
|
||||
|
@ -2692,7 +2692,7 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
|
|||
if (head_result.lhs_kind == LHSKind::VarBinding || head_result.lhs_kind == LHSKind::LexicalBinding) {
|
||||
auto& declaration = static_cast<VariableDeclaration const&>(*lhs.get<NonnullRefPtr<ASTNode const>>());
|
||||
VERIFY(declaration.declarations().size() == 1);
|
||||
auto& binding_pattern = declaration.declarations().first().target().get<NonnullRefPtr<BindingPattern const>>();
|
||||
auto& binding_pattern = declaration.declarations().first()->target().get<NonnullRefPtr<BindingPattern const>>();
|
||||
|
||||
auto value_register = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::Store>(value_register);
|
||||
|
|
|
@ -231,13 +231,13 @@ public:
|
|||
|
||||
for (size_t i = 0; i < m_functions_to_hoist.size(); i++) {
|
||||
auto const& function_declaration = m_functions_to_hoist[i];
|
||||
if (m_lexical_names.contains(function_declaration.name()) || m_forbidden_var_names.contains(function_declaration.name()))
|
||||
if (m_lexical_names.contains(function_declaration->name()) || m_forbidden_var_names.contains(function_declaration->name()))
|
||||
continue;
|
||||
if (is_top_level()) {
|
||||
m_node->add_hoisted_function(move(m_functions_to_hoist.ptr_at(i)));
|
||||
m_node->add_hoisted_function(move(m_functions_to_hoist[i]));
|
||||
} else {
|
||||
if (!m_parent_scope->m_lexical_names.contains(function_declaration.name()) && !m_parent_scope->m_function_names.contains(function_declaration.name()))
|
||||
m_parent_scope->m_functions_to_hoist.append(move(m_functions_to_hoist.ptr_at(i)));
|
||||
if (!m_parent_scope->m_lexical_names.contains(function_declaration->name()) && !m_parent_scope->m_function_names.contains(function_declaration->name()))
|
||||
m_parent_scope->m_functions_to_hoist.append(move(m_functions_to_hoist[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ private:
|
|||
|
||||
HashTable<DeprecatedFlyString> m_forbidden_lexical_names;
|
||||
HashTable<DeprecatedFlyString> m_forbidden_var_names;
|
||||
NonnullRefPtrVector<FunctionDeclaration const> m_functions_to_hoist;
|
||||
Vector<NonnullRefPtr<FunctionDeclaration const>> m_functions_to_hoist;
|
||||
|
||||
Optional<Vector<FunctionParameter>> m_function_parameters;
|
||||
|
||||
|
@ -565,9 +565,9 @@ void Parser::parse_module(Program& program)
|
|||
program.set_has_top_level_await();
|
||||
|
||||
for (auto& export_statement : program.exports()) {
|
||||
if (export_statement.has_statement())
|
||||
if (export_statement->has_statement())
|
||||
continue;
|
||||
for (auto& entry : export_statement.entries()) {
|
||||
for (auto& entry : export_statement->entries()) {
|
||||
if (entry.is_module_request() || entry.kind == ExportEntry::Kind::EmptyNamedExport)
|
||||
return;
|
||||
|
||||
|
@ -586,14 +586,14 @@ void Parser::parse_module(Program& program)
|
|||
found = true;
|
||||
}));
|
||||
for (auto& import : program.imports()) {
|
||||
if (import.has_bound_name(exported_name)) {
|
||||
if (import->has_bound_name(exported_name)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
syntax_error(DeprecatedString::formatted("'{}' in export is not declared", exported_name), export_statement.source_range().start);
|
||||
syntax_error(DeprecatedString::formatted("'{}' in export is not declared", exported_name), export_statement->source_range().start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1065,7 +1065,7 @@ NonnullRefPtr<ClassExpression const> Parser::parse_class_expression(bool expect_
|
|||
|
||||
consume(TokenType::Class);
|
||||
|
||||
NonnullRefPtrVector<ClassElement const> elements;
|
||||
Vector<NonnullRefPtr<ClassElement const>> elements;
|
||||
RefPtr<Expression const> super_class;
|
||||
RefPtr<FunctionExpression const> constructor;
|
||||
HashTable<DeprecatedFlyString> found_private_names;
|
||||
|
@ -1188,18 +1188,18 @@ NonnullRefPtr<ClassExpression const> Parser::parse_class_expression(bool expect_
|
|||
// and the getter and setter are either both static or both non-static.
|
||||
|
||||
for (auto& element : elements) {
|
||||
auto private_name = element.private_bound_identifier();
|
||||
auto private_name = element->private_bound_identifier();
|
||||
if (!private_name.has_value() || private_name.value() != name)
|
||||
continue;
|
||||
|
||||
if (element.class_element_kind() != ClassElement::ElementKind::Method
|
||||
|| element.is_static() != is_static) {
|
||||
if (element->class_element_kind() != ClassElement::ElementKind::Method
|
||||
|| element->is_static() != is_static) {
|
||||
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
|
||||
break;
|
||||
}
|
||||
|
||||
VERIFY(is<ClassMethod>(element));
|
||||
auto& class_method_element = static_cast<ClassMethod const&>(element);
|
||||
VERIFY(is<ClassMethod>(*element));
|
||||
auto& class_method_element = static_cast<ClassMethod const&>(*element);
|
||||
|
||||
if (class_method_element.kind() == ClassMethod::Kind::Method || class_method_element.kind() == method_kind) {
|
||||
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
|
||||
|
@ -1690,7 +1690,7 @@ NonnullRefPtr<ObjectExpression const> Parser::parse_object_expression()
|
|||
auto rule_start = push_start();
|
||||
consume(TokenType::CurlyOpen);
|
||||
|
||||
NonnullRefPtrVector<ObjectProperty> properties;
|
||||
Vector<NonnullRefPtr<ObjectProperty>> properties;
|
||||
ObjectProperty::Type property_type;
|
||||
Optional<SourceRange> invalid_object_literal_property_range;
|
||||
|
||||
|
@ -1908,8 +1908,8 @@ NonnullRefPtr<TemplateLiteral const> Parser::parse_template_literal(bool is_tagg
|
|||
auto rule_start = push_start();
|
||||
consume(TokenType::TemplateLiteralStart);
|
||||
|
||||
NonnullRefPtrVector<Expression const> expressions;
|
||||
NonnullRefPtrVector<Expression const> raw_strings;
|
||||
Vector<NonnullRefPtr<Expression const>> expressions;
|
||||
Vector<NonnullRefPtr<Expression const>> raw_strings;
|
||||
|
||||
auto append_empty_string = [this, &rule_start, &expressions, &raw_strings, is_tagged]() {
|
||||
auto string_literal = create_ast_node<StringLiteral>({ m_source_code, rule_start.position(), position() }, "");
|
||||
|
@ -2044,7 +2044,7 @@ NonnullRefPtr<Expression const> Parser::parse_expression(int min_precedence, Ass
|
|||
}
|
||||
|
||||
if (match(TokenType::Comma) && min_precedence <= 1) {
|
||||
NonnullRefPtrVector<Expression const> expressions;
|
||||
Vector<NonnullRefPtr<Expression const>> expressions;
|
||||
expressions.append(expression);
|
||||
while (match(TokenType::Comma)) {
|
||||
consume();
|
||||
|
@ -3024,7 +3024,7 @@ NonnullRefPtr<VariableDeclaration const> Parser::parse_variable_declaration(IsFo
|
|||
}
|
||||
consume();
|
||||
|
||||
NonnullRefPtrVector<VariableDeclarator const> declarations;
|
||||
Vector<NonnullRefPtr<VariableDeclarator const>> declarations;
|
||||
for (;;) {
|
||||
Variant<NonnullRefPtr<Identifier const>, NonnullRefPtr<BindingPattern const>, Empty> target {};
|
||||
if (auto pattern = parse_binding_pattern(declaration_kind != DeclarationKind::Var ? AllowDuplicates::No : AllowDuplicates::Yes, AllowMemberExpressions::No)) {
|
||||
|
@ -3096,7 +3096,7 @@ NonnullRefPtr<UsingDeclaration const> Parser::parse_using_declaration(IsForLoopV
|
|||
VERIFY(m_state.current_token.original_value() == "using"sv);
|
||||
consume(TokenType::Identifier);
|
||||
VERIFY(!m_state.current_token.trivia_contains_line_terminator());
|
||||
NonnullRefPtrVector<VariableDeclarator const> declarations;
|
||||
Vector<NonnullRefPtr<VariableDeclarator const>> declarations;
|
||||
|
||||
for (;;) {
|
||||
auto lexical_binding = parse_lexical_binding();
|
||||
|
@ -3385,7 +3385,7 @@ NonnullRefPtr<SwitchStatement const> Parser::parse_switch_statement()
|
|||
|
||||
consume(TokenType::CurlyOpen);
|
||||
|
||||
NonnullRefPtrVector<SwitchCase> cases;
|
||||
Vector<NonnullRefPtr<SwitchCase>> cases;
|
||||
|
||||
auto switch_statement = create_ast_node<SwitchStatement>({ m_source_code, rule_start.position(), position() }, move(determinant));
|
||||
|
||||
|
@ -3431,7 +3431,7 @@ NonnullRefPtr<SwitchCase const> Parser::parse_switch_case()
|
|||
|
||||
consume(TokenType::Colon);
|
||||
|
||||
NonnullRefPtrVector<Statement> consequent;
|
||||
Vector<NonnullRefPtr<Statement>> consequent;
|
||||
TemporaryChange break_change(m_state.in_break_context, true);
|
||||
auto switch_case = create_ast_node<SwitchCase>({ m_source_code, rule_start.position(), position() }, move(test));
|
||||
parse_statement_list(switch_case);
|
||||
|
@ -3609,7 +3609,7 @@ NonnullRefPtr<Statement const> Parser::parse_for_statement()
|
|||
if (match_of(m_state.current_token)) {
|
||||
if (declaration->declarations().size() != 1)
|
||||
syntax_error("Must have exactly one declaration in for using of");
|
||||
else if (declaration->declarations().first().init())
|
||||
else if (declaration->declarations().first()->init())
|
||||
syntax_error("Using declaration cannot have initializer");
|
||||
|
||||
return parse_for_in_of_statement(move(declaration), is_await_loop);
|
||||
|
@ -3643,7 +3643,7 @@ NonnullRefPtr<Statement const> Parser::parse_for_statement()
|
|||
}
|
||||
if (declaration->declaration_kind() == DeclarationKind::Const) {
|
||||
for (auto const& variable : declaration->declarations()) {
|
||||
if (!variable.init())
|
||||
if (!variable->init())
|
||||
syntax_error("Missing initializer in 'const' variable declaration");
|
||||
}
|
||||
}
|
||||
|
@ -3699,8 +3699,8 @@ NonnullRefPtr<Statement const> Parser::parse_for_in_of_statement(NonnullRefPtr<A
|
|||
if (!declaration.declarations().is_empty()) {
|
||||
// AnnexB extension B.3.5 Initializers in ForIn Statement Heads, https://tc39.es/ecma262/#sec-initializers-in-forin-statement-heads
|
||||
auto& variable = declaration.declarations().first();
|
||||
if (variable.init()) {
|
||||
if (m_state.strict_mode || declaration.declaration_kind() != DeclarationKind::Var || !variable.target().has<NonnullRefPtr<Identifier const>>())
|
||||
if (variable->init()) {
|
||||
if (m_state.strict_mode || declaration.declaration_kind() != DeclarationKind::Var || !variable->target().has<NonnullRefPtr<Identifier const>>())
|
||||
syntax_error("Variable initializer not allowed in for..in/of");
|
||||
else
|
||||
has_annexB_for_in_init_extension = true;
|
||||
|
@ -4441,7 +4441,7 @@ NonnullRefPtr<ImportStatement const> Parser::parse_import_statement(Program& pro
|
|||
|
||||
for (auto& entry : entries_with_location) {
|
||||
for (auto& import_statement : program.imports()) {
|
||||
if (import_statement.has_bound_name(entry.entry.local_name))
|
||||
if (import_statement->has_bound_name(entry.entry.local_name))
|
||||
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
|
||||
}
|
||||
|
||||
|
@ -4660,7 +4660,7 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
|
|||
auto& variables = static_cast<VariableDeclaration const&>(*declaration);
|
||||
VERIFY(variables.is_lexical_declaration());
|
||||
for (auto& decl : variables.declarations()) {
|
||||
decl.target().visit(
|
||||
decl->target().visit(
|
||||
[&](NonnullRefPtr<Identifier const> const& identifier) {
|
||||
entries_with_location.append({ ExportEntry::named_export(identifier->string(), identifier->string()), identifier->source_range().start });
|
||||
},
|
||||
|
@ -4678,7 +4678,7 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
|
|||
auto variable_declaration = parse_variable_declaration();
|
||||
m_state.current_scope_pusher->add_declaration(variable_declaration);
|
||||
for (auto& decl : variable_declaration->declarations()) {
|
||||
decl.target().visit(
|
||||
decl->target().visit(
|
||||
[&](NonnullRefPtr<Identifier const> const& identifier) {
|
||||
entries_with_location.append({ ExportEntry::named_export(identifier->string(), identifier->string()), identifier->source_range().start });
|
||||
},
|
||||
|
@ -4742,7 +4742,7 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
|
|||
|
||||
for (auto& entry : entries_with_location) {
|
||||
for (auto& export_statement : program.exports()) {
|
||||
if (export_statement.has_export(entry.entry.export_name))
|
||||
if (export_statement->has_export(entry.entry.export_name))
|
||||
syntax_error(DeprecatedString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,13 +55,13 @@ static Vector<ModuleRequest> module_requests(Program& program, Vector<Deprecated
|
|||
Vector<RequestedModuleAndSourceIndex> requested_modules_with_indices;
|
||||
|
||||
for (auto& import_statement : program.imports())
|
||||
requested_modules_with_indices.empend(import_statement.start_offset(), &import_statement.module_request());
|
||||
requested_modules_with_indices.empend(import_statement->start_offset(), &import_statement->module_request());
|
||||
|
||||
for (auto& export_statement : program.exports()) {
|
||||
for (auto& export_entry : export_statement.entries()) {
|
||||
for (auto& export_entry : export_statement->entries()) {
|
||||
if (!export_entry.is_module_request())
|
||||
continue;
|
||||
requested_modules_with_indices.empend(export_statement.start_offset(), &export_statement.module_request());
|
||||
requested_modules_with_indices.empend(export_statement->start_offset(), &export_statement->module_request());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
|
|||
// 4. Let importEntries be ImportEntries of body.
|
||||
Vector<ImportEntry> import_entries;
|
||||
for (auto const& import_statement : body->imports())
|
||||
import_entries.extend(import_statement.entries());
|
||||
import_entries.extend(import_statement->entries());
|
||||
|
||||
// 5. Let importedBoundNames be ImportedLocalNames(importEntries).
|
||||
// Note: Since we have to potentially extract the import entry we just use importEntries
|
||||
|
@ -163,12 +163,12 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
|
|||
// 10. For each ExportEntry Record ee of exportEntries, do
|
||||
for (auto const& export_statement : body->exports()) {
|
||||
|
||||
if (export_statement.is_default_export()) {
|
||||
if (export_statement->is_default_export()) {
|
||||
VERIFY(!default_export);
|
||||
VERIFY(export_statement.entries().size() == 1);
|
||||
VERIFY(export_statement.has_statement());
|
||||
VERIFY(export_statement->entries().size() == 1);
|
||||
VERIFY(export_statement->has_statement());
|
||||
|
||||
auto const& entry = export_statement.entries()[0];
|
||||
auto const& entry = export_statement->entries()[0];
|
||||
VERIFY(entry.kind == ExportEntry::Kind::NamedExport);
|
||||
VERIFY(!entry.is_module_request());
|
||||
VERIFY(import_entries.find_if(
|
||||
|
@ -179,12 +179,12 @@ Result<NonnullGCPtr<SourceTextModule>, Vector<ParserError>> SourceTextModule::pa
|
|||
default_export = export_statement;
|
||||
}
|
||||
|
||||
for (auto const& export_entry : export_statement.entries()) {
|
||||
for (auto const& export_entry : export_statement->entries()) {
|
||||
|
||||
// Special case, export {} from "module" should add "module" to
|
||||
// required_modules but not any import or export so skip here.
|
||||
if (export_entry.kind == ExportEntry::Kind::EmptyNamedExport) {
|
||||
VERIFY(export_statement.entries().size() == 1);
|
||||
VERIFY(export_statement->entries().size() == 1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue