Chromium Code Reviews| Index: vm/unit_test.cc |
| =================================================================== |
| --- vm/unit_test.cc (revision 6979) |
| +++ vm/unit_test.cc (working copy) |
| @@ -8,9 +8,11 @@ |
| #include "vm/assembler.h" |
| #include "vm/ast_printer.h" |
| +#include "bin/builtin.h" |
|
cshapiro
2012/05/01 00:37:24
Trivial but, usually includes are ordered by the d
siva
2012/05/01 00:59:48
Done.
|
| #include "vm/code_generator.h" |
| #include "vm/compiler.h" |
| #include "vm/dart_api_impl.h" |
| +#include "bin/dartutils.h" |
| #include "vm/disassembler.h" |
| #include "vm/longjump.h" |
| #include "vm/parser.h" |
| @@ -60,17 +62,42 @@ |
| if (Dart_IsError(result)) { |
| return Dart_Error("accessing url characters failed"); |
| } |
| - static const char* kDartScheme = "dart:"; |
| - static const intptr_t kDartSchemeLen = strlen(kDartScheme); |
| - // If the URL starts with "dart:" then it is not modified as it will be |
| - // handled by the VM internally. |
| - if (strncmp(url_chars, kDartScheme, kDartSchemeLen) == 0) { |
| - if (tag == kCanonicalizeUrl) { |
| + bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars); |
| + if (tag == kCanonicalizeUrl) { |
| + // If this is a Dart Scheme URL then it is not modified as it will be |
| + // handled by the VM internally. |
| + if (is_dart_scheme_url) { |
| return url; |
| } |
| - return Dart_Error("unexpected tag encountered %d", tag); |
| + Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); |
| + DART_CHECK_VALID(builtin_lib); |
| + return DartUtils::CanonicalizeURL(NULL, library, url_chars); |
| } |
| - return Dart_Error("unsupported url encountered %s", url_chars); |
| + if (is_dart_scheme_url) { |
| + ASSERT(tag == kImportTag); |
| + // Handle imports of other built-in libraries present in the SDK. |
| + if (DartUtils::IsDartIOLibURL(url_chars)) { |
| + return Builtin::LoadLibrary(Builtin::kIOLibrary); |
| + } else if (DartUtils::IsDartJsonLibURL(url_chars)) { |
| + return Builtin::LoadLibrary(Builtin::kJsonLibrary); |
| + } else if (DartUtils::IsDartUriLibURL(url_chars)) { |
| + return Builtin::LoadLibrary(Builtin::kUriLibrary); |
| + } else if (DartUtils::IsDartUtfLibURL(url_chars)) { |
| + return Builtin::LoadLibrary(Builtin::kUtfLibrary); |
| + } else { |
| + return Dart_Error("Do not know how to load '%s'", url_chars); |
| + } |
| + } |
| + result = DartUtils::LoadSource(NULL, |
| + library, |
| + url, |
| + tag, |
| + url_chars, |
| + import_map); |
| + if (!Dart_IsError(result) && (tag == kImportTag)) { |
| + Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); |
| + } |
| + return result; |
| } |