| 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 "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 "include/dart_api.h" | 10 #include "include/dart_api.h" |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 return script_path; | 336 return script_path; |
| 337 } | 337 } |
| 338 const char* script_path_cstr; | 338 const char* script_path_cstr; |
| 339 Dart_StringToCString(script_path, &script_path_cstr); | 339 Dart_StringToCString(script_path, &script_path_cstr); |
| 340 Dart_Handle source = DartUtils::ReadStringFromFile(script_path_cstr); | 340 Dart_Handle source = DartUtils::ReadStringFromFile(script_path_cstr); |
| 341 return source; | 341 return source; |
| 342 } | 342 } |
| 343 | 343 |
| 344 | 344 |
| 345 Dart_Handle DartUtils::LoadScript(const char* script_uri, | 345 Dart_Handle DartUtils::LoadScript(const char* script_uri, |
| 346 bool resolve_script, | |
| 347 Dart_Handle builtin_lib) { | 346 Dart_Handle builtin_lib) { |
| 348 Dart_Handle resolved_script_uri; | 347 Dart_Handle resolved_script_uri; |
| 349 if (resolve_script) { | 348 resolved_script_uri = ResolveScriptUri(Dart_NewString(script_uri), |
| 350 resolved_script_uri = ResolveScriptUri(Dart_NewString(script_uri), | 349 builtin_lib); |
| 351 builtin_lib); | 350 if (Dart_IsError(resolved_script_uri)) { |
| 352 if (Dart_IsError(resolved_script_uri)) { | 351 return resolved_script_uri; |
| 353 return resolved_script_uri; | |
| 354 } | |
| 355 } else { | |
| 356 resolved_script_uri = Dart_NewString(script_uri); | |
| 357 } | 352 } |
| 358 Dart_Handle source = ReadSource(resolved_script_uri, builtin_lib); | 353 Dart_Handle source = ReadSource(resolved_script_uri, builtin_lib); |
| 359 if (Dart_IsError(source)) { | 354 if (Dart_IsError(source)) { |
| 360 return source; | 355 return source; |
| 361 } | 356 } |
| 362 return Dart_LoadScript(resolved_script_uri, source); | 357 return Dart_LoadScript(resolved_script_uri, source); |
| 363 } | 358 } |
| 364 | 359 |
| 365 | 360 |
| 366 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, | 361 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 655 |
| 661 CObject* CObject::NewOSError(OSError* os_error) { | 656 CObject* CObject::NewOSError(OSError* os_error) { |
| 662 CObject* error_message = | 657 CObject* error_message = |
| 663 new CObjectString(CObject::NewString(os_error->message())); | 658 new CObjectString(CObject::NewString(os_error->message())); |
| 664 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 659 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 665 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 660 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 666 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 661 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 667 result->SetAt(2, error_message); | 662 result->SetAt(2, error_message); |
| 668 return result; | 663 return result; |
| 669 } | 664 } |
| OLD | NEW |