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

Side by Side Diff: src/parser.cc

Issue 3181036: Created collector class and used it to collect identifiers during scanning. (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « src/conversions.cc ('k') | src/runtime.h » ('j') | src/utils.h » ('J')
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 3346 matching lines...) Expand 10 before | Expand all | Expand 10 after
3357 result = VariableProxySentinel::identifier_proxy(); 3357 result = VariableProxySentinel::identifier_proxy();
3358 } else { 3358 } else {
3359 result = top_scope_->NewUnresolved(name, inside_with()); 3359 result = top_scope_->NewUnresolved(name, inside_with());
3360 } 3360 }
3361 break; 3361 break;
3362 } 3362 }
3363 3363
3364 case Token::NUMBER: { 3364 case Token::NUMBER: {
3365 Consume(Token::NUMBER); 3365 Consume(Token::NUMBER);
3366 double value = 3366 double value =
3367 StringToDouble(scanner_.literal_string(), ALLOW_HEX | ALLOW_OCTALS); 3367 StringToDouble(scanner_.literal(), ALLOW_HEX | ALLOW_OCTALS);
3368 result = NewNumberLiteral(value); 3368 result = NewNumberLiteral(value);
3369 break; 3369 break;
3370 } 3370 }
3371 3371
3372 case Token::STRING: { 3372 case Token::STRING: {
3373 Consume(Token::STRING); 3373 Consume(Token::STRING);
3374 Handle<String> symbol = 3374 Handle<String> symbol =
3375 factory()->LookupSymbol(scanner_.literal_string(), 3375 factory()->LookupSymbol(scanner_.literal_string(),
3376 scanner_.literal_length()); 3376 scanner_.literal_length());
3377 result = NEW(Literal(symbol)); 3377 result = NEW(Literal(symbol));
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 if (!string.is_null() && string->AsArrayIndex(&index)) { 3715 if (!string.is_null() && string->AsArrayIndex(&index)) {
3716 key = NewNumberLiteral(index); 3716 key = NewNumberLiteral(index);
3717 break; 3717 break;
3718 } 3718 }
3719 key = NEW(Literal(string)); 3719 key = NEW(Literal(string));
3720 break; 3720 break;
3721 } 3721 }
3722 case Token::NUMBER: { 3722 case Token::NUMBER: {
3723 Consume(Token::NUMBER); 3723 Consume(Token::NUMBER);
3724 double value = 3724 double value =
3725 StringToDouble(scanner_.literal_string(), ALLOW_HEX | ALLOW_OCTALS); 3725 StringToDouble(scanner_.literal(), ALLOW_HEX | ALLOW_OCTALS);
3726 key = NewNumberLiteral(value); 3726 key = NewNumberLiteral(value);
3727 break; 3727 break;
3728 } 3728 }
3729 default: 3729 default:
3730 if (Token::IsKeyword(next)) { 3730 if (Token::IsKeyword(next)) {
3731 Consume(next); 3731 Consume(next);
3732 Handle<String> string = 3732 Handle<String> string =
3733 factory()->LookupSymbol(scanner_.literal_string(), 3733 factory()->LookupSymbol(scanner_.literal_string(),
3734 scanner_.literal_length()); 3734 scanner_.literal_length());
3735 key = NEW(Literal(string)); 3735 key = NEW(Literal(string));
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 } 3976 }
3977 3977
3978 3978
3979 Expression* Parser::ParseV8Intrinsic(bool* ok) { 3979 Expression* Parser::ParseV8Intrinsic(bool* ok) {
3980 // CallRuntime :: 3980 // CallRuntime ::
3981 // '%' Identifier Arguments 3981 // '%' Identifier Arguments
3982 3982
3983 Expect(Token::MOD, CHECK_OK); 3983 Expect(Token::MOD, CHECK_OK);
3984 Handle<String> name = ParseIdentifier(CHECK_OK); 3984 Handle<String> name = ParseIdentifier(CHECK_OK);
3985 Runtime::Function* function = 3985 Runtime::Function* function =
3986 Runtime::FunctionForName(scanner_.literal_string()); 3986 Runtime::FunctionForName(scanner_.literal());
3987 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); 3987 ZoneList<Expression*>* args = ParseArguments(CHECK_OK);
3988 if (function == NULL && extension_ != NULL) { 3988 if (function == NULL && extension_ != NULL) {
3989 // The extension structures are only accessible while parsing the 3989 // The extension structures are only accessible while parsing the
3990 // very first time not when reparsing because of lazy compilation. 3990 // very first time not when reparsing because of lazy compilation.
3991 top_scope_->ForceEagerCompilation(); 3991 top_scope_->ForceEagerCompilation();
3992 } 3992 }
3993 3993
3994 // Check for built-in macros. 3994 // Check for built-in macros.
3995 if (!is_pre_parsing_) { 3995 if (!is_pre_parsing_) {
3996 if (function == Runtime::FunctionForId(Runtime::kIS_VAR)) { 3996 if (function == Runtime::FunctionForId(Runtime::kIS_VAR)) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
4263 const char* literal_string = scanner_.literal_string(); 4263 const char* literal_string = scanner_.literal_string();
4264 if (literal_length == 0) { 4264 if (literal_length == 0) {
4265 return NEW(Literal(Factory::empty_string())); 4265 return NEW(Literal(Factory::empty_string()));
4266 } 4266 }
4267 Vector<const char> literal(literal_string, literal_length); 4267 Vector<const char> literal(literal_string, literal_length);
4268 return NEW(Literal(Factory::NewStringFromUtf8(literal, TENURED))); 4268 return NEW(Literal(Factory::NewStringFromUtf8(literal, TENURED)));
4269 } 4269 }
4270 case Token::NUMBER: { 4270 case Token::NUMBER: {
4271 Consume(Token::NUMBER); 4271 Consume(Token::NUMBER);
4272 ASSERT(scanner_.literal_length() > 0); 4272 ASSERT(scanner_.literal_length() > 0);
4273 double value = StringToDouble(scanner_.literal_string(), 4273 double value = StringToDouble(scanner_.literal(),
4274 NO_FLAGS, // Hex, octal or trailing junk. 4274 NO_FLAGS, // Hex, octal or trailing junk.
4275 OS::nan_value()); 4275 OS::nan_value());
4276 return NewNumberLiteral(value); 4276 return NewNumberLiteral(value);
4277 } 4277 }
4278 case Token::FALSE_LITERAL: 4278 case Token::FALSE_LITERAL:
4279 Consume(Token::FALSE_LITERAL); 4279 Consume(Token::FALSE_LITERAL);
4280 return NEW(Literal(Factory::false_value())); 4280 return NEW(Literal(Factory::false_value()));
4281 case Token::TRUE_LITERAL: 4281 case Token::TRUE_LITERAL:
4282 Consume(Token::TRUE_LITERAL); 4282 Consume(Token::TRUE_LITERAL);
4283 return NEW(Literal(Factory::true_value())); 4283 return NEW(Literal(Factory::true_value()));
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
5306 parser.ParseLazy(script_source, name, 5306 parser.ParseLazy(script_source, name,
5307 start_position, end_position, is_expression); 5307 start_position, end_position, is_expression);
5308 return result; 5308 return result;
5309 } 5309 }
5310 5310
5311 5311
5312 #undef NEW 5312 #undef NEW
5313 5313
5314 5314
5315 } } // namespace v8::internal 5315 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/conversions.cc ('k') | src/runtime.h » ('j') | src/utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698