| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/scopeinfo.h" | 9 #include "src/scopeinfo.h" |
| 10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 bool ScopeInfo::block_scope_is_class_scope() { | 498 bool ScopeInfo::block_scope_is_class_scope() { |
| 499 return BlockScopeIsClassScopeField::decode(Flags()); | 499 return BlockScopeIsClassScopeField::decode(Flags()); |
| 500 } | 500 } |
| 501 | 501 |
| 502 | 502 |
| 503 FunctionKind ScopeInfo::function_kind() { | 503 FunctionKind ScopeInfo::function_kind() { |
| 504 return FunctionKindField::decode(Flags()); | 504 return FunctionKindField::decode(Flags()); |
| 505 } | 505 } |
| 506 | 506 |
| 507 | 507 |
| 508 void ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, | 508 bool ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, |
| 509 Handle<Context> context, | 509 Handle<Context> context, |
| 510 Handle<JSObject> scope_object) { | 510 Handle<JSObject> scope_object) { |
| 511 Isolate* isolate = scope_info->GetIsolate(); | 511 Isolate* isolate = scope_info->GetIsolate(); |
| 512 int local_count = scope_info->ContextLocalCount(); | 512 int local_count = scope_info->ContextLocalCount(); |
| 513 if (local_count == 0) return; | 513 if (local_count == 0) return true; |
| 514 // Fill all context locals to the context extension. | 514 // Fill all context locals to the context extension. |
| 515 int first_context_var = scope_info->StackLocalCount(); | 515 int first_context_var = scope_info->StackLocalCount(); |
| 516 int start = scope_info->ContextLocalNameEntriesIndex(); | 516 int start = scope_info->ContextLocalNameEntriesIndex(); |
| 517 for (int i = 0; i < local_count; ++i) { | 517 for (int i = 0; i < local_count; ++i) { |
| 518 if (scope_info->LocalIsSynthetic(first_context_var + i)) continue; | 518 if (scope_info->LocalIsSynthetic(first_context_var + i)) continue; |
| 519 int context_index = Context::MIN_CONTEXT_SLOTS + i; | 519 int context_index = Context::MIN_CONTEXT_SLOTS + i; |
| 520 Handle<Object> value = Handle<Object>(context->get(context_index), isolate); | 520 Handle<Object> value = Handle<Object>(context->get(context_index), isolate); |
| 521 // Reflect variables under TDZ as undefined in scope object. | 521 // Reflect variables under TDZ as undefined in scope object. |
| 522 if (value->IsTheHole()) continue; | 522 if (value->IsTheHole()) continue; |
| 523 // This should always succeed. | 523 RETURN_ON_EXCEPTION_VALUE( |
| 524 // TODO(verwaest): Use AddDataProperty instead. | 524 isolate, Runtime::DefineObjectProperty( |
| 525 JSObject::SetOwnPropertyIgnoreAttributes( | 525 scope_object, |
| 526 scope_object, handle(String::cast(scope_info->get(i + start))), value, | 526 Handle<String>(String::cast(scope_info->get(i + start))), |
| 527 ::NONE).Check(); | 527 value, ::NONE), |
| 528 false); |
| 528 } | 529 } |
| 530 return true; |
| 529 } | 531 } |
| 530 | 532 |
| 531 | 533 |
| 532 int ScopeInfo::ParameterEntriesIndex() { | 534 int ScopeInfo::ParameterEntriesIndex() { |
| 533 DCHECK(length() > 0); | 535 DCHECK(length() > 0); |
| 534 return kVariablePartIndex; | 536 return kVariablePartIndex; |
| 535 } | 537 } |
| 536 | 538 |
| 537 | 539 |
| 538 int ScopeInfo::StackLocalFirstSlotIndex() { | 540 int ScopeInfo::StackLocalFirstSlotIndex() { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 info->set_mode(i, var->mode()); | 719 info->set_mode(i, var->mode()); |
| 718 DCHECK(var->index() >= 0); | 720 DCHECK(var->index() >= 0); |
| 719 info->set_index(i, var->index()); | 721 info->set_index(i, var->index()); |
| 720 } | 722 } |
| 721 DCHECK(i == info->length()); | 723 DCHECK(i == info->length()); |
| 722 return info; | 724 return info; |
| 723 } | 725 } |
| 724 | 726 |
| 725 } // namespace internal | 727 } // namespace internal |
| 726 } // namespace v8 | 728 } // namespace v8 |
| OLD | NEW |