Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Side by Side Diff: src/preparser.cc

Issue 196343033: Make PreParser track valid left hand sides. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 // ('[' Expression ']' | '.' Identifier)* 973 // ('[' Expression ']' | '.' Identifier)*
974 while (true) { 974 while (true) {
975 switch (peek()) { 975 switch (peek()) {
976 case Token::LBRACK: { 976 case Token::LBRACK: {
977 Consume(Token::LBRACK); 977 Consume(Token::LBRACK);
978 ParseExpression(true, CHECK_OK); 978 ParseExpression(true, CHECK_OK);
979 Expect(Token::RBRACK, CHECK_OK); 979 Expect(Token::RBRACK, CHECK_OK);
980 if (expression.IsThis()) { 980 if (expression.IsThis()) {
981 expression = Expression::ThisProperty(); 981 expression = Expression::ThisProperty();
982 } else { 982 } else {
983 expression = Expression::Default(); 983 expression = Expression::Property();
984 } 984 }
985 break; 985 break;
986 } 986 }
987 case Token::PERIOD: { 987 case Token::PERIOD: {
988 Consume(Token::PERIOD); 988 Consume(Token::PERIOD);
989 ParseIdentifierName(CHECK_OK); 989 ParseIdentifierName(CHECK_OK);
990 if (expression.IsThis()) { 990 if (expression.IsThis()) {
991 expression = Expression::ThisProperty(); 991 expression = Expression::ThisProperty();
992 } else { 992 } else {
993 expression = Expression::Default(); 993 expression = Expression::Property();
994 } 994 }
995 break; 995 break;
996 } 996 }
997 default: 997 default:
998 return expression; 998 return expression;
999 } 999 }
1000 } 1000 }
1001 ASSERT(false); 1001 ASSERT(false);
1002 return PreParserExpression::Default(); 1002 return PreParserExpression::Default();
1003 } 1003 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 return Expression::Default(); 1095 return Expression::Default();
1096 } 1096 }
1097 if (reserved_error_loc.IsValid()) { 1097 if (reserved_error_loc.IsValid()) {
1098 ReportMessageAt(reserved_error_loc, "unexpected_strict_reserved"); 1098 ReportMessageAt(reserved_error_loc, "unexpected_strict_reserved");
1099 *ok = false; 1099 *ok = false;
1100 return Expression::Default(); 1100 return Expression::Default();
1101 } 1101 }
1102 1102
1103 int end_position = scanner()->location().end_pos; 1103 int end_position = scanner()->location().end_pos;
1104 CheckOctalLiteral(start_position, end_position, CHECK_OK); 1104 CheckOctalLiteral(start_position, end_position, CHECK_OK);
1105 return Expression::StrictFunction();
1106 } 1105 }
1107 1106
1108 return Expression::Default(); 1107 return Expression::Default();
1109 } 1108 }
1110 1109
1111 1110
1112 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { 1111 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
1113 int body_start = position(); 1112 int body_start = position();
1114 bool is_logging = log_->ShouldLogSymbols(); 1113 bool is_logging = log_->ShouldLogSymbols();
1115 if (is_logging) log_->PauseRecording(); 1114 if (is_logging) log_->PauseRecording();
(...skipping 30 matching lines...) Expand all
1146 1145
1147 1146
1148 void PreParser::LogSymbol() { 1147 void PreParser::LogSymbol() {
1149 if (log_->ShouldLogSymbols()) { 1148 if (log_->ShouldLogSymbols()) {
1150 scanner()->LogSymbol(log_, position()); 1149 scanner()->LogSymbol(log_, position());
1151 } 1150 }
1152 } 1151 }
1153 1152
1154 1153
1155 } } // v8::internal 1154 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698