OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |