Chromium Code Reviews| Index: src/parsing/parameter-initializer-rewriter.cc |
| diff --git a/src/parsing/parameter-initializer-rewriter.cc b/src/parsing/parameter-initializer-rewriter.cc |
| index 4bb367d7d08ba91dae3ac67a42a4a3705455f179..27c4d7a8d05f29b05658020201d0edec70ff1674 100644 |
| --- a/src/parsing/parameter-initializer-rewriter.cc |
| +++ b/src/parsing/parameter-initializer-rewriter.cc |
| @@ -33,7 +33,6 @@ class Rewriter final : public AstExpressionVisitor { |
| void VisitExpression(Expression* expr) override {} |
| void VisitFunctionLiteral(FunctionLiteral* expr) override; |
| - void VisitClassLiteral(ClassLiteral* expr) override; |
| void VisitVariableProxy(VariableProxy* expr) override; |
| void VisitBlock(Block* stmt) override; |
| @@ -66,26 +65,8 @@ Rewriter::~Rewriter() { |
| } |
| void Rewriter::VisitFunctionLiteral(FunctionLiteral* function_literal) { |
| - function_literal->scope()->ReplaceOuterScope(new_scope_); |
| -} |
| - |
| - |
| -void Rewriter::VisitClassLiteral(ClassLiteral* class_literal) { |
| - class_literal->scope()->ReplaceOuterScope(new_scope_); |
| - if (class_literal->extends() != nullptr) { |
| - Visit(class_literal->extends()); |
| - } |
| - // No need to visit the constructor since it will have the class |
| - // scope on its scope chain. |
| - ZoneList<ObjectLiteralProperty*>* props = class_literal->properties(); |
| - for (int i = 0; i < props->length(); ++i) { |
| - ObjectLiteralProperty* prop = props->at(i); |
| - if (!prop->key()->IsLiteral()) { |
| - Visit(prop->key()); |
| - } |
| - // No need to visit the values, since all values are functions with |
| - // the class scope on their scope chain. |
| - DCHECK(prop->value()->IsFunctionLiteral()); |
| + if (function_literal->scope()->outer_scope() == old_scope_) { |
| + function_literal->scope()->ReplaceOuterScope(new_scope_); |
| } |
| } |
| @@ -109,22 +90,26 @@ void Rewriter::VisitVariableProxy(VariableProxy* proxy) { |
| void Rewriter::VisitBlock(Block* stmt) { |
| - if (stmt->scope() != nullptr) |
| + if (stmt->scope() != nullptr && stmt->scope()->outer_scope() == old_scope_) { |
| stmt->scope()->ReplaceOuterScope(new_scope_); |
| - else |
|
adamk
2016/07/14 22:00:47
Why does this else go away?
bakkot
2016/07/14 22:46:01
It prevents recursing into statements in DoExpress
|
| - VisitStatements(stmt->statements()); |
| + } |
| + VisitStatements(stmt->statements()); |
| } |
| void Rewriter::VisitTryCatchStatement(TryCatchStatement* stmt) { |
| Visit(stmt->try_block()); |
| - stmt->scope()->ReplaceOuterScope(new_scope_); |
| + if (stmt->scope()->outer_scope() == old_scope_) { |
| + stmt->scope()->ReplaceOuterScope(new_scope_); |
| + } |
| } |
| void Rewriter::VisitWithStatement(WithStatement* stmt) { |
| Visit(stmt->expression()); |
| - stmt->scope()->ReplaceOuterScope(new_scope_); |
| + if (stmt->scope()->outer_scope() == old_scope_) { |
| + stmt->scope()->ReplaceOuterScope(new_scope_); |
| + } |
| } |