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

Side by Side Diff: src/scopes.cc

Issue 749633002: harmony-scoping: make assignment to 'const' a late error. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment update Created 6 years 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/runtime/runtime-scopes.cc ('k') | src/x64/full-codegen-x64.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/scopes.h" 7 #include "src/scopes.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1086
1087 case DYNAMIC_LOOKUP: 1087 case DYNAMIC_LOOKUP:
1088 // The variable could not be resolved statically. 1088 // The variable could not be resolved statically.
1089 var = NonLocal(proxy->raw_name(), DYNAMIC); 1089 var = NonLocal(proxy->raw_name(), DYNAMIC);
1090 break; 1090 break;
1091 } 1091 }
1092 1092
1093 DCHECK(var != NULL); 1093 DCHECK(var != NULL);
1094 if (proxy->is_assigned()) var->set_maybe_assigned(); 1094 if (proxy->is_assigned()) var->set_maybe_assigned();
1095 1095
1096 if (FLAG_harmony_scoping && strict_mode() == STRICT &&
1097 var->is_const_mode() && proxy->is_assigned()) {
1098 // Assignment to const. Throw a syntax error.
1099 MessageLocation location(
1100 info->script(), proxy->position(), proxy->position());
1101 Isolate* isolate = info->isolate();
1102 Factory* factory = isolate->factory();
1103 Handle<JSArray> array = factory->NewJSArray(0);
1104 Handle<Object> error;
1105 MaybeHandle<Object> maybe_error =
1106 factory->NewSyntaxError("harmony_const_assign", array);
1107 if (maybe_error.ToHandle(&error)) isolate->Throw(*error, &location);
1108 return false;
1109 }
1110
1111 if (FLAG_harmony_modules) { 1096 if (FLAG_harmony_modules) {
1112 bool ok; 1097 bool ok;
1113 #ifdef DEBUG 1098 #ifdef DEBUG
1114 if (FLAG_print_interface_details) { 1099 if (FLAG_print_interface_details) {
1115 PrintF("# Resolve %.*s:\n", var->raw_name()->length(), 1100 PrintF("# Resolve %.*s:\n", var->raw_name()->length(),
1116 var->raw_name()->raw_data()); 1101 var->raw_name()->raw_data());
1117 } 1102 }
1118 #endif 1103 #endif
1119 proxy->interface()->Unify(var->interface(), zone(), &ok); 1104 proxy->interface()->Unify(var->interface(), zone(), &ok);
1120 if (!ok) { 1105 if (!ok) {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 } 1417 }
1433 1418
1434 1419
1435 int Scope::ContextLocalCount() const { 1420 int Scope::ContextLocalCount() const {
1436 if (num_heap_slots() == 0) return 0; 1421 if (num_heap_slots() == 0) return 0;
1437 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1422 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1438 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1423 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1439 } 1424 }
1440 1425
1441 } } // namespace v8::internal 1426 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-scopes.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698