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 10386107: Implement spawnUri from dart:isolate. This function allows us to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
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 "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 4552 matching lines...) Expand 10 before | Expand all | Expand 10 after
4563 4563
4564 void ClassDictionaryIterator::MoveToNextClass() { 4564 void ClassDictionaryIterator::MoveToNextClass() {
4565 Object& obj = Object::Handle(array_.At(next_ix_)); 4565 Object& obj = Object::Handle(array_.At(next_ix_));
4566 while (!obj.IsClass() && HasNext()) { 4566 while (!obj.IsClass() && HasNext()) {
4567 next_ix_++; 4567 next_ix_++;
4568 obj = array_.At(next_ix_); 4568 obj = array_.At(next_ix_);
4569 } 4569 }
4570 } 4570 }
4571 4571
4572 4572
4573 void Library::set_import_map(const Array& map) const {
4574 StorePointer(&raw_ptr()->import_map_, map.raw());
4575 }
4576
4577
4578 void Library::SetName(const String& name) const { 4573 void Library::SetName(const String& name) const {
4579 // Only set name once. 4574 // Only set name once.
4580 ASSERT(!Loaded()); 4575 ASSERT(!Loaded());
4581 ASSERT(name.IsSymbol()); 4576 ASSERT(name.IsSymbol());
4582 StorePointer(&raw_ptr()->name_, name.raw()); 4577 StorePointer(&raw_ptr()->name_, name.raw());
4583 } 4578 }
4584 4579
4585 4580
4586 void Library::SetLoadInProgress() const { 4581 void Library::SetLoadInProgress() const {
4587 // Should not be already loaded. 4582 // Should not be already loaded.
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
5169 lib ^= imports.At(i); 5164 lib ^= imports.At(i);
5170 import_url = lib.url(); 5165 import_url = lib.url();
5171 if (url.Equals(import_url)) { 5166 if (url.Equals(import_url)) {
5172 return lib.raw(); 5167 return lib.raw();
5173 } 5168 }
5174 } 5169 }
5175 return Library::null(); 5170 return Library::null();
5176 } 5171 }
5177 5172
5178 5173
5179 RawString* Library::LookupImportMap(const String& ident) const {
5180 Array& import_map = Array::Handle(this->import_map());
5181 intptr_t length = import_map.Length();
5182 intptr_t index = 0;
5183 String& name = String::Handle();
5184 while (index < (length - 1)) {
5185 name ^= import_map.At(index);
5186 if (name.Equals(ident)) {
5187 name ^= import_map.At(index + 1);
5188 return name.raw();
5189 }
5190 index += 2;
5191 }
5192 return String::null();
5193 }
5194
5195
5196 void Library::AddImport(const Library& library) const { 5174 void Library::AddImport(const Library& library) const {
5197 Array& imports = Array::Handle(this->imports()); 5175 Array& imports = Array::Handle(this->imports());
5198 intptr_t capacity = imports.Length(); 5176 intptr_t capacity = imports.Length();
5199 if (num_imports() == capacity) { 5177 if (num_imports() == capacity) {
5200 capacity = capacity + kImportsCapacityIncrement; 5178 capacity = capacity + kImportsCapacityIncrement;
5201 imports = Array::Grow(imports, capacity); 5179 imports = Array::Grow(imports, capacity);
5202 StorePointer(&raw_ptr()->imports_, imports.raw()); 5180 StorePointer(&raw_ptr()->imports_, imports.raw());
5203 } 5181 }
5204 intptr_t index = num_imports(); 5182 intptr_t index = num_imports();
5205 imports.SetAt(index, library); 5183 imports.SetAt(index, library);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5261 5239
5262 RawLibrary* Library::NewLibraryHelper(const String& url, 5240 RawLibrary* Library::NewLibraryHelper(const String& url,
5263 bool import_core_lib) { 5241 bool import_core_lib) {
5264 const Library& result = Library::Handle(Library::New()); 5242 const Library& result = Library::Handle(Library::New());
5265 result.raw_ptr()->name_ = url.raw(); 5243 result.raw_ptr()->name_ = url.raw();
5266 result.raw_ptr()->url_ = url.raw(); 5244 result.raw_ptr()->url_ = url.raw();
5267 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result); 5245 result.raw_ptr()->private_key_ = Scanner::AllocatePrivateKey(result);
5268 result.raw_ptr()->dictionary_ = Array::Empty(); 5246 result.raw_ptr()->dictionary_ = Array::Empty();
5269 result.raw_ptr()->anonymous_classes_ = Array::Empty(); 5247 result.raw_ptr()->anonymous_classes_ = Array::Empty();
5270 result.raw_ptr()->num_anonymous_ = 0; 5248 result.raw_ptr()->num_anonymous_ = 0;
5271 result.raw_ptr()->import_map_ = Array::Empty();
5272 result.raw_ptr()->imports_ = Array::Empty(); 5249 result.raw_ptr()->imports_ = Array::Empty();
5273 result.raw_ptr()->next_registered_ = Library::null(); 5250 result.raw_ptr()->next_registered_ = Library::null();
5274 result.raw_ptr()->loaded_scripts_ = Array::null(); 5251 result.raw_ptr()->loaded_scripts_ = Array::null();
5275 result.set_native_entry_resolver(NULL); 5252 result.set_native_entry_resolver(NULL);
5276 result.raw_ptr()->corelib_imported_ = true; 5253 result.raw_ptr()->corelib_imported_ = true;
5277 result.raw_ptr()->load_state_ = RawLibrary::kAllocated; 5254 result.raw_ptr()->load_state_ = RawLibrary::kAllocated;
5278 result.InitClassDictionary(); 5255 result.InitClassDictionary();
5279 result.InitImportList(); 5256 result.InitImportList();
5280 result.InitImportedIntoList(); 5257 result.InitImportedIntoList();
5281 if (import_core_lib) { 5258 if (import_core_lib) {
(...skipping 4619 matching lines...) Expand 10 before | Expand all | Expand 10 after
9901 const String& str = String::Handle(pattern()); 9878 const String& str = String::Handle(pattern());
9902 const char* format = "JSRegExp: pattern=%s flags=%s"; 9879 const char* format = "JSRegExp: pattern=%s flags=%s";
9903 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 9880 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
9904 char* chars = reinterpret_cast<char*>( 9881 char* chars = reinterpret_cast<char*>(
9905 Isolate::Current()->current_zone()->Allocate(len + 1)); 9882 Isolate::Current()->current_zone()->Allocate(len + 1));
9906 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 9883 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
9907 return chars; 9884 return chars;
9908 } 9885 }
9909 9886
9910 } // namespace dart 9887 } // namespace dart
OLDNEW
« runtime/lib/isolate.cc ('K') | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698