Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(755)

Unified Diff: src/parsing/parameter-initializer-rewriter.cc

Issue 2142333002: Refactor class declaration logic to the parser and runtime Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: minor cleanup per Adam Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
- 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_);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698