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

Side by Side Diff: src/preparser.cc

Issue 6066010: Merge 6095:6198 from bleeding_edge to experimental/gc. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « src/preparser.h ('k') | src/preparser-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 Expect(i::Token::LBRACE, CHECK_OK); 943 Expect(i::Token::LBRACE, CHECK_OK);
944 while (peek() != i::Token::RBRACE) { 944 while (peek() != i::Token::RBRACE) {
945 i::Token::Value next = peek(); 945 i::Token::Value next = peek();
946 switch (next) { 946 switch (next) {
947 case i::Token::IDENTIFIER: { 947 case i::Token::IDENTIFIER: {
948 bool is_getter = false; 948 bool is_getter = false;
949 bool is_setter = false; 949 bool is_setter = false;
950 ParseIdentifierOrGetOrSet(&is_getter, &is_setter, CHECK_OK); 950 ParseIdentifierOrGetOrSet(&is_getter, &is_setter, CHECK_OK);
951 if ((is_getter || is_setter) && peek() != i::Token::COLON) { 951 if ((is_getter || is_setter) && peek() != i::Token::COLON) {
952 i::Token::Value name = Next(); 952 i::Token::Value name = Next();
953 bool is_keyword = i::Token::IsKeyword(name);
953 if (name != i::Token::IDENTIFIER && 954 if (name != i::Token::IDENTIFIER &&
954 name != i::Token::NUMBER && 955 name != i::Token::NUMBER &&
955 name != i::Token::STRING && 956 name != i::Token::STRING &&
956 !i::Token::IsKeyword(name)) { 957 !is_keyword) {
957 *ok = false; 958 *ok = false;
958 return kUnknownExpression; 959 return kUnknownExpression;
959 } 960 }
961 if (!is_keyword) {
962 LogSymbol();
963 }
960 ParseFunctionLiteral(CHECK_OK); 964 ParseFunctionLiteral(CHECK_OK);
961 if (peek() != i::Token::RBRACE) { 965 if (peek() != i::Token::RBRACE) {
962 Expect(i::Token::COMMA, CHECK_OK); 966 Expect(i::Token::COMMA, CHECK_OK);
963 } 967 }
964 continue; // restart the while 968 continue; // restart the while
965 } 969 }
966 break; 970 break;
967 } 971 }
968 case i::Token::STRING: 972 case i::Token::STRING:
969 Consume(next); 973 Consume(next);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 } 1117 }
1114 if (scanner_->has_line_terminator_before_next() || 1118 if (scanner_->has_line_terminator_before_next() ||
1115 tok == i::Token::RBRACE || 1119 tok == i::Token::RBRACE ||
1116 tok == i::Token::EOS) { 1120 tok == i::Token::EOS) {
1117 return; 1121 return;
1118 } 1122 }
1119 Expect(i::Token::SEMICOLON, ok); 1123 Expect(i::Token::SEMICOLON, ok);
1120 } 1124 }
1121 1125
1122 1126
1127 void PreParser::LogSymbol() {
1128 int identifier_pos = scanner_->location().beg_pos;
1129 if (scanner_->is_literal_ascii()) {
1130 log_->LogAsciiSymbol(identifier_pos, scanner_->literal_ascii_string());
1131 } else {
1132 log_->LogUC16Symbol(identifier_pos, scanner_->literal_uc16_string());
1133 }
1134 }
1135
1136
1123 PreParser::Identifier PreParser::GetIdentifierSymbol() { 1137 PreParser::Identifier PreParser::GetIdentifierSymbol() {
1124 const char* literal_chars = scanner_->literal_string(); 1138 LogSymbol();
1125 int literal_length = scanner_->literal_length(); 1139 return kUnknownIdentifier;
1126 int identifier_pos = scanner_->location().beg_pos;
1127
1128 log_->LogSymbol(identifier_pos, literal_chars, literal_length);
1129
1130 return kUnknownExpression;
1131 } 1140 }
1132 1141
1133 1142
1134 PreParser::Expression PreParser::GetStringSymbol() { 1143 PreParser::Expression PreParser::GetStringSymbol() {
1135 const char* literal_chars = scanner_->literal_string(); 1144 LogSymbol();
1136 int literal_length = scanner_->literal_length();
1137
1138 int literal_position = scanner_->location().beg_pos;
1139 log_->LogSymbol(literal_position, literal_chars, literal_length);
1140
1141 return kUnknownExpression; 1145 return kUnknownExpression;
1142 } 1146 }
1143 1147
1144 1148
1145 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { 1149 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
1146 Expect(i::Token::IDENTIFIER, ok); 1150 Expect(i::Token::IDENTIFIER, ok);
1147 if (!*ok) return kUnknownIdentifier; 1151 if (!*ok) return kUnknownIdentifier;
1148 return GetIdentifierSymbol(); 1152 return GetIdentifierSymbol();
1149 } 1153 }
1150 1154
1151 1155
1152 PreParser::Identifier PreParser::ParseIdentifierName(bool* ok) { 1156 PreParser::Identifier PreParser::ParseIdentifierName(bool* ok) {
1153 i::Token::Value next = Next(); 1157 i::Token::Value next = Next();
1154 if (i::Token::IsKeyword(next)) { 1158 if (i::Token::IsKeyword(next)) {
1155 int pos = scanner_->location().beg_pos; 1159 int pos = scanner_->location().beg_pos;
1156 const char* keyword = i::Token::String(next); 1160 const char* keyword = i::Token::String(next);
1157 log_->LogSymbol(pos, keyword, i::StrLength(keyword)); 1161 log_->LogAsciiSymbol(pos, i::Vector<const char>(keyword,
1162 i::StrLength(keyword)));
1158 return kUnknownExpression; 1163 return kUnknownExpression;
1159 } 1164 }
1160 if (next == i::Token::IDENTIFIER) { 1165 if (next == i::Token::IDENTIFIER) {
1161 return GetIdentifierSymbol(); 1166 return GetIdentifierSymbol();
1162 } 1167 }
1163 *ok = false; 1168 *ok = false;
1164 return kUnknownIdentifier; 1169 return kUnknownIdentifier;
1165 } 1170 }
1166 1171
1167 1172
1168 // This function reads an identifier and determines whether or not it 1173 // This function reads an identifier and determines whether or not it
1169 // is 'get' or 'set'. The reason for not using ParseIdentifier and 1174 // is 'get' or 'set'. The reason for not using ParseIdentifier and
1170 // checking on the output is that this involves heap allocation which 1175 // checking on the output is that this involves heap allocation which
1171 // we can't do during preparsing. 1176 // we can't do during preparsing.
1172 PreParser::Identifier PreParser::ParseIdentifierOrGetOrSet(bool* is_get, 1177 PreParser::Identifier PreParser::ParseIdentifierOrGetOrSet(bool* is_get,
1173 bool* is_set, 1178 bool* is_set,
1174 bool* ok) { 1179 bool* ok) {
1175 Expect(i::Token::IDENTIFIER, CHECK_OK); 1180 Expect(i::Token::IDENTIFIER, CHECK_OK);
1176 if (scanner_->literal_length() == 3) { 1181 if (scanner_->is_literal_ascii() && scanner_->literal_length() == 3) {
1177 const char* token = scanner_->literal_string(); 1182 const char* token = scanner_->literal_ascii_string().start();
1178 *is_get = strncmp(token, "get", 3) == 0; 1183 *is_get = strncmp(token, "get", 3) == 0;
1179 *is_set = !*is_get && strncmp(token, "set", 3) == 0; 1184 *is_set = !*is_get && strncmp(token, "set", 3) == 0;
1180 } 1185 }
1181 return GetIdentifierSymbol(); 1186 return GetIdentifierSymbol();
1182 } 1187 }
1183 1188
1184 #undef CHECK_OK 1189 #undef CHECK_OK
1185 } } // v8::preparser 1190 } } // v8::preparser
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/preparser-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698