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

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: Addressed Florian's comments. Created 8 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/ia32/full-codegen-ia32.cc ('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 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 /* is valid LHS */,
4451 } else { 4451 Variable::NORMAL, kCreatedInitialized);
4452 fvar_mode = CONST; 4452 VariableProxy* proxy = factory()->NewVariableProxy(fvar);
4453 } 4453 VariableDeclaration* fvar_declaration =
4454 fvar = 4454 factory()->NewVariableDeclaration(proxy, fvar_mode, top_scope_);
4455 top_scope_->DeclareFunctionVar(function_name, fvar_mode, factory()); 4455 top_scope_->DeclareFunctionVar(fvar_declaration);
4456 } 4456 }
4457 4457
4458 // Determine whether the function will be lazily compiled. 4458 // Determine whether the function will be lazily compiled.
4459 // The heuristics are: 4459 // The heuristics are:
4460 // - It must not have been prohibited by the caller to Parse (some callers 4460 // - It must not have been prohibited by the caller to Parse (some callers
4461 // need a full AST). 4461 // need a full AST).
4462 // - The outer scope must be trivial (only global variables in scope). 4462 // - The outer scope must be trivial (only global variables in scope).
4463 // - The function mustn't be a function expression with an open parenthesis 4463 // - 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 4464 // 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 4465 // 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()); 5999 ASSERT(info->isolate()->has_pending_exception());
6000 } else { 6000 } else {
6001 result = parser.ParseProgram(info); 6001 result = parser.ParseProgram(info);
6002 } 6002 }
6003 } 6003 }
6004 info->SetFunction(result); 6004 info->SetFunction(result);
6005 return (result != NULL); 6005 return (result != NULL);
6006 } 6006 }
6007 6007
6008 } } // namespace v8::internal 6008 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698