OLD | NEW |
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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "include/dart_debugger_api.h" | 10 #include "include/dart_debugger_api.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (tag == kCanonicalizeUrl) { | 232 if (tag == kCanonicalizeUrl) { |
233 // If this is a Dart Scheme URL then it is not modified as it will be | 233 // If this is a Dart Scheme URL then it is not modified as it will be |
234 // handled by the VM internally. | 234 // handled by the VM internally. |
235 if (is_dart_scheme_url) { | 235 if (is_dart_scheme_url) { |
236 return url; | 236 return url; |
237 } | 237 } |
238 // Create a canonical path based on the including library and current url. | 238 // Create a canonical path based on the including library and current url. |
239 return DartUtils::CanonicalizeURL(NULL, library, url_string); | 239 return DartUtils::CanonicalizeURL(NULL, library, url_string); |
240 } | 240 } |
241 if (is_dart_scheme_url) { | 241 if (is_dart_scheme_url) { |
242 return Dart_Error("Do not know how to load '%s'", url_string); | 242 // Handle imports of dart:io. |
| 243 if (DartUtils::IsDartIOLibURL(url_string) && (tag == kImportTag)) { |
| 244 return Builtin::LoadLibrary(Builtin::kIOLibrary); |
| 245 } else { |
| 246 return Dart_Error("Do not know how to load '%s'", url_string); |
| 247 } |
243 } | 248 } |
244 result = DartUtils::LoadSource(NULL, library, url, tag, url_string); | 249 result = DartUtils::LoadSource(NULL, library, url, tag, url_string); |
245 if (!Dart_IsError(result) && (tag == kImportTag)) { | 250 if (!Dart_IsError(result) && (tag == kImportTag)) { |
246 Builtin::ImportLibrary(result); | 251 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); |
247 } | 252 } |
248 return result; | 253 return result; |
249 } | 254 } |
250 | 255 |
251 | 256 |
252 static Dart_Handle LoadScript(const char* script_name) { | 257 static Dart_Handle LoadScript(const char* script_name) { |
253 Dart_Handle source = DartUtils::ReadStringFromFile(script_name); | 258 Dart_Handle source = DartUtils::ReadStringFromFile(script_name); |
254 if (Dart_IsError(source)) { | 259 if (Dart_IsError(source)) { |
255 return source; | 260 return source; |
256 } | 261 } |
(...skipping 30 matching lines...) Expand all Loading... |
287 char errbuf[256]; | 292 char errbuf[256]; |
288 snprintf(errbuf, sizeof(errbuf), | 293 snprintf(errbuf, sizeof(errbuf), |
289 "Expected a library when loading script: %s", | 294 "Expected a library when loading script: %s", |
290 canonical_script_name); | 295 canonical_script_name); |
291 *error = strdup(errbuf); | 296 *error = strdup(errbuf); |
292 Dart_ExitScope(); | 297 Dart_ExitScope(); |
293 Dart_ShutdownIsolate(); | 298 Dart_ShutdownIsolate(); |
294 return false; | 299 return false; |
295 } | 300 } |
296 if (script_snapshot_buffer == NULL) { | 301 if (script_snapshot_buffer == NULL) { |
297 Builtin::ImportLibrary(library); // Implicitly import builtin into app. | 302 // Implicitly import builtin into app. |
| 303 Builtin::ImportLibrary(library, Builtin::kBuiltinLibrary); |
298 } | 304 } |
299 if (snapshot_buffer != NULL) { | 305 if (snapshot_buffer != NULL) { |
300 // Setup the native resolver as the snapshot does not carry it. | 306 // Setup the native resolver as the snapshot does not carry it. |
301 Builtin::SetNativeResolver(); | 307 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| 308 Builtin::SetNativeResolver(Builtin::kIOLibrary); |
302 } | 309 } |
303 Dart_ExitScope(); | 310 Dart_ExitScope(); |
304 return true; | 311 return true; |
305 } | 312 } |
306 | 313 |
307 | 314 |
308 static bool CaptureScriptSnapshot() { | 315 static bool CaptureScriptSnapshot() { |
309 char* error = NULL; | 316 char* error = NULL; |
310 Dart_Handle result; | 317 Dart_Handle result; |
311 | 318 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 Dart_ExitScope(); | 553 Dart_ExitScope(); |
547 // Dump symbol information for the profiler. | 554 // Dump symbol information for the profiler. |
548 DumpPprofSymbolInfo(); | 555 DumpPprofSymbolInfo(); |
549 // Shutdown the isolate. | 556 // Shutdown the isolate. |
550 Dart_ShutdownIsolate(); | 557 Dart_ShutdownIsolate(); |
551 // Terminate event handler. | 558 // Terminate event handler. |
552 EventHandler::Terminate(); | 559 EventHandler::Terminate(); |
553 | 560 |
554 return 0; | 561 return 0; |
555 } | 562 } |
OLD | NEW |