| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 bool is_generator, | 139 bool is_generator, |
| 140 int function_token_position, | 140 int function_token_position, |
| 141 FunctionLiteral::FunctionType type, | 141 FunctionLiteral::FunctionType type, |
| 142 bool* ok) { | 142 bool* ok) { |
| 143 return pre_parser_->ParseFunctionLiteral( | 143 return pre_parser_->ParseFunctionLiteral( |
| 144 name, function_name_location, name_is_strict_reserved, is_generator, | 144 name, function_name_location, name_is_strict_reserved, is_generator, |
| 145 function_token_position, type, ok); | 145 function_token_position, type, ok); |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 PreParserExpression PreParserTraits::ParseLeftHandSideExpression(bool* ok) { | 149 PreParserExpression PreParserTraits::ParseMemberWithNewPrefixesExpression( |
| 150 return pre_parser_->ParseLeftHandSideExpression(ok); | 150 bool* ok) { |
| 151 return pre_parser_->ParseMemberWithNewPrefixesExpression(ok); |
| 151 } | 152 } |
| 152 | 153 |
| 153 | 154 |
| 154 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 155 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 155 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { | 156 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
| 156 log_ = log; | 157 log_ = log; |
| 157 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 158 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
| 158 PreParserScope top_scope(scope_, GLOBAL_SCOPE); | 159 PreParserScope top_scope(scope_, GLOBAL_SCOPE); |
| 159 FunctionState top_state(&function_state_, &scope_, &top_scope); | 160 FunctionState top_state(&function_state_, &scope_, &top_scope); |
| 160 scope_->SetStrictMode(strict_mode); | 161 scope_->SetStrictMode(strict_mode); |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 | 836 |
| 836 | 837 |
| 837 #undef CHECK_OK | 838 #undef CHECK_OK |
| 838 #define CHECK_OK ok); \ | 839 #define CHECK_OK ok); \ |
| 839 if (!*ok) return Expression::Default(); \ | 840 if (!*ok) return Expression::Default(); \ |
| 840 ((void)0 | 841 ((void)0 |
| 841 #define DUMMY ) // to make indentation work | 842 #define DUMMY ) // to make indentation work |
| 842 #undef DUMMY | 843 #undef DUMMY |
| 843 | 844 |
| 844 | 845 |
| 845 PreParser::Expression PreParser::ParseLeftHandSideExpression(bool* ok) { | |
| 846 // LeftHandSideExpression :: | |
| 847 // (NewExpression | MemberExpression) ... | |
| 848 | |
| 849 Expression result = ParseMemberWithNewPrefixesExpression(CHECK_OK); | |
| 850 | |
| 851 while (true) { | |
| 852 switch (peek()) { | |
| 853 case Token::LBRACK: { | |
| 854 Consume(Token::LBRACK); | |
| 855 ParseExpression(true, CHECK_OK); | |
| 856 Expect(Token::RBRACK, CHECK_OK); | |
| 857 if (result.IsThis()) { | |
| 858 result = Expression::ThisProperty(); | |
| 859 } else { | |
| 860 result = Expression::Property(); | |
| 861 } | |
| 862 break; | |
| 863 } | |
| 864 | |
| 865 case Token::LPAREN: { | |
| 866 ParseArguments(CHECK_OK); | |
| 867 result = Expression::Default(); | |
| 868 break; | |
| 869 } | |
| 870 | |
| 871 case Token::PERIOD: { | |
| 872 Consume(Token::PERIOD); | |
| 873 ParseIdentifierName(CHECK_OK); | |
| 874 if (result.IsThis()) { | |
| 875 result = Expression::ThisProperty(); | |
| 876 } else { | |
| 877 result = Expression::Property(); | |
| 878 } | |
| 879 break; | |
| 880 } | |
| 881 | |
| 882 default: | |
| 883 return result; | |
| 884 } | |
| 885 } | |
| 886 } | |
| 887 | |
| 888 | |
| 889 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( | 846 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( |
| 890 bool* ok) { | 847 bool* ok) { |
| 891 // NewExpression :: | 848 // NewExpression :: |
| 892 // ('new')+ MemberExpression | 849 // ('new')+ MemberExpression |
| 893 | 850 |
| 894 // See Parser::ParseNewExpression. | 851 // See Parser::ParseNewExpression. |
| 895 | 852 |
| 896 if (peek() == Token::NEW) { | 853 if (peek() == Token::NEW) { |
| 897 Consume(Token::NEW); | 854 Consume(Token::NEW); |
| 898 ParseMemberWithNewPrefixesExpression(CHECK_OK); | 855 ParseMemberWithNewPrefixesExpression(CHECK_OK); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 | 1089 |
| 1133 | 1090 |
| 1134 void PreParser::LogSymbol() { | 1091 void PreParser::LogSymbol() { |
| 1135 if (log_->ShouldLogSymbols()) { | 1092 if (log_->ShouldLogSymbols()) { |
| 1136 scanner()->LogSymbol(log_, position()); | 1093 scanner()->LogSymbol(log_, position()); |
| 1137 } | 1094 } |
| 1138 } | 1095 } |
| 1139 | 1096 |
| 1140 | 1097 |
| 1141 } } // v8::internal | 1098 } } // v8::internal |
| OLD | NEW |