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::ParseUnaryExpression(bool* ok) { | 149 PreParserExpression PreParserTraits::ParsePostfixExpression(bool* ok) { |
150 return pre_parser_->ParseUnaryExpression(ok); | 150 return pre_parser_->ParsePostfixExpression(ok); |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 154 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
155 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { | 155 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
156 log_ = log; | 156 log_ = log; |
157 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 157 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
158 PreParserScope top_scope(scope_, GLOBAL_SCOPE); | 158 PreParserScope top_scope(scope_, GLOBAL_SCOPE); |
159 FunctionState top_state(&function_state_, &scope_, &top_scope); | 159 FunctionState top_state(&function_state_, &scope_, &top_scope); |
160 scope_->SetStrictMode(strict_mode); | 160 scope_->SetStrictMode(strict_mode); |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 835 |
836 | 836 |
837 #undef CHECK_OK | 837 #undef CHECK_OK |
838 #define CHECK_OK ok); \ | 838 #define CHECK_OK ok); \ |
839 if (!*ok) return Expression::Default(); \ | 839 if (!*ok) return Expression::Default(); \ |
840 ((void)0 | 840 ((void)0 |
841 #define DUMMY ) // to make indentation work | 841 #define DUMMY ) // to make indentation work |
842 #undef DUMMY | 842 #undef DUMMY |
843 | 843 |
844 | 844 |
845 PreParser::Expression PreParser::ParseUnaryExpression(bool* ok) { | |
846 // UnaryExpression :: | |
847 // PostfixExpression | |
848 // 'delete' UnaryExpression | |
849 // 'void' UnaryExpression | |
850 // 'typeof' UnaryExpression | |
851 // '++' UnaryExpression | |
852 // '--' UnaryExpression | |
853 // '+' UnaryExpression | |
854 // '-' UnaryExpression | |
855 // '~' UnaryExpression | |
856 // '!' UnaryExpression | |
857 | |
858 Token::Value op = peek(); | |
859 if (Token::IsUnaryOp(op)) { | |
860 op = Next(); | |
861 ParseUnaryExpression(ok); | |
862 return Expression::Default(); | |
863 } else if (Token::IsCountOp(op)) { | |
864 op = Next(); | |
865 Expression expression = ParseUnaryExpression(CHECK_OK); | |
866 if (strict_mode() == STRICT) { | |
867 CheckStrictModeLValue(expression, CHECK_OK); | |
868 } | |
869 return Expression::Default(); | |
870 } else { | |
871 return ParsePostfixExpression(ok); | |
872 } | |
873 } | |
874 | |
875 | |
876 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { | 845 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { |
877 // PostfixExpression :: | 846 // PostfixExpression :: |
878 // LeftHandSideExpression ('++' | '--')? | 847 // LeftHandSideExpression ('++' | '--')? |
879 | 848 |
880 Expression expression = ParseLeftHandSideExpression(CHECK_OK); | 849 Expression expression = ParseLeftHandSideExpression(CHECK_OK); |
881 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 850 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
882 Token::IsCountOp(peek())) { | 851 Token::IsCountOp(peek())) { |
883 if (strict_mode() == STRICT) { | 852 if (strict_mode() == STRICT) { |
884 CheckStrictModeLValue(expression, CHECK_OK); | 853 CheckStrictModeLValue(expression, CHECK_OK); |
885 } | 854 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 | 1146 |
1178 | 1147 |
1179 void PreParser::LogSymbol() { | 1148 void PreParser::LogSymbol() { |
1180 if (log_->ShouldLogSymbols()) { | 1149 if (log_->ShouldLogSymbols()) { |
1181 scanner()->LogSymbol(log_, position()); | 1150 scanner()->LogSymbol(log_, position()); |
1182 } | 1151 } |
1183 } | 1152 } |
1184 | 1153 |
1185 | 1154 |
1186 } } // v8::internal | 1155 } } // v8::internal |
OLD | NEW |