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

Side by Side Diff: src/parsing/preparser.h

Issue 2617923003: PreParsing inner funcs: make scope analysis more complete. (Closed)
Patch Set: Created 3 years, 11 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
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 #ifndef V8_PARSING_PREPARSER_H 5 #ifndef V8_PARSING_PREPARSER_H
6 #define V8_PARSING_PREPARSER_H 6 #define V8_PARSING_PREPARSER_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/parsing/parser-base.h" 10 #include "src/parsing/parser-base.h"
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1042
1043 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value, 1043 V8_INLINE PreParserExpression RewriteReturn(PreParserExpression return_value,
1044 int pos) { 1044 int pos) {
1045 return return_value; 1045 return return_value;
1046 } 1046 }
1047 V8_INLINE PreParserStatement RewriteSwitchStatement( 1047 V8_INLINE PreParserStatement RewriteSwitchStatement(
1048 PreParserExpression tag, PreParserStatement switch_statement, 1048 PreParserExpression tag, PreParserStatement switch_statement,
1049 PreParserStatementList cases, Scope* scope) { 1049 PreParserStatementList cases, Scope* scope) {
1050 return PreParserStatement::Default(); 1050 return PreParserStatement::Default();
1051 } 1051 }
1052 V8_INLINE void RewriteCatchPattern(CatchInfo* catch_info, bool* ok) {} 1052
1053 V8_INLINE void RewriteCatchPattern(CatchInfo* catch_info, bool* ok) {
1054 if (track_unresolved_variables_) {
1055 if (catch_info->name.string_ != nullptr) {
1056 // Unlike in the parser, we need to declare the catch variable as LET
adamk 2017/01/06 19:05:04 High-level question...would it make sense, once th
1057 // variable, so that it won't get hoisted out of the scope.
1058 catch_info->scope->DeclareVariableName(catch_info->name.string_, LET);
1059 }
1060 if (catch_info->pattern.variables_ != nullptr) {
1061 for (auto variable : *catch_info->pattern.variables_) {
1062 scope()->DeclareVariableName(variable->raw_name(), LET);
1063 }
1064 }
1065 }
1066 }
1067
1053 V8_INLINE void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok) {} 1068 V8_INLINE void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok) {}
1054 V8_INLINE PreParserStatement RewriteTryStatement( 1069 V8_INLINE PreParserStatement RewriteTryStatement(
1055 PreParserStatement try_block, PreParserStatement catch_block, 1070 PreParserStatement try_block, PreParserStatement catch_block,
1056 PreParserStatement finally_block, const CatchInfo& catch_info, int pos) { 1071 PreParserStatement finally_block, const CatchInfo& catch_info, int pos) {
1057 return PreParserStatement::Default(); 1072 return PreParserStatement::Default();
1058 } 1073 }
1059 1074
1060 V8_INLINE PreParserExpression RewriteDoExpression(PreParserStatement body, 1075 V8_INLINE PreParserExpression RewriteDoExpression(PreParserStatement body,
1061 int pos, bool* ok) { 1076 int pos, bool* ok) {
1062 return PreParserExpression::Default(); 1077 return PreParserExpression::Default();
(...skipping 14 matching lines...) Expand all
1077 PreParserIdentifier variable_name, PreParserExpression function, int pos, 1092 PreParserIdentifier variable_name, PreParserExpression function, int pos,
1078 bool is_generator, bool is_async, ZoneList<const AstRawString*>* names, 1093 bool is_generator, bool is_async, ZoneList<const AstRawString*>* names,
1079 bool* ok) { 1094 bool* ok) {
1080 return Statement::Default(); 1095 return Statement::Default();
1081 } 1096 }
1082 1097
1083 V8_INLINE PreParserStatement 1098 V8_INLINE PreParserStatement
1084 DeclareClass(PreParserIdentifier variable_name, PreParserExpression value, 1099 DeclareClass(PreParserIdentifier variable_name, PreParserExpression value,
1085 ZoneList<const AstRawString*>* names, int class_token_pos, 1100 ZoneList<const AstRawString*>* names, int class_token_pos,
1086 int end_pos, bool* ok) { 1101 int end_pos, bool* ok) {
1102 // Preparser shouldn't be used in contexts where we need to track the names.
1103 DCHECK_NULL(names);
marja 2017/01/06 15:44:29 This DCHECK is also unrelated, but I'm adding it s
1104 if (variable_name.string_ != nullptr) {
1105 DCHECK(track_unresolved_variables_);
1106 scope()->DeclareVariableName(variable_name.string_, LET);
1107 }
1087 return PreParserStatement::Default(); 1108 return PreParserStatement::Default();
1088 } 1109 }
1089 V8_INLINE void DeclareClassVariable(PreParserIdentifier name, 1110 V8_INLINE void DeclareClassVariable(PreParserIdentifier name,
1090 Scope* block_scope, ClassInfo* class_info, 1111 Scope* block_scope, ClassInfo* class_info,
1091 int class_token_pos, bool* ok) {} 1112 int class_token_pos, bool* ok) {}
1092 V8_INLINE void DeclareClassProperty(PreParserIdentifier class_name, 1113 V8_INLINE void DeclareClassProperty(PreParserIdentifier class_name,
1093 PreParserExpression property, 1114 PreParserExpression property,
1094 ClassLiteralProperty::Kind kind, 1115 ClassLiteralProperty::Kind kind,
1095 bool is_static, bool is_constructor, 1116 bool is_static, bool is_constructor,
1096 ClassInfo* class_info, bool* ok) { 1117 ClassInfo* class_info, bool* ok) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 InitializeForEachStatement(PreParserStatement stmt, PreParserExpression each, 1278 InitializeForEachStatement(PreParserStatement stmt, PreParserExpression each,
1258 PreParserExpression subject, 1279 PreParserExpression subject,
1259 PreParserStatement body, int each_keyword_pos) { 1280 PreParserStatement body, int each_keyword_pos) {
1260 MarkExpressionAsAssigned(each); 1281 MarkExpressionAsAssigned(each);
1261 return stmt; 1282 return stmt;
1262 } 1283 }
1263 1284
1264 V8_INLINE PreParserStatement RewriteForVarInLegacy(const ForInfo& for_info) { 1285 V8_INLINE PreParserStatement RewriteForVarInLegacy(const ForInfo& for_info) {
1265 return PreParserStatement::Null(); 1286 return PreParserStatement::Null();
1266 } 1287 }
1288
1267 V8_INLINE void DesugarBindingInForEachStatement( 1289 V8_INLINE void DesugarBindingInForEachStatement(
1268 ForInfo* for_info, PreParserStatement* body_block, 1290 ForInfo* for_info, PreParserStatement* body_block,
1269 PreParserExpression* each_variable, bool* ok) {} 1291 PreParserExpression* each_variable, bool* ok) {
1292 if (track_unresolved_variables_) {
1293 DCHECK(for_info->parsing_result.declarations.length() == 1);
1294 DeclareAndInitializeVariables(
1295 PreParserStatement::Default(), &for_info->parsing_result.descriptor,
1296 &for_info->parsing_result.declarations[0], nullptr, ok);
1297 }
1298 }
1299
1270 V8_INLINE PreParserStatement CreateForEachStatementTDZ( 1300 V8_INLINE PreParserStatement CreateForEachStatementTDZ(
1271 PreParserStatement init_block, const ForInfo& for_info, bool* ok) { 1301 PreParserStatement init_block, const ForInfo& for_info, bool* ok) {
1272 return init_block; 1302 return init_block;
1273 } 1303 }
1274 1304
1275 V8_INLINE StatementT DesugarLexicalBindingsInForStatement( 1305 V8_INLINE StatementT DesugarLexicalBindingsInForStatement(
1276 PreParserStatement loop, PreParserStatement init, 1306 PreParserStatement loop, PreParserStatement init,
1277 PreParserExpression cond, PreParserStatement next, 1307 PreParserExpression cond, PreParserStatement next,
1278 PreParserStatement body, Scope* inner_scope, const ForInfo& for_info, 1308 PreParserStatement body, Scope* inner_scope, const ForInfo& for_info,
1279 bool* ok) { 1309 bool* ok) {
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 function_state_->NextMaterializedLiteralIndex(); 1633 function_state_->NextMaterializedLiteralIndex();
1604 function_state_->NextMaterializedLiteralIndex(); 1634 function_state_->NextMaterializedLiteralIndex();
1605 } 1635 }
1606 return EmptyExpression(); 1636 return EmptyExpression();
1607 } 1637 }
1608 1638
1609 } // namespace internal 1639 } // namespace internal
1610 } // namespace v8 1640 } // namespace v8
1611 1641
1612 #endif // V8_PARSING_PREPARSER_H 1642 #endif // V8_PARSING_PREPARSER_H
OLDNEW
« src/parsing/parser.cc ('K') | « src/parsing/parser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698