| 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/file.h" | 7 #include "bin/file.h" |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 Dart_Handle str = Dart_NewString(text_buffer); | 211 Dart_Handle str = Dart_NewString(text_buffer); |
| 212 free(text_buffer); | 212 free(text_buffer); |
| 213 return str; | 213 return str; |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, | 217 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, |
| 218 Dart_Handle library, | 218 Dart_Handle library, |
| 219 Dart_Handle url, | 219 Dart_Handle url, |
| 220 Dart_LibraryTag tag, | 220 Dart_LibraryTag tag, |
| 221 const char* url_string, | 221 const char* url_string) { |
| 222 Dart_Handle import_map) { | |
| 223 if (url_mapping != NULL && IsDartSchemeURL(url_string)) { | 222 if (url_mapping != NULL && IsDartSchemeURL(url_string)) { |
| 224 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string); | 223 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string); |
| 225 if (mapped_url_string == NULL) { | 224 if (mapped_url_string == NULL) { |
| 226 return Dart_Error("Do not know how to load %s", url_string); | 225 return Dart_Error("Do not know how to load %s", url_string); |
| 227 } | 226 } |
| 228 // We have a URL mapping specified, just read the file that the | 227 // We have a URL mapping specified, just read the file that the |
| 229 // URL mapping specifies and load it. | 228 // URL mapping specifies and load it. |
| 230 url_string = mapped_url_string; | 229 url_string = mapped_url_string; |
| 231 } | 230 } |
| 232 // The tag is either an import or a source tag. | 231 // The tag is either an import or a source tag. |
| 233 // Read the file and load it according to the specified tag. | 232 // Read the file and load it according to the specified tag. |
| 234 Dart_Handle source = DartUtils::ReadStringFromFile(url_string); | 233 Dart_Handle source = DartUtils::ReadStringFromFile(url_string); |
| 235 if (Dart_IsError(source)) { | 234 if (Dart_IsError(source)) { |
| 236 return source; // source contains the error string. | 235 return source; // source contains the error string. |
| 237 } | 236 } |
| 238 if (tag == kImportTag) { | 237 if (tag == kImportTag) { |
| 239 // Return library object or an error string. | 238 // Return library object or an error string. |
| 240 return Dart_LoadLibrary(url, source, import_map); | 239 return Dart_LoadLibrary(url, source); |
| 241 } else if (tag == kSourceTag) { | 240 } else if (tag == kSourceTag) { |
| 242 return Dart_LoadSource(library, url, source); | 241 return Dart_LoadSource(library, url, source); |
| 243 } | 242 } |
| 244 return Dart_Error("wrong tag"); | 243 return Dart_Error("wrong tag"); |
| 245 } | 244 } |
| 246 | 245 |
| 247 | 246 |
| 248 const char* DartUtils::GetCanonicalPath(const char* reference_dir, | 247 const char* DartUtils::GetCanonicalPath(const char* reference_dir, |
| 249 const char* filename) { | 248 const char* filename) { |
| 250 if (File::IsAbsolutePath(filename)) { | 249 if (File::IsAbsolutePath(filename)) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 451 |
| 453 CObject* CObject::NewOSError(OSError* os_error) { | 452 CObject* CObject::NewOSError(OSError* os_error) { |
| 454 CObject* error_message = | 453 CObject* error_message = |
| 455 new CObjectString(CObject::NewString(os_error->message())); | 454 new CObjectString(CObject::NewString(os_error->message())); |
| 456 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 455 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 457 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 456 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 458 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 457 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 459 result->SetAt(2, error_message); | 458 result->SetAt(2, error_message); |
| 460 return result; | 459 return result; |
| 461 } | 460 } |
| OLD | NEW |