| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 Dart_Handle str = Dart_NewString(text_buffer); | 198 Dart_Handle str = Dart_NewString(text_buffer); |
| 199 free(text_buffer); | 199 free(text_buffer); |
| 200 return str; | 200 return str; |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, | 204 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, |
| 205 Dart_Handle library, | 205 Dart_Handle library, |
| 206 Dart_Handle url, | 206 Dart_Handle url, |
| 207 Dart_LibraryTag tag, | 207 Dart_LibraryTag tag, |
| 208 const char* url_string, | 208 const char* url_string) { |
| 209 Dart_Handle import_map) { | |
| 210 if (url_mapping != NULL && IsDartSchemeURL(url_string)) { | 209 if (url_mapping != NULL && IsDartSchemeURL(url_string)) { |
| 211 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string); | 210 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string); |
| 212 if (mapped_url_string == NULL) { | 211 if (mapped_url_string == NULL) { |
| 213 return Dart_Error("Do not know how to load %s", url_string); | 212 return Dart_Error("Do not know how to load %s", url_string); |
| 214 } | 213 } |
| 215 // We have a URL mapping specified, just read the file that the | 214 // We have a URL mapping specified, just read the file that the |
| 216 // URL mapping specifies and load it. | 215 // URL mapping specifies and load it. |
| 217 url_string = mapped_url_string; | 216 url_string = mapped_url_string; |
| 218 } | 217 } |
| 219 // The tag is either an import or a source tag. | 218 // The tag is either an import or a source tag. |
| 220 // Read the file and load it according to the specified tag. | 219 // Read the file and load it according to the specified tag. |
| 221 Dart_Handle source = DartUtils::ReadStringFromFile(url_string); | 220 Dart_Handle source = DartUtils::ReadStringFromFile(url_string); |
| 222 if (Dart_IsError(source)) { | 221 if (Dart_IsError(source)) { |
| 223 return source; // source contains the error string. | 222 return source; // source contains the error string. |
| 224 } | 223 } |
| 225 if (tag == kImportTag) { | 224 if (tag == kImportTag) { |
| 226 // Return library object or an error string. | 225 // Return library object or an error string. |
| 227 return Dart_LoadLibrary(url, source, import_map); | 226 return Dart_LoadLibrary(url, source); |
| 228 } else if (tag == kSourceTag) { | 227 } else if (tag == kSourceTag) { |
| 229 return Dart_LoadSource(library, url, source); | 228 return Dart_LoadSource(library, url, source); |
| 230 } | 229 } |
| 231 return Dart_Error("wrong tag"); | 230 return Dart_Error("wrong tag"); |
| 232 } | 231 } |
| 233 | 232 |
| 234 | 233 |
| 235 const char* DartUtils::GetCanonicalPath(const char* reference_dir, | 234 const char* DartUtils::GetCanonicalPath(const char* reference_dir, |
| 236 const char* filename) { | 235 const char* filename) { |
| 237 if (File::IsAbsolutePath(filename)) { | 236 if (File::IsAbsolutePath(filename)) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 438 |
| 440 CObject* CObject::NewOSError(OSError* os_error) { | 439 CObject* CObject::NewOSError(OSError* os_error) { |
| 441 CObject* error_message = | 440 CObject* error_message = |
| 442 new CObjectString(CObject::NewString(os_error->message())); | 441 new CObjectString(CObject::NewString(os_error->message())); |
| 443 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 442 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 444 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 443 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 445 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 444 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 446 result->SetAt(2, error_message); | 445 result->SetAt(2, error_message); |
| 447 return result; | 446 return result; |
| 448 } | 447 } |
| OLD | NEW |