| 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 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 return true; | 1153 return true; |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 bool IsValidPattern(ExpressionT expression) { | 1156 bool IsValidPattern(ExpressionT expression) { |
| 1157 return expression->IsObjectLiteral() || expression->IsArrayLiteral(); | 1157 return expression->IsObjectLiteral() || expression->IsArrayLiteral(); |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 // Keep track of eval() calls since they disable all local variable | 1160 // Keep track of eval() calls since they disable all local variable |
| 1161 // optimizations. This checks if expression is an eval call, and if yes, | 1161 // optimizations. This checks if expression is an eval call, and if yes, |
| 1162 // forwards the information to scope. | 1162 // forwards the information to scope. |
| 1163 void CheckPossibleEvalCall(ExpressionT expression, Scope* scope) { | 1163 Call::PossiblyEval CheckPossibleEvalCall(ExpressionT expression, |
| 1164 Scope* scope) { |
| 1164 if (Traits::IsIdentifier(expression) && | 1165 if (Traits::IsIdentifier(expression) && |
| 1165 Traits::IsEval(Traits::AsIdentifier(expression))) { | 1166 Traits::IsEval(Traits::AsIdentifier(expression))) { |
| 1166 scope->RecordEvalCall(); | 1167 scope->RecordEvalCall(); |
| 1167 if (is_sloppy(scope->language_mode())) { | 1168 if (is_sloppy(scope->language_mode())) { |
| 1168 // For sloppy scopes we also have to record the call at function level, | 1169 // For sloppy scopes we also have to record the call at function level, |
| 1169 // in case it includes declarations that will be hoisted. | 1170 // in case it includes declarations that will be hoisted. |
| 1170 scope->GetDeclarationScope()->RecordEvalCall(); | 1171 scope->GetDeclarationScope()->RecordEvalCall(); |
| 1171 } | 1172 } |
| 1173 return Call::IS_POSSIBLY_EVAL; |
| 1172 } | 1174 } |
| 1175 return Call::NOT_EVAL; |
| 1173 } | 1176 } |
| 1174 | 1177 |
| 1175 // Used to validate property names in object literals and class literals | 1178 // Used to validate property names in object literals and class literals |
| 1176 enum PropertyKind { | 1179 enum PropertyKind { |
| 1177 kAccessorProperty, | 1180 kAccessorProperty, |
| 1178 kValueProperty, | 1181 kValueProperty, |
| 1179 kMethodProperty | 1182 kMethodProperty |
| 1180 }; | 1183 }; |
| 1181 | 1184 |
| 1182 class ObjectLiteralCheckerBase { | 1185 class ObjectLiteralCheckerBase { |
| (...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2909 | 2912 |
| 2910 ArrowFormalParametersUnexpectedToken(classifier); | 2913 ArrowFormalParametersUnexpectedToken(classifier); |
| 2911 | 2914 |
| 2912 // Keep track of eval() calls since they disable all local variable | 2915 // Keep track of eval() calls since they disable all local variable |
| 2913 // optimizations. | 2916 // optimizations. |
| 2914 // The calls that need special treatment are the | 2917 // The calls that need special treatment are the |
| 2915 // direct eval calls. These calls are all of the form eval(...), with | 2918 // direct eval calls. These calls are all of the form eval(...), with |
| 2916 // no explicit receiver. | 2919 // no explicit receiver. |
| 2917 // These calls are marked as potentially direct eval calls. Whether | 2920 // These calls are marked as potentially direct eval calls. Whether |
| 2918 // they are actually direct calls to eval is determined at run time. | 2921 // they are actually direct calls to eval is determined at run time. |
| 2919 this->CheckPossibleEvalCall(result, scope()); | 2922 Call::PossiblyEval is_possibly_eval = |
| 2923 CheckPossibleEvalCall(result, scope()); |
| 2920 | 2924 |
| 2921 bool is_super_call = result->IsSuperCallReference(); | 2925 bool is_super_call = result->IsSuperCallReference(); |
| 2922 if (spread_pos.IsValid()) { | 2926 if (spread_pos.IsValid()) { |
| 2923 args = Traits::PrepareSpreadArguments(args); | 2927 args = Traits::PrepareSpreadArguments(args); |
| 2924 result = Traits::SpreadCall(result, args, pos); | 2928 result = Traits::SpreadCall(result, args, pos); |
| 2925 } else { | 2929 } else { |
| 2926 result = factory()->NewCall(result, args, pos); | 2930 result = factory()->NewCall(result, args, pos, is_possibly_eval); |
| 2927 } | 2931 } |
| 2928 | 2932 |
| 2929 // Explicit calls to the super constructor using super() perform an | 2933 // Explicit calls to the super constructor using super() perform an |
| 2930 // implicit binding assignment to the 'this' variable. | 2934 // implicit binding assignment to the 'this' variable. |
| 2931 if (is_super_call) { | 2935 if (is_super_call) { |
| 2932 ExpressionT this_expr = this->ThisExpression(pos); | 2936 ExpressionT this_expr = this->ThisExpression(pos); |
| 2933 result = | 2937 result = |
| 2934 factory()->NewAssignment(Token::INIT, this_expr, result, pos); | 2938 factory()->NewAssignment(Token::INIT, this_expr, result, pos); |
| 2935 } | 2939 } |
| 2936 | 2940 |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3722 has_seen_constructor_ = true; | 3726 has_seen_constructor_ = true; |
| 3723 return; | 3727 return; |
| 3724 } | 3728 } |
| 3725 } | 3729 } |
| 3726 | 3730 |
| 3727 | 3731 |
| 3728 } // namespace internal | 3732 } // namespace internal |
| 3729 } // namespace v8 | 3733 } // namespace v8 |
| 3730 | 3734 |
| 3731 #endif // V8_PARSING_PARSER_BASE_H | 3735 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |