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

Side by Side Diff: src/parser.cc

Issue 927953003: [strong] Forbid var. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: loop w const omg 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 unified diff | Download patch
« no previous file with comments | « src/messages.js ('k') | src/preparser.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 int pos = peek_position(); 2149 int pos = peek_position();
2150 VariableMode mode = VAR; 2150 VariableMode mode = VAR;
2151 // True if the binding needs initialization. 'let' and 'const' declared 2151 // True if the binding needs initialization. 'let' and 'const' declared
2152 // bindings are created uninitialized by their declaration nodes and 2152 // bindings are created uninitialized by their declaration nodes and
2153 // need initialization. 'var' declared bindings are always initialized 2153 // need initialization. 'var' declared bindings are always initialized
2154 // immediately by their declaration nodes. 2154 // immediately by their declaration nodes.
2155 bool needs_init = false; 2155 bool needs_init = false;
2156 bool is_const = false; 2156 bool is_const = false;
2157 Token::Value init_op = Token::INIT_VAR; 2157 Token::Value init_op = Token::INIT_VAR;
2158 if (peek() == Token::VAR) { 2158 if (peek() == Token::VAR) {
2159 if (is_strong(language_mode())) {
2160 Scanner::Location location = scanner()->peek_location();
2161 ReportMessageAt(location, "strong_var");
2162 *ok = false;
2163 return NULL;
2164 }
2159 Consume(Token::VAR); 2165 Consume(Token::VAR);
2160 } else if (peek() == Token::CONST) { 2166 } else if (peek() == Token::CONST) {
2161 Consume(Token::CONST); 2167 Consume(Token::CONST);
2162 if (is_sloppy(language_mode())) { 2168 if (is_sloppy(language_mode())) {
2163 mode = CONST_LEGACY; 2169 mode = CONST_LEGACY;
2164 init_op = Token::INIT_CONST_LEGACY; 2170 init_op = Token::INIT_CONST_LEGACY;
2165 } else { 2171 } else {
2166 DCHECK(var_context != kStatement); 2172 DCHECK(var_context != kStatement);
2167 // In ES5 const is not allowed in strict mode. 2173 // In ES5 const is not allowed in strict mode.
2168 if (!allow_harmony_scoping()) { 2174 if (!allow_harmony_scoping()) {
(...skipping 3299 matching lines...) Expand 10 before | Expand all | Expand 10 after
5468 } else { 5474 } else {
5469 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5475 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5470 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5476 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5471 raw_string->length()); 5477 raw_string->length());
5472 } 5478 }
5473 } 5479 }
5474 5480
5475 return running_hash; 5481 return running_hash;
5476 } 5482 }
5477 } } // namespace v8::internal 5483 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/messages.js ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698