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

Side by Side Diff: src/ast/ast.cc

Issue 2176653003: Wrap ClassLiterals in DoExpressions instead of giving them BlockScopes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/ast/ast.h ('k') | src/compiler/ast-graph-builder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast/ast.h" 5 #include "src/ast/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 135
136 bool Expression::IsValidReferenceExpressionOrThis() const { 136 bool Expression::IsValidReferenceExpressionOrThis() const {
137 return IsValidReferenceExpression() || 137 return IsValidReferenceExpression() ||
138 (IsVariableProxy() && AsVariableProxy()->is_this()); 138 (IsVariableProxy() && AsVariableProxy()->is_this());
139 } 139 }
140 140
141 bool Expression::IsAnonymousFunctionDefinition() const { 141 bool Expression::IsAnonymousFunctionDefinition() const {
142 return (IsFunctionLiteral() && 142 return (IsFunctionLiteral() &&
143 AsFunctionLiteral()->IsAnonymousFunctionDefinition()) || 143 AsFunctionLiteral()->IsAnonymousFunctionDefinition()) ||
144 (IsClassLiteral() && 144 (IsDoExpression() &&
145 AsClassLiteral()->IsAnonymousFunctionDefinition()); 145 AsDoExpression()->IsAnonymousFunctionDefinition());
146 } 146 }
147 147
148 void Expression::MarkTail() { 148 void Expression::MarkTail() {
149 if (IsConditional()) { 149 if (IsConditional()) {
150 AsConditional()->MarkTail(); 150 AsConditional()->MarkTail();
151 } else if (IsCall()) { 151 } else if (IsCall()) {
152 AsCall()->MarkTail(); 152 AsCall()->MarkTail();
153 } else if (IsBinaryOperation()) { 153 } else if (IsBinaryOperation()) {
154 AsBinaryOperation()->MarkTail(); 154 AsBinaryOperation()->MarkTail();
155 } 155 }
156 } 156 }
157 157
158 bool DoExpression::IsAnonymousFunctionDefinition() const {
159 // This is specifically to allow DoExpressions to represent ClassLiterals.
160 return represented_function_ != nullptr &&
161 represented_function_->raw_name()->length() == 0;
162 }
163
158 bool Statement::IsJump() const { 164 bool Statement::IsJump() const {
159 switch (node_type()) { 165 switch (node_type()) {
160 #define JUMP_NODE_LIST(V) \ 166 #define JUMP_NODE_LIST(V) \
161 V(Block) \ 167 V(Block) \
162 V(ExpressionStatement) \ 168 V(ExpressionStatement) \
163 V(ContinueStatement) \ 169 V(ContinueStatement) \
164 V(BreakStatement) \ 170 V(BreakStatement) \
165 V(ReturnStatement) \ 171 V(ReturnStatement) \
166 V(IfStatement) 172 V(IfStatement)
167 #define GENERATE_CASE(Node) \ 173 #define GENERATE_CASE(Node) \
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 bool Literal::Match(void* literal1, void* literal2) { 947 bool Literal::Match(void* literal1, void* literal2) {
942 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 948 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
943 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 949 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
944 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || 950 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) ||
945 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 951 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
946 } 952 }
947 953
948 954
949 } // namespace internal 955 } // namespace internal
950 } // namespace v8 956 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | src/compiler/ast-graph-builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698