Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: runtime/bin/main.cc

Issue 9254026: Split dart:builtin into dart:builtin and dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment and add binaries. Created 8 years, 11 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
« no previous file with comments | « runtime/bin/io_sources.gypi ('k') | runtime/bin/stdio.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 if (tag == kCanonicalizeUrl) { 246 if (tag == kCanonicalizeUrl) {
247 // If this is a Dart Scheme URL then it is not modified as it will be 247 // If this is a Dart Scheme URL then it is not modified as it will be
248 // handled by the VM internally. 248 // handled by the VM internally.
249 if (is_dart_scheme_url) { 249 if (is_dart_scheme_url) {
250 return url; 250 return url;
251 } 251 }
252 // Create a canonical path based on the including library and current url. 252 // Create a canonical path based on the including library and current url.
253 return DartUtils::CanonicalizeURL(NULL, library, url_string); 253 return DartUtils::CanonicalizeURL(NULL, library, url_string);
254 } 254 }
255 if (is_dart_scheme_url) { 255 if (is_dart_scheme_url) {
256 return Dart_Error("Do not know how to load '%s'", url_string); 256 // Handle imports of dart:io.
257 if (DartUtils::IsDartIOLibURL(url_string) && (tag == kImportTag)) {
258 return Builtin::LoadLibrary(Builtin::kIOLibrary);
259 } else {
260 return Dart_Error("Do not know how to load '%s'", url_string);
261 }
257 } 262 }
258 result = DartUtils::LoadSource(NULL, library, url, tag, url_string); 263 result = DartUtils::LoadSource(NULL, library, url, tag, url_string);
259 if (!Dart_IsError(result) && (tag == kImportTag)) { 264 if (!Dart_IsError(result) && (tag == kImportTag)) {
260 Builtin::ImportLibrary(result); 265 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary);
261 } 266 }
262 return result; 267 return result;
263 } 268 }
264 269
265 270
266 static Dart_Handle LoadScript(const char* script_name) { 271 static Dart_Handle LoadScript(const char* script_name) {
267 Dart_Handle source = DartUtils::ReadStringFromFile(script_name); 272 Dart_Handle source = DartUtils::ReadStringFromFile(script_name);
268 if (Dart_IsError(source)) { 273 if (Dart_IsError(source)) {
269 return source; 274 return source;
270 } 275 }
(...skipping 30 matching lines...) Expand all
301 char errbuf[256]; 306 char errbuf[256];
302 snprintf(errbuf, sizeof(errbuf), 307 snprintf(errbuf, sizeof(errbuf),
303 "Expected a library when loading script: %s", 308 "Expected a library when loading script: %s",
304 canonical_script_name); 309 canonical_script_name);
305 *error = strdup(errbuf); 310 *error = strdup(errbuf);
306 Dart_ExitScope(); 311 Dart_ExitScope();
307 Dart_ShutdownIsolate(); 312 Dart_ShutdownIsolate();
308 return false; 313 return false;
309 } 314 }
310 if (script_snapshot_buffer == NULL) { 315 if (script_snapshot_buffer == NULL) {
311 Builtin::ImportLibrary(library); // Implicitly import builtin into app. 316 // Implicitly import builtin into app.
317 Builtin::ImportLibrary(library, Builtin::kBuiltinLibrary);
312 } 318 }
313 if (snapshot_buffer != NULL) { 319 if (snapshot_buffer != NULL) {
314 // Setup the native resolver as the snapshot does not carry it. 320 // Setup the native resolver as the snapshot does not carry it.
315 Builtin::SetNativeResolver(); 321 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
322 Builtin::SetNativeResolver(Builtin::kIOLibrary);
316 } 323 }
317 Dart_ExitScope(); 324 Dart_ExitScope();
318 return true; 325 return true;
319 } 326 }
320 327
321 328
322 static bool CaptureScriptSnapshot() { 329 static bool CaptureScriptSnapshot() {
323 char* error = NULL; 330 char* error = NULL;
324 Dart_Handle result; 331 Dart_Handle result;
325 332
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 Dart_ExitScope(); 568 Dart_ExitScope();
562 // Dump symbol information for the profiler. 569 // Dump symbol information for the profiler.
563 DumpPprofSymbolInfo(); 570 DumpPprofSymbolInfo();
564 // Shutdown the isolate. 571 // Shutdown the isolate.
565 Dart_ShutdownIsolate(); 572 Dart_ShutdownIsolate();
566 // Terminate event handler. 573 // Terminate event handler.
567 EventHandler::Terminate(); 574 EventHandler::Terminate();
568 575
569 return 0; 576 return 0;
570 } 577 }
OLDNEW
« no previous file with comments | « runtime/bin/io_sources.gypi ('k') | runtime/bin/stdio.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698