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/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 IdentifierT js_pattern = this->GetNextSymbol(scanner()); | 1211 IdentifierT js_pattern = this->GetNextSymbol(scanner()); |
1212 Maybe<RegExp::Flags> flags = scanner()->ScanRegExpFlags(); | 1212 Maybe<RegExp::Flags> flags = scanner()->ScanRegExpFlags(); |
1213 if (flags.IsNothing()) { | 1213 if (flags.IsNothing()) { |
1214 Next(); | 1214 Next(); |
1215 ReportMessage(MessageTemplate::kMalformedRegExpFlags); | 1215 ReportMessage(MessageTemplate::kMalformedRegExpFlags); |
1216 *ok = false; | 1216 *ok = false; |
1217 return Traits::EmptyExpression(); | 1217 return Traits::EmptyExpression(); |
1218 } | 1218 } |
1219 int js_flags = flags.FromJust(); | 1219 int js_flags = flags.FromJust(); |
1220 Next(); | 1220 Next(); |
1221 return factory()->NewRegExpLiteral(js_pattern, js_flags, literal_index, | 1221 return factory()->NewRegExpLiteral(js_pattern, js_flags, literal_index, pos); |
1222 is_strong(language_mode()), pos); | |
1223 } | 1222 } |
1224 | 1223 |
1225 | 1224 |
1226 #define CHECK_OK ok); \ | 1225 #define CHECK_OK ok); \ |
1227 if (!*ok) return this->EmptyExpression(); \ | 1226 if (!*ok) return this->EmptyExpression(); \ |
1228 ((void)0 | 1227 ((void)0 |
1229 #define DUMMY ) // to make indentation work | 1228 #define DUMMY ) // to make indentation work |
1230 #undef DUMMY | 1229 #undef DUMMY |
1231 | 1230 |
1232 // Used in functions where the return type is not ExpressionT. | 1231 // Used in functions where the return type is not ExpressionT. |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 values->Add(elem, zone_); | 1551 values->Add(elem, zone_); |
1553 if (peek() != Token::RBRACK) { | 1552 if (peek() != Token::RBRACK) { |
1554 Expect(Token::COMMA, CHECK_OK); | 1553 Expect(Token::COMMA, CHECK_OK); |
1555 } | 1554 } |
1556 } | 1555 } |
1557 Expect(Token::RBRACK, CHECK_OK); | 1556 Expect(Token::RBRACK, CHECK_OK); |
1558 | 1557 |
1559 // Update the scope information before the pre-parsing bailout. | 1558 // Update the scope information before the pre-parsing bailout. |
1560 int literal_index = function_state_->NextMaterializedLiteralIndex(); | 1559 int literal_index = function_state_->NextMaterializedLiteralIndex(); |
1561 | 1560 |
1562 ExpressionT result = | 1561 ExpressionT result = factory()->NewArrayLiteral(values, first_spread_index, |
1563 factory()->NewArrayLiteral(values, first_spread_index, literal_index, | 1562 literal_index, pos); |
1564 is_strong(language_mode()), pos); | |
1565 if (first_spread_index >= 0) { | 1563 if (first_spread_index >= 0) { |
1566 result = factory()->NewRewritableExpression(result); | 1564 result = factory()->NewRewritableExpression(result); |
1567 Traits::QueueNonPatternForRewriting(result); | 1565 Traits::QueueNonPatternForRewriting(result); |
1568 } | 1566 } |
1569 return result; | 1567 return result; |
1570 } | 1568 } |
1571 | 1569 |
1572 | 1570 |
1573 template <class Traits> | 1571 template <class Traits> |
1574 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName( | 1572 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName( |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1870 } | 1868 } |
1871 Expect(Token::RBRACE, CHECK_OK); | 1869 Expect(Token::RBRACE, CHECK_OK); |
1872 | 1870 |
1873 // Computation of literal_index must happen before pre parse bailout. | 1871 // Computation of literal_index must happen before pre parse bailout. |
1874 int literal_index = function_state_->NextMaterializedLiteralIndex(); | 1872 int literal_index = function_state_->NextMaterializedLiteralIndex(); |
1875 | 1873 |
1876 return factory()->NewObjectLiteral(properties, | 1874 return factory()->NewObjectLiteral(properties, |
1877 literal_index, | 1875 literal_index, |
1878 number_of_boilerplate_properties, | 1876 number_of_boilerplate_properties, |
1879 has_function, | 1877 has_function, |
1880 is_strong(language_mode()), | |
1881 pos); | 1878 pos); |
1882 } | 1879 } |
1883 | 1880 |
1884 | 1881 |
1885 template <class Traits> | 1882 template <class Traits> |
1886 typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments( | 1883 typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments( |
1887 Scanner::Location* first_spread_arg_loc, ExpressionClassifier* classifier, | 1884 Scanner::Location* first_spread_arg_loc, ExpressionClassifier* classifier, |
1888 bool* ok) { | 1885 bool* ok) { |
1889 // Arguments :: | 1886 // Arguments :: |
1890 // '(' (AssignmentExpression)*[','] ')' | 1887 // '(' (AssignmentExpression)*[','] ')' |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3372 has_seen_constructor_ = true; | 3369 has_seen_constructor_ = true; |
3373 return; | 3370 return; |
3374 } | 3371 } |
3375 } | 3372 } |
3376 | 3373 |
3377 | 3374 |
3378 } // namespace internal | 3375 } // namespace internal |
3379 } // namespace v8 | 3376 } // namespace v8 |
3380 | 3377 |
3381 #endif // V8_PARSING_PARSER_BASE_H | 3378 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |