| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 scanner->literal_length() == kUseStrictLength && | 115 scanner->literal_length() == kUseStrictLength && |
| 116 !scanner->literal_contains_escapes() && | 116 !scanner->literal_contains_escapes() && |
| 117 !strncmp(scanner->literal_ascii_string().start(), kUseStrictChars, | 117 !strncmp(scanner->literal_ascii_string().start(), kUseStrictChars, |
| 118 kUseStrictLength)) { | 118 kUseStrictLength)) { |
| 119 return PreParserExpression::UseStrictStringLiteral(); | 119 return PreParserExpression::UseStrictStringLiteral(); |
| 120 } | 120 } |
| 121 return PreParserExpression::StringLiteral(); | 121 return PreParserExpression::StringLiteral(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 | 124 |
| 125 PreParserExpression PreParserTraits::ParseArrayLiteral(bool* ok) { | |
| 126 return pre_parser_->ParseArrayLiteral(ok); | |
| 127 } | |
| 128 | |
| 129 | |
| 130 PreParserExpression PreParserTraits::ParseObjectLiteral(bool* ok) { | 125 PreParserExpression PreParserTraits::ParseObjectLiteral(bool* ok) { |
| 131 return pre_parser_->ParseObjectLiteral(ok); | 126 return pre_parser_->ParseObjectLiteral(ok); |
| 132 } | 127 } |
| 133 | 128 |
| 134 | 129 |
| 135 PreParserExpression PreParserTraits::ParseExpression(bool accept_IN, bool* ok) { | 130 PreParserExpression PreParserTraits::ParseAssignmentExpression(bool accept_IN, |
| 136 return pre_parser_->ParseExpression(accept_IN, ok); | 131 bool* ok) { |
| 132 return pre_parser_->ParseAssignmentExpression(accept_IN, ok); |
| 137 } | 133 } |
| 138 | 134 |
| 139 | 135 |
| 140 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { | 136 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { |
| 141 return pre_parser_->ParseV8Intrinsic(ok); | 137 return pre_parser_->ParseV8Intrinsic(ok); |
| 142 } | 138 } |
| 143 | 139 |
| 144 | 140 |
| 145 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 141 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 146 LanguageMode mode, bool is_generator, ParserRecorder* log) { | 142 LanguageMode mode, bool is_generator, ParserRecorder* log) { |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 823 |
| 828 | 824 |
| 829 #undef CHECK_OK | 825 #undef CHECK_OK |
| 830 #define CHECK_OK ok); \ | 826 #define CHECK_OK ok); \ |
| 831 if (!*ok) return Expression::Default(); \ | 827 if (!*ok) return Expression::Default(); \ |
| 832 ((void)0 | 828 ((void)0 |
| 833 #define DUMMY ) // to make indentation work | 829 #define DUMMY ) // to make indentation work |
| 834 #undef DUMMY | 830 #undef DUMMY |
| 835 | 831 |
| 836 | 832 |
| 837 // Precedence = 1 | |
| 838 PreParser::Expression PreParser::ParseExpression(bool accept_IN, bool* ok) { | |
| 839 // Expression :: | |
| 840 // AssignmentExpression | |
| 841 // Expression ',' AssignmentExpression | |
| 842 | |
| 843 Expression result = ParseAssignmentExpression(accept_IN, CHECK_OK); | |
| 844 while (peek() == Token::COMMA) { | |
| 845 Expect(Token::COMMA, CHECK_OK); | |
| 846 ParseAssignmentExpression(accept_IN, CHECK_OK); | |
| 847 result = Expression::Default(); | |
| 848 } | |
| 849 return result; | |
| 850 } | |
| 851 | |
| 852 | |
| 853 // Precedence = 2 | 833 // Precedence = 2 |
| 854 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, | 834 PreParser::Expression PreParser::ParseAssignmentExpression(bool accept_IN, |
| 855 bool* ok) { | 835 bool* ok) { |
| 856 // AssignmentExpression :: | 836 // AssignmentExpression :: |
| 857 // ConditionalExpression | 837 // ConditionalExpression |
| 858 // YieldExpression | 838 // YieldExpression |
| 859 // LeftHandSideExpression AssignmentOperator AssignmentExpression | 839 // LeftHandSideExpression AssignmentOperator AssignmentExpression |
| 860 | 840 |
| 861 if (function_state_->is_generator() && peek() == Token::YIELD) { | 841 if (function_state_->is_generator() && peek() == Token::YIELD) { |
| 862 return ParseYieldExpression(ok); | 842 return ParseYieldExpression(ok); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 } | 1115 } |
| 1136 default: | 1116 default: |
| 1137 return expression; | 1117 return expression; |
| 1138 } | 1118 } |
| 1139 } | 1119 } |
| 1140 ASSERT(false); | 1120 ASSERT(false); |
| 1141 return PreParserExpression::Default(); | 1121 return PreParserExpression::Default(); |
| 1142 } | 1122 } |
| 1143 | 1123 |
| 1144 | 1124 |
| 1145 PreParser::Expression PreParser::ParseArrayLiteral(bool* ok) { | |
| 1146 // ArrayLiteral :: | |
| 1147 // '[' Expression? (',' Expression?)* ']' | |
| 1148 Expect(Token::LBRACK, CHECK_OK); | |
| 1149 while (peek() != Token::RBRACK) { | |
| 1150 if (peek() != Token::COMMA) { | |
| 1151 ParseAssignmentExpression(true, CHECK_OK); | |
| 1152 } | |
| 1153 if (peek() != Token::RBRACK) { | |
| 1154 Expect(Token::COMMA, CHECK_OK); | |
| 1155 } | |
| 1156 } | |
| 1157 Expect(Token::RBRACK, CHECK_OK); | |
| 1158 | |
| 1159 function_state_->NextMaterializedLiteralIndex(); | |
| 1160 return Expression::Default(); | |
| 1161 } | |
| 1162 | |
| 1163 | |
| 1164 PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { | 1125 PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { |
| 1165 // ObjectLiteral :: | 1126 // ObjectLiteral :: |
| 1166 // '{' ( | 1127 // '{' ( |
| 1167 // ((IdentifierName | String | Number) ':' AssignmentExpression) | 1128 // ((IdentifierName | String | Number) ':' AssignmentExpression) |
| 1168 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) | 1129 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) |
| 1169 // )*[','] '}' | 1130 // )*[','] '}' |
| 1170 | 1131 |
| 1171 ObjectLiteralChecker checker(this, scope_->language_mode()); | 1132 ObjectLiteralChecker checker(this, scope_->language_mode()); |
| 1172 | 1133 |
| 1173 Expect(Token::LBRACE, CHECK_OK); | 1134 Expect(Token::LBRACE, CHECK_OK); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 int identifier_pos = position(); | 1377 int identifier_pos = position(); |
| 1417 if (scanner()->is_literal_ascii()) { | 1378 if (scanner()->is_literal_ascii()) { |
| 1418 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_ascii_string()); | 1379 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_ascii_string()); |
| 1419 } else { | 1380 } else { |
| 1420 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string()); | 1381 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string()); |
| 1421 } | 1382 } |
| 1422 } | 1383 } |
| 1423 | 1384 |
| 1424 | 1385 |
| 1425 } } // v8::internal | 1386 } } // v8::internal |
| OLD | NEW |