| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 | 5 |
| 6 #include "bin/loader.h" | 6 #include "bin/loader.h" |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
| 10 #include "bin/extensions.h" | 10 #include "bin/extensions.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 (strstr(path, File::PathSeparator()) != NULL)); | 283 (strstr(path, File::PathSeparator()) != NULL)); |
| 284 } | 284 } |
| 285 | 285 |
| 286 | 286 |
| 287 void Loader::AddDependencyLocked(Loader* loader, const char* resolved_uri) { | 287 void Loader::AddDependencyLocked(Loader* loader, const char* resolved_uri) { |
| 288 MallocGrowableArray<char*>* dependencies = | 288 MallocGrowableArray<char*>* dependencies = |
| 289 loader->isolate_data_->dependencies(); | 289 loader->isolate_data_->dependencies(); |
| 290 if (dependencies == NULL) { | 290 if (dependencies == NULL) { |
| 291 return; | 291 return; |
| 292 } | 292 } |
| 293 uint8_t* scoped_file_path = NULL; | 293 dependencies->Add(strdup(resolved_uri)); |
| 294 intptr_t scoped_file_path_length = -1; | |
| 295 Dart_Handle uri = Dart_NewStringFromCString(resolved_uri); | |
| 296 ASSERT(!Dart_IsError(uri)); | |
| 297 Dart_Handle result = Loader::ResolveAsFilePath(uri, &scoped_file_path, | |
| 298 &scoped_file_path_length); | |
| 299 if (Dart_IsError(result)) { | |
| 300 Log::Print("Error resolving dependency: %s\n", Dart_GetError(result)); | |
| 301 return; | |
| 302 } | |
| 303 dependencies->Add(StringUtils::StrNDup( | |
| 304 reinterpret_cast<const char*>(scoped_file_path), | |
| 305 scoped_file_path_length)); | |
| 306 } | 294 } |
| 307 | 295 |
| 308 | 296 |
| 297 void Loader::ResolveDependenciesAsFilePaths() { |
| 298 IsolateData* isolate_data = |
| 299 reinterpret_cast<IsolateData*>(Dart_CurrentIsolateData()); |
| 300 ASSERT(isolate_data != NULL); |
| 301 MallocGrowableArray<char*>* dependencies = isolate_data->dependencies(); |
| 302 if (dependencies == NULL) { |
| 303 return; |
| 304 } |
| 305 |
| 306 for (intptr_t i = 0; i < dependencies->length(); i++) { |
| 307 char* resolved_uri = (*dependencies)[i]; |
| 308 |
| 309 uint8_t* scoped_file_path = NULL; |
| 310 intptr_t scoped_file_path_length = -1; |
| 311 Dart_Handle uri = Dart_NewStringFromCString(resolved_uri); |
| 312 ASSERT(!Dart_IsError(uri)); |
| 313 Dart_Handle result = Loader::ResolveAsFilePath(uri, &scoped_file_path, |
| 314 &scoped_file_path_length); |
| 315 if (Dart_IsError(result)) { |
| 316 Log::Print("Error resolving dependency: %s\n", Dart_GetError(result)); |
| 317 return; |
| 318 } |
| 319 |
| 320 (*dependencies)[i] = |
| 321 StringUtils::StrNDup(reinterpret_cast<const char*>(scoped_file_path), |
| 322 scoped_file_path_length); |
| 323 free(resolved_uri); |
| 324 } |
| 325 } |
| 326 |
| 327 |
| 309 bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) { | 328 bool Loader::ProcessResultLocked(Loader* loader, Loader::IOResult* result) { |
| 310 // We have to copy everything we care about out of |result| because after | 329 // We have to copy everything we care about out of |result| because after |
| 311 // dropping the lock below |result| may no longer valid. | 330 // dropping the lock below |result| may no longer valid. |
| 312 Dart_Handle uri = | 331 Dart_Handle uri = |
| 313 Dart_NewStringFromCString(reinterpret_cast<char*>(result->uri)); | 332 Dart_NewStringFromCString(reinterpret_cast<char*>(result->uri)); |
| 314 Dart_Handle resolved_uri = | 333 Dart_Handle resolved_uri = |
| 315 Dart_NewStringFromCString(reinterpret_cast<char*>(result->resolved_uri)); | 334 Dart_NewStringFromCString(reinterpret_cast<char*>(result->resolved_uri)); |
| 316 Dart_Handle library_uri = Dart_Null(); | 335 Dart_Handle library_uri = Dart_Null(); |
| 317 if (result->library_uri != NULL) { | 336 if (result->library_uri != NULL) { |
| 318 library_uri = | 337 library_uri = |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 MutexLocker ml(loader_infos_lock_); | 890 MutexLocker ml(loader_infos_lock_); |
| 872 Loader* loader = LoaderForLocked(dest_port_id); | 891 Loader* loader = LoaderForLocked(dest_port_id); |
| 873 if (loader == NULL) { | 892 if (loader == NULL) { |
| 874 return; | 893 return; |
| 875 } | 894 } |
| 876 loader->QueueMessage(message); | 895 loader->QueueMessage(message); |
| 877 } | 896 } |
| 878 | 897 |
| 879 } // namespace bin | 898 } // namespace bin |
| 880 } // namespace dart | 899 } // namespace dart |
| OLD | NEW |