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 bool ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info, | 508 void 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 true; | 513 if (local_count == 0) return; |
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 RETURN_ON_EXCEPTION_VALUE( | 523 // This should always succeed. |
524 isolate, Runtime::DefineObjectProperty( | 524 // TODO(verwaest): Use AddDataProperty instead. |
525 scope_object, | 525 JSObject::SetOwnPropertyIgnoreAttributes( |
526 Handle<String>(String::cast(scope_info->get(i + start))), | 526 scope_object, handle(String::cast(scope_info->get(i + start))), value, |
527 value, ::NONE), | 527 ::NONE).Check(); |
528 false); | |
529 } | 528 } |
530 return true; | |
531 } | 529 } |
532 | 530 |
533 | 531 |
534 int ScopeInfo::ParameterEntriesIndex() { | 532 int ScopeInfo::ParameterEntriesIndex() { |
535 DCHECK(length() > 0); | 533 DCHECK(length() > 0); |
536 return kVariablePartIndex; | 534 return kVariablePartIndex; |
537 } | 535 } |
538 | 536 |
539 | 537 |
540 int ScopeInfo::StackLocalFirstSlotIndex() { | 538 int ScopeInfo::StackLocalFirstSlotIndex() { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 info->set_mode(i, var->mode()); | 717 info->set_mode(i, var->mode()); |
720 DCHECK(var->index() >= 0); | 718 DCHECK(var->index() >= 0); |
721 info->set_index(i, var->index()); | 719 info->set_index(i, var->index()); |
722 } | 720 } |
723 DCHECK(i == info->length()); | 721 DCHECK(i == info->length()); |
724 return info; | 722 return info; |
725 } | 723 } |
726 | 724 |
727 } // namespace internal | 725 } // namespace internal |
728 } // namespace v8 | 726 } // namespace v8 |
OLD | NEW |