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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 | 867 |
868 while (true) { | 868 while (true) { |
869 switch (peek()) { | 869 switch (peek()) { |
870 case Token::LBRACK: { | 870 case Token::LBRACK: { |
871 Consume(Token::LBRACK); | 871 Consume(Token::LBRACK); |
872 ParseExpression(true, CHECK_OK); | 872 ParseExpression(true, CHECK_OK); |
873 Expect(Token::RBRACK, CHECK_OK); | 873 Expect(Token::RBRACK, CHECK_OK); |
874 if (result.IsThis()) { | 874 if (result.IsThis()) { |
875 result = Expression::ThisProperty(); | 875 result = Expression::ThisProperty(); |
876 } else { | 876 } else { |
877 result = Expression::Default(); | 877 result = Expression::Property(); |
878 } | 878 } |
879 break; | 879 break; |
880 } | 880 } |
881 | 881 |
882 case Token::LPAREN: { | 882 case Token::LPAREN: { |
883 ParseArguments(CHECK_OK); | 883 ParseArguments(CHECK_OK); |
884 result = Expression::Default(); | 884 result = Expression::Default(); |
885 break; | 885 break; |
886 } | 886 } |
887 | 887 |
888 case Token::PERIOD: { | 888 case Token::PERIOD: { |
889 Consume(Token::PERIOD); | 889 Consume(Token::PERIOD); |
890 ParseIdentifierName(CHECK_OK); | 890 ParseIdentifierName(CHECK_OK); |
891 if (result.IsThis()) { | 891 if (result.IsThis()) { |
892 result = Expression::ThisProperty(); | 892 result = Expression::ThisProperty(); |
893 } else { | 893 } else { |
894 result = Expression::Default(); | 894 result = Expression::Property(); |
895 } | 895 } |
896 break; | 896 break; |
897 } | 897 } |
898 | 898 |
899 default: | 899 default: |
900 return result; | 900 return result; |
901 } | 901 } |
902 } | 902 } |
903 } | 903 } |
904 | 904 |
905 | 905 |
906 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( | 906 PreParser::Expression PreParser::ParseMemberWithNewPrefixesExpression( |
907 bool* ok) { | 907 bool* ok) { |
908 // NewExpression :: | 908 // NewExpression :: |
909 // ('new')+ MemberExpression | 909 // ('new')+ MemberExpression |
910 | 910 |
911 // See Parser::ParseNewExpression. | 911 // See Parser::ParseNewExpression. |
912 | 912 |
913 if (peek() == Token::NEW) { | 913 if (peek() == Token::NEW) { |
914 Consume(Token::NEW); | 914 Consume(Token::NEW); |
915 ParseMemberWithNewPrefixesExpression(CHECK_OK); | 915 ParseMemberWithNewPrefixesExpression(CHECK_OK); |
| 916 Expression expression = Expression::Default(); |
916 if (peek() == Token::LPAREN) { | 917 if (peek() == Token::LPAREN) { |
917 // NewExpression with arguments. | 918 // NewExpression with arguments. |
918 ParseArguments(CHECK_OK); | 919 ParseArguments(CHECK_OK); |
919 // The expression can still continue with . or [ after the arguments. | 920 // The expression can still continue with . or [ after the arguments. Here |
920 ParseMemberExpressionContinuation(Expression::Default(), CHECK_OK); | 921 // we need to transmit the "is valid left hand side" property of the |
| 922 // expression. |
| 923 expression = |
| 924 ParseMemberExpressionContinuation(Expression::Default(), CHECK_OK); |
921 } | 925 } |
922 return Expression::Default(); | 926 return expression; |
923 } | 927 } |
924 // No 'new' keyword. | 928 // No 'new' keyword. |
925 return ParseMemberExpression(ok); | 929 return ParseMemberExpression(ok); |
926 } | 930 } |
927 | 931 |
928 | 932 |
929 PreParser::Expression PreParser::ParseMemberExpression(bool* ok) { | 933 PreParser::Expression PreParser::ParseMemberExpression(bool* ok) { |
930 // MemberExpression :: | 934 // MemberExpression :: |
931 // (PrimaryExpression | FunctionLiteral) | 935 // (PrimaryExpression | FunctionLiteral) |
932 // ('[' Expression ']' | '.' Identifier | Arguments)* | 936 // ('[' Expression ']' | '.' Identifier | Arguments)* |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 // ('[' Expression ']' | '.' Identifier)* | 977 // ('[' Expression ']' | '.' Identifier)* |
974 while (true) { | 978 while (true) { |
975 switch (peek()) { | 979 switch (peek()) { |
976 case Token::LBRACK: { | 980 case Token::LBRACK: { |
977 Consume(Token::LBRACK); | 981 Consume(Token::LBRACK); |
978 ParseExpression(true, CHECK_OK); | 982 ParseExpression(true, CHECK_OK); |
979 Expect(Token::RBRACK, CHECK_OK); | 983 Expect(Token::RBRACK, CHECK_OK); |
980 if (expression.IsThis()) { | 984 if (expression.IsThis()) { |
981 expression = Expression::ThisProperty(); | 985 expression = Expression::ThisProperty(); |
982 } else { | 986 } else { |
983 expression = Expression::Default(); | 987 expression = Expression::Property(); |
984 } | 988 } |
985 break; | 989 break; |
986 } | 990 } |
987 case Token::PERIOD: { | 991 case Token::PERIOD: { |
988 Consume(Token::PERIOD); | 992 Consume(Token::PERIOD); |
989 ParseIdentifierName(CHECK_OK); | 993 ParseIdentifierName(CHECK_OK); |
990 if (expression.IsThis()) { | 994 if (expression.IsThis()) { |
991 expression = Expression::ThisProperty(); | 995 expression = Expression::ThisProperty(); |
992 } else { | 996 } else { |
993 expression = Expression::Default(); | 997 expression = Expression::Property(); |
994 } | 998 } |
995 break; | 999 break; |
996 } | 1000 } |
997 default: | 1001 default: |
998 return expression; | 1002 return expression; |
999 } | 1003 } |
1000 } | 1004 } |
1001 ASSERT(false); | 1005 ASSERT(false); |
1002 return PreParserExpression::Default(); | 1006 return PreParserExpression::Default(); |
1003 } | 1007 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 return Expression::Default(); | 1099 return Expression::Default(); |
1096 } | 1100 } |
1097 if (reserved_error_loc.IsValid()) { | 1101 if (reserved_error_loc.IsValid()) { |
1098 ReportMessageAt(reserved_error_loc, "unexpected_strict_reserved"); | 1102 ReportMessageAt(reserved_error_loc, "unexpected_strict_reserved"); |
1099 *ok = false; | 1103 *ok = false; |
1100 return Expression::Default(); | 1104 return Expression::Default(); |
1101 } | 1105 } |
1102 | 1106 |
1103 int end_position = scanner()->location().end_pos; | 1107 int end_position = scanner()->location().end_pos; |
1104 CheckOctalLiteral(start_position, end_position, CHECK_OK); | 1108 CheckOctalLiteral(start_position, end_position, CHECK_OK); |
1105 return Expression::StrictFunction(); | |
1106 } | 1109 } |
1107 | 1110 |
1108 return Expression::Default(); | 1111 return Expression::Default(); |
1109 } | 1112 } |
1110 | 1113 |
1111 | 1114 |
1112 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { | 1115 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { |
1113 int body_start = position(); | 1116 int body_start = position(); |
1114 bool is_logging = log_->ShouldLogSymbols(); | 1117 bool is_logging = log_->ShouldLogSymbols(); |
1115 if (is_logging) log_->PauseRecording(); | 1118 if (is_logging) log_->PauseRecording(); |
(...skipping 30 matching lines...) Expand all Loading... |
1146 | 1149 |
1147 | 1150 |
1148 void PreParser::LogSymbol() { | 1151 void PreParser::LogSymbol() { |
1149 if (log_->ShouldLogSymbols()) { | 1152 if (log_->ShouldLogSymbols()) { |
1150 scanner()->LogSymbol(log_, position()); | 1153 scanner()->LogSymbol(log_, position()); |
1151 } | 1154 } |
1152 } | 1155 } |
1153 | 1156 |
1154 | 1157 |
1155 } } // v8::internal | 1158 } } // v8::internal |
OLD | NEW |