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

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

Issue 9657001: Start using Dart_PropagateError in the runtime/bin directory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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/gen_snapshot.cc ('k') | runtime/bin/process.cc » ('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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 Dart_Handle import_map) { 237 Dart_Handle import_map) {
238 if (!Dart_IsLibrary(library)) { 238 if (!Dart_IsLibrary(library)) {
239 return Dart_Error("not a library"); 239 return Dart_Error("not a library");
240 } 240 }
241 if (!Dart_IsString8(url)) { 241 if (!Dart_IsString8(url)) {
242 return Dart_Error("url is not a string"); 242 return Dart_Error("url is not a string");
243 } 243 }
244 const char* url_string = NULL; 244 const char* url_string = NULL;
245 Dart_Handle result = Dart_StringToCString(url, &url_string); 245 Dart_Handle result = Dart_StringToCString(url, &url_string);
246 if (Dart_IsError(result)) { 246 if (Dart_IsError(result)) {
247 return Dart_Error("accessing url characters failed"); 247 return result;
248 } 248 }
249 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); 249 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string);
250 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string); 250 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string);
251 if (tag == kCanonicalizeUrl) { 251 if (tag == kCanonicalizeUrl) {
252 // If this is a Dart Scheme URL then it is not modified as it will be 252 // If this is a Dart Scheme URL then it is not modified as it will be
253 // handled by the VM internally. 253 // handled by the VM internally.
254 if (is_dart_scheme_url || is_dart_extension_url) { 254 if (is_dart_scheme_url || is_dart_extension_url) {
255 return url; 255 return url;
256 } 256 }
257 // Resolve the url within the context of the library's URL. 257 // Resolve the url within the context of the library's URL.
258 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); 258 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary);
259 Dart_Handle library_url = Dart_LibraryUrl(library); 259 Dart_Handle library_url = Dart_LibraryUrl(library);
260 if (Dart_IsError(library_url)) { 260 if (Dart_IsError(library_url)) {
261 return Dart_Error("accessing library url failed"); 261 return library_url;
262 } 262 }
263 Dart_Handle dart_args[2]; 263 Dart_Handle dart_args[2];
264 dart_args[0] = library_url; 264 dart_args[0] = library_url;
265 dart_args[1] = url; 265 dart_args[1] = url;
266 return Dart_InvokeStatic(builtin_lib, 266 return Dart_InvokeStatic(builtin_lib,
267 Dart_NewString(""), Dart_NewString("resolveUri"), 267 Dart_NewString(""), Dart_NewString("resolveUri"),
268 2, dart_args); 268 2, dart_args);
269 } 269 }
270 if (is_dart_scheme_url) { 270 if (is_dart_scheme_url) {
271 ASSERT(tag == kImportTag); 271 ASSERT(tag == kImportTag);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 dart_args[2] = Dart_False(); 322 dart_args[2] = Dart_False();
323 #else // !defined(TARGET_OS_WINDOWS) 323 #else // !defined(TARGET_OS_WINDOWS)
324 dart_args[2] = Dart_True(); 324 dart_args[2] = Dart_True();
325 #endif // !defined(TARGET_OS_WINDOWS) 325 #endif // !defined(TARGET_OS_WINDOWS)
326 Dart_Handle script_url = Dart_InvokeStatic(builtin_lib, 326 Dart_Handle script_url = Dart_InvokeStatic(builtin_lib,
327 Dart_NewString(""), 327 Dart_NewString(""),
328 Dart_NewString("resolveScriptUri"), 328 Dart_NewString("resolveScriptUri"),
329 3, dart_args); 329 3, dart_args);
330 if (Dart_IsError(script_url)) { 330 if (Dart_IsError(script_url)) {
331 fprintf(stderr, "%s", Dart_GetError(script_url)); 331 fprintf(stderr, "%s", Dart_GetError(script_url));
332 return false; 332 return script_url;
333 } 333 }
334 if (original_script_url == NULL) { 334 if (original_script_url == NULL) {
335 const char* script_url_cstr; 335 const char* script_url_cstr;
336 Dart_StringToCString(script_url, &script_url_cstr); 336 Dart_StringToCString(script_url, &script_url_cstr);
337 original_script_url = strdup(script_url_cstr); 337 original_script_url = strdup(script_url_cstr);
338 } 338 }
339 dart_args[0] = script_url; 339 dart_args[0] = script_url;
340 Dart_Handle script_path = Dart_InvokeStatic(builtin_lib, 340 Dart_Handle script_path = Dart_InvokeStatic(builtin_lib,
341 Dart_NewString(""), 341 Dart_NewString(""),
342 Dart_NewString("filePathFromUri"), 342 Dart_NewString("filePathFromUri"),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 EventHandler::Terminate(); 601 EventHandler::Terminate();
602 // Terminate process exit-code handler. 602 // Terminate process exit-code handler.
603 Process::TerminateExitCodeHandler(); 603 Process::TerminateExitCodeHandler();
604 604
605 free(const_cast<char*>(original_script_name)); 605 free(const_cast<char*>(original_script_name));
606 free(const_cast<char*>(original_working_directory)); 606 free(const_cast<char*>(original_working_directory));
607 free(const_cast<char*>(original_script_url)); 607 free(const_cast<char*>(original_script_url));
608 608
609 return 0; 609 return 0;
610 } 610 }
OLDNEW
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698