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 "vm/unit_test.h" | 5 #include "vm/unit_test.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string); | 74 bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string); |
75 if (tag == Dart_kCanonicalizeUrl) { | 75 if (tag == Dart_kCanonicalizeUrl) { |
76 // If this is a Dart Scheme URL then it is not modified as it will be | 76 // If this is a Dart Scheme URL then it is not modified as it will be |
77 // handled by the VM internally. | 77 // handled by the VM internally. |
78 if (is_dart_scheme_url || is_io_library) { | 78 if (is_dart_scheme_url || is_io_library) { |
79 return url; | 79 return url; |
80 } | 80 } |
81 Dart_Handle builtin_lib = | 81 Dart_Handle builtin_lib = |
82 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 82 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
83 DART_CHECK_VALID(builtin_lib); | 83 DART_CHECK_VALID(builtin_lib); |
84 return DartUtils::CanonicalizeURL(NULL, library, url_chars); | 84 return DartUtils::CanonicalizeURL(library, url_chars); |
Ivan Posva
2014/05/07 22:04:06
This is the only surviving call to CanonicalizeURL
hausner
2014/05/08 23:10:03
Eliminated this use of CanonicalizeURL, which requ
| |
85 } | 85 } |
86 if (is_dart_scheme_url) { | 86 if (is_dart_scheme_url) { |
87 ASSERT(tag == Dart_kImportTag); | 87 ASSERT(tag == Dart_kImportTag); |
88 // Handle imports of other built-in libraries present in the SDK. | 88 // Handle imports of other built-in libraries present in the SDK. |
89 if (DartUtils::IsDartIOLibURL(url_chars)) { | 89 if (DartUtils::IsDartIOLibURL(url_chars)) { |
90 return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); | 90 return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
91 } else if (DartUtils::IsDartBuiltinLibURL(url_chars)) { | 91 } else if (DartUtils::IsDartBuiltinLibURL(url_chars)) { |
92 return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 92 return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
93 } else { | 93 } else { |
94 return DartUtils::NewError("Do not know how to load '%s'", url_chars); | 94 return DartUtils::NewError("Do not know how to load '%s'", url_chars); |
95 } | 95 } |
96 } | 96 } |
97 if (is_io_library) { | 97 if (is_io_library) { |
98 ASSERT(tag == Dart_kSourceTag); | 98 ASSERT(tag == Dart_kSourceTag); |
99 return Dart_LoadSource(library, | 99 return Dart_LoadSource(library, |
100 url, | 100 url, |
101 Builtin::PartSource(Builtin::kIOLibrary, | 101 Builtin::PartSource(Builtin::kIOLibrary, |
102 url_chars)); | 102 url_chars)); |
103 } | 103 } |
104 return DartUtils::LoadSource(NULL, | 104 return DartUtils::LoadSource(library, url, tag, url_chars); |
105 library, | |
106 url, | |
107 tag, | |
108 url_chars); | |
109 } | 105 } |
110 | 106 |
111 | 107 |
112 Dart_Handle TestCase::LoadTestScript(const char* script, | 108 Dart_Handle TestCase::LoadTestScript(const char* script, |
113 Dart_NativeEntryResolver resolver) { | 109 Dart_NativeEntryResolver resolver) { |
114 Dart_Handle url = NewString(TestCase::url()); | 110 Dart_Handle url = NewString(TestCase::url()); |
115 Dart_Handle source = NewString(script); | 111 Dart_Handle source = NewString(script); |
116 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler); | 112 Dart_Handle result = Dart_SetLibraryTagHandler(LibraryTagHandler); |
117 EXPECT_VALID(result); | 113 EXPECT_VALID(result); |
118 EXPECT_VALID(result); | 114 EXPECT_VALID(result); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 bool CompilerTest::TestCompileFunction(const Function& function) { | 228 bool CompilerTest::TestCompileFunction(const Function& function) { |
233 Isolate* isolate = Isolate::Current(); | 229 Isolate* isolate = Isolate::Current(); |
234 ASSERT(isolate != NULL); | 230 ASSERT(isolate != NULL); |
235 ASSERT(ClassFinalizer::AllClassesFinalized()); | 231 ASSERT(ClassFinalizer::AllClassesFinalized()); |
236 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 232 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
237 return error.IsNull(); | 233 return error.IsNull(); |
238 } | 234 } |
239 | 235 |
240 | 236 |
241 } // namespace dart | 237 } // namespace dart |
OLD | NEW |