Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: runtime/vm/unit_test.cc

Issue 14752008: Final step towards loading core library scripts directly from the sources (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« runtime/bin/bin.gypi ('K') | « runtime/tools/concat_library.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return Dart_Error("not a library"); 56 return Dart_Error("not a library");
57 } 57 }
58 if (!Dart_IsString(url)) { 58 if (!Dart_IsString(url)) {
59 return Dart_Error("url is not a string"); 59 return Dart_Error("url is not a string");
60 } 60 }
61 const char* url_chars = NULL; 61 const char* url_chars = NULL;
62 Dart_Handle result = Dart_StringToCString(url, &url_chars); 62 Dart_Handle result = Dart_StringToCString(url, &url_chars);
63 if (Dart_IsError(result)) { 63 if (Dart_IsError(result)) {
64 return Dart_Error("accessing url characters failed"); 64 return Dart_Error("accessing url characters failed");
65 } 65 }
66 Dart_Handle library_url = Dart_LibraryUrl(library);
67 const char* library_url_string = NULL;
68 result = Dart_StringToCString(library_url, &library_url_string);
69 if (Dart_IsError(result)) {
70 return result;
71 }
72
66 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars); 73 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_chars);
74 bool is_io_library = DartUtils::IsDartIOLibURL(library_url_string);
67 if (tag == kCanonicalizeUrl) { 75 if (tag == kCanonicalizeUrl) {
68 // 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
69 // handled by the VM internally. 77 // handled by the VM internally.
70 if (is_dart_scheme_url) { 78 if (is_dart_scheme_url || is_io_library) {
71 return url; 79 return url;
72 } 80 }
73 Dart_Handle builtin_lib = 81 Dart_Handle builtin_lib =
74 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 82 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
75 DART_CHECK_VALID(builtin_lib); 83 DART_CHECK_VALID(builtin_lib);
76 return DartUtils::CanonicalizeURL(NULL, library, url_chars); 84 return DartUtils::CanonicalizeURL(NULL, library, url_chars);
77 } 85 }
78 if (is_dart_scheme_url) { 86 if (is_dart_scheme_url) {
79 ASSERT(tag == kImportTag); 87 ASSERT(tag == kImportTag);
80 // Handle imports of other built-in libraries present in the SDK. 88 // Handle imports of other built-in libraries present in the SDK.
81 if (DartUtils::IsDartIOLibURL(url_chars)) { 89 if (DartUtils::IsDartIOLibURL(url_chars)) {
82 return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); 90 return Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary);
83 } else if (DartUtils::IsDartBuiltinLibURL(url_chars)) { 91 } else if (DartUtils::IsDartBuiltinLibURL(url_chars)) {
84 return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 92 return Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
85 } else { 93 } else {
86 return Dart_Error("Do not know how to load '%s'", url_chars); 94 return Dart_Error("Do not know how to load '%s'", url_chars);
87 } 95 }
88 } 96 }
97 if (is_io_library) {
98 ASSERT(tag == kSourceTag);
99 return Dart_LoadSource(library,
100 url,
101 Builtin::PartSource(Builtin::kIOLibrary,
102 url_chars));
Mads Ager (google) 2013/05/08 06:20:49 indentation
siva 2013/05/08 16:38:17 Done.
103 }
89 return DartUtils::LoadSource(NULL, 104 return DartUtils::LoadSource(NULL,
90 library, 105 library,
91 url, 106 url,
92 tag, 107 tag,
93 url_chars); 108 url_chars);
94 } 109 }
95 110
96 111
97 Dart_Handle TestCase::LoadTestScript(const char* script, 112 Dart_Handle TestCase::LoadTestScript(const char* script,
98 Dart_NativeEntryResolver resolver) { 113 Dart_NativeEntryResolver resolver) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 226
212 bool CompilerTest::TestCompileFunction(const Function& function) { 227 bool CompilerTest::TestCompileFunction(const Function& function) {
213 Isolate* isolate = Isolate::Current(); 228 Isolate* isolate = Isolate::Current();
214 ASSERT(isolate != NULL); 229 ASSERT(isolate != NULL);
215 ASSERT(ClassFinalizer::AllClassesFinalized()); 230 ASSERT(ClassFinalizer::AllClassesFinalized());
216 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 231 const Error& error = Error::Handle(Compiler::CompileFunction(function));
217 return error.IsNull(); 232 return error.IsNull();
218 } 233 }
219 234
220 } // namespace dart 235 } // namespace dart
OLDNEW
« runtime/bin/bin.gypi ('K') | « runtime/tools/concat_library.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698