OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "bin/vmservice_impl.h" | 5 #include "bin/vmservice_impl.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 | 150 |
151 const char* VmService::error_msg_ = NULL; | 151 const char* VmService::error_msg_ = NULL; |
152 char VmService::server_uri_[kServerUriStringBufferSize]; | 152 char VmService::server_uri_[kServerUriStringBufferSize]; |
153 | 153 |
154 | 154 |
155 bool VmService::LoadForGenPrecompiled() { | 155 bool VmService::LoadForGenPrecompiled() { |
156 Dart_Handle result; | 156 Dart_Handle result; |
157 Dart_SetLibraryTagHandler(LibraryTagHandler); | 157 Dart_SetLibraryTagHandler(LibraryTagHandler); |
158 Dart_Handle library = LoadLibrary(kVMServiceIOLibraryScriptResourceName); | 158 Dart_Handle library = |
| 159 LookupOrLoadLibrary(kVMServiceIOLibraryScriptResourceName); |
159 ASSERT(library != Dart_Null()); | 160 ASSERT(library != Dart_Null()); |
160 SHUTDOWN_ON_ERROR(library); | 161 SHUTDOWN_ON_ERROR(library); |
161 result = Dart_SetNativeResolver(library, VmServiceIONativeResolver, NULL); | 162 result = Dart_SetNativeResolver(library, VmServiceIONativeResolver, NULL); |
162 SHUTDOWN_ON_ERROR(result); | 163 SHUTDOWN_ON_ERROR(result); |
163 result = Dart_FinalizeLoading(false); | 164 result = Dart_FinalizeLoading(false); |
164 SHUTDOWN_ON_ERROR(result); | 165 SHUTDOWN_ON_ERROR(result); |
165 return true; | 166 return true; |
166 } | 167 } |
167 | 168 |
168 | 169 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 308 } |
308 | 309 |
309 | 310 |
310 Dart_Handle VmService::LoadScript(const char* name) { | 311 Dart_Handle VmService::LoadScript(const char* name) { |
311 Dart_Handle uri = Dart_NewStringFromCString(kVMServiceIOLibraryUri); | 312 Dart_Handle uri = Dart_NewStringFromCString(kVMServiceIOLibraryUri); |
312 Dart_Handle source = GetSource(name); | 313 Dart_Handle source = GetSource(name); |
313 return Dart_LoadScript(uri, Dart_Null(), source, 0, 0); | 314 return Dart_LoadScript(uri, Dart_Null(), source, 0, 0); |
314 } | 315 } |
315 | 316 |
316 | 317 |
317 Dart_Handle VmService::LoadLibrary(const char* name) { | 318 Dart_Handle VmService::LookupOrLoadLibrary(const char* name) { |
318 Dart_Handle uri = Dart_NewStringFromCString(kVMServiceIOLibraryUri); | 319 Dart_Handle uri = Dart_NewStringFromCString(kVMServiceIOLibraryUri); |
319 Dart_Handle source = GetSource(name); | 320 Dart_Handle library = Dart_LookupLibrary(uri); |
320 return Dart_LoadLibrary(uri, Dart_Null(), source, 0, 0); | 321 if (!Dart_IsLibrary(library)) { |
| 322 Dart_Handle source = GetSource(name); |
| 323 library = Dart_LoadLibrary(uri, Dart_Null(), source, 0, 0); |
| 324 } |
| 325 return library; |
321 } | 326 } |
322 | 327 |
323 | 328 |
324 Dart_Handle VmService::LoadSource(Dart_Handle library, const char* name) { | 329 Dart_Handle VmService::LoadSource(Dart_Handle library, const char* name) { |
325 Dart_Handle uri = Dart_NewStringFromCString(name); | 330 Dart_Handle uri = Dart_NewStringFromCString(name); |
326 Dart_Handle source = GetSource(name); | 331 Dart_Handle source = GetSource(name); |
327 return Dart_LoadSource(library, uri, Dart_Null(), source, 0, 0); | 332 return Dart_LoadSource(library, uri, Dart_Null(), source, 0, 0); |
328 } | 333 } |
329 | 334 |
330 | 335 |
(...skipping 29 matching lines...) Expand all Loading... |
360 Dart_Handle source = GetSource(url_string); | 365 Dart_Handle source = GetSource(url_string); |
361 if (Dart_IsError(source)) { | 366 if (Dart_IsError(source)) { |
362 return source; | 367 return source; |
363 } | 368 } |
364 return Dart_LoadSource(library, url, Dart_Null(), source, 0, 0); | 369 return Dart_LoadSource(library, url, Dart_Null(), source, 0, 0); |
365 } | 370 } |
366 | 371 |
367 | 372 |
368 } // namespace bin | 373 } // namespace bin |
369 } // namespace dart | 374 } // namespace dart |
OLD | NEW |