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

Side by Side Diff: src/parser.cc

Issue 225823003: Implement handlified String::Equals and Name::Equals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: refactored StringToDouble Created 6 years, 8 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/objects-inl.h ('k') | src/runtime.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 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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 ExpressionStatement* e_stat; 1119 ExpressionStatement* e_stat;
1120 Literal* literal; 1120 Literal* literal;
1121 // Still processing directive prologue? 1121 // Still processing directive prologue?
1122 if ((e_stat = stat->AsExpressionStatement()) != NULL && 1122 if ((e_stat = stat->AsExpressionStatement()) != NULL &&
1123 (literal = e_stat->expression()->AsLiteral()) != NULL && 1123 (literal = e_stat->expression()->AsLiteral()) != NULL &&
1124 literal->value()->IsString()) { 1124 literal->value()->IsString()) {
1125 Handle<String> directive = Handle<String>::cast(literal->value()); 1125 Handle<String> directive = Handle<String>::cast(literal->value());
1126 1126
1127 // Check "use strict" directive (ES5 14.1). 1127 // Check "use strict" directive (ES5 14.1).
1128 if (strict_mode() == SLOPPY && 1128 if (strict_mode() == SLOPPY &&
1129 directive->Equals(isolate()->heap()->use_strict_string()) && 1129 String::Equals(isolate()->factory()->use_strict_string(),
1130 directive) &&
1130 token_loc.end_pos - token_loc.beg_pos == 1131 token_loc.end_pos - token_loc.beg_pos ==
1131 isolate()->heap()->use_strict_string()->length() + 2) { 1132 isolate()->heap()->use_strict_string()->length() + 2) {
1132 // TODO(mstarzinger): Global strict eval calls, need their own scope 1133 // TODO(mstarzinger): Global strict eval calls, need their own scope
1133 // as specified in ES5 10.4.2(3). The correct fix would be to always 1134 // as specified in ES5 10.4.2(3). The correct fix would be to always
1134 // add this scope in DoParseProgram(), but that requires adaptations 1135 // add this scope in DoParseProgram(), but that requires adaptations
1135 // all over the code base, so we go with a quick-fix for now. 1136 // all over the code base, so we go with a quick-fix for now.
1136 // In the same manner, we have to patch the parsing mode. 1137 // In the same manner, we have to patch the parsing mode.
1137 if (is_eval && !scope_->is_eval_scope()) { 1138 if (is_eval && !scope_->is_eval_scope()) {
1138 ASSERT(scope_->is_global_scope()); 1139 ASSERT(scope_->is_global_scope());
1139 Scope* scope = NewScope(scope_, EVAL_SCOPE); 1140 Scope* scope = NewScope(scope_, EVAL_SCOPE);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 default: { 1189 default: {
1189 Statement* stmt = ParseStatement(labels, CHECK_OK); 1190 Statement* stmt = ParseStatement(labels, CHECK_OK);
1190 // Handle 'module' as a context-sensitive keyword. 1191 // Handle 'module' as a context-sensitive keyword.
1191 if (FLAG_harmony_modules && 1192 if (FLAG_harmony_modules &&
1192 peek() == Token::IDENTIFIER && 1193 peek() == Token::IDENTIFIER &&
1193 !scanner()->HasAnyLineTerminatorBeforeNext() && 1194 !scanner()->HasAnyLineTerminatorBeforeNext() &&
1194 stmt != NULL) { 1195 stmt != NULL) {
1195 ExpressionStatement* estmt = stmt->AsExpressionStatement(); 1196 ExpressionStatement* estmt = stmt->AsExpressionStatement();
1196 if (estmt != NULL && 1197 if (estmt != NULL &&
1197 estmt->expression()->AsVariableProxy() != NULL && 1198 estmt->expression()->AsVariableProxy() != NULL &&
1198 estmt->expression()->AsVariableProxy()->name()->Equals( 1199 String::Equals(isolate()->factory()->module_string(),
1199 isolate()->heap()->module_string()) && 1200 estmt->expression()->AsVariableProxy()->name()) &&
1200 !scanner()->literal_contains_escapes()) { 1201 !scanner()->literal_contains_escapes()) {
1201 return ParseModuleDeclaration(NULL, ok); 1202 return ParseModuleDeclaration(NULL, ok);
1202 } 1203 }
1203 } 1204 }
1204 return stmt; 1205 return stmt;
1205 } 1206 }
1206 } 1207 }
1207 } 1208 }
1208 1209
1209 1210
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 } 2387 }
2387 2388
2388 // If we have an extension, we allow a native function declaration. 2389 // If we have an extension, we allow a native function declaration.
2389 // A native function declaration starts with "native function" with 2390 // A native function declaration starts with "native function" with
2390 // no line-terminator between the two words. 2391 // no line-terminator between the two words.
2391 if (extension_ != NULL && 2392 if (extension_ != NULL &&
2392 peek() == Token::FUNCTION && 2393 peek() == Token::FUNCTION &&
2393 !scanner()->HasAnyLineTerminatorBeforeNext() && 2394 !scanner()->HasAnyLineTerminatorBeforeNext() &&
2394 expr != NULL && 2395 expr != NULL &&
2395 expr->AsVariableProxy() != NULL && 2396 expr->AsVariableProxy() != NULL &&
2396 expr->AsVariableProxy()->name()->Equals( 2397 String::Equals(isolate()->factory()->native_string(),
2397 isolate()->heap()->native_string()) && 2398 expr->AsVariableProxy()->name()) &&
2398 !scanner()->literal_contains_escapes()) { 2399 !scanner()->literal_contains_escapes()) {
2399 return ParseNativeDeclaration(ok); 2400 return ParseNativeDeclaration(ok);
2400 } 2401 }
2401 2402
2402 // Parsed expression statement, or the context-sensitive 'module' keyword. 2403 // Parsed expression statement, or the context-sensitive 'module' keyword.
2403 // Only expect semicolon in the former case. 2404 // Only expect semicolon in the former case.
2404 if (!FLAG_harmony_modules || 2405 if (!FLAG_harmony_modules ||
2405 peek() != Token::IDENTIFIER || 2406 peek() != Token::IDENTIFIER ||
2406 scanner()->HasAnyLineTerminatorBeforeNext() || 2407 scanner()->HasAnyLineTerminatorBeforeNext() ||
2407 expr->AsVariableProxy() == NULL || 2408 expr->AsVariableProxy() == NULL ||
2408 !expr->AsVariableProxy()->name()->Equals( 2409 !String::Equals(isolate()->factory()->module_string(),
2409 isolate()->heap()->module_string()) || 2410 expr->AsVariableProxy()->name()) ||
2410 scanner()->literal_contains_escapes()) { 2411 scanner()->literal_contains_escapes()) {
2411 ExpectSemicolon(CHECK_OK); 2412 ExpectSemicolon(CHECK_OK);
2412 } 2413 }
2413 return factory()->NewExpressionStatement(expr, pos); 2414 return factory()->NewExpressionStatement(expr, pos);
2414 } 2415 }
2415 2416
2416 2417
2417 IfStatement* Parser::ParseIfStatement(ZoneStringList* labels, bool* ok) { 2418 IfStatement* Parser::ParseIfStatement(ZoneStringList* labels, bool* ok) {
2418 // IfStatement :: 2419 // IfStatement ::
2419 // 'if' '(' Expression ')' Statement ('else' Statement)? 2420 // 'if' '(' Expression ')' Statement ('else' Statement)?
(...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 ASSERT(info()->isolate()->has_pending_exception()); 4679 ASSERT(info()->isolate()->has_pending_exception());
4679 } else { 4680 } else {
4680 result = ParseProgram(); 4681 result = ParseProgram();
4681 } 4682 }
4682 } 4683 }
4683 info()->SetFunction(result); 4684 info()->SetFunction(result);
4684 return (result != NULL); 4685 return (result != NULL);
4685 } 4686 }
4686 4687
4687 } } // namespace v8::internal 4688 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698