| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 if (Dart_IsError(result)) { | 61 if (Dart_IsError(result)) { |
| 62 return Dart_Error("accessing url characters failed"); | 62 return Dart_Error("accessing url characters failed"); |
| 63 } | 63 } |
| 64 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars); | 64 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars); |
| 65 if (tag == kCanonicalizeUrl) { | 65 if (tag == kCanonicalizeUrl) { |
| 66 // If this is a Dart Scheme URL then it is not modified as it will be | 66 // If this is a Dart Scheme URL then it is not modified as it will be |
| 67 // handled by the VM internally. | 67 // handled by the VM internally. |
| 68 if (is_dart_scheme_url) { | 68 if (is_dart_scheme_url) { |
| 69 return url; | 69 return url; |
| 70 } | 70 } |
| 71 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); | 71 Dart_Handle builtin_lib = |
| 72 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| 72 DART_CHECK_VALID(builtin_lib); | 73 DART_CHECK_VALID(builtin_lib); |
| 73 return DartUtils::CanonicalizeURL(NULL, library, url_chars); | 74 return DartUtils::CanonicalizeURL(NULL, library, url_chars); |
| 74 } | 75 } |
| 75 if (is_dart_scheme_url) { | 76 if (is_dart_scheme_url) { |
| 76 ASSERT(tag == kImportTag); | 77 ASSERT(tag == kImportTag); |
| 77 // Handle imports of other built-in libraries present in the SDK. | 78 // Handle imports of other built-in libraries present in the SDK. |
| 78 if (DartUtils::IsDartIOLibURL(url_chars)) { | 79 if (DartUtils::IsDartIOLibURL(url_chars)) { |
| 79 return Builtin::LoadLibrary(Builtin::kIOLibrary); | 80 return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
| 80 } else if (DartUtils::IsDartJsonLibURL(url_chars)) { | 81 } else if (DartUtils::IsDartJsonLibURL(url_chars)) { |
| 81 return Builtin::LoadLibrary(Builtin::kJsonLibrary); | 82 return Builtin::LoadAndCheckLibrary(Builtin::kJsonLibrary); |
| 82 } else if (DartUtils::IsDartUriLibURL(url_chars)) { | 83 } else if (DartUtils::IsDartUriLibURL(url_chars)) { |
| 83 return Builtin::LoadLibrary(Builtin::kUriLibrary); | 84 return Builtin::LoadAndCheckLibrary(Builtin::kUriLibrary); |
| 84 } else if (DartUtils::IsDartUtfLibURL(url_chars)) { | 85 } else if (DartUtils::IsDartUtfLibURL(url_chars)) { |
| 85 return Builtin::LoadLibrary(Builtin::kUtfLibrary); | 86 return Builtin::LoadAndCheckLibrary(Builtin::kUtfLibrary); |
| 86 } else if (DartUtils::IsDartCryptoLibURL(url_chars)) { | 87 } else if (DartUtils::IsDartCryptoLibURL(url_chars)) { |
| 87 return Builtin::LoadLibrary(Builtin::kCryptoLibrary); | 88 return Builtin::LoadAndCheckLibrary(Builtin::kCryptoLibrary); |
| 88 } else if (DartUtils::IsDartWebLibURL(url_chars)) { | 89 } else if (DartUtils::IsDartWebLibURL(url_chars)) { |
| 89 return Builtin::LoadLibrary(Builtin::kWebLibrary); | 90 return Builtin::LoadAndCheckLibrary(Builtin::kWebLibrary); |
| 90 } else { | 91 } else { |
| 91 return Dart_Error("Do not know how to load '%s'", url_chars); | 92 return Dart_Error("Do not know how to load '%s'", url_chars); |
| 92 } | 93 } |
| 93 } | 94 } |
| 94 return DartUtils::LoadSource(NULL, | 95 return DartUtils::LoadSource(NULL, |
| 95 library, | 96 library, |
| 96 url, | 97 url, |
| 97 tag, | 98 tag, |
| 98 url_chars); | 99 url_chars); |
| 99 } | 100 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 217 |
| 217 bool CompilerTest::TestCompileFunction(const Function& function) { | 218 bool CompilerTest::TestCompileFunction(const Function& function) { |
| 218 Isolate* isolate = Isolate::Current(); | 219 Isolate* isolate = Isolate::Current(); |
| 219 ASSERT(isolate != NULL); | 220 ASSERT(isolate != NULL); |
| 220 ASSERT(ClassFinalizer::AllClassesFinalized()); | 221 ASSERT(ClassFinalizer::AllClassesFinalized()); |
| 221 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 222 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| 222 return error.IsNull(); | 223 return error.IsNull(); |
| 223 } | 224 } |
| 224 | 225 |
| 225 } // namespace dart | 226 } // namespace dart |
| OLD | NEW |