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

Side by Side Diff: src/rewriter.cc

Issue 67168: Allow multiple function literals to be assigned to the same var / property. (Closed)
Patch Set: Changes according to Kevin's and Lasse's comments Created 11 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
« no previous file with comments | « src/func-name-inferrer.cc ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void AstOptimizer::VisitDebuggerStatement(DebuggerStatement* node) { 187 void AstOptimizer::VisitDebuggerStatement(DebuggerStatement* node) {
188 USE(node); 188 USE(node);
189 } 189 }
190 190
191 191
192 void AstOptimizer::VisitFunctionLiteral(FunctionLiteral* node) { 192 void AstOptimizer::VisitFunctionLiteral(FunctionLiteral* node) {
193 has_function_literal_ = true; 193 has_function_literal_ = true;
194 194
195 if (node->name()->length() == 0) { 195 if (node->name()->length() == 0) {
196 // Anonymous function. 196 // Anonymous function.
197 func_name_inferrer_.SetFuncToInfer(node); 197 func_name_inferrer_.AddFunction(node);
198 } 198 }
199 } 199 }
200 200
201 201
202 void AstOptimizer::VisitFunctionBoilerplateLiteral( 202 void AstOptimizer::VisitFunctionBoilerplateLiteral(
203 FunctionBoilerplateLiteral* node) { 203 FunctionBoilerplateLiteral* node) {
204 USE(node); 204 USE(node);
205 } 205 }
206 206
207 207
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 276
277 void AstOptimizer::VisitAssignment(Assignment* node) { 277 void AstOptimizer::VisitAssignment(Assignment* node) {
278 ScopedFuncNameInferrer scoped_fni(&func_name_inferrer_); 278 ScopedFuncNameInferrer scoped_fni(&func_name_inferrer_);
279 switch (node->op()) { 279 switch (node->op()) {
280 case Token::INIT_VAR: 280 case Token::INIT_VAR:
281 case Token::INIT_CONST: 281 case Token::INIT_CONST:
282 case Token::ASSIGN: 282 case Token::ASSIGN:
283 // No type can be infered from the general assignment. 283 // No type can be infered from the general assignment.
284 284
285 if (node->value()->AsFunctionLiteral() != NULL || 285 scoped_fni.Enter();
286 node->value()->AsObjectLiteral() != NULL) {
287 scoped_fni.Enter();
288 }
289 break; 286 break;
290 case Token::ASSIGN_BIT_OR: 287 case Token::ASSIGN_BIT_OR:
291 case Token::ASSIGN_BIT_XOR: 288 case Token::ASSIGN_BIT_XOR:
292 case Token::ASSIGN_BIT_AND: 289 case Token::ASSIGN_BIT_AND:
293 case Token::ASSIGN_SHL: 290 case Token::ASSIGN_SHL:
294 case Token::ASSIGN_SAR: 291 case Token::ASSIGN_SAR:
295 case Token::ASSIGN_SHR: 292 case Token::ASSIGN_SHR:
296 node->type()->SetAsLikelySmiIfUnknown(); 293 node->type()->SetAsLikelySmiIfUnknown();
297 node->target()->type()->SetAsLikelySmiIfUnknown(); 294 node->target()->type()->SetAsLikelySmiIfUnknown();
298 node->value()->type()->SetAsLikelySmiIfUnknown(); 295 node->value()->type()->SetAsLikelySmiIfUnknown();
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 optimizer.Optimize(body); 827 optimizer.Optimize(body);
831 if (optimizer.HasStackOverflow()) { 828 if (optimizer.HasStackOverflow()) {
832 return false; 829 return false;
833 } 830 }
834 } 831 }
835 return true; 832 return true;
836 } 833 }
837 834
838 835
839 } } // namespace v8::internal 836 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/func-name-inferrer.cc ('k') | test/cctest/test-func-name-inference.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698