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

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

Issue 13842019: - Check for error when creating the source string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | « no previous file | no next file » | 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 "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/extensions.h" 7 #include "bin/extensions.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/file.h" 9 #include "bin/file.h"
10 #include "bin/io_buffer.h" 10 #include "bin/io_buffer.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 const uint8_t* text_buffer = ReadFile(script_path_cstr, &len, &error_msg); 384 const uint8_t* text_buffer = ReadFile(script_path_cstr, &len, &error_msg);
385 if (text_buffer == NULL) { 385 if (text_buffer == NULL) {
386 return Dart_Error(error_msg); 386 return Dart_Error(error_msg);
387 } 387 }
388 bool is_snapshot = false; 388 bool is_snapshot = false;
389 text_buffer = SniffForMagicNumber(text_buffer, &len, &is_snapshot); 389 text_buffer = SniffForMagicNumber(text_buffer, &len, &is_snapshot);
390 if (is_snapshot) { 390 if (is_snapshot) {
391 return Dart_LoadScriptFromSnapshot(text_buffer, len); 391 return Dart_LoadScriptFromSnapshot(text_buffer, len);
392 } else { 392 } else {
393 Dart_Handle source = Dart_NewStringFromUTF8(text_buffer, len); 393 Dart_Handle source = Dart_NewStringFromUTF8(text_buffer, len);
394 if (Dart_IsError(source)) {
395 return source;
396 }
394 return Dart_LoadScript(resolved_script_uri, source, 0, 0); 397 return Dart_LoadScript(resolved_script_uri, source, 0, 0);
Mads Ager (google) 2013/04/22 13:05:41 I thought all of the APIs had the property that th
Ivan Posva 2013/04/22 13:12:42 Dart_LoadScript does return an error if it gets un
Mads Ager (google) 2013/04/22 13:13:48 I see. Thanks! :)
395 } 398 }
396 } 399 }
397 400
398 401
399 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, 402 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping,
400 Dart_Handle library, 403 Dart_Handle library,
401 Dart_Handle url, 404 Dart_Handle url,
402 Dart_LibraryTag tag, 405 Dart_LibraryTag tag,
403 const char* url_string) { 406 const char* url_string) {
404 if (url_mapping != NULL && IsDartSchemeURL(url_string)) { 407 if (url_mapping != NULL && IsDartSchemeURL(url_string)) {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 742
740 CObject* CObject::NewOSError(OSError* os_error) { 743 CObject* CObject::NewOSError(OSError* os_error) {
741 CObject* error_message = 744 CObject* error_message =
742 new CObjectString(CObject::NewString(os_error->message())); 745 new CObjectString(CObject::NewString(os_error->message()));
743 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 746 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
744 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 747 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
745 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 748 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
746 result->SetAt(2, error_message); 749 result->SetAt(2, error_message);
747 return result; 750 return result;
748 } 751 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698