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_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/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 925 |
926 inline void RewriteDestructuringAssignments() {} | 926 inline void RewriteDestructuringAssignments() {} |
927 | 927 |
928 inline void QueueDestructuringAssignmentForRewriting(PreParserExpression) {} | 928 inline void QueueDestructuringAssignmentForRewriting(PreParserExpression) {} |
929 | 929 |
930 void SetFunctionNameFromPropertyName(PreParserExpression, | 930 void SetFunctionNameFromPropertyName(PreParserExpression, |
931 PreParserIdentifier) {} | 931 PreParserIdentifier) {} |
932 void SetFunctionNameFromIdentifierRef(PreParserExpression, | 932 void SetFunctionNameFromIdentifierRef(PreParserExpression, |
933 PreParserExpression) {} | 933 PreParserExpression) {} |
934 | 934 |
| 935 inline PreParserExpression RewriteNonPattern( |
| 936 PreParserExpression expr, const ExpressionClassifier* classifier, |
| 937 bool* ok); |
| 938 inline PreParserExpression RewriteNonPatternArguments( |
| 939 PreParserExpression args, const ExpressionClassifier* classifier, |
| 940 bool* ok); |
| 941 inline PreParserExpression RewriteNonPatternObjectLiteralProperty( |
| 942 PreParserExpression property, const ExpressionClassifier* classifier, |
| 943 bool* ok); |
| 944 |
935 private: | 945 private: |
936 PreParser* pre_parser_; | 946 PreParser* pre_parser_; |
937 }; | 947 }; |
938 | 948 |
939 | 949 |
940 // Preparsing checks a JavaScript program and emits preparse-data that helps | 950 // Preparsing checks a JavaScript program and emits preparse-data that helps |
941 // a later parsing to be faster. | 951 // a later parsing to be faster. |
942 // See preparse-data-format.h for the data format. | 952 // See preparse-data-format.h for the data format. |
943 | 953 |
944 // The PreParser checks that the syntax follows the grammar for JavaScript, | 954 // The PreParser checks that the syntax follows the grammar for JavaScript, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter | 1116 // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter |
1107 // lists that are too long. | 1117 // lists that are too long. |
1108 } | 1118 } |
1109 | 1119 |
1110 | 1120 |
1111 PreParserExpression PreParserTraits::ParseDoExpression(bool* ok) { | 1121 PreParserExpression PreParserTraits::ParseDoExpression(bool* ok) { |
1112 return pre_parser_->ParseDoExpression(ok); | 1122 return pre_parser_->ParseDoExpression(ok); |
1113 } | 1123 } |
1114 | 1124 |
1115 | 1125 |
| 1126 PreParserExpression PreParserTraits::RewriteNonPattern( |
| 1127 PreParserExpression expr, const ExpressionClassifier* classifier, |
| 1128 bool* ok) { |
| 1129 pre_parser_->ValidateExpression(classifier, ok); |
| 1130 return expr; |
| 1131 } |
| 1132 |
| 1133 |
| 1134 PreParserExpression PreParserTraits::RewriteNonPatternArguments( |
| 1135 PreParserExpression args, const ExpressionClassifier* classifier, |
| 1136 bool* ok) { |
| 1137 pre_parser_->ValidateExpression(classifier, ok); |
| 1138 return args; |
| 1139 } |
| 1140 |
| 1141 |
| 1142 PreParserExpression PreParserTraits::RewriteNonPatternObjectLiteralProperty( |
| 1143 PreParserExpression property, const ExpressionClassifier* classifier, |
| 1144 bool* ok) { |
| 1145 pre_parser_->ValidateExpression(classifier, ok); |
| 1146 return property; |
| 1147 } |
| 1148 |
| 1149 |
1116 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1150 PreParserStatementList PreParser::ParseEagerFunctionBody( |
1117 PreParserIdentifier function_name, int pos, | 1151 PreParserIdentifier function_name, int pos, |
1118 const PreParserFormalParameters& parameters, FunctionKind kind, | 1152 const PreParserFormalParameters& parameters, FunctionKind kind, |
1119 FunctionLiteral::FunctionType function_type, bool* ok) { | 1153 FunctionLiteral::FunctionType function_type, bool* ok) { |
1120 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1154 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
1121 | 1155 |
1122 ParseStatementList(Token::RBRACE, ok); | 1156 ParseStatementList(Token::RBRACE, ok); |
1123 if (!*ok) return PreParserStatementList(); | 1157 if (!*ok) return PreParserStatementList(); |
1124 | 1158 |
1125 Expect(Token::RBRACE, ok); | 1159 Expect(Token::RBRACE, ok); |
1126 return PreParserStatementList(); | 1160 return PreParserStatementList(); |
1127 } | 1161 } |
1128 | 1162 |
1129 | 1163 |
1130 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1164 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
1131 PreParserIdentifier function_name, int pos, | 1165 PreParserIdentifier function_name, int pos, |
1132 const PreParserFormalParameters& parameters, FunctionKind kind, | 1166 const PreParserFormalParameters& parameters, FunctionKind kind, |
1133 FunctionLiteral::FunctionType function_type, bool* ok) { | 1167 FunctionLiteral::FunctionType function_type, bool* ok) { |
1134 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1168 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
1135 kind, function_type, ok); | 1169 kind, function_type, ok); |
1136 } | 1170 } |
1137 | 1171 |
1138 } // namespace internal | 1172 } // namespace internal |
1139 } // namespace v8 | 1173 } // namespace v8 |
1140 | 1174 |
1141 #endif // V8_PARSING_PREPARSER_H | 1175 #endif // V8_PARSING_PREPARSER_H |
OLD | NEW |