mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibJS: Restructure and fully implement BindingPatterns
This commit is contained in:
parent
10372b8118
commit
ce04c2259f
9 changed files with 244 additions and 169 deletions
|
@ -1133,29 +1133,41 @@ void BindingPattern::dump(int indent) const
|
|||
{
|
||||
print_indent(indent);
|
||||
outln("BindingPattern {}", kind == Kind::Array ? "Array" : "Object");
|
||||
print_indent(++indent);
|
||||
outln("(Properties)");
|
||||
for (auto& property : properties) {
|
||||
|
||||
for (auto& entry : entries) {
|
||||
print_indent(indent + 1);
|
||||
outln("(Identifier)");
|
||||
if (property.name) {
|
||||
property.name->dump(indent + 2);
|
||||
} else {
|
||||
outln("(Property)");
|
||||
|
||||
if (kind == Kind::Object) {
|
||||
print_indent(indent + 2);
|
||||
outln("(None)");
|
||||
outln("(Identifier)");
|
||||
if (entry.name.has<NonnullRefPtr<Identifier>>()) {
|
||||
entry.name.get<NonnullRefPtr<Identifier>>()->dump(indent + 3);
|
||||
} else {
|
||||
entry.name.get<NonnullRefPtr<Expression>>()->dump(indent + 3);
|
||||
}
|
||||
} else if (entry.is_elision()) {
|
||||
print_indent(indent + 2);
|
||||
outln("(Elision)");
|
||||
continue;
|
||||
}
|
||||
|
||||
print_indent(indent + 1);
|
||||
outln("(Pattern)");
|
||||
if (property.pattern) {
|
||||
property.pattern->dump(indent + 2);
|
||||
print_indent(indent + 2);
|
||||
outln("(Pattern{})", entry.is_rest ? " rest=true" : "");
|
||||
if (entry.alias.has<NonnullRefPtr<Identifier>>()) {
|
||||
entry.alias.get<NonnullRefPtr<Identifier>>()->dump(indent + 3);
|
||||
} else if (entry.alias.has<NonnullRefPtr<BindingPattern>>()) {
|
||||
entry.alias.get<NonnullRefPtr<BindingPattern>>()->dump(indent + 3);
|
||||
} else {
|
||||
print_indent(indent + 2);
|
||||
outln("(None)");
|
||||
print_indent(indent + 3);
|
||||
outln("<empty>");
|
||||
}
|
||||
|
||||
print_indent(indent + 1);
|
||||
outln("(Is Rest = {})", property.is_rest);
|
||||
if (entry.initializer) {
|
||||
print_indent(indent + 2);
|
||||
outln("(Initializer)");
|
||||
entry.initializer->dump(indent + 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue