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

Side by Side Diff: src/parser.cc

Issue 9704054: Refactoring of code generation for declarations, in preparation for modules. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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
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 4426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 4437
4438 // If we have a named function expression, we add a local variable 4438 // If we have a named function expression, we add a local variable
4439 // declaration to the body of the function with the name of the 4439 // declaration to the body of the function with the name of the
4440 // function and let it refer to the function itself (closure). 4440 // function and let it refer to the function itself (closure).
4441 // NOTE: We create a proxy and resolve it here so that in the 4441 // NOTE: We create a proxy and resolve it here so that in the
4442 // future we can change the AST to only refer to VariableProxies 4442 // future we can change the AST to only refer to VariableProxies
4443 // instead of Variables and Proxis as is the case now. 4443 // instead of Variables and Proxis as is the case now.
4444 Variable* fvar = NULL; 4444 Variable* fvar = NULL;
4445 Token::Value fvar_init_op = Token::INIT_CONST; 4445 Token::Value fvar_init_op = Token::INIT_CONST;
4446 if (type == FunctionLiteral::NAMED_EXPRESSION) { 4446 if (type == FunctionLiteral::NAMED_EXPRESSION) {
4447 VariableMode fvar_mode; 4447 if (is_extended_mode()) fvar_init_op = Token::INIT_CONST_HARMONY;
4448 if (is_extended_mode()) { 4448 VariableMode fvar_mode = is_extended_mode() ? CONST_HARMONY : CONST;
4449 fvar_mode = CONST_HARMONY; 4449 fvar = new(zone()) Variable(top_scope_,
4450 fvar_init_op = Token::INIT_CONST_HARMONY; 4450 function_name, fvar_mode, true, Variable::NORMAL, kCreatedInitialized);
fschneider 2012/04/11 11:00:42 Maybe break after each parameter and add a short s
rossberg 2012/04/16 11:25:13 Done.
4451 } else { 4451 VariableProxy* proxy = factory()->NewVariableProxy(fvar);
4452 fvar_mode = CONST; 4452 VariableDeclaration* fvar_declaration =
4453 } 4453 factory()->NewVariableDeclaration(proxy, fvar_mode, top_scope_);
4454 fvar = 4454 top_scope_->DeclareFunctionVar(fvar_declaration);
4455 top_scope_->DeclareFunctionVar(function_name, fvar_mode, factory());
4456 } 4455 }
4457 4456
4458 // Determine whether the function will be lazily compiled. 4457 // Determine whether the function will be lazily compiled.
4459 // The heuristics are: 4458 // The heuristics are:
4460 // - It must not have been prohibited by the caller to Parse (some callers 4459 // - It must not have been prohibited by the caller to Parse (some callers
4461 // need a full AST). 4460 // need a full AST).
4462 // - The outer scope must be trivial (only global variables in scope). 4461 // - The outer scope must be trivial (only global variables in scope).
4463 // - The function mustn't be a function expression with an open parenthesis 4462 // - The function mustn't be a function expression with an open parenthesis
4464 // before; we consider that a hint that the function will be called 4463 // before; we consider that a hint that the function will be called
4465 // immediately, and it would be a waste of time to make it lazily 4464 // immediately, and it would be a waste of time to make it lazily
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
5999 ASSERT(info->isolate()->has_pending_exception()); 5998 ASSERT(info->isolate()->has_pending_exception());
6000 } else { 5999 } else {
6001 result = parser.ParseProgram(info); 6000 result = parser.ParseProgram(info);
6002 } 6001 }
6003 } 6002 }
6004 info->SetFunction(result); 6003 info->SetFunction(result);
6005 return (result != NULL); 6004 return (result != NULL);
6006 } 6005 }
6007 6006
6008 } } // namespace v8::internal 6007 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698