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

Side by Side Diff: src/parser.cc

Issue 8112007: Fix incorrect function name inference in case of assignment / global assignment. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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/func-name-inferrer.h ('k') | test/cctest/test-func-name-inference.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 int position = -1; 1758 int position = -1;
1759 if (peek() == Token::ASSIGN) { 1759 if (peek() == Token::ASSIGN) {
1760 Expect(Token::ASSIGN, CHECK_OK); 1760 Expect(Token::ASSIGN, CHECK_OK);
1761 position = scanner().location().beg_pos; 1761 position = scanner().location().beg_pos;
1762 value = ParseAssignmentExpression(var_context != kForStatement, CHECK_OK); 1762 value = ParseAssignmentExpression(var_context != kForStatement, CHECK_OK);
1763 // Don't infer if it is "a = function(){...}();"-like expression. 1763 // Don't infer if it is "a = function(){...}();"-like expression.
1764 if (fni_ != NULL && 1764 if (fni_ != NULL &&
1765 value->AsCall() == NULL && 1765 value->AsCall() == NULL &&
1766 value->AsCallNew() == NULL) { 1766 value->AsCallNew() == NULL) {
1767 fni_->Infer(); 1767 fni_->Infer();
1768 } else {
1769 fni_->RemoveLastFunction();
1768 } 1770 }
1769 } 1771 }
1770 1772
1771 // Make sure that 'const x' and 'let x' initialize 'x' to undefined. 1773 // Make sure that 'const x' and 'let x' initialize 'x' to undefined.
1772 if (value == NULL && needs_init) { 1774 if (value == NULL && needs_init) {
1773 value = GetLiteralUndefined(); 1775 value = GetLiteralUndefined();
1774 } 1776 }
1775 1777
1776 // Global variable declarations must be compiled in a specific 1778 // Global variable declarations must be compiled in a specific
1777 // way. When the script containing the global variable declaration 1779 // way. When the script containing the global variable declaration
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 2510
2509 if (fni_ != NULL) { 2511 if (fni_ != NULL) {
2510 // Check if the right hand side is a call to avoid inferring a 2512 // Check if the right hand side is a call to avoid inferring a
2511 // name if we're dealing with "a = function(){...}();"-like 2513 // name if we're dealing with "a = function(){...}();"-like
2512 // expression. 2514 // expression.
2513 if ((op == Token::INIT_VAR 2515 if ((op == Token::INIT_VAR
2514 || op == Token::INIT_CONST 2516 || op == Token::INIT_CONST
2515 || op == Token::ASSIGN) 2517 || op == Token::ASSIGN)
2516 && (right->AsCall() == NULL && right->AsCallNew() == NULL)) { 2518 && (right->AsCall() == NULL && right->AsCallNew() == NULL)) {
2517 fni_->Infer(); 2519 fni_->Infer();
2520 } else {
2521 fni_->RemoveLastFunction();
2518 } 2522 }
2519 fni_->Leave(); 2523 fni_->Leave();
2520 } 2524 }
2521 2525
2522 return new(zone()) Assignment(isolate(), op, expression, right, pos); 2526 return new(zone()) Assignment(isolate(), op, expression, right, pos);
2523 } 2527 }
2524 2528
2525 2529
2526 // Precedence = 3 2530 // Precedence = 3
2527 Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) { 2531 Expression* Parser::ParseConditionalExpression(bool accept_IN, bool* ok) {
(...skipping 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after
5214 result = parser.ParseProgram(source, 5218 result = parser.ParseProgram(source,
5215 info->is_global(), 5219 info->is_global(),
5216 info->StrictMode()); 5220 info->StrictMode());
5217 } 5221 }
5218 } 5222 }
5219 info->SetFunction(result); 5223 info->SetFunction(result);
5220 return (result != NULL); 5224 return (result != NULL);
5221 } 5225 }
5222 5226
5223 } } // namespace v8::internal 5227 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/func-name-inferrer.h ('k') | test/cctest/test-func-name-inference.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698