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

Side by Side Diff: src/accessors.cc

Issue 10690043: Implement proper module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Michael's comments. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/accessors.h ('k') | src/ast.h » ('j') | src/full-codegen.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 return receiver->SetPrototype(value, skip_hidden_prototypes); 795 return receiver->SetPrototype(value, skip_hidden_prototypes);
796 } 796 }
797 797
798 798
799 const AccessorDescriptor Accessors::ObjectPrototype = { 799 const AccessorDescriptor Accessors::ObjectPrototype = {
800 ObjectGetPrototype, 800 ObjectGetPrototype,
801 ObjectSetPrototype, 801 ObjectSetPrototype,
802 0 802 0
803 }; 803 };
804 804
805
806 //
807 // Accessors::MakeModuleExport
808 //
809
810 static v8::Handle<v8::Value> ModuleGetExport(
811 v8::Local<v8::String> property,
812 const v8::AccessorInfo& info) {
813 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
814 Context* context = Context::cast(instance->context());
815 ASSERT(context->IsModuleContext());
816 int slot = info.Data()->Int32Value();
817 Object* value = context->get(slot);
818 if (value->IsTheHole()) {
819 Handle<String> name = v8::Utils::OpenHandle(*property);
820 Isolate* isolate = instance->GetIsolate();
821 isolate->ScheduleThrow(
822 *isolate->factory()->NewReferenceError("not_defined",
823 HandleVector(&name, 1)));
824 return v8::Handle<v8::Value>();
825 }
826 return v8::Utils::ToLocal(Handle<Object>(value));
827 }
828
829
830 static void ModuleSetExport(
831 v8::Local<v8::String> property,
832 v8::Local<v8::Value> value,
833 const v8::AccessorInfo& info) {
834 JSModule* instance = JSModule::cast(*v8::Utils::OpenHandle(*info.Holder()));
835 Context* context = Context::cast(instance->context());
836 ASSERT(context->IsModuleContext());
837 int slot = info.Data()->Int32Value();
838 Object* old_value = context->get(slot);
839 if (old_value->IsTheHole()) {
840 Handle<String> name = v8::Utils::OpenHandle(*property);
841 Isolate* isolate = instance->GetIsolate();
842 isolate->ScheduleThrow(
843 *isolate->factory()->NewReferenceError("not_defined",
844 HandleVector(&name, 1)));
845 return;
846 }
847 context->set(slot, *v8::Utils::OpenHandle(*value));
848 }
849
850
851 Handle<AccessorInfo> Accessors::MakeModuleExport(
852 Handle<String> name,
853 int index,
854 PropertyAttributes attributes) {
855 Factory* factory = name->GetIsolate()->factory();
856 Handle<AccessorInfo> info = factory->NewAccessorInfo();
857 info->set_property_attributes(attributes);
858 info->set_all_can_read(true);
859 info->set_all_can_write(true);
860 info->set_name(*name);
861 info->set_data(Smi::FromInt(index));
862 v8::AccessorGetter getter = &ModuleGetExport;
863 v8::AccessorSetter setter = &ModuleSetExport;
864 info->set_getter(*v8::FromCData(getter));
865 if (!(attributes & ReadOnly)) info->set_setter(*v8::FromCData(setter));
866 return info;
867 }
868
869
805 } } // namespace v8::internal 870 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/ast.h » ('j') | src/full-codegen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698