OLD | NEW |
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 Loading... |
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 (IsDoExpression() && | 144 (IsClassLiteral() && |
145 AsDoExpression()->IsAnonymousFunctionDefinition()); | 145 AsClassLiteral()->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 | |
164 bool Statement::IsJump() const { | 158 bool Statement::IsJump() const { |
165 switch (node_type()) { | 159 switch (node_type()) { |
166 #define JUMP_NODE_LIST(V) \ | 160 #define JUMP_NODE_LIST(V) \ |
167 V(Block) \ | 161 V(Block) \ |
168 V(ExpressionStatement) \ | 162 V(ExpressionStatement) \ |
169 V(ContinueStatement) \ | 163 V(ContinueStatement) \ |
170 V(BreakStatement) \ | 164 V(BreakStatement) \ |
171 V(ReturnStatement) \ | 165 V(ReturnStatement) \ |
172 V(IfStatement) | 166 V(IfStatement) |
173 #define GENERATE_CASE(Node) \ | 167 #define GENERATE_CASE(Node) \ |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 bool Literal::Match(void* literal1, void* literal2) { | 941 bool Literal::Match(void* literal1, void* literal2) { |
948 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 942 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
949 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 943 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
950 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 944 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
951 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 945 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
952 } | 946 } |
953 | 947 |
954 | 948 |
955 } // namespace internal | 949 } // namespace internal |
956 } // namespace v8 | 950 } // namespace v8 |
OLD | NEW |