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

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

Issue 690103004: Move dart2js from sdk/lib/_internal/compiler to pkg/compiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | sdk/bin/dart2js » ('j') | 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 "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 30 matching lines...) Expand all
41 41
42 42
43 void TestCaseBase::RunAll() { 43 void TestCaseBase::RunAll() {
44 TestCaseBase* test = first_; 44 TestCaseBase* test = first_;
45 while (test != NULL) { 45 while (test != NULL) {
46 test->RunTest(); 46 test->RunTest();
47 test = test->next_; 47 test = test->next_;
48 } 48 }
49 } 49 }
50 50
51 static const char* kPackageScheme = "package:";
52
53 static bool IsPackageSchemeURL(const char* url_name) {
54 static const intptr_t kPackageSchemeLen = strlen(kPackageScheme);
55 return (strncmp(url_name, kPackageScheme, kPackageSchemeLen) == 0);
56 }
57
58 static Dart_Handle ResolvePackageUri(Dart_Handle builtin_lib,
59 const char* uri_chars) {
60 const int kNumArgs = 1;
61 Dart_Handle dart_args[kNumArgs];
62 dart_args[0] = DartUtils::NewString(uri_chars);
63 return Dart_Invoke(builtin_lib,
64 DartUtils::NewString("_filePathFromUri"),
65 kNumArgs,
66 dart_args);
67 }
51 68
52 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, 69 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
53 Dart_Handle library, 70 Dart_Handle library,
54 Dart_Handle url) { 71 Dart_Handle url) {
55 if (!Dart_IsLibrary(library)) { 72 if (!Dart_IsLibrary(library)) {
56 return Dart_NewApiError("not a library"); 73 return Dart_NewApiError("not a library");
57 } 74 }
58 if (!Dart_IsString(url)) { 75 if (!Dart_IsString(url)) {
59 return Dart_NewApiError("url is not a string"); 76 return Dart_NewApiError("url is not a string");
60 } 77 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 118 }
102 } 119 }
103 if (is_io_library) { 120 if (is_io_library) {
104 ASSERT(tag == Dart_kSourceTag); 121 ASSERT(tag == Dart_kSourceTag);
105 return Dart_LoadSource(library, 122 return Dart_LoadSource(library,
106 url, 123 url,
107 Builtin::PartSource(Builtin::kIOLibrary, 124 Builtin::PartSource(Builtin::kIOLibrary,
108 url_chars), 125 url_chars),
109 0, 0); 126 0, 0);
110 } 127 }
128 if (IsPackageSchemeURL(url_chars)) {
129 Dart_Handle resolved_uri = ResolvePackageUri(builtin_lib, url_chars);
130 DART_CHECK_VALID(resolved_uri);
131 url_chars = NULL;
132 Dart_Handle result = Dart_StringToCString(resolved_uri, &url_chars);
133 if (Dart_IsError(result)) {
134 return Dart_NewApiError("accessing url characters failed");
135 }
136 }
111 // Do sync loading since unit_test doesn't support async. 137 // Do sync loading since unit_test doesn't support async.
112 Dart_Handle source = DartUtils::ReadStringFromFile(url_chars); 138 Dart_Handle source = DartUtils::ReadStringFromFile(url_chars);
113 EXPECT_VALID(source); 139 EXPECT_VALID(source);
114 if (tag == Dart_kImportTag) { 140 if (tag == Dart_kImportTag) {
115 return Dart_LoadLibrary(url, source, 0, 0); 141 return Dart_LoadLibrary(url, source, 0, 0);
116 } else { 142 } else {
117 ASSERT(tag == Dart_kSourceTag); 143 ASSERT(tag == Dart_kSourceTag);
118 return Dart_LoadSource(library, url, source, 0, 0); 144 return Dart_LoadSource(library, url, source, 0, 0);
119 } 145 }
120 } 146 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 Isolate* isolate = Isolate::Current(); 277 Isolate* isolate = Isolate::Current();
252 ASSERT(isolate != NULL); 278 ASSERT(isolate != NULL);
253 ASSERT(ClassFinalizer::AllClassesFinalized()); 279 ASSERT(ClassFinalizer::AllClassesFinalized());
254 const Error& error = Error::Handle(Compiler::CompileFunction(isolate, 280 const Error& error = Error::Handle(Compiler::CompileFunction(isolate,
255 function)); 281 function));
256 return error.IsNull(); 282 return error.IsNull();
257 } 283 }
258 284
259 285
260 } // namespace dart 286 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/benchmark_test.cc ('k') | sdk/bin/dart2js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698