Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/debug/debug-scopes.cc

Issue 1292753007: [es6] Parameter scopes for sloppy eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug-scopes.h ('k') | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/debug/debug-scopes.h" 5 #include "src/debug/debug-scopes.h"
6 6
7 #include "src/debug/debug.h" 7 #include "src/debug/debug.h"
8 #include "src/frames-inl.h" 8 #include "src/frames-inl.h"
9 #include "src/globals.h" 9 #include "src/globals.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 case ScopeIterator::ScopeTypeGlobal: 230 case ScopeIterator::ScopeTypeGlobal:
231 return Handle<JSObject>(CurrentContext()->global_proxy()); 231 return Handle<JSObject>(CurrentContext()->global_proxy());
232 case ScopeIterator::ScopeTypeScript: 232 case ScopeIterator::ScopeTypeScript:
233 return MaterializeScriptScope(); 233 return MaterializeScriptScope();
234 case ScopeIterator::ScopeTypeLocal: 234 case ScopeIterator::ScopeTypeLocal:
235 // Materialize the content of the local scope into a JSObject. 235 // Materialize the content of the local scope into a JSObject.
236 DCHECK(nested_scope_chain_.length() == 1); 236 DCHECK(nested_scope_chain_.length() == 1);
237 return MaterializeLocalScope(); 237 return MaterializeLocalScope();
238 case ScopeIterator::ScopeTypeWith: 238 case ScopeIterator::ScopeTypeWith:
239 // Return the with object. 239 // Return the with object.
240 return Handle<JSObject>(JSObject::cast(CurrentContext()->extension())); 240 // TODO(neis): This breaks for proxies.
241 return handle(JSObject::cast(CurrentContext()->extension_receiver()));
241 case ScopeIterator::ScopeTypeCatch: 242 case ScopeIterator::ScopeTypeCatch:
242 return MaterializeCatchScope(); 243 return MaterializeCatchScope();
243 case ScopeIterator::ScopeTypeClosure: 244 case ScopeIterator::ScopeTypeClosure:
244 // Materialize the content of the closure scope into a JSObject. 245 // Materialize the content of the closure scope into a JSObject.
245 return MaterializeClosure(); 246 return MaterializeClosure();
246 case ScopeIterator::ScopeTypeBlock: 247 case ScopeIterator::ScopeTypeBlock:
247 return MaterializeBlockScope(); 248 return MaterializeBlockScope();
248 case ScopeIterator::ScopeTypeModule: 249 case ScopeIterator::ScopeTypeModule:
249 return MaterializeModuleScope(); 250 return MaterializeModuleScope();
250 } 251 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 289 }
289 return false; 290 return false;
290 } 291 }
291 292
292 293
293 Handle<ScopeInfo> ScopeIterator::CurrentScopeInfo() { 294 Handle<ScopeInfo> ScopeIterator::CurrentScopeInfo() {
294 DCHECK(!failed_); 295 DCHECK(!failed_);
295 if (!nested_scope_chain_.is_empty()) { 296 if (!nested_scope_chain_.is_empty()) {
296 return nested_scope_chain_.last(); 297 return nested_scope_chain_.last();
297 } else if (context_->IsBlockContext()) { 298 } else if (context_->IsBlockContext()) {
298 return Handle<ScopeInfo>(ScopeInfo::cast(context_->extension())); 299 return Handle<ScopeInfo>(context_->scope_info());
299 } else if (context_->IsFunctionContext()) { 300 } else if (context_->IsFunctionContext()) {
300 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info()); 301 return Handle<ScopeInfo>(context_->closure()->shared()->scope_info());
301 } 302 }
302 return Handle<ScopeInfo>::null(); 303 return Handle<ScopeInfo>::null();
303 } 304 }
304 305
305 306
306 Handle<Context> ScopeIterator::CurrentContext() { 307 Handle<Context> ScopeIterator::CurrentContext() {
307 DCHECK(!failed_); 308 DCHECK(!failed_);
308 if (Type() == ScopeTypeGlobal || Type() == ScopeTypeScript || 309 if (Type() == ScopeTypeGlobal || Type() == ScopeTypeScript ||
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 Handle<ScriptContextTable> script_contexts( 404 Handle<ScriptContextTable> script_contexts(
404 global->native_context()->script_context_table()); 405 global->native_context()->script_context_table());
405 406
406 Handle<JSObject> script_scope = 407 Handle<JSObject> script_scope =
407 isolate_->factory()->NewJSObject(isolate_->object_function()); 408 isolate_->factory()->NewJSObject(isolate_->object_function());
408 409
409 for (int context_index = 0; context_index < script_contexts->used(); 410 for (int context_index = 0; context_index < script_contexts->used();
410 context_index++) { 411 context_index++) {
411 Handle<Context> context = 412 Handle<Context> context =
412 ScriptContextTable::GetContext(script_contexts, context_index); 413 ScriptContextTable::GetContext(script_contexts, context_index);
413 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); 414 Handle<ScopeInfo> scope_info(context->scope_info());
414 CopyContextLocalsToScopeObject(scope_info, context, script_scope); 415 CopyContextLocalsToScopeObject(scope_info, context, script_scope);
415 } 416 }
416 return script_scope; 417 return script_scope;
417 } 418 }
418 419
419 420
420 MaybeHandle<JSObject> ScopeIterator::MaterializeLocalScope() { 421 MaybeHandle<JSObject> ScopeIterator::MaterializeLocalScope() {
421 Handle<JSFunction> function = GetFunction(); 422 Handle<JSFunction> function = GetFunction();
422 423
423 Handle<JSObject> local_scope = 424 Handle<JSObject> local_scope =
424 isolate_->factory()->NewJSObject(isolate_->object_function()); 425 isolate_->factory()->NewJSObject(isolate_->object_function());
425 frame_inspector_->MaterializeStackLocals(local_scope, function); 426 frame_inspector_->MaterializeStackLocals(local_scope, function);
426 427
427 Handle<Context> frame_context(Context::cast(frame_inspector_->GetContext())); 428 Handle<Context> frame_context(Context::cast(frame_inspector_->GetContext()));
428 429
429 HandleScope scope(isolate_); 430 HandleScope scope(isolate_);
430 Handle<SharedFunctionInfo> shared(function->shared()); 431 Handle<SharedFunctionInfo> shared(function->shared());
431 Handle<ScopeInfo> scope_info(shared->scope_info()); 432 Handle<ScopeInfo> scope_info(shared->scope_info());
432 433
433 if (!scope_info->HasContext()) return local_scope; 434 if (!scope_info->HasContext()) return local_scope;
434 435
435 // Third fill all context locals. 436 // Third fill all context locals.
436 Handle<Context> function_context(frame_context->declaration_context()); 437 Handle<Context> function_context(frame_context->declaration_context());
437 CopyContextLocalsToScopeObject(scope_info, function_context, local_scope); 438 CopyContextLocalsToScopeObject(scope_info, function_context, local_scope);
438 439
439 // Finally copy any properties from the function context extension. 440 // Finally copy any properties from the function context extension.
440 // These will be variables introduced by eval. 441 // These will be variables introduced by eval.
441 if (function_context->closure() == *function) { 442 if (function_context->closure() == *function &&
442 if (function_context->has_extension() && 443 function_context->has_extension() &&
443 !function_context->IsNativeContext()) { 444 !function_context->IsNativeContext()) {
444 Handle<JSObject> ext(JSObject::cast(function_context->extension())); 445 bool success = CopyContextExtensionToScopeObject(
445 Handle<FixedArray> keys; 446 handle(function_context->extension_object(), isolate_),
446 ASSIGN_RETURN_ON_EXCEPTION( 447 local_scope, JSReceiver::INCLUDE_PROTOS);
447 isolate_, keys, JSReceiver::GetKeys(ext, JSReceiver::INCLUDE_PROTOS), 448 if (!success) return MaybeHandle<JSObject>();
448 JSObject);
449
450 for (int i = 0; i < keys->length(); i++) {
451 // Names of variables introduced by eval are strings.
452 DCHECK(keys->get(i)->IsString());
453 Handle<String> key(String::cast(keys->get(i)));
454 Handle<Object> value;
455 ASSIGN_RETURN_ON_EXCEPTION(
456 isolate_, value, Object::GetPropertyOrElement(ext, key), JSObject);
457 RETURN_ON_EXCEPTION(isolate_,
458 Runtime::SetObjectProperty(isolate_, local_scope,
459 key, value, SLOPPY),
460 JSObject);
461 }
462 }
463 } 449 }
464 450
465 return local_scope; 451 return local_scope;
466 } 452 }
467 453
468 454
469 // Create a plain JSObject which materializes the closure content for the 455 // Create a plain JSObject which materializes the closure content for the
470 // context. 456 // context.
471 Handle<JSObject> ScopeIterator::MaterializeClosure() { 457 Handle<JSObject> ScopeIterator::MaterializeClosure() {
472 Handle<Context> context = CurrentContext(); 458 Handle<Context> context = CurrentContext();
473 DCHECK(context->IsFunctionContext()); 459 DCHECK(context->IsFunctionContext());
474 460
475 Handle<SharedFunctionInfo> shared(context->closure()->shared()); 461 Handle<SharedFunctionInfo> shared(context->closure()->shared());
476 Handle<ScopeInfo> scope_info(shared->scope_info()); 462 Handle<ScopeInfo> scope_info(shared->scope_info());
477 463
478 // Allocate and initialize a JSObject with all the content of this function 464 // Allocate and initialize a JSObject with all the content of this function
479 // closure. 465 // closure.
480 Handle<JSObject> closure_scope = 466 Handle<JSObject> closure_scope =
481 isolate_->factory()->NewJSObject(isolate_->object_function()); 467 isolate_->factory()->NewJSObject(isolate_->object_function());
482 468
483 // Fill all context locals to the context extension. 469 // Fill all context locals to the context extension.
484 CopyContextLocalsToScopeObject(scope_info, context, closure_scope); 470 CopyContextLocalsToScopeObject(scope_info, context, closure_scope);
485 471
486 // Finally copy any properties from the function context extension. This will 472 // Finally copy any properties from the function context extension. This will
487 // be variables introduced by eval. 473 // be variables introduced by eval.
488 if (context->has_extension()) { 474 if (context->has_extension()) {
489 Handle<JSObject> ext(JSObject::cast(context->extension())); 475 bool success = CopyContextExtensionToScopeObject(
490 DCHECK(ext->IsJSContextExtensionObject()); 476 handle(context->extension_object(), isolate_), closure_scope,
491 Handle<FixedArray> keys = 477 JSReceiver::OWN_ONLY);
492 JSReceiver::GetKeys(ext, JSReceiver::OWN_ONLY).ToHandleChecked(); 478 DCHECK(success);
493 479 USE(success);
494 for (int i = 0; i < keys->length(); i++) {
495 HandleScope scope(isolate_);
496 // Names of variables introduced by eval are strings.
497 DCHECK(keys->get(i)->IsString());
498 Handle<String> key(String::cast(keys->get(i)));
499 Handle<Object> value = Object::GetProperty(ext, key).ToHandleChecked();
500 JSObject::SetOwnPropertyIgnoreAttributes(closure_scope, key, value, NONE)
501 .Check();
502 }
503 } 480 }
504 481
505 return closure_scope; 482 return closure_scope;
506 } 483 }
507 484
508 485
509 // Create a plain JSObject which materializes the scope for the specified 486 // Create a plain JSObject which materializes the scope for the specified
510 // catch context. 487 // catch context.
511 Handle<JSObject> ScopeIterator::MaterializeCatchScope() { 488 Handle<JSObject> ScopeIterator::MaterializeCatchScope() {
512 Handle<Context> context = CurrentContext(); 489 Handle<Context> context = CurrentContext();
513 DCHECK(context->IsCatchContext()); 490 DCHECK(context->IsCatchContext());
514 Handle<String> name(String::cast(context->extension())); 491 Handle<String> name(context->catch_name());
515 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), 492 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX),
516 isolate_); 493 isolate_);
517 Handle<JSObject> catch_scope = 494 Handle<JSObject> catch_scope =
518 isolate_->factory()->NewJSObject(isolate_->object_function()); 495 isolate_->factory()->NewJSObject(isolate_->object_function());
519 JSObject::SetOwnPropertyIgnoreAttributes(catch_scope, name, thrown_object, 496 JSObject::SetOwnPropertyIgnoreAttributes(catch_scope, name, thrown_object,
520 NONE) 497 NONE)
521 .Check(); 498 .Check();
522 return catch_scope; 499 return catch_scope;
523 } 500 }
524 501
525 502
526 // Create a plain JSObject which materializes the block scope for the specified 503 // Create a plain JSObject which materializes the block scope for the specified
527 // block context. 504 // block context.
528 Handle<JSObject> ScopeIterator::MaterializeBlockScope() { 505 Handle<JSObject> ScopeIterator::MaterializeBlockScope() {
529 Handle<JSObject> block_scope = 506 Handle<JSObject> block_scope =
530 isolate_->factory()->NewJSObject(isolate_->object_function()); 507 isolate_->factory()->NewJSObject(isolate_->object_function());
531 508
532 Handle<Context> context = Handle<Context>::null(); 509 Handle<Context> context = Handle<Context>::null();
533 if (!nested_scope_chain_.is_empty()) { 510 if (!nested_scope_chain_.is_empty()) {
534 Handle<ScopeInfo> scope_info = nested_scope_chain_.last(); 511 Handle<ScopeInfo> scope_info = nested_scope_chain_.last();
535 frame_inspector_->MaterializeStackLocals(block_scope, scope_info); 512 frame_inspector_->MaterializeStackLocals(block_scope, scope_info);
536 if (scope_info->HasContext()) context = CurrentContext(); 513 if (scope_info->HasContext()) context = CurrentContext();
537 } else { 514 } else {
538 context = CurrentContext(); 515 context = CurrentContext();
539 } 516 }
540 517
541 if (!context.is_null()) { 518 if (!context.is_null()) {
542 Handle<ScopeInfo> scope_info_from_context(
543 ScopeInfo::cast(context->extension()));
544 // Fill all context locals. 519 // Fill all context locals.
545 CopyContextLocalsToScopeObject(scope_info_from_context, context, 520 CopyContextLocalsToScopeObject(handle(context->scope_info()),
546 block_scope); 521 context, block_scope);
522 // Fill all extension variables.
523 if (context->extension_object() != nullptr) {
524 bool success = CopyContextExtensionToScopeObject(
525 handle(context->extension_object()), block_scope,
526 JSReceiver::OWN_ONLY);
527 DCHECK(success);
528 USE(success);
529 }
547 } 530 }
548 return block_scope; 531 return block_scope;
549 } 532 }
550 533
551 534
552 // Create a plain JSObject which materializes the module scope for the specified 535 // Create a plain JSObject which materializes the module scope for the specified
553 // module context. 536 // module context.
554 MaybeHandle<JSObject> ScopeIterator::MaterializeModuleScope() { 537 MaybeHandle<JSObject> ScopeIterator::MaterializeModuleScope() {
555 Handle<Context> context = CurrentContext(); 538 Handle<Context> context = CurrentContext();
556 DCHECK(context->IsModuleContext()); 539 DCHECK(context->IsModuleContext());
557 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); 540 Handle<ScopeInfo> scope_info(context->scope_info());
558 541
559 // Allocate and initialize a JSObject with all the members of the debugged 542 // Allocate and initialize a JSObject with all the members of the debugged
560 // module. 543 // module.
561 Handle<JSObject> module_scope = 544 Handle<JSObject> module_scope =
562 isolate_->factory()->NewJSObject(isolate_->object_function()); 545 isolate_->factory()->NewJSObject(isolate_->object_function());
563 546
564 // Fill all context locals. 547 // Fill all context locals.
565 CopyContextLocalsToScopeObject(scope_info, context, module_scope); 548 CopyContextLocalsToScopeObject(scope_info, context, module_scope);
566 549
567 return module_scope; 550 return module_scope;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 Handle<Context> function_context(frame_context->declaration_context()); 612 Handle<Context> function_context(frame_context->declaration_context());
630 if (SetContextLocalValue(scope_info, function_context, variable_name, 613 if (SetContextLocalValue(scope_info, function_context, variable_name,
631 new_value)) { 614 new_value)) {
632 return true; 615 return true;
633 } 616 }
634 617
635 // Function context extension. These are variables introduced by eval. 618 // Function context extension. These are variables introduced by eval.
636 if (function_context->closure() == *function) { 619 if (function_context->closure() == *function) {
637 if (function_context->has_extension() && 620 if (function_context->has_extension() &&
638 !function_context->IsNativeContext()) { 621 !function_context->IsNativeContext()) {
639 Handle<JSObject> ext(JSObject::cast(function_context->extension())); 622 Handle<JSObject> ext(function_context->extension_object());
640 623
641 Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name); 624 Maybe<bool> maybe = JSReceiver::HasProperty(ext, variable_name);
642 DCHECK(maybe.IsJust()); 625 DCHECK(maybe.IsJust());
643 if (maybe.FromJust()) { 626 if (maybe.FromJust()) {
644 // We don't expect this to do anything except replacing 627 // We don't expect this to do anything except replacing
645 // property value. 628 // property value.
646 Runtime::SetObjectProperty(isolate_, ext, variable_name, new_value, 629 Runtime::SetObjectProperty(isolate_, ext, variable_name, new_value,
647 SLOPPY) 630 SLOPPY)
648 .Assert(); 631 .Assert();
649 return true; 632 return true;
(...skipping 13 matching lines...) Expand all
663 646
664 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 647 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
665 HandleScope scope(isolate_); 648 HandleScope scope(isolate_);
666 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) { 649 if (String::Equals(handle(scope_info->StackLocalName(i)), variable_name)) {
667 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value); 650 frame->SetExpression(scope_info->StackLocalIndex(i), *new_value);
668 return true; 651 return true;
669 } 652 }
670 } 653 }
671 654
672 if (HasContext()) { 655 if (HasContext()) {
673 return SetContextLocalValue(scope_info, CurrentContext(), variable_name, 656 Handle<Context> context = CurrentContext();
674 new_value); 657 if (SetContextLocalValue(scope_info, context, variable_name, new_value)) {
658 return true;
659 }
660
661 Handle<JSObject> ext(context->extension_object(), isolate_);
662 if (!ext.is_null()) {
663 Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name);
664 DCHECK(maybe.IsJust());
665 if (maybe.FromJust()) {
666 // We don't expect this to do anything except replacing property value.
667 JSObject::SetOwnPropertyIgnoreAttributes(ext, variable_name, new_value,
668 NONE)
669 .Check();
670 return true;
671 }
672 }
675 } 673 }
674
676 return false; 675 return false;
677 } 676 }
678 677
679 678
680 // This method copies structure of MaterializeClosure method above. 679 // This method copies structure of MaterializeClosure method above.
681 bool ScopeIterator::SetClosureVariableValue(Handle<String> variable_name, 680 bool ScopeIterator::SetClosureVariableValue(Handle<String> variable_name,
682 Handle<Object> new_value) { 681 Handle<Object> new_value) {
683 Handle<Context> context = CurrentContext(); 682 Handle<Context> context = CurrentContext();
684 DCHECK(context->IsFunctionContext()); 683 DCHECK(context->IsFunctionContext());
685 684
686 // Context locals to the context extension. 685 // Context locals to the context extension.
687 Handle<SharedFunctionInfo> shared(context->closure()->shared()); 686 Handle<SharedFunctionInfo> shared(context->closure()->shared());
688 Handle<ScopeInfo> scope_info(shared->scope_info()); 687 Handle<ScopeInfo> scope_info(shared->scope_info());
689 if (SetContextLocalValue(scope_info, context, variable_name, new_value)) { 688 if (SetContextLocalValue(scope_info, context, variable_name, new_value)) {
690 return true; 689 return true;
691 } 690 }
692 691
693 // Properties from the function context extension. This will 692 // Properties from the function context extension. This will
694 // be variables introduced by eval. 693 // be variables introduced by eval.
695 if (context->has_extension()) { 694 if (context->has_extension()) {
696 Handle<JSObject> ext(JSObject::cast(context->extension())); 695 Handle<JSObject> ext(JSObject::cast(context->extension_object()));
697 DCHECK(ext->IsJSContextExtensionObject());
698 Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name); 696 Maybe<bool> maybe = JSReceiver::HasOwnProperty(ext, variable_name);
699 DCHECK(maybe.IsJust()); 697 DCHECK(maybe.IsJust());
700 if (maybe.FromJust()) { 698 if (maybe.FromJust()) {
701 // We don't expect this to do anything except replacing property value. 699 // We don't expect this to do anything except replacing property value.
702 JSObject::SetOwnPropertyIgnoreAttributes(ext, variable_name, new_value, 700 JSObject::SetOwnPropertyIgnoreAttributes(ext, variable_name, new_value,
703 NONE) 701 NONE)
704 .Check(); 702 .Check();
705 return true; 703 return true;
706 } 704 }
707 } 705 }
(...skipping 17 matching lines...) Expand all
725 } 723 }
726 724
727 return false; 725 return false;
728 } 726 }
729 727
730 728
731 bool ScopeIterator::SetCatchVariableValue(Handle<String> variable_name, 729 bool ScopeIterator::SetCatchVariableValue(Handle<String> variable_name,
732 Handle<Object> new_value) { 730 Handle<Object> new_value) {
733 Handle<Context> context = CurrentContext(); 731 Handle<Context> context = CurrentContext();
734 DCHECK(context->IsCatchContext()); 732 DCHECK(context->IsCatchContext());
735 Handle<String> name(String::cast(context->extension())); 733 Handle<String> name(context->catch_name());
736 if (!String::Equals(name, variable_name)) { 734 if (!String::Equals(name, variable_name)) {
737 return false; 735 return false;
738 } 736 }
739 context->set(Context::THROWN_OBJECT_INDEX, *new_value); 737 context->set(Context::THROWN_OBJECT_INDEX, *new_value);
740 return true; 738 return true;
741 } 739 }
742 740
743 741
744 void ScopeIterator::CopyContextLocalsToScopeObject( 742 void ScopeIterator::CopyContextLocalsToScopeObject(
745 Handle<ScopeInfo> scope_info, Handle<Context> context, 743 Handle<ScopeInfo> scope_info, Handle<Context> context,
(...skipping 12 matching lines...) Expand all
758 if (value->IsTheHole()) continue; 756 if (value->IsTheHole()) continue;
759 // This should always succeed. 757 // This should always succeed.
760 // TODO(verwaest): Use AddDataProperty instead. 758 // TODO(verwaest): Use AddDataProperty instead.
761 JSObject::SetOwnPropertyIgnoreAttributes( 759 JSObject::SetOwnPropertyIgnoreAttributes(
762 scope_object, handle(String::cast(scope_info->get(i + start))), value, 760 scope_object, handle(String::cast(scope_info->get(i + start))), value,
763 ::NONE) 761 ::NONE)
764 .Check(); 762 .Check();
765 } 763 }
766 } 764 }
767 765
766
767 bool ScopeIterator::CopyContextExtensionToScopeObject(
768 Handle<JSObject> extension, Handle<JSObject> scope_object,
769 JSReceiver::KeyCollectionType type) {
770 Handle<FixedArray> keys;
771 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
772 isolate_, keys, JSReceiver::GetKeys(extension, type), false);
773
774 for (int i = 0; i < keys->length(); i++) {
775 // Names of variables introduced by eval are strings.
776 DCHECK(keys->get(i)->IsString());
777 Handle<String> key(String::cast(keys->get(i)));
778 Handle<Object> value;
779 ASSIGN_RETURN_ON_EXCEPTION_VALUE(
780 isolate_, value, Object::GetPropertyOrElement(extension, key), false);
781 RETURN_ON_EXCEPTION_VALUE(
782 isolate_, JSObject::SetOwnPropertyIgnoreAttributes(
783 scope_object, key, value, NONE), false);
784 }
785 return true;
786 }
787
768 } // namespace internal 788 } // namespace internal
769 } // namespace v8 789 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-scopes.h ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698