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

Unified Diff: src/parser.cc

Issue 932283003: [strong] make function and class declarations lexical & immutable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Adjusted assertion Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast.h ('k') | test/mjsunit/strong/arguments.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 84a94efbfc6a991bb99b5b6d0a1a038e70a0e1cf..985a90f8dc5f0154a1829680e99f37cb2e008085 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1975,6 +1975,7 @@ Statement* Parser::ParseFunctionDeclaration(
// In ES6, a function behaves as a lexical binding, except in
// a script scope, or the initial scope of eval or another function.
VariableMode mode =
+ is_strong(language_mode()) ? CONST :
allow_harmony_scoping() && is_strict(language_mode()) &&
!(scope_->is_script_scope() || scope_->is_eval_scope() ||
scope_->is_function_scope())
@@ -2018,13 +2019,15 @@ Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names,
ClassLiteral* value = ParseClassLiteral(name, scanner()->location(),
is_strict_reserved, pos, CHECK_OK);
- VariableProxy* proxy = NewUnresolved(name, LET);
+ VariableMode mode = is_strong(language_mode()) ? CONST : LET;
+ VariableProxy* proxy = NewUnresolved(name, mode);
Declaration* declaration =
- factory()->NewVariableDeclaration(proxy, LET, scope_, pos);
+ factory()->NewVariableDeclaration(proxy, mode, scope_, pos);
Declare(declaration, true, CHECK_OK);
proxy->var()->set_initializer_position(pos);
- Token::Value init_op = Token::INIT_LET;
+ Token::Value init_op =
+ is_strong(language_mode()) ? Token::INIT_CONST : Token::INIT_LET;
Assignment* assignment = factory()->NewAssignment(init_op, proxy, value, pos);
Statement* assignment_statement =
factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition);
« no previous file with comments | « src/ast.h ('k') | test/mjsunit/strong/arguments.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698