Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/contexts.h" | 5 #include "src/contexts.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 | 10 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 171 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 172 isolate, blacklist, | 172 isolate, blacklist, |
| 173 JSReceiver::GetProperty(Handle<JSReceiver>::cast(unscopables), | 173 JSReceiver::GetProperty(Handle<JSReceiver>::cast(unscopables), |
| 174 it->name()), | 174 it->name()), |
| 175 Nothing<bool>()); | 175 Nothing<bool>()); |
| 176 return Just(!blacklist->BooleanValue()); | 176 return Just(!blacklist->BooleanValue()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 static PropertyAttributes GetAttributesForMode(VariableMode mode) { | 179 static PropertyAttributes GetAttributesForMode(VariableMode mode) { |
| 180 DCHECK(IsDeclaredVariableMode(mode)); | 180 DCHECK(IsDeclaredVariableMode(mode)); |
| 181 return IsImmutableVariableMode(mode) ? READ_ONLY : NONE; | 181 return mode == CONST ? READ_ONLY : NONE; |
| 182 } | 182 } |
| 183 | 183 |
| 184 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, | 184 Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, |
| 185 int* index, PropertyAttributes* attributes, | 185 int* index, PropertyAttributes* attributes, |
| 186 InitializationFlag* init_flag, | 186 InitializationFlag* init_flag, |
| 187 VariableMode* variable_mode) { | 187 VariableMode* variable_mode) { |
| 188 Isolate* isolate = GetIsolate(); | 188 Isolate* isolate = GetIsolate(); |
| 189 Handle<Context> context(this, isolate); | 189 Handle<Context> context(this, isolate); |
| 190 | 190 |
| 191 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; | 191 bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 slot_index, mode); | 300 slot_index, mode); |
| 301 } | 301 } |
| 302 *index = slot_index; | 302 *index = slot_index; |
| 303 *variable_mode = mode; | 303 *variable_mode = mode; |
| 304 *init_flag = flag; | 304 *init_flag = flag; |
| 305 *attributes = GetAttributesForMode(mode); | 305 *attributes = GetAttributesForMode(mode); |
| 306 return context; | 306 return context; |
| 307 } | 307 } |
| 308 | 308 |
| 309 // Check the slot corresponding to the intermediate context holding | 309 // Check the slot corresponding to the intermediate context holding |
| 310 // only the function name variable. | 310 // only the function name variable. It's conceptually (and spec-wise) |
| 311 if (follow_context_chain && context->IsFunctionContext()) { | 311 // in an outer scope of the function's declaration scope. |
| 312 VariableMode mode; | 312 if (follow_context_chain && (flags & STOP_AT_DECLARATION_SCOPE) == 0 && |
|
adamk
2016/08/11 01:02:39
This was wrong before (the function name is concep
| |
| 313 int function_index = scope_info->FunctionContextSlotIndex(*name, &mode); | 313 context->IsFunctionContext()) { |
| 314 int function_index = scope_info->FunctionContextSlotIndex(*name); | |
| 314 if (function_index >= 0) { | 315 if (function_index >= 0) { |
| 315 if (FLAG_trace_contexts) { | 316 if (FLAG_trace_contexts) { |
| 316 PrintF("=> found intermediate function in context slot %d\n", | 317 PrintF("=> found intermediate function in context slot %d\n", |
| 317 function_index); | 318 function_index); |
| 318 } | 319 } |
| 319 *index = function_index; | 320 *index = function_index; |
| 320 *attributes = READ_ONLY; | 321 *attributes = READ_ONLY; |
| 321 DCHECK(mode == CONST_LEGACY || mode == CONST); | |
| 322 *init_flag = kCreatedInitialized; | 322 *init_flag = kCreatedInitialized; |
| 323 *variable_mode = mode; | 323 *variable_mode = CONST; |
| 324 return context; | 324 return context; |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 } else if (context->IsCatchContext()) { | 328 } else if (context->IsCatchContext()) { |
| 329 // Catch contexts have the variable name in the extension slot. | 329 // Catch contexts have the variable name in the extension slot. |
| 330 if (String::Equals(name, handle(context->catch_name()))) { | 330 if (String::Equals(name, handle(context->catch_name()))) { |
| 331 if (FLAG_trace_contexts) { | 331 if (FLAG_trace_contexts) { |
| 332 PrintF("=> found in catch context\n"); | 332 PrintF("=> found in catch context\n"); |
| 333 } | 333 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 | 574 |
| 575 int previous_value = errors_thrown()->value(); | 575 int previous_value = errors_thrown()->value(); |
| 576 set_errors_thrown(Smi::FromInt(previous_value + 1)); | 576 set_errors_thrown(Smi::FromInt(previous_value + 1)); |
| 577 } | 577 } |
| 578 | 578 |
| 579 | 579 |
| 580 int Context::GetErrorsThrown() { return errors_thrown()->value(); } | 580 int Context::GetErrorsThrown() { return errors_thrown()->value(); } |
| 581 | 581 |
| 582 } // namespace internal | 582 } // namespace internal |
| 583 } // namespace v8 | 583 } // namespace v8 |
| OLD | NEW |