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

Side by Side Diff: src/preparser.cc

Issue 6075005: Change scanner buffers to not use utf-8. (Closed)
Patch Set: Fixed linto. Created 10 years 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
« no previous file with comments | « src/preparse-data.cc ('k') | src/scanner.h » ('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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 if (scanner_->has_line_terminator_before_next() || 1114 if (scanner_->has_line_terminator_before_next() ||
1115 tok == i::Token::RBRACE || 1115 tok == i::Token::RBRACE ||
1116 tok == i::Token::EOS) { 1116 tok == i::Token::EOS) {
1117 return; 1117 return;
1118 } 1118 }
1119 Expect(i::Token::SEMICOLON, ok); 1119 Expect(i::Token::SEMICOLON, ok);
1120 } 1120 }
1121 1121
1122 1122
1123 PreParser::Identifier PreParser::GetIdentifierSymbol() { 1123 PreParser::Identifier PreParser::GetIdentifierSymbol() {
1124 const char* literal_chars = scanner_->literal_string();
1125 int literal_length = scanner_->literal_length();
1126 int identifier_pos = scanner_->location().beg_pos; 1124 int identifier_pos = scanner_->location().beg_pos;
1127 1125 if (scanner_->is_literal_ascii()) {
1128 log_->LogSymbol(identifier_pos, literal_chars, literal_length); 1126 log_->LogAsciiSymbol(identifier_pos, scanner_->literal_ascii_string());
1129 1127 } else {
1130 return kUnknownExpression; 1128 log_->LogUC16Symbol(identifier_pos, scanner_->literal_uc16_string());
1129 }
1130 return kUnknownIdentifier;
1131 } 1131 }
1132 1132
1133 1133
1134 PreParser::Expression PreParser::GetStringSymbol() { 1134 PreParser::Expression PreParser::GetStringSymbol() {
1135 const char* literal_chars = scanner_->literal_string(); 1135 int identifier_pos = scanner_->location().beg_pos;
1136 int literal_length = scanner_->literal_length(); 1136 if (scanner_->is_literal_ascii()) {
1137 1137 log_->LogAsciiSymbol(identifier_pos, scanner_->literal_ascii_string());
1138 int literal_position = scanner_->location().beg_pos; 1138 } else {
1139 log_->LogSymbol(literal_position, literal_chars, literal_length); 1139 log_->LogUC16Symbol(identifier_pos, scanner_->literal_uc16_string());
1140 1140 }
1141 return kUnknownExpression; 1141 return kUnknownExpression;
1142 } 1142 }
1143 1143
1144 1144
1145 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) { 1145 PreParser::Identifier PreParser::ParseIdentifier(bool* ok) {
1146 Expect(i::Token::IDENTIFIER, ok); 1146 Expect(i::Token::IDENTIFIER, ok);
1147 if (!*ok) return kUnknownIdentifier; 1147 if (!*ok) return kUnknownIdentifier;
1148 return GetIdentifierSymbol(); 1148 return GetIdentifierSymbol();
1149 } 1149 }
1150 1150
1151 1151
1152 PreParser::Identifier PreParser::ParseIdentifierName(bool* ok) { 1152 PreParser::Identifier PreParser::ParseIdentifierName(bool* ok) {
1153 i::Token::Value next = Next(); 1153 i::Token::Value next = Next();
1154 if (i::Token::IsKeyword(next)) { 1154 if (i::Token::IsKeyword(next)) {
1155 int pos = scanner_->location().beg_pos; 1155 int pos = scanner_->location().beg_pos;
1156 const char* keyword = i::Token::String(next); 1156 const char* keyword = i::Token::String(next);
1157 log_->LogSymbol(pos, keyword, i::StrLength(keyword)); 1157 log_->LogAsciiSymbol(pos, i::Vector<const char>(keyword,
1158 i::StrLength(keyword)));
1158 return kUnknownExpression; 1159 return kUnknownExpression;
1159 } 1160 }
1160 if (next == i::Token::IDENTIFIER) { 1161 if (next == i::Token::IDENTIFIER) {
1161 return GetIdentifierSymbol(); 1162 return GetIdentifierSymbol();
1162 } 1163 }
1163 *ok = false; 1164 *ok = false;
1164 return kUnknownIdentifier; 1165 return kUnknownIdentifier;
1165 } 1166 }
1166 1167
1167 1168
1168 // This function reads an identifier and determines whether or not it 1169 // This function reads an identifier and determines whether or not it
1169 // is 'get' or 'set'. The reason for not using ParseIdentifier and 1170 // is 'get' or 'set'. The reason for not using ParseIdentifier and
1170 // checking on the output is that this involves heap allocation which 1171 // checking on the output is that this involves heap allocation which
1171 // we can't do during preparsing. 1172 // we can't do during preparsing.
1172 PreParser::Identifier PreParser::ParseIdentifierOrGetOrSet(bool* is_get, 1173 PreParser::Identifier PreParser::ParseIdentifierOrGetOrSet(bool* is_get,
1173 bool* is_set, 1174 bool* is_set,
1174 bool* ok) { 1175 bool* ok) {
1175 Expect(i::Token::IDENTIFIER, CHECK_OK); 1176 Expect(i::Token::IDENTIFIER, CHECK_OK);
1176 if (scanner_->literal_length() == 3) { 1177 if (scanner_->is_literal_ascii() && scanner_->literal_length() == 3) {
1177 const char* token = scanner_->literal_string(); 1178 const char* token = scanner_->literal_ascii_string().start();
1178 *is_get = strncmp(token, "get", 3) == 0; 1179 *is_get = strncmp(token, "get", 3) == 0;
1179 *is_set = !*is_get && strncmp(token, "set", 3) == 0; 1180 *is_set = !*is_get && strncmp(token, "set", 3) == 0;
1180 } 1181 }
1181 return GetIdentifierSymbol(); 1182 return GetIdentifierSymbol();
1182 } 1183 }
1183 1184
1184 #undef CHECK_OK 1185 #undef CHECK_OK
1185 } } // v8::preparser 1186 } } // v8::preparser
OLDNEW
« no previous file with comments | « src/preparse-data.cc ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698