Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 // Last element contains the count of used slots. | 415 // Last element contains the count of used slots. |
| 416 array.SetAt(kInitialSymbolTableSize, Smi::Handle(Smi::New(0))); | 416 array.SetAt(kInitialSymbolTableSize, Smi::Handle(Smi::New(0))); |
| 417 object_store->set_symbol_table(array); | 417 object_store->set_symbol_table(array); |
| 418 | 418 |
| 419 // Basic infrastructure has been setup, initialize the class dictionary. | 419 // Basic infrastructure has been setup, initialize the class dictionary. |
| 420 Library::InitCoreLibrary(isolate); | 420 Library::InitCoreLibrary(isolate); |
| 421 Library& core_lib = Library::Handle(isolate->object_store()->core_library()); | 421 Library& core_lib = Library::Handle(isolate->object_store()->core_library()); |
| 422 ASSERT(!core_lib.IsNull()); | 422 ASSERT(!core_lib.IsNull()); |
| 423 Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | 423 Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
| 424 ASSERT(!core_impl_lib.IsNull()); | 424 ASSERT(!core_impl_lib.IsNull()); |
| 425 Library::InitNativeFieldsLibrary(isolate); | |
| 426 ASSERT(isolate->object_store()->native_fields_library() != Library::null()); | |
| 425 | 427 |
| 426 // Allocate pre-initialized values. | 428 // Allocate pre-initialized values. |
| 427 Bool& bool_value = Bool::Handle(); | 429 Bool& bool_value = Bool::Handle(); |
| 428 bool_value = Bool::New(true); | 430 bool_value = Bool::New(true); |
| 429 object_store->set_true_value(bool_value); | 431 object_store->set_true_value(bool_value); |
| 430 bool_value = Bool::New(false); | 432 bool_value = Bool::New(false); |
| 431 object_store->set_false_value(bool_value); | 433 object_store->set_false_value(bool_value); |
| 432 | 434 |
| 433 object_store->set_pending_classes(Array::Handle(Array::Empty())); | 435 object_store->set_pending_classes(Array::Handle(Array::Empty())); |
| 434 | 436 |
| (...skipping 3648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4083 const Library& core_impl_lib = | 4085 const Library& core_impl_lib = |
| 4084 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); | 4086 Library::Handle(Library::NewLibraryHelper(core_impl_lib_url, false)); |
| 4085 isolate->object_store()->set_core_impl_library(core_impl_lib); | 4087 isolate->object_store()->set_core_impl_library(core_impl_lib); |
| 4086 core_impl_lib.Register(); | 4088 core_impl_lib.Register(); |
| 4087 core_lib.AddImport(core_impl_lib); | 4089 core_lib.AddImport(core_impl_lib); |
| 4088 core_impl_lib.AddImport(core_lib); | 4090 core_impl_lib.AddImport(core_lib); |
| 4089 isolate->object_store()->set_root_library(Library::Handle()); | 4091 isolate->object_store()->set_root_library(Library::Handle()); |
| 4090 } | 4092 } |
| 4091 | 4093 |
| 4092 | 4094 |
| 4095 void Library::InitNativeFieldsLibrary(Isolate* isolate) { | |
| 4096 static const int kNumNativeFieldClasses = 4; | |
| 4097 ASSERT(kNumNativeFieldClasses > 0 && kNumNativeFieldClasses < 10); | |
| 4098 const String& native_flds_lib_url = String::Handle( | |
| 4099 String::NewSymbol("dart:core_native_fields")); | |
|
Anton Muhin
2011/11/13 16:19:32
somehow reuse kCoreNativeFieldsLibURL?
siva
2011/11/15 02:16:52
Agree, would be nice, we need to expose thse throu
| |
| 4100 Library& native_flds_lib = Library::Handle( | |
| 4101 Library::NewLibraryHelper(native_flds_lib_url, false)); | |
| 4102 native_flds_lib.Register(); | |
| 4103 isolate->object_store()->set_native_fields_library(native_flds_lib); | |
| 4104 const String& name = String::Handle(String::New("NativeFieldWrapperClass")); | |
| 4105 String& index_str = String::Handle(); | |
| 4106 String& cls_name = String::Handle(); | |
| 4107 static const int kBufferSize = 2; | |
| 4108 char chars[kBufferSize]; | |
| 4109 for (int fld_cnt = 1; fld_cnt <= kNumNativeFieldClasses; fld_cnt++) { | |
| 4110 OS::SNPrint(chars, kBufferSize, "%d", fld_cnt); | |
|
Anton Muhin
2011/11/13 16:19:32
up to you, but for me something like below would b
siva
2011/11/15 02:16:52
Done.
| |
| 4111 index_str = String::New(chars); | |
| 4112 cls_name = String::Concat(name, index_str); | |
| 4113 cls_name = String::NewSymbol(cls_name); | |
| 4114 Class::NewNativeWrapper(&native_flds_lib, cls_name, fld_cnt); | |
| 4115 } | |
| 4116 } | |
| 4117 | |
| 4118 | |
| 4093 RawLibrary* Library::LookupLibrary(const String &url) { | 4119 RawLibrary* Library::LookupLibrary(const String &url) { |
| 4094 Library& lib = Library::Handle(); | 4120 Library& lib = Library::Handle(); |
| 4095 String& lib_url = String::Handle(); | 4121 String& lib_url = String::Handle(); |
| 4096 lib = Isolate::Current()->object_store()->registered_libraries(); | 4122 lib = Isolate::Current()->object_store()->registered_libraries(); |
| 4097 while (!lib.IsNull()) { | 4123 while (!lib.IsNull()) { |
| 4098 lib_url = lib.url(); | 4124 lib_url = lib.url(); |
| 4099 if (lib_url.Equals(url)) { | 4125 if (lib_url.Equals(url)) { |
| 4100 return lib.raw(); | 4126 return lib.raw(); |
| 4101 } | 4127 } |
| 4102 lib = lib.next_registered(); | 4128 lib = lib.next_registered(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4153 RawLibrary* Library::CoreLibrary() { | 4179 RawLibrary* Library::CoreLibrary() { |
| 4154 return Isolate::Current()->object_store()->core_library(); | 4180 return Isolate::Current()->object_store()->core_library(); |
| 4155 } | 4181 } |
| 4156 | 4182 |
| 4157 | 4183 |
| 4158 RawLibrary* Library::CoreImplLibrary() { | 4184 RawLibrary* Library::CoreImplLibrary() { |
| 4159 return Isolate::Current()->object_store()->core_impl_library(); | 4185 return Isolate::Current()->object_store()->core_impl_library(); |
| 4160 } | 4186 } |
| 4161 | 4187 |
| 4162 | 4188 |
| 4189 RawLibrary* Library::NativeFieldsLibrary() { | |
| 4190 return Isolate::Current()->object_store()->native_fields_library(); | |
| 4191 } | |
| 4192 | |
| 4193 | |
| 4163 const char* Library::ToCString() const { | 4194 const char* Library::ToCString() const { |
| 4164 const char* kFormat = "Library:'%s'"; | 4195 const char* kFormat = "Library:'%s'"; |
| 4165 const String& name = String::Handle(url()); | 4196 const String& name = String::Handle(url()); |
| 4166 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; | 4197 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString()) + 1; |
| 4167 char* chars = reinterpret_cast<char*>( | 4198 char* chars = reinterpret_cast<char*>( |
| 4168 Isolate::Current()->current_zone()->Allocate(len)); | 4199 Isolate::Current()->current_zone()->Allocate(len)); |
| 4169 OS::SNPrint(chars, len, kFormat, name.ToCString()); | 4200 OS::SNPrint(chars, len, kFormat, name.ToCString()); |
| 4170 return chars; | 4201 return chars; |
| 4171 } | 4202 } |
| 4172 | 4203 |
| (...skipping 2791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6964 const String& str = String::Handle(pattern()); | 6995 const String& str = String::Handle(pattern()); |
| 6965 const char* format = "JSRegExp: pattern=%s flags=%s"; | 6996 const char* format = "JSRegExp: pattern=%s flags=%s"; |
| 6966 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 6997 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
| 6967 char* chars = reinterpret_cast<char*>( | 6998 char* chars = reinterpret_cast<char*>( |
| 6968 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6999 Isolate::Current()->current_zone()->Allocate(len + 1)); |
| 6969 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 7000 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
| 6970 return chars; | 7001 return chars; |
| 6971 } | 7002 } |
| 6972 | 7003 |
| 6973 } // namespace dart | 7004 } // namespace dart |
| OLD | NEW |