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

Side by Side Diff: src/parser.cc

Issue 15421007: Remove unneeded argument from Parser::GetSymbol (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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/parser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 zone_scope->DeleteOnExit(); 787 zone_scope->DeleteOnExit();
788 if (stack_overflow_) isolate()->StackOverflow(); 788 if (stack_overflow_) isolate()->StackOverflow();
789 } else { 789 } else {
790 Handle<String> inferred_name(shared_info->inferred_name()); 790 Handle<String> inferred_name(shared_info->inferred_name());
791 result->set_inferred_name(inferred_name); 791 result->set_inferred_name(inferred_name);
792 } 792 }
793 return result; 793 return result;
794 } 794 }
795 795
796 796
797 Handle<String> Parser::GetSymbol(bool* ok) { 797 Handle<String> Parser::GetSymbol() {
798 int symbol_id = -1; 798 int symbol_id = -1;
799 if (pre_parse_data() != NULL) { 799 if (pre_parse_data() != NULL) {
800 symbol_id = pre_parse_data()->GetSymbolIdentifier(); 800 symbol_id = pre_parse_data()->GetSymbolIdentifier();
801 } 801 }
802 return LookupSymbol(symbol_id); 802 return LookupSymbol(symbol_id);
803 } 803 }
804 804
805 805
806 void Parser::ReportMessage(const char* type, Vector<const char*> args) { 806 void Parser::ReportMessage(const char* type, Vector<const char*> args) {
807 Scanner::Location source_location = scanner().location(); 807 Scanner::Location source_location = scanner().location();
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 1334
1335 return factory()->NewModuleVariable(proxy); 1335 return factory()->NewModuleVariable(proxy);
1336 } 1336 }
1337 1337
1338 1338
1339 Module* Parser::ParseModuleUrl(bool* ok) { 1339 Module* Parser::ParseModuleUrl(bool* ok) {
1340 // Module: 1340 // Module:
1341 // String 1341 // String
1342 1342
1343 Expect(Token::STRING, CHECK_OK); 1343 Expect(Token::STRING, CHECK_OK);
1344 Handle<String> symbol = GetSymbol(CHECK_OK); 1344 Handle<String> symbol = GetSymbol();
1345 1345
1346 // TODO(ES6): Request JS resource from environment... 1346 // TODO(ES6): Request JS resource from environment...
1347 1347
1348 #ifdef DEBUG 1348 #ifdef DEBUG
1349 if (FLAG_print_interface_details) PrintF("# Url "); 1349 if (FLAG_print_interface_details) PrintF("# Url ");
1350 #endif 1350 #endif
1351 1351
1352 // Create an empty literal as long as the feature isn't finished. 1352 // Create an empty literal as long as the feature isn't finished.
1353 USE(symbol); 1353 USE(symbol);
1354 Scope* scope = NewScope(top_scope_, MODULE_SCOPE); 1354 Scope* scope = NewScope(top_scope_, MODULE_SCOPE);
(...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3685 ASSERT(scanner().is_literal_ascii()); 3685 ASSERT(scanner().is_literal_ascii());
3686 double value = StringToDouble(isolate()->unicode_cache(), 3686 double value = StringToDouble(isolate()->unicode_cache(),
3687 scanner().literal_ascii_string(), 3687 scanner().literal_ascii_string(),
3688 ALLOW_HEX | ALLOW_OCTALS); 3688 ALLOW_HEX | ALLOW_OCTALS);
3689 result = factory()->NewNumberLiteral(value); 3689 result = factory()->NewNumberLiteral(value);
3690 break; 3690 break;
3691 } 3691 }
3692 3692
3693 case Token::STRING: { 3693 case Token::STRING: {
3694 Consume(Token::STRING); 3694 Consume(Token::STRING);
3695 Handle<String> symbol = GetSymbol(CHECK_OK); 3695 Handle<String> symbol = GetSymbol();
3696 result = factory()->NewLiteral(symbol); 3696 result = factory()->NewLiteral(symbol);
3697 if (fni_ != NULL) fni_->PushLiteralName(symbol); 3697 if (fni_ != NULL) fni_->PushLiteralName(symbol);
3698 break; 3698 break;
3699 } 3699 }
3700 3700
3701 case Token::ASSIGN_DIV: 3701 case Token::ASSIGN_DIV:
3702 result = ParseRegExpLiteral(true, CHECK_OK); 3702 result = ParseRegExpLiteral(true, CHECK_OK);
3703 break; 3703 break;
3704 3704
3705 case Token::DIV: 3705 case Token::DIV:
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 Token::Value next = Next(); 4040 Token::Value next = Next();
4041 bool is_keyword = Token::IsKeyword(next); 4041 bool is_keyword = Token::IsKeyword(next);
4042 if (next == Token::IDENTIFIER || next == Token::NUMBER || 4042 if (next == Token::IDENTIFIER || next == Token::NUMBER ||
4043 next == Token::FUTURE_RESERVED_WORD || 4043 next == Token::FUTURE_RESERVED_WORD ||
4044 next == Token::FUTURE_STRICT_RESERVED_WORD || 4044 next == Token::FUTURE_STRICT_RESERVED_WORD ||
4045 next == Token::STRING || is_keyword) { 4045 next == Token::STRING || is_keyword) {
4046 Handle<String> name; 4046 Handle<String> name;
4047 if (is_keyword) { 4047 if (is_keyword) {
4048 name = isolate_->factory()->InternalizeUtf8String(Token::String(next)); 4048 name = isolate_->factory()->InternalizeUtf8String(Token::String(next));
4049 } else { 4049 } else {
4050 name = GetSymbol(CHECK_OK); 4050 name = GetSymbol();
4051 } 4051 }
4052 FunctionLiteral* value = 4052 FunctionLiteral* value =
4053 ParseFunctionLiteral(name, 4053 ParseFunctionLiteral(name,
4054 false, // reserved words are allowed here 4054 false, // reserved words are allowed here
4055 false, // not a generator 4055 false, // not a generator
4056 RelocInfo::kNoPosition, 4056 RelocInfo::kNoPosition,
4057 FunctionLiteral::ANONYMOUS_EXPRESSION, 4057 FunctionLiteral::ANONYMOUS_EXPRESSION,
4058 CHECK_OK); 4058 CHECK_OK);
4059 // Allow any number of parameters for compatibilty with JSC. 4059 // Allow any number of parameters for compatibilty with JSC.
4060 // Specification only allows zero parameters for get and one for set. 4060 // Specification only allows zero parameters for get and one for set.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 } 4121 }
4122 continue; // restart the while 4122 continue; // restart the while
4123 } 4123 }
4124 // Failed to parse as get/set property, so it's just a property 4124 // Failed to parse as get/set property, so it's just a property
4125 // called "get" or "set". 4125 // called "get" or "set".
4126 key = factory()->NewLiteral(id); 4126 key = factory()->NewLiteral(id);
4127 break; 4127 break;
4128 } 4128 }
4129 case Token::STRING: { 4129 case Token::STRING: {
4130 Consume(Token::STRING); 4130 Consume(Token::STRING);
4131 Handle<String> string = GetSymbol(CHECK_OK); 4131 Handle<String> string = GetSymbol();
4132 if (fni_ != NULL) fni_->PushLiteralName(string); 4132 if (fni_ != NULL) fni_->PushLiteralName(string);
4133 uint32_t index; 4133 uint32_t index;
4134 if (!string.is_null() && string->AsArrayIndex(&index)) { 4134 if (!string.is_null() && string->AsArrayIndex(&index)) {
4135 key = factory()->NewNumberLiteral(index); 4135 key = factory()->NewNumberLiteral(index);
4136 break; 4136 break;
4137 } 4137 }
4138 key = factory()->NewLiteral(string); 4138 key = factory()->NewLiteral(string);
4139 break; 4139 break;
4140 } 4140 }
4141 case Token::NUMBER: { 4141 case Token::NUMBER: {
4142 Consume(Token::NUMBER); 4142 Consume(Token::NUMBER);
4143 ASSERT(scanner().is_literal_ascii()); 4143 ASSERT(scanner().is_literal_ascii());
4144 double value = StringToDouble(isolate()->unicode_cache(), 4144 double value = StringToDouble(isolate()->unicode_cache(),
4145 scanner().literal_ascii_string(), 4145 scanner().literal_ascii_string(),
4146 ALLOW_HEX | ALLOW_OCTALS); 4146 ALLOW_HEX | ALLOW_OCTALS);
4147 key = factory()->NewNumberLiteral(value); 4147 key = factory()->NewNumberLiteral(value);
4148 break; 4148 break;
4149 } 4149 }
4150 default: 4150 default:
4151 if (Token::IsKeyword(next)) { 4151 if (Token::IsKeyword(next)) {
4152 Consume(next); 4152 Consume(next);
4153 Handle<String> string = GetSymbol(CHECK_OK); 4153 Handle<String> string = GetSymbol();
4154 key = factory()->NewLiteral(string); 4154 key = factory()->NewLiteral(string);
4155 } else { 4155 } else {
4156 // Unexpected token. 4156 // Unexpected token.
4157 Token::Value next = Next(); 4157 Token::Value next = Next();
4158 ReportUnexpectedToken(next); 4158 ReportUnexpectedToken(next);
4159 *ok = false; 4159 *ok = false;
4160 return NULL; 4160 return NULL;
4161 } 4161 }
4162 } 4162 }
4163 4163
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
4816 tok == Token::EOS) { 4816 tok == Token::EOS) {
4817 return; 4817 return;
4818 } 4818 }
4819 Expect(Token::SEMICOLON, ok); 4819 Expect(Token::SEMICOLON, ok);
4820 } 4820 }
4821 4821
4822 4822
4823 void Parser::ExpectContextualKeyword(const char* keyword, bool* ok) { 4823 void Parser::ExpectContextualKeyword(const char* keyword, bool* ok) {
4824 Expect(Token::IDENTIFIER, ok); 4824 Expect(Token::IDENTIFIER, ok);
4825 if (!*ok) return; 4825 if (!*ok) return;
4826 Handle<String> symbol = GetSymbol(ok); 4826 Handle<String> symbol = GetSymbol();
4827 if (!*ok) return; 4827 if (!*ok) return;
4828 if (!symbol->IsUtf8EqualTo(CStrVector(keyword))) { 4828 if (!symbol->IsUtf8EqualTo(CStrVector(keyword))) {
4829 *ok = false; 4829 *ok = false;
4830 ReportUnexpectedToken(scanner().current_token()); 4830 ReportUnexpectedToken(scanner().current_token());
4831 } 4831 }
4832 } 4832 }
4833 4833
4834 4834
4835 Literal* Parser::GetLiteralUndefined() { 4835 Literal* Parser::GetLiteralUndefined() {
4836 return factory()->NewLiteral(isolate()->factory()->undefined_value()); 4836 return factory()->NewLiteral(isolate()->factory()->undefined_value());
4837 } 4837 }
4838 4838
4839 4839
4840 Literal* Parser::GetLiteralTheHole() { 4840 Literal* Parser::GetLiteralTheHole() {
4841 return factory()->NewLiteral(isolate()->factory()->the_hole_value()); 4841 return factory()->NewLiteral(isolate()->factory()->the_hole_value());
4842 } 4842 }
4843 4843
4844 4844
4845 // Parses an identifier that is valid for the current scope, in particular it 4845 // Parses an identifier that is valid for the current scope, in particular it
4846 // fails on strict mode future reserved keywords in a strict scope. 4846 // fails on strict mode future reserved keywords in a strict scope.
4847 Handle<String> Parser::ParseIdentifier(bool* ok) { 4847 Handle<String> Parser::ParseIdentifier(bool* ok) {
4848 Token::Value next = Next(); 4848 Token::Value next = Next();
4849 if (next == Token::IDENTIFIER || 4849 if (next == Token::IDENTIFIER ||
4850 (top_scope_->is_classic_mode() && 4850 (top_scope_->is_classic_mode() &&
4851 (next == Token::FUTURE_STRICT_RESERVED_WORD || 4851 (next == Token::FUTURE_STRICT_RESERVED_WORD ||
4852 (next == Token::YIELD && !is_generator())))) { 4852 (next == Token::YIELD && !is_generator())))) {
4853 return GetSymbol(ok); 4853 return GetSymbol();
4854 } else { 4854 } else {
4855 ReportUnexpectedToken(next); 4855 ReportUnexpectedToken(next);
4856 *ok = false; 4856 *ok = false;
4857 return Handle<String>(); 4857 return Handle<String>();
4858 } 4858 }
4859 } 4859 }
4860 4860
4861 4861
4862 // Parses and identifier or a strict mode future reserved word, and indicate 4862 // Parses and identifier or a strict mode future reserved word, and indicate
4863 // whether it is strict mode future reserved. 4863 // whether it is strict mode future reserved.
4864 Handle<String> Parser::ParseIdentifierOrStrictReservedWord( 4864 Handle<String> Parser::ParseIdentifierOrStrictReservedWord(
4865 bool* is_strict_reserved, bool* ok) { 4865 bool* is_strict_reserved, bool* ok) {
4866 Token::Value next = Next(); 4866 Token::Value next = Next();
4867 if (next == Token::IDENTIFIER) { 4867 if (next == Token::IDENTIFIER) {
4868 *is_strict_reserved = false; 4868 *is_strict_reserved = false;
4869 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || 4869 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD ||
4870 (next == Token::YIELD && !is_generator())) { 4870 (next == Token::YIELD && !is_generator())) {
4871 *is_strict_reserved = true; 4871 *is_strict_reserved = true;
4872 } else { 4872 } else {
4873 ReportUnexpectedToken(next); 4873 ReportUnexpectedToken(next);
4874 *ok = false; 4874 *ok = false;
4875 return Handle<String>(); 4875 return Handle<String>();
4876 } 4876 }
4877 return GetSymbol(ok); 4877 return GetSymbol();
4878 } 4878 }
4879 4879
4880 4880
4881 Handle<String> Parser::ParseIdentifierName(bool* ok) { 4881 Handle<String> Parser::ParseIdentifierName(bool* ok) {
4882 Token::Value next = Next(); 4882 Token::Value next = Next();
4883 if (next != Token::IDENTIFIER && 4883 if (next != Token::IDENTIFIER &&
4884 next != Token::FUTURE_RESERVED_WORD && 4884 next != Token::FUTURE_RESERVED_WORD &&
4885 next != Token::FUTURE_STRICT_RESERVED_WORD && 4885 next != Token::FUTURE_STRICT_RESERVED_WORD &&
4886 !Token::IsKeyword(next)) { 4886 !Token::IsKeyword(next)) {
4887 ReportUnexpectedToken(next); 4887 ReportUnexpectedToken(next);
4888 *ok = false; 4888 *ok = false;
4889 return Handle<String>(); 4889 return Handle<String>();
4890 } 4890 }
4891 return GetSymbol(ok); 4891 return GetSymbol();
4892 } 4892 }
4893 4893
4894 4894
4895 void Parser::MarkAsLValue(Expression* expression) { 4895 void Parser::MarkAsLValue(Expression* expression) {
4896 VariableProxy* proxy = expression != NULL 4896 VariableProxy* proxy = expression != NULL
4897 ? expression->AsVariableProxy() 4897 ? expression->AsVariableProxy()
4898 : NULL; 4898 : NULL;
4899 4899
4900 if (proxy != NULL) proxy->MarkAsLValue(); 4900 if (proxy != NULL) proxy->MarkAsLValue();
4901 } 4901 }
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
6025 ASSERT(info()->isolate()->has_pending_exception()); 6025 ASSERT(info()->isolate()->has_pending_exception());
6026 } else { 6026 } else {
6027 result = ParseProgram(); 6027 result = ParseProgram();
6028 } 6028 }
6029 } 6029 }
6030 info()->SetFunction(result); 6030 info()->SetFunction(result);
6031 return (result != NULL); 6031 return (result != NULL);
6032 } 6032 }
6033 6033
6034 } } // namespace v8::internal 6034 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698