mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
LibJS/Bytecode: Support using MemberExpression as rest property
Also, don't assert while dumping an AST with this construct. 7 new passes on test262. :^)
This commit is contained in:
parent
0df7255fe7
commit
b0ae1e80fb
2 changed files with 20 additions and 11 deletions
|
@ -2461,8 +2461,12 @@ void BindingPattern::dump(int indent) const
|
|||
outln("(Identifier)");
|
||||
if (entry.name.has<NonnullRefPtr<Identifier const>>()) {
|
||||
entry.name.get<NonnullRefPtr<Identifier const>>()->dump(indent + 3);
|
||||
} else {
|
||||
} else if (entry.name.has<NonnullRefPtr<Expression const>>()) {
|
||||
entry.name.get<NonnullRefPtr<Expression const>>()->dump(indent + 3);
|
||||
} else {
|
||||
VERIFY(entry.name.has<Empty>());
|
||||
print_indent(indent + 3);
|
||||
outln("<empty>");
|
||||
}
|
||||
} else if (entry.is_elision()) {
|
||||
print_indent(indent + 2);
|
||||
|
|
|
@ -1032,19 +1032,24 @@ static Bytecode::CodeGenerationErrorOr<void> generate_object_binding_pattern_byt
|
|||
|
||||
for (auto& [name, alias, initializer, is_rest] : pattern.entries) {
|
||||
if (is_rest) {
|
||||
VERIFY(name.has<NonnullRefPtr<Identifier const>>());
|
||||
VERIFY(alias.has<Empty>());
|
||||
VERIFY(!initializer);
|
||||
if (name.has<NonnullRefPtr<Identifier const>>()) {
|
||||
auto identifier = name.get<NonnullRefPtr<Identifier const>>()->string();
|
||||
auto interned_identifier = generator.intern_identifier(identifier);
|
||||
|
||||
auto identifier = name.get<NonnullRefPtr<Identifier const>>()->string();
|
||||
auto interned_identifier = generator.intern_identifier(identifier);
|
||||
generator.emit_with_extra_register_slots<Bytecode::Op::CopyObjectExcludingProperties>(excluded_property_names.size(), value_reg, excluded_property_names);
|
||||
if (create_variables)
|
||||
generator.emit<Bytecode::Op::CreateVariable>(interned_identifier, Bytecode::Op::EnvironmentMode::Lexical, false);
|
||||
generator.emit<Bytecode::Op::SetVariable>(interned_identifier, initialization_mode);
|
||||
|
||||
generator.emit_with_extra_register_slots<Bytecode::Op::CopyObjectExcludingProperties>(excluded_property_names.size(), value_reg, excluded_property_names);
|
||||
if (create_variables)
|
||||
generator.emit<Bytecode::Op::CreateVariable>(interned_identifier, Bytecode::Op::EnvironmentMode::Lexical, false);
|
||||
generator.emit<Bytecode::Op::SetVariable>(interned_identifier, initialization_mode);
|
||||
|
||||
return {};
|
||||
return {};
|
||||
}
|
||||
if (alias.has<NonnullRefPtr<MemberExpression const>>()) {
|
||||
generator.emit_with_extra_register_slots<Bytecode::Op::CopyObjectExcludingProperties>(excluded_property_names.size(), value_reg, excluded_property_names);
|
||||
TRY(generator.emit_store_to_reference(alias.get<NonnullRefPtr<MemberExpression const>>()));
|
||||
return {};
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
Bytecode::StringTableIndex name_index;
|
||||
|
|
Loading…
Add table
Reference in a new issue