| 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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/scopeinfo.h" | 10 #include "src/scopeinfo.h" |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 } | 619 } |
| 620 return -1; | 620 return -1; |
| 621 } | 621 } |
| 622 | 622 |
| 623 | 623 |
| 624 FunctionKind ScopeInfo::function_kind() { | 624 FunctionKind ScopeInfo::function_kind() { |
| 625 return FunctionKindField::decode(Flags()); | 625 return FunctionKindField::decode(Flags()); |
| 626 } | 626 } |
| 627 | 627 |
| 628 | 628 |
| 629 void ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, | |
| 630 Handle<Context> context, | |
| 631 Handle<JSObject> scope_object) { | |
| 632 Isolate* isolate = scope_info->GetIsolate(); | |
| 633 int local_count = scope_info->ContextLocalCount(); | |
| 634 if (local_count == 0) return; | |
| 635 // Fill all context locals to the context extension. | |
| 636 int first_context_var = scope_info->StackLocalCount(); | |
| 637 int start = scope_info->ContextLocalNameEntriesIndex(); | |
| 638 for (int i = 0; i < local_count; ++i) { | |
| 639 if (scope_info->LocalIsSynthetic(first_context_var + i)) continue; | |
| 640 int context_index = Context::MIN_CONTEXT_SLOTS + i; | |
| 641 Handle<Object> value = Handle<Object>(context->get(context_index), isolate); | |
| 642 // Reflect variables under TDZ as undefined in scope object. | |
| 643 if (value->IsTheHole()) continue; | |
| 644 // This should always succeed. | |
| 645 // TODO(verwaest): Use AddDataProperty instead. | |
| 646 JSObject::SetOwnPropertyIgnoreAttributes( | |
| 647 scope_object, handle(String::cast(scope_info->get(i + start))), value, | |
| 648 ::NONE).Check(); | |
| 649 } | |
| 650 } | |
| 651 | |
| 652 | |
| 653 int ScopeInfo::ParameterEntriesIndex() { | 629 int ScopeInfo::ParameterEntriesIndex() { |
| 654 DCHECK(length() > 0); | 630 DCHECK(length() > 0); |
| 655 return kVariablePartIndex; | 631 return kVariablePartIndex; |
| 656 } | 632 } |
| 657 | 633 |
| 658 | 634 |
| 659 int ScopeInfo::StackLocalFirstSlotIndex() { | 635 int ScopeInfo::StackLocalFirstSlotIndex() { |
| 660 return ParameterEntriesIndex() + ParameterCount(); | 636 return ParameterEntriesIndex() + ParameterCount(); |
| 661 } | 637 } |
| 662 | 638 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 info->set_mode(i, var->mode()); | 830 info->set_mode(i, var->mode()); |
| 855 DCHECK(var->index() >= 0); | 831 DCHECK(var->index() >= 0); |
| 856 info->set_index(i, var->index()); | 832 info->set_index(i, var->index()); |
| 857 } | 833 } |
| 858 DCHECK(i == info->length()); | 834 DCHECK(i == info->length()); |
| 859 return info; | 835 return info; |
| 860 } | 836 } |
| 861 | 837 |
| 862 } // namespace internal | 838 } // namespace internal |
| 863 } // namespace v8 | 839 } // namespace v8 |
| OLD | NEW |