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

Side by Side Diff: runtime/vm/object.cc

Issue 10827434: - Pass the correct version of handle reference to Class::NewNativeWrapper. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 return Class::New<Closure>(); 1775 return Class::New<Closure>();
1776 } 1776 }
1777 return Class::New<Instance>(); 1777 return Class::New<Instance>();
1778 } 1778 }
1779 OS::Print("Class::GetClass id unknown: %d\n", class_id); 1779 OS::Print("Class::GetClass id unknown: %d\n", class_id);
1780 UNREACHABLE(); 1780 UNREACHABLE();
1781 return Class::null(); 1781 return Class::null();
1782 } 1782 }
1783 1783
1784 1784
1785 RawClass* Class::NewNativeWrapper(Library* library, 1785 RawClass* Class::NewNativeWrapper(const Library& library,
1786 const String& name, 1786 const String& name,
1787 int field_count) { 1787 int field_count) {
1788 Class& cls = Class::Handle(library->LookupClass(name)); 1788 Class& cls = Class::Handle(library.LookupClass(name));
1789 if (cls.IsNull()) { 1789 if (cls.IsNull()) {
1790 const Array& empty_array = Array::Handle(Object::empty_array()); 1790 const Array& empty_array = Array::Handle(Object::empty_array());
1791 cls = New<Instance>(name, Script::Handle(), Scanner::kDummyTokenIndex); 1791 cls = New<Instance>(name, Script::Handle(), Scanner::kDummyTokenIndex);
1792 cls.SetFields(empty_array); 1792 cls.SetFields(empty_array);
1793 cls.SetFunctions(empty_array); 1793 cls.SetFunctions(empty_array);
1794 // Set super class to Object. 1794 // Set super class to Object.
1795 cls.set_super_type(Type::Handle(Type::ObjectType())); 1795 cls.set_super_type(Type::Handle(Type::ObjectType()));
1796 // Compute instance size. 1796 // Compute instance size.
1797 intptr_t instance_size = (field_count * kWordSize) + sizeof(RawObject); 1797 intptr_t instance_size = (field_count * kWordSize) + sizeof(RawObject);
1798 cls.set_instance_size(RoundedAllocationSize(instance_size)); 1798 cls.set_instance_size(RoundedAllocationSize(instance_size));
1799 cls.set_next_field_offset(instance_size); 1799 cls.set_next_field_offset(instance_size);
1800 cls.set_num_native_fields(field_count); 1800 cls.set_num_native_fields(field_count);
1801 cls.set_is_finalized(); 1801 cls.set_is_finalized();
1802 library->AddClass(cls); 1802 library.AddClass(cls);
1803 return cls.raw(); 1803 return cls.raw();
1804 } else { 1804 } else {
1805 return Class::null(); 1805 return Class::null();
1806 } 1806 }
1807 } 1807 }
1808 1808
1809 1809
1810 void Class::set_name(const String& value) const { 1810 void Class::set_name(const String& value) const {
1811 ASSERT(value.IsSymbol()); 1811 ASSERT(value.IsSymbol());
1812 StorePointer(&raw_ptr()->name_, value.raw()); 1812 StorePointer(&raw_ptr()->name_, value.raw());
(...skipping 4412 matching lines...) Expand 10 before | Expand all | Expand 10 after
6225 lib.AddImport(wrappers_lib); 6225 lib.AddImport(wrappers_lib);
6226 isolate->object_store()->set_mirrors_library(lib); 6226 isolate->object_store()->set_mirrors_library(lib);
6227 } 6227 }
6228 6228
6229 6229
6230 void Library::InitNativeWrappersLibrary(Isolate* isolate) { 6230 void Library::InitNativeWrappersLibrary(Isolate* isolate) {
6231 static const int kNumNativeWrappersClasses = 4; 6231 static const int kNumNativeWrappersClasses = 4;
6232 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10); 6232 ASSERT(kNumNativeWrappersClasses > 0 && kNumNativeWrappersClasses < 10);
6233 const String& native_flds_lib_url = String::Handle( 6233 const String& native_flds_lib_url = String::Handle(
6234 Symbols::New("dart:nativewrappers")); 6234 Symbols::New("dart:nativewrappers"));
6235 Library& native_flds_lib = Library::Handle( 6235 const Library& native_flds_lib = Library::Handle(
6236 Library::NewLibraryHelper(native_flds_lib_url, false)); 6236 Library::NewLibraryHelper(native_flds_lib_url, false));
6237 native_flds_lib.Register(); 6237 native_flds_lib.Register();
6238 isolate->object_store()->set_native_wrappers_library(native_flds_lib); 6238 isolate->object_store()->set_native_wrappers_library(native_flds_lib);
6239 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; 6239 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass";
6240 static const int kNameLength = 25; 6240 static const int kNameLength = 25;
6241 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); 6241 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1));
6242 char name_buffer[kNameLength]; 6242 char name_buffer[kNameLength];
6243 String& cls_name = String::Handle(); 6243 String& cls_name = String::Handle();
6244 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { 6244 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) {
6245 OS::SNPrint(name_buffer, 6245 OS::SNPrint(name_buffer,
6246 kNameLength, 6246 kNameLength,
6247 "%s%d", 6247 "%s%d",
6248 kNativeWrappersClass, 6248 kNativeWrappersClass,
6249 fld_cnt); 6249 fld_cnt);
6250 cls_name = Symbols::New(name_buffer); 6250 cls_name = Symbols::New(name_buffer);
6251 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt); 6251 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt);
6252 } 6252 }
6253 } 6253 }
6254 6254
6255 6255
6256 RawLibrary* Library::LookupLibrary(const String &url) { 6256 RawLibrary* Library::LookupLibrary(const String &url) {
6257 Isolate* isolate = Isolate::Current(); 6257 Isolate* isolate = Isolate::Current();
6258 Library& lib = Library::Handle(isolate, Library::null()); 6258 Library& lib = Library::Handle(isolate, Library::null());
6259 String& lib_url = String::Handle(isolate, String::null()); 6259 String& lib_url = String::Handle(isolate, String::null());
6260 GrowableObjectArray& libs = GrowableObjectArray::Handle( 6260 GrowableObjectArray& libs = GrowableObjectArray::Handle(
6261 isolate, isolate->object_store()->libraries()); 6261 isolate, isolate->object_store()->libraries());
(...skipping 4887 matching lines...) Expand 10 before | Expand all | Expand 10 after
11149 } 11149 }
11150 return result.raw(); 11150 return result.raw();
11151 } 11151 }
11152 11152
11153 11153
11154 const char* WeakProperty::ToCString() const { 11154 const char* WeakProperty::ToCString() const {
11155 return "WeakProperty"; 11155 return "WeakProperty";
11156 } 11156 }
11157 11157
11158 } // namespace dart 11158 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698