OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 ZoneList<T*>* elements() { return list_; } | 633 ZoneList<T*>* elements() { return list_; } |
634 T* at(int index) { return list_->at(index); } | 634 T* at(int index) { return list_->at(index); } |
635 private: | 635 private: |
636 ZoneList<T*>* list_; | 636 ZoneList<T*>* list_; |
637 }; | 637 }; |
638 | 638 |
639 | 639 |
640 // Allocation macro that should be used to allocate objects that must | 640 // Allocation macro that should be used to allocate objects that must |
641 // only be allocated in real parsing mode. Note that in preparse mode | 641 // only be allocated in real parsing mode. Note that in preparse mode |
642 // not only is the syntax tree not created but the constructor | 642 // not only is the syntax tree not created but the constructor |
643 // arguments are not evaulated. | 643 // arguments are not evaluated. |
644 #define NEW(expr) (is_pre_parsing_ ? NULL : new expr) | 644 #define NEW(expr) (is_pre_parsing_ ? NULL : new expr) |
645 | 645 |
646 | 646 |
647 class ParserFactory BASE_EMBEDDED { | 647 class ParserFactory BASE_EMBEDDED { |
648 public: | 648 public: |
649 explicit ParserFactory(bool is_pre_parsing) : | 649 explicit ParserFactory(bool is_pre_parsing) : |
650 is_pre_parsing_(is_pre_parsing) { } | 650 is_pre_parsing_(is_pre_parsing) { } |
651 | 651 |
652 virtual ~ParserFactory() { } | 652 virtual ~ParserFactory() { } |
653 | 653 |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 // LabelledStatement | 1247 // LabelledStatement |
1248 // SwitchStatement | 1248 // SwitchStatement |
1249 // ThrowStatement | 1249 // ThrowStatement |
1250 // TryStatement | 1250 // TryStatement |
1251 // DebuggerStatement | 1251 // DebuggerStatement |
1252 | 1252 |
1253 // Note: Since labels can only be used by 'break' and 'continue' | 1253 // Note: Since labels can only be used by 'break' and 'continue' |
1254 // statements, which themselves are only valid within blocks, | 1254 // statements, which themselves are only valid within blocks, |
1255 // iterations or 'switch' statements (i.e., BreakableStatements), | 1255 // iterations or 'switch' statements (i.e., BreakableStatements), |
1256 // labels can be simply ignored in all other cases; except for | 1256 // labels can be simply ignored in all other cases; except for |
1257 // trivial labelled break statements 'label: break label' which is | 1257 // trivial labeled break statements 'label: break label' which is |
1258 // parsed into an empty statement. | 1258 // parsed into an empty statement. |
1259 | 1259 |
1260 // Keep the source position of the statement | 1260 // Keep the source position of the statement |
1261 int statement_pos = scanner().peek_location().beg_pos; | 1261 int statement_pos = scanner().peek_location().beg_pos; |
1262 Statement* stmt = NULL; | 1262 Statement* stmt = NULL; |
1263 switch (peek()) { | 1263 switch (peek()) { |
1264 case Token::LBRACE: | 1264 case Token::LBRACE: |
1265 return ParseBlock(labels, ok); | 1265 return ParseBlock(labels, ok); |
1266 | 1266 |
1267 case Token::CONST: // fall through | 1267 case Token::CONST: // fall through |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 // BreakStatement :: | 1862 // BreakStatement :: |
1863 // 'break' Identifier? ';' | 1863 // 'break' Identifier? ';' |
1864 | 1864 |
1865 Expect(Token::BREAK, CHECK_OK); | 1865 Expect(Token::BREAK, CHECK_OK); |
1866 Handle<String> label; | 1866 Handle<String> label; |
1867 Token::Value tok = peek(); | 1867 Token::Value tok = peek(); |
1868 if (!scanner_.has_line_terminator_before_next() && | 1868 if (!scanner_.has_line_terminator_before_next() && |
1869 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { | 1869 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { |
1870 label = ParseIdentifier(CHECK_OK); | 1870 label = ParseIdentifier(CHECK_OK); |
1871 } | 1871 } |
1872 // Parse labelled break statements that target themselves into | 1872 // Parse labeled break statements that target themselves into |
1873 // empty statements, e.g. 'l1: l2: l3: break l2;' | 1873 // empty statements, e.g. 'l1: l2: l3: break l2;' |
1874 if (!label.is_null() && ContainsLabel(labels, label)) { | 1874 if (!label.is_null() && ContainsLabel(labels, label)) { |
1875 return factory()->EmptyStatement(); | 1875 return factory()->EmptyStatement(); |
1876 } | 1876 } |
1877 BreakableStatement* target = NULL; | 1877 BreakableStatement* target = NULL; |
1878 if (!is_pre_parsing_) { | 1878 if (!is_pre_parsing_) { |
1879 target = LookupBreakTarget(label, CHECK_OK); | 1879 target = LookupBreakTarget(label, CHECK_OK); |
1880 if (target == NULL) { | 1880 if (target == NULL) { |
1881 // Illegal break statement. To be consistent with KJS we delay | 1881 // Illegal break statement. To be consistent with KJS we delay |
1882 // reporting of the syntax error until runtime. | 1882 // reporting of the syntax error until runtime. |
(...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4378 start_position, | 4378 start_position, |
4379 is_expression); | 4379 is_expression); |
4380 return result; | 4380 return result; |
4381 } | 4381 } |
4382 | 4382 |
4383 | 4383 |
4384 #undef NEW | 4384 #undef NEW |
4385 | 4385 |
4386 | 4386 |
4387 } } // namespace v8::internal | 4387 } } // namespace v8::internal |
OLD | NEW |