@@ -157,13 +157,6 @@ void SetupCoreLibrariesForUnitTest() {
157157 RELEASE_ASSERT (!Dart_IsError (result));
158158}
159159
160- static const char * kPackageScheme = " package:" ;
161-
162- static bool IsPackageSchemeURL (const char * url_name) {
163- static const intptr_t kPackageSchemeLen = strlen (kPackageScheme );
164- return (strncmp (url_name, kPackageScheme , kPackageSchemeLen ) == 0 );
165- }
166-
167160struct TestLibEntry {
168161 const char * url;
169162 const char * source;
@@ -212,13 +205,6 @@ static const char* IsolateReloadTestLibUri() {
212205 return " test:isolate_reload_helper" ;
213206}
214207
215- static bool IsIsolateReloadTestLib (const char * url_name) {
216- static const intptr_t kIsolateReloadTestLibUriLen =
217- strlen (IsolateReloadTestLibUri ());
218- return (strncmp (url_name, IsolateReloadTestLibUri (),
219- kIsolateReloadTestLibUriLen ) == 0 );
220- }
221-
222208static void ReloadTest (Dart_NativeArguments native_args) {
223209 Dart_Handle result = TestCase::TriggerReload (/* kernel_buffer= */ NULL ,
224210 /* kernel_buffer_size= */ 0 );
@@ -241,15 +227,6 @@ static Dart_Handle LoadIsolateReloadTestLib() {
241227}
242228#endif // !PRODUCT
243229
244- static Dart_Handle ResolvePackageUri (const char * uri_chars) {
245- const int kNumArgs = 1 ;
246- Dart_Handle dart_args[kNumArgs ];
247- dart_args[0 ] = DartUtils::NewString (uri_chars);
248- return Dart_Invoke (DartUtils::LookupBuiltinLib (),
249- DartUtils::NewString (" _filePathFromUri" ), kNumArgs ,
250- dart_args);
251- }
252-
253230char * TestCase::CompileTestScriptWithDFE (const char * url,
254231 const char * source,
255232 const uint8_t ** kernel_buffer,
@@ -273,54 +250,6 @@ char* TestCase::CompileTestScriptWithDFE(const char* url,
273250 multiroot_filepaths, multiroot_scheme);
274251}
275252
276- #if 0
277-
278- char* TestCase::CompileTestScriptWithDFE(const char* url,
279- int sourcefiles_count,
280- Dart_SourceFile sourcefiles[],
281- void** kernel_pgm,
282- bool incrementally,
283- bool allow_compile_errors) {
284- Zone* zone = Thread::Current()->zone();
285- Dart_KernelCompilationResult compilation_result = Dart_CompileSourcesToKernel(
286- url, platform_strong_dill, platform_strong_dill_size,
287- sourcefiles_count, sourcefiles, incrementally, NULL);
288- return ValidateCompilationResult(zone, compilation_result, kernel_pgm);
289- }
290-
291- char* TestCase::ValidateCompilationResult(
292- Zone* zone,
293- Dart_KernelCompilationResult compilation_result,
294- void** kernel_pgm,
295- bool allow_compile_errors) {
296- if (!allow_compile_errors &&
297- (compilation_result.status != Dart_KernelCompilationStatus_Ok)) {
298- char* result =
299- OS::SCreate(zone, "Compilation failed %s", compilation_result.error);
300- free(compilation_result.error);
301- return result;
302- }
303-
304- const uint8_t* kernel_file = compilation_result.kernel;
305- intptr_t kernel_length = compilation_result.kernel_size;
306- if (kernel_file == NULL) {
307- return OS::SCreate(zone, "front end generated a NULL kernel file");
308- }
309- *kernel_pgm =
310- Dart_ReadKernelBinary(kernel_file, kernel_length, ReleaseFetchedBytes);
311- if (*kernel_pgm == NULL) {
312- return OS::SCreate(zone, "Failed to read generated kernel binary");
313- }
314- if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
315- char* result =
316- OS::SCreate(zone, "Compilation failed %s", compilation_result.error);
317- free(compilation_result.error);
318- return result;
319- }
320- return NULL;
321- }
322- #endif
323-
324253char * TestCase::CompileTestScriptWithDFE (const char * url,
325254 int sourcefiles_count,
326255 Dart_SourceFile sourcefiles[],
@@ -377,70 +306,6 @@ static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
377306 }
378307 return Dart_DefaultCanonicalizeUrl (library_url, url);
379308 }
380- if (!Dart_IsLibrary (library)) {
381- return Dart_NewApiError (" not a library" );
382- }
383- if (!Dart_IsString (url)) {
384- return Dart_NewApiError (" url is not a string" );
385- }
386- const char * url_chars = NULL ;
387- Dart_Handle result = Dart_StringToCString (url, &url_chars);
388- if (Dart_IsError (result)) {
389- return Dart_NewApiError (" accessing url characters failed" );
390- }
391- Dart_Handle library_url = Dart_LibraryUrl (library);
392- const char * library_url_string = NULL ;
393- result = Dart_StringToCString (library_url, &library_url_string);
394- if (Dart_IsError (result)) {
395- return result;
396- }
397-
398- bool is_dart_scheme_url = DartUtils::IsDartSchemeURL (url_chars);
399- bool is_io_library = DartUtils::IsDartIOLibURL (library_url_string);
400- bool is_standalone_library = DartUtils::IsDartCLILibURL (library_url_string);
401- if (is_dart_scheme_url) {
402- ASSERT (tag == Dart_kImportTag);
403- // Handle imports of other built-in libraries present in the SDK.
404- if (DartUtils::IsDartIOLibURL (url_chars)) {
405- return Builtin::LoadAndCheckLibrary (Builtin::kIOLibrary );
406- } else if (DartUtils::IsDartBuiltinLibURL (url_chars)) {
407- return Builtin::LoadAndCheckLibrary (Builtin::kBuiltinLibrary );
408- } else if (DartUtils::IsDartCLILibURL (url_chars)) {
409- return Builtin::LoadAndCheckLibrary (Builtin::kCLILibrary );
410- } else {
411- return DartUtils::NewError (" Do not know how to load '%s'" , url_chars);
412- }
413- }
414- const char * lib_source = TestCase::GetTestLib (url_chars);
415- if (lib_source != NULL ) {
416- UNREACHABLE ();
417- }
418- #if !defined(PRODUCT)
419- if (IsIsolateReloadTestLib (url_chars)) {
420- UNREACHABLE ();
421- return Dart_Null ();
422- }
423- #endif
424- if (is_io_library) {
425- UNREACHABLE ();
426- return Dart_Null ();
427- }
428- if (is_standalone_library) {
429- UNREACHABLE ();
430- return Dart_Null ();
431- }
432- Dart_Handle resolved_url = url;
433- const char * resolved_url_chars = url_chars;
434- if (IsPackageSchemeURL (url_chars)) {
435- resolved_url = ResolvePackageUri (url_chars);
436- EXPECT_VALID (resolved_url);
437- if (Dart_IsError (Dart_StringToCString (resolved_url, &resolved_url_chars))) {
438- return Dart_NewApiError (" unable to convert resolved uri to string" );
439- }
440- }
441- // Do sync loading since unit_test doesn't support async.
442- Dart_Handle source = DartUtils::ReadStringFromFile (resolved_url_chars);
443- EXPECT_VALID (source);
444309 UNREACHABLE ();
445310 return Dart_Null ();
446311}
0 commit comments